diff --git a/S7.Net/PLC.cs b/S7.Net/PLC.cs index c700e03..dc38326 100644 --- a/S7.Net/PLC.cs +++ b/S7.Net/PLC.cs @@ -1,8 +1,11 @@ using System; +using System.Collections; using System.Net; using System.Net.NetworkInformation; using System.Net.Sockets; using S7.Net.Interfaces; +using S7.Net.Types; +using Double = System.Double; namespace S7.Net { @@ -318,7 +321,7 @@ namespace S7.Net UInt16 objUInt16; UInt32 objUInt32; double objDouble; - bool[] objBoolArray; + BitArray objBoolArray; string txt = variable.ToUpper(); txt = txt.Replace(" ", ""); // remove spaces @@ -351,7 +354,8 @@ namespace S7.Net mByte = dbIndex; mBit = int.Parse(strings[2]); if (mBit > 7) throw new Exception(); - objBoolArray = (bool[])Read(DataType.DataBlock, mDB, mByte, VarType.Bit, 1); + byte obj2 = (byte)Read(DataType.DataBlock, mDB, mByte, VarType.Byte, 1); + objBoolArray = new BitArray(new byte[] { obj2 }); return objBoolArray[mBit]; default: throw new Exception(); @@ -428,7 +432,8 @@ namespace S7.Net mByte = int.Parse(txt2.Substring(0, txt2.IndexOf("."))); mBit = int.Parse(txt2.Substring(txt2.IndexOf(".") + 1)); if (mBit > 7) throw new Exception(); - objBoolArray = (bool[])Read(mDataType, 0, mByte, VarType.Bit, 1); + var obj3 = (byte)Read(mDataType, 0, mByte, VarType.Bit, 1); + objBoolArray = new BitArray(new byte[]{obj3}); return objBoolArray[mBit]; } }