From 7012205c3e199e2cf9c08605763155c6ae8cb47a Mon Sep 17 00:00:00 2001 From: Michele Cattafesta Date: Fri, 26 Aug 2016 13:06:34 +0200 Subject: [PATCH] documentation, cleanup and formatting + output xml documentation. --- S7.Net/Conversion.cs | 8 +++ S7.Net/Enums.cs | 125 +++++++++++++++++++++++++++++++++++++++ S7.Net/PLC.cs | 13 ++-- S7.Net/S7.Net.csproj | 2 + S7.Net/Types/Boolean.cs | 12 ++++ S7.Net/Types/Byte.cs | 22 +++++-- S7.Net/Types/Class.cs | 3 + S7.Net/Types/Counter.cs | 29 ++++++--- S7.Net/Types/DInt.cs | 35 +++++++---- S7.Net/Types/DWord.cs | 29 ++++++--- S7.Net/Types/DataItem.cs | 29 +++++++++ S7.Net/Types/Double.cs | 40 ++++++++----- S7.Net/Types/Int.cs | 37 ++++++++---- S7.Net/Types/String.cs | 21 ++++--- S7.Net/Types/Struct.cs | 3 + S7.Net/Types/Timer.cs | 25 +++++--- S7.Net/Types/Word.cs | 47 +++++++++------ 17 files changed, 383 insertions(+), 97 deletions(-) diff --git a/S7.Net/Conversion.cs b/S7.Net/Conversion.cs index 360e282..246ed00 100644 --- a/S7.Net/Conversion.cs +++ b/S7.Net/Conversion.cs @@ -3,6 +3,9 @@ using System.Globalization; namespace S7.Net { + /// + /// Conversion methods to convert from Siemens numeric format to C# and back + /// public static class Conversion { /// @@ -25,6 +28,11 @@ namespace S7.Net return ret; } + /// + /// Converts a binary string to a byte. Can return null. + /// + /// + /// public static byte? BinStringToByte(this string txt) { int cnt = 0; diff --git a/S7.Net/Enums.cs b/S7.Net/Enums.cs index 56aaa87..b128285 100644 --- a/S7.Net/Enums.cs +++ b/S7.Net/Enums.cs @@ -1,51 +1,176 @@ namespace S7.Net { + /// + /// Types of S7 cpu supported by the library + /// public enum CpuType { + /// + /// S7 200 cpu type + /// S7200 = 0, + + /// + /// S7 300 cpu type + /// S7300 = 10, + + /// + /// S7 400 cpu type + /// S7400 = 20, + + /// + /// S7 1200 cpu type + /// S71200 = 30, + + /// + /// S7 1500 cpu type + /// S71500 = 40, } + /// + /// Types of error code that can be set after a function is called + /// public enum ErrorCode { + /// + /// The function has been executed correctly + /// NoError = 0, + + /// + /// Wrong type of CPU error + /// WrongCPU_Type = 1, + + /// + /// Connection error + /// ConnectionError = 2, + + /// + /// Ip address not available + /// IPAddressNotAvailable, + /// + /// Wrong format of the variable + /// WrongVarFormat = 10, + + /// + /// Wrong number of received bytes + /// WrongNumberReceivedBytes = 11, + /// + /// Error on send data + /// SendData = 20, + + /// + /// Error on read data + /// ReadData = 30, + /// + /// Error on write data + /// WriteData = 50 } + /// + /// Types of memory area that can be read + /// public enum DataType { + /// + /// Input area memory + /// Input = 129, + + /// + /// Output area memory + /// Output = 130, + + /// + /// Merkers area memory (M0, M0.0, ...) + /// Memory = 131, + + /// + /// DB area memory (DB1, DB2, ...) + /// DataBlock = 132, + + /// + /// Timer area memory(T1, T2, ...) + /// Timer = 29, + + /// + /// Counter area memory (C1, C2, ...) + /// Counter = 28 } + /// + /// Types + /// public enum VarType { + /// + /// S7 Bit variable type (bool) + /// Bit, + + /// + /// S7 Byte variable type (8 bits) + /// Byte, + + /// + /// S7 Word variable type (16 bits, 2 bytes) + /// Word, + + /// + /// S7 DWord variable type (32 bits, 4 bytes) + /// DWord, + + /// + /// S7 Int variable type (16 bits, 2 bytes) + /// Int, + + /// + /// DInt variable type (32 bits, 4 bytes) + /// DInt, + + /// + /// Real variable type (32 bits, 4 bytes) + /// Real, + + /// + /// String variable type (variable) + /// String, + + /// + /// Timer variable type + /// Timer, + + /// + /// Counter variable type + /// Counter } } diff --git a/S7.Net/PLC.cs b/S7.Net/PLC.cs index d389354..735d5ac 100644 --- a/S7.Net/PLC.cs +++ b/S7.Net/PLC.cs @@ -11,6 +11,9 @@ using Double = System.Double; namespace S7.Net { + /// + /// Creates an instance of S7.Net driver + /// public class Plc : IDisposable { private Socket _mSocket; //TCP connection to device @@ -343,7 +346,7 @@ namespace S7.Net /// Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. /// Start byte address. If you want to read DB1.DBW200, this is 200. /// Type of the variable/s that you are reading - /// Number of + /// public object Read(DataType dataType, int db, int startByteAdr, VarType varType, int varCount) { int cntBytes = VarTypeToByteLength(varType, varCount); @@ -1090,19 +1093,21 @@ namespace S7.Net #region IDisposable members + /// + /// Releases all resources, disonnects from the plc and closes the socket + /// public void Dispose() { if (_mSocket != null) { if (_mSocket.Connected) { - //Close() performs a Dispose on the socket. _mSocket.Shutdown(SocketShutdown.Both); _mSocket.Close(); } - //((IDisposable)_mSocket).Dispose(); } } -#endregion + + #endregion } } diff --git a/S7.Net/S7.Net.csproj b/S7.Net/S7.Net.csproj index ec08448..6ff90eb 100644 --- a/S7.Net/S7.Net.csproj +++ b/S7.Net/S7.Net.csproj @@ -43,6 +43,7 @@ prompt 4 false + bin\Debug\S7.Net.xml pdbonly @@ -52,6 +53,7 @@ prompt 4 false + bin\Release\S7.Net.xml true diff --git a/S7.Net/Types/Boolean.cs b/S7.Net/Types/Boolean.cs index bcbdefd..cd9149a 100644 --- a/S7.Net/Types/Boolean.cs +++ b/S7.Net/Types/Boolean.cs @@ -2,8 +2,14 @@ namespace S7.Net.Types { + /// + /// Contains the methods to read, set and reset bits inside bytes + /// public static class Boolean { + /// + /// Returns the value of a bit in a bit, given the address of the bit + /// public static bool GetValue(byte value, int bit) { if ((value & (int)Math.Pow(2, bit)) != 0) @@ -12,11 +18,17 @@ namespace S7.Net.Types return false; } + /// + /// Sets the value of a bit to 1 (true), given the address of the bit + /// public static byte SetBit(byte value, int bit) { return (byte)(value | (byte)Math.Pow(2, bit)); } + /// + /// Resets the value of a bit to 0 (false), given the address of the bit + /// public static byte ClearBit(byte value, int bit) { return (byte)(value & (byte)(~(byte)Math.Pow(2, bit))); diff --git a/S7.Net/Types/Byte.cs b/S7.Net/Types/Byte.cs index 47090c3..2727ef6 100644 --- a/S7.Net/Types/Byte.cs +++ b/S7.Net/Types/Byte.cs @@ -1,16 +1,26 @@ -namespace S7.Net.Types +using System; + +namespace S7.Net.Types { + /// + /// Contains the methods to convert from bytes to byte arrays + /// public static class Byte { - // publics - #region ToByteArray + /// + /// Converts a byte to byte array + /// public static byte[] ToByteArray(byte value) { byte[] bytes = new byte[] { value}; return bytes; } - #endregion - #region FromByteArray + + /// + /// Converts a byte array to byte + /// + /// + /// public static byte FromByteArray(byte[] bytes) { if (bytes.Length != 1) @@ -19,6 +29,6 @@ } return bytes[0]; } - #endregion + } } diff --git a/S7.Net/Types/Class.cs b/S7.Net/Types/Class.cs index bd47432..477ee7c 100644 --- a/S7.Net/Types/Class.cs +++ b/S7.Net/Types/Class.cs @@ -3,6 +3,9 @@ using System.Reflection; namespace S7.Net.Types { + /// + /// Contains the methods to convert a C# class to S7 data types + /// public static class Class { /// diff --git a/S7.Net/Types/Counter.cs b/S7.Net/Types/Counter.cs index df47572..dfbc6f5 100644 --- a/S7.Net/Types/Counter.cs +++ b/S7.Net/Types/Counter.cs @@ -2,10 +2,14 @@ namespace S7.Net.Types { + /// + /// Contains the conversion methods to convert Counter from S7 plc to C# ushort (UInt16). + /// public static class Counter { - // publics - #region FromByteArray + /// + /// Converts a Counter (2 bytes) to ushort (UInt16) + /// public static UInt16 FromByteArray(byte[] bytes) { if (bytes.Length != 2) @@ -16,15 +20,18 @@ namespace S7.Net.Types // bytes[1] -> LowByte return FromBytes(bytes[1], bytes[0]); } - #endregion - #region FromBytes + + /// + /// Converts a Counter (2 bytes) to ushort (UInt16) + /// public static UInt16 FromBytes(byte LoVal, byte HiVal) { return (UInt16)(HiVal * 256 + LoVal); } - #endregion - #region ToByteArray + /// + /// Converts a ushort (UInt16) to word (2 bytes) + /// public static byte[] ToByteArray(UInt16 value) { byte[] bytes = new byte[2]; @@ -41,6 +48,9 @@ namespace S7.Net.Types return bytes; } + /// + /// Converts an array of ushort (UInt16) to an array of bytes + /// public static byte[] ToByteArray(UInt16[] value) { ByteArray arr = new ByteArray(); @@ -48,8 +58,10 @@ namespace S7.Net.Types arr.Add(ToByteArray(val)); return arr.array; } - #endregion - #region ToArray + + /// + /// Converts an array of bytes to an array of ushort + /// public static UInt16[] ToArray(byte[] bytes) { UInt16[] values = new UInt16[bytes.Length / 2]; @@ -60,6 +72,5 @@ namespace S7.Net.Types return values; } - #endregion } } diff --git a/S7.Net/Types/DInt.cs b/S7.Net/Types/DInt.cs index 2fd8b79..fc3b523 100644 --- a/S7.Net/Types/DInt.cs +++ b/S7.Net/Types/DInt.cs @@ -2,10 +2,14 @@ namespace S7.Net.Types { + /// + /// Contains the conversion methods to convert DInt from S7 plc to C# int (Int32). + /// public static class DInt { - // publics - #region FromByteArray + /// + /// Converts a S7 DInt (4 bytes) to int (Int32) + /// public static Int32 FromByteArray(byte[] bytes) { if (bytes.Length != 4) @@ -14,15 +18,18 @@ namespace S7.Net.Types } return FromBytes(bytes[3], bytes[2], bytes[1], bytes[0]); } - #endregion - #region FromBytes + + /// + /// Converts a S7 DInt (4 bytes) to int (Int32) + /// public static Int32 FromBytes(byte v1, byte v2, byte v3, byte v4) { return (Int32)(v1 + v2 * Math.Pow(2, 8) + v3 * Math.Pow(2, 16) + v4 * Math.Pow(2, 24)); } - #endregion - #region ToByteArray + /// + /// Converts a int (Int32) to S7 DInt (4 bytes) + /// public static byte[] ToByteArray(Int32 value) { byte[] bytes = new byte[4]; @@ -39,6 +46,9 @@ namespace S7.Net.Types return bytes; } + /// + /// Converts an array of int (Int32) to an array of bytes + /// public static byte[] ToByteArray(Int32[] value) { ByteArray arr = new ByteArray(); @@ -46,8 +56,10 @@ namespace S7.Net.Types arr.Add(ToByteArray(val)); return arr.array; } - #endregion - #region ToArray + + /// + /// Converts an array of S7 DInt to an array of int (Int32) + /// public static Int32[] ToArray(byte[] bytes) { Int32[] values = new Int32[bytes.Length / 4]; @@ -58,9 +70,10 @@ namespace S7.Net.Types return values; } - #endregion - - // conversion + + /// + /// Converts from C# long (Int64) to C# int (Int32) + /// public static Int32 CDWord(Int64 value) { if (value > Int32.MaxValue) diff --git a/S7.Net/Types/DWord.cs b/S7.Net/Types/DWord.cs index 20a2e67..c735ad1 100644 --- a/S7.Net/Types/DWord.cs +++ b/S7.Net/Types/DWord.cs @@ -2,23 +2,30 @@ namespace S7.Net.Types { + /// + /// Contains the conversion methods to convert DWord from S7 plc to C#. + /// public static class DWord { - // publics - #region FromByteArray + /// + /// Converts a S7 DWord (4 bytes) to uint (UInt32) + /// public static UInt32 FromByteArray(byte[] bytes) { return FromBytes(bytes[3], bytes[2], bytes[1], bytes[0]); } - #endregion - #region FromBytes + + /// + /// Converts a S7 DWord (4 bytes) to uint (UInt32) + /// public static UInt32 FromBytes(byte v1, byte v2, byte v3, byte v4) { return (UInt32)(v1 + v2 * Math.Pow(2, 8) + v3 * Math.Pow(2, 16) + v4 * Math.Pow(2, 24)); } - #endregion - #region ToByteArray + /// + /// Converts a uint (UInt32) to S7 DWord (4 bytes) + /// public static byte[] ToByteArray(UInt32 value) { byte[] bytes = new byte[4]; @@ -35,6 +42,9 @@ namespace S7.Net.Types return bytes; } + /// + /// Converts an array of uint (UInt32) to an array of S7 DWord (4 bytes) + /// public static byte[] ToByteArray(UInt32[] value) { ByteArray arr = new ByteArray(); @@ -42,8 +52,10 @@ namespace S7.Net.Types arr.Add(ToByteArray(val)); return arr.array; } - #endregion - #region ToArray + + /// + /// Converts an array of S7 DWord to an array of uint (UInt32) + /// public static UInt32[] ToArray(byte[] bytes) { UInt32[] values = new UInt32[bytes.Length / 4]; @@ -54,6 +66,5 @@ namespace S7.Net.Types return values; } - #endregion } } diff --git a/S7.Net/Types/DataItem.cs b/S7.Net/Types/DataItem.cs index b5d7e78..454497f 100644 --- a/S7.Net/Types/DataItem.cs +++ b/S7.Net/Types/DataItem.cs @@ -1,17 +1,46 @@ namespace S7.Net.Types { + /// + /// Create an instance of a memory block that can be read by using ReadMultipleVars + /// public class DataItem { + /// + /// Memory area to read + /// public DataType DataType { get; set; } + + /// + /// Type of data to be read (default is bytes) + /// public VarType VarType { get; set; } + + /// + /// Address of memory area to read (example: for DB1 this value is 1, for T45 this value is 45) + /// public int DB { get; set; } + + /// + /// Address of the first byte to read + /// public int StartByteAdr { get; set; } + + /// + /// Number of variables to read + /// public int Count { get; set; } + /// + /// Contains the value of the memory area after the read has been executed + /// public object Value { get; set; } + /// + /// Create an instance of DataItem + /// public DataItem() { + VarType = VarType.Byte; Count = 1; } } diff --git a/S7.Net/Types/Double.cs b/S7.Net/Types/Double.cs index f423687..85bcbbd 100644 --- a/S7.Net/Types/Double.cs +++ b/S7.Net/Types/Double.cs @@ -2,10 +2,14 @@ namespace S7.Net.Types { + /// + /// Contains the conversion methods to convert Real from S7 plc to C# double. + /// public static class Double { - // publics - #region FromByteArray + /// + /// Converts a S7 Real (4 bytes) to double + /// public static double FromByteArray(byte[] bytes) { if (bytes.Length != 4) @@ -45,8 +49,10 @@ namespace S7.Net.Types return Math.Pow((-1), vz) * Math.Pow(2, (exd - 127)) * mantisse; } } - #endregion - #region FromDWord + + /// + /// Converts a S7 DInt to double + /// public static double FromDWord(Int32 value) { byte[] b = DInt.ToByteArray(value); @@ -54,15 +60,20 @@ namespace S7.Net.Types return d; } + /// + /// Converts a S7 DWord to double + /// public static double FromDWord(UInt32 value) { byte[] b = DWord.ToByteArray(value); double d = FromByteArray(b); return d; } - #endregion - #region ToByteArray + + /// + /// Converts a double to S7 Real (4 bytes) + /// public static byte[] ToByteArray(double value) { double wert = (double)value; @@ -109,6 +120,9 @@ namespace S7.Net.Types return bytes; } + /// + /// Converts an array of double to an array of bytes + /// public static byte[] ToByteArray(double[] value) { ByteArray arr = new ByteArray(); @@ -116,8 +130,10 @@ namespace S7.Net.Types arr.Add(ToByteArray(val)); return arr.array; } - #endregion - #region ToArray + + /// + /// Converts an array of S7 Real to an array of double + /// public static double[] ToArray(byte[] bytes) { double[] values = new double[bytes.Length / 4]; @@ -128,10 +144,8 @@ namespace S7.Net.Types return values; } - #endregion - // privates - #region ValToBinString + private static string ValToBinString(byte value) { string txt = ""; @@ -145,8 +159,7 @@ namespace S7.Net.Types } return txt; } - #endregion - #region BinStringToByte + private static byte? BinStringToByte(string txt) { int cnt = 0; @@ -165,6 +178,5 @@ namespace S7.Net.Types } return null; } - #endregion } } diff --git a/S7.Net/Types/Int.cs b/S7.Net/Types/Int.cs index 4c328d6..f2d7124 100644 --- a/S7.Net/Types/Int.cs +++ b/S7.Net/Types/Int.cs @@ -2,10 +2,14 @@ namespace S7.Net.Types { + /// + /// Contains the conversion methods to convert Int from S7 plc to C#. + /// public static class Int { - // publics - #region FromByteArray + /// + /// Converts a S7 Int (2 bytes) to short (Int16) + /// public static Int16 FromByteArray(byte[] bytes) { if (bytes.Length != 2) @@ -16,15 +20,18 @@ namespace S7.Net.Types // bytes[1] -> LowByte return FromBytes(bytes[1], bytes[0]); } - #endregion - #region FromBytes + + /// + /// Converts a S7 Int (2 bytes) to short (Int16) + /// public static Int16 FromBytes(byte LoVal, byte HiVal) { return (Int16)(HiVal * 256 + LoVal); } - #endregion - #region ToByteArray + /// + /// Converts a short (Int16) to a S7 Int byte array (2 bytes) + /// public static byte[] ToByteArray(Int16 value) { byte[] bytes = new byte[2]; @@ -41,6 +48,9 @@ namespace S7.Net.Types return bytes; } + /// + /// Converts an array of short (Int16) to a S7 Int byte array (2 bytes) + /// public static byte[] ToByteArray(Int16[] value) { ByteArray arr = new ByteArray(); @@ -48,8 +58,10 @@ namespace S7.Net.Types arr.Add(ToByteArray(val)); return arr.array; } - #endregion - #region ToArray + + /// + /// Converts an array of S7 Int to an array of short (Int16) + /// public static Int16[] ToArray(byte[] bytes) { Int16[] values = new Int16[bytes.Length / 2]; @@ -60,9 +72,12 @@ namespace S7.Net.Types return values; } - #endregion - - // conversion + + /// + /// Converts a C# int value to a C# short value, to be used as word. + /// + /// + /// public static Int16 CWord(int value) { if (value > 32767) diff --git a/S7.Net/Types/String.cs b/S7.Net/Types/String.cs index d5f9651..d2a1d50 100644 --- a/S7.Net/Types/String.cs +++ b/S7.Net/Types/String.cs @@ -1,9 +1,13 @@ namespace S7.Net.Types { + /// + /// Contains the methods to convert from S7 strings to C# strings + /// public static class String { - // publics - #region ToByteArray + /// + /// Converts a string to S7 bytes + /// public static byte[] ToByteArray(string value) { string txt = (string)value; @@ -13,16 +17,17 @@ bytes[cnt] = (byte)Asc(ca[cnt].ToString()); return bytes; } - #endregion - - #region FromByteArray + + /// + /// Converts S7 bytes to a string + /// + /// + /// public static string FromByteArray(byte[] bytes) { return System.Text.Encoding.ASCII.GetString(bytes); } - #endregion - - // privates + private static int Asc(string s) { byte[] b = System.Text.Encoding.ASCII.GetBytes(s); diff --git a/S7.Net/Types/Struct.cs b/S7.Net/Types/Struct.cs index 15214b2..9ee05c2 100644 --- a/S7.Net/Types/Struct.cs +++ b/S7.Net/Types/Struct.cs @@ -5,6 +5,9 @@ using System.Reflection; namespace S7.Net.Types { + /// + /// Contains the method to convert a C# struct to S7 data types + /// public static class Struct { /// diff --git a/S7.Net/Types/Timer.cs b/S7.Net/Types/Timer.cs index 4db25a0..167c12f 100644 --- a/S7.Net/Types/Timer.cs +++ b/S7.Net/Types/Timer.cs @@ -2,10 +2,14 @@ namespace S7.Net.Types { + /// + /// Converts the Timer data type to C# data type + /// public static class Timer { - // publics - #region FromByteArray + /// + /// Converts the timer bytes to a double + /// public static double FromByteArray(byte[] bytes) { double wert = 0; @@ -31,9 +35,10 @@ namespace S7.Net.Types } return wert; } - #endregion - #region ToByteArray + /// + /// Converts a ushort (UInt16) to an array of bytes formatted as time + /// public static byte[] ToByteArray(UInt16 value) { byte[] bytes = new byte[2]; @@ -50,6 +55,9 @@ namespace S7.Net.Types return bytes; } + /// + /// Converts an array of ushorts (Uint16) to an array of bytes formatted as time + /// public static byte[] ToByteArray(UInt16[] value) { ByteArray arr = new ByteArray(); @@ -57,8 +65,12 @@ namespace S7.Net.Types arr.Add(ToByteArray(val)); return arr.array; } - #endregion - #region ToArray + + /// + /// Converts an array of bytes formatted as time to an array of doubles + /// + /// + /// public static double[] ToArray(byte[] bytes) { double[] values = new double[bytes.Length / 2]; @@ -69,6 +81,5 @@ namespace S7.Net.Types return values; } - #endregion } } diff --git a/S7.Net/Types/Word.cs b/S7.Net/Types/Word.cs index 0b943e4..f0f4347 100644 --- a/S7.Net/Types/Word.cs +++ b/S7.Net/Types/Word.cs @@ -2,10 +2,14 @@ namespace S7.Net.Types { + /// + /// Contains the conversion methods to convert Words from S7 plc to C#. + /// public static class Word { - // publics - #region FromByteArray + /// + /// Converts a word (2 bytes) to ushort (UInt16) + /// public static UInt16 FromByteArray(byte[] bytes) { if (bytes.Length != 2) @@ -16,31 +20,37 @@ namespace S7.Net.Types // bytes[1] -> LowByte return FromBytes(bytes[1], bytes[0]); } - #endregion - #region FromBytes + + /// + /// Converts a word (2 bytes) to ushort (UInt16) + /// public static UInt16 FromBytes(byte LoVal, byte HiVal) { - return (UInt16)(HiVal * 256 + LoVal); + return (UInt16) (HiVal*256 + LoVal); } - #endregion - #region ToByteArray + /// + /// Converts a ushort (UInt16) to word (2 bytes) + /// public static byte[] ToByteArray(UInt16 value) { byte[] bytes = new byte[2]; int x = 2; - long valLong = (long)((UInt16)value); + long valLong = (long) ((UInt16) value); for (int cnt = 0; cnt < x; cnt++) { - Int64 x1 = (Int64)Math.Pow(256, (cnt)); + Int64 x1 = (Int64) Math.Pow(256, (cnt)); - Int64 x3 = (Int64)(valLong / x1); - bytes[x - cnt - 1] = (byte)(x3 & 255); - valLong -= bytes[x - cnt - 1] * x1; + Int64 x3 = (Int64) (valLong/x1); + bytes[x - cnt - 1] = (byte) (x3 & 255); + valLong -= bytes[x - cnt - 1]*x1; } return bytes; } + /// + /// Converts an array of ushort (UInt16) to an array of bytes + /// public static byte[] ToByteArray(UInt16[] value) { ByteArray arr = new ByteArray(); @@ -48,18 +58,19 @@ namespace S7.Net.Types arr.Add(ToByteArray(val)); return arr.array; } - #endregion - #region ToArray + + /// + /// Converts an array of bytes to an array of ushort + /// public static UInt16[] ToArray(byte[] bytes) { - UInt16[] values = new UInt16[bytes.Length / 2]; + UInt16[] values = new UInt16[bytes.Length/2]; int counter = 0; - for (int cnt = 0; cnt < bytes.Length / 2; cnt++) - values[cnt] = FromByteArray(new byte[] { bytes[counter++], bytes[counter++] }); + for (int cnt = 0; cnt < bytes.Length/2; cnt++) + values[cnt] = FromByteArray(new byte[] {bytes[counter++], bytes[counter++]}); return values; } - #endregion } }