diff options
| author | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
|---|---|---|
| committer | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
| commit | 00a491d93733d4625ad329b2ba8237f445364b3f (patch) | |
| tree | 4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Stubs Collection/stubs/Scripts/ConvertFloat2Bytes.cs | |
| parent | 124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff) | |
| download | Tango-00a491d9.tar.gz Tango-00a491d9.zip | |
merge
Diffstat (limited to 'Software/Stubs Collection/stubs/Scripts/ConvertFloat2Bytes.cs')
| -rw-r--r-- | Software/Stubs Collection/stubs/Scripts/ConvertFloat2Bytes.cs | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/Software/Stubs Collection/stubs/Scripts/ConvertFloat2Bytes.cs b/Software/Stubs Collection/stubs/Scripts/ConvertFloat2Bytes.cs deleted file mode 100644 index c199b9c29..000000000 --- a/Software/Stubs Collection/stubs/Scripts/ConvertFloat2Bytes.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Text; -using System.Linq; -using System.Drawing; -using System.Diagnostics; -using System.Windows.Forms; -using System.Threading; -using System.Threading.Tasks; -using System.Collections.Generic; -using Tango.PMR.Stubs; -using Tango.Stubs; - - - -public void OnExecute(StubManager stubManager) -{ - //see online Floating Point to Hex Converter (with Swap endianness) :https://gregstoll.com/~gregstoll/floattohex/ - // ----------------- option 1 ------------------------------- - stubManager.WriteLine("--- option 1 ---"); - float value = 5.2F; - byte [] byteArray1 = new byte[4];// a single float is 4 bytes/32 bits - byteArray1 = BitConverter.GetBytes(value); - - //print - for(int i =0;i<4;i++) - { - stubManager.WriteHex(byteArray1[i],2); - stubManager.Write(" "); - } - stubManager.WriteLine(""); - stubManager.WriteLine(""); - - // ----------------- option 2 for buffer ------------------------------- - stubManager.WriteLine("--- option 2 ---"); - var floatArray1 = new float[] {5.2f, 1.2f, 3.7f}; - - - // create a byte array and copy the floats into it... - var byteArray = new byte[floatArray1.Length * 4];// a single float is 4 bytes/32 bits - Buffer.BlockCopy(floatArray1, 0, byteArray, 0, byteArray.Length); - - //print - for(int j =0;j<floatArray1.Length;j++) - { - for(int i =0;i<4;i++) - { - stubManager.WriteHex(byteArray[j+i],2); - stubManager.Write(" "); - } - stubManager.WriteLine(""); - } - - -}
\ No newline at end of file |
