private void button7_Click(object sender, EventArgs e) { int Pos = System.Convert.ToInt32(textBox13.Text); UInt32 DWord = S7.GetDWordAt(Buffer, Pos); textBox12.Text = "16#" + System.Convert.ToString(DWord, 16).ToUpper(); }
private void BtnRead_Click(object sender, EventArgs e) { var buffer = new byte[14];//guncelle int readresult = Plc.DBRead(2, 0, buffer.Length, buffer); TxtRead1.Text = Convert.ToString(S7.GetBitAt(buffer, 0, 0)); //0.byte'ın 0.biti TxtRead2.Text = Convert.ToString(S7.GetBitAt(buffer, 0, 1)); //0.byte'ın 1.biti TxtRead3.Text = Convert.ToString(S7.GetIntAt(buffer, 2)); // 2. byte (for plc 1int= 2 byte) TxtRead4.Text = Convert.ToString(S7.GetUDIntAt(buffer, 4)); //4. byte (for plc 1dint= 4 byte) TxtRead5.Text = Convert.ToString(S7.GetWordAt(buffer, 8)); //8.byte (1 word = 2 byte) TxtRead6.Text = Convert.ToString(S7.GetDWordAt(buffer, 10)); //10.byte (1 dword = 4 byte) =10+4=14 oldu bufferda 14tü. }
internal static object GetS7Value(Tag tagItem, byte[] buffer) { object returnValue; if (tagItem.DataType == "Bit") { returnValue = S7.GetBitAt(buffer, tagItem.Position, 0); } else if (tagItem.DataType == "Word") { returnValue = S7.GetWordAt(buffer, 0); } else if (tagItem.DataType == "Short") { returnValue = S7.GetShortAt(buffer, 0); } else if (tagItem.DataType == "DWord") { returnValue = S7.GetDWordAt(buffer, 0); } else if (tagItem.DataType == "DInt") { returnValue = S7.GetDIntAt(buffer, 0); } else if (tagItem.DataType == "Float") { returnValue = S7.GetFloatAt(buffer, 0); } else if (tagItem.DataType == "String") { returnValue = S7.GetStringAt(buffer, 0, buffer.Length); } else if (tagItem.DataType == "PrintableString") { returnValue = S7.GetPrintableStringAt(buffer, 0, buffer.Length); } else if (tagItem.DataType == "Date") { returnValue = S7.GetDateAt(buffer, 0); } else { returnValue = S7.GetStringAt(buffer, 0, buffer.Length); } return(returnValue); }
/// <summary> /// extract value from raw buffer /// </summary> /// <param name="buffer"> buffer length must be greater than Offset.ByteOffset+4, else do nothing </param> public void GetValueFromGroupBuffer(byte[] buffer) { if (buffer.Length < Offset.ByteOffset + 4) { return; } switch (VType) { case varType.BOOL: Value = S7.GetBitAt(buffer, Offset.ByteOffset, Offset.BitOffset); break; case varType.BYTE: Value = S7.GetByteAt(buffer, Offset.ByteOffset); break; case varType.WORD: Value = S7.GetWordAt(buffer, Offset.ByteOffset); break; case varType.DWORD: Value = S7.GetDWordAt(buffer, Offset.ByteOffset); break; case varType.INT: Value = S7.GetIntAt(buffer, Offset.ByteOffset); break; case varType.DINT: Value = S7.GetDIntAt(buffer, Offset.ByteOffset); break; case varType.REAL: Value = S7.GetRealAt(buffer, Offset.ByteOffset); break; // Added String Read case varType.STRING: Value = S7.GetStringAt(buffer, Offset.ByteOffset); break; } }
private void FieldBtn_Click(object sender, EventArgs e) { /* * 0 Byte 8 Bit Word (All) * 1 Word 16 Bit Word (All) * 2 DWord 32 Bit Word (All) * 3 LWord 64 Bit Word (S71500) * 4 USint 8 Bit Unsigned Integer (S71200/1500) * 5 UInt 16 Bit Unsigned Integer (S71200/1500) * 6 UDInt 32 Bit Unsigned Integer (S71200/1500) * 7 ULint 64 Bit Unsigned Integer (S71500) * 8 Sint 8 Bit Signed Integer (S71200/1500) * 9 Int 16 Bit Signed Integer (All) * 10 DInt 32 Bit Signed Integer (S71200/1500) * 11 LInt 64 Bit Signed Integer (S71500) * 12 Real 32 Bit Floating point (All) * 13 LReal 64 Bit Floating point (S71200/1500) * 14 Time 32 Bit Time elapsed ms (All) * 15 LTime 64 Bit Time Elapsed ns (S71500) * 16 Date 16 Bit days from 1990/1/1 (All) * 17 TOD 32 Bit ms elapsed from midnight (All) * 18 DT 8 Byte Date and Time (All) * 19 LTOD 64 Bit time of day (ns) (S71500) * 20 DTL 12 Byte Date and Time Long (S71200/1500) * 21 LDT 64 Bit ns elapsed from 1970/1/1 (S71500) */ int Pos = System.Convert.ToInt32(TxtOffset.Text); switch (CBType.SelectedIndex) { case 0: { TxtValue.Text = "16#" + System.Convert.ToString(Buffer[Pos], 16).ToUpper(); break; } case 1: { UInt16 Word = S7.GetWordAt(Buffer, Pos); TxtValue.Text = "16#" + System.Convert.ToString(Word, 16).ToUpper(); break; } case 2: { UInt32 DWord = S7.GetDWordAt(Buffer, Pos); TxtValue.Text = "16#" + System.Convert.ToString(DWord, 16).ToUpper(); break; } case 3: { UInt64 LWord = S7.GetLWordAt(Buffer, Pos); TxtValue.Text = "16#" + System.Convert.ToString((Int64)LWord, 16).ToUpper(); // <-- Convert.ToString does not handle UInt64 break; } case 4: { UInt16 USInt = S7.GetUSIntAt(Buffer, Pos); TxtValue.Text = System.Convert.ToString(USInt); break; } case 5: { UInt16 UInt = S7.GetUIntAt(Buffer, Pos); TxtValue.Text = System.Convert.ToString(UInt); break; } case 6: { UInt32 UDInt = S7.GetDWordAt(Buffer, Pos); TxtValue.Text = System.Convert.ToString(UDInt); break; } case 7: { UInt64 ULInt = S7.GetLWordAt(Buffer, Pos); TxtValue.Text = System.Convert.ToString(ULInt); break; } case 8: { int SInt = S7.GetSIntAt(Buffer, Pos); TxtValue.Text = System.Convert.ToString(SInt); break; } case 9: { int S7Int = S7.GetIntAt(Buffer, Pos); TxtValue.Text = System.Convert.ToString(S7Int); break; } case 10: { int DInt = S7.GetDIntAt(Buffer, Pos); TxtValue.Text = System.Convert.ToString(DInt); break; } case 11: { Int64 LInt = S7.GetLIntAt(Buffer, Pos); TxtValue.Text = System.Convert.ToString(LInt); break; } case 12: { Single S7Real = S7.GetRealAt(Buffer, Pos); TxtValue.Text = System.Convert.ToString(S7Real); break; } case 13: { Double S7LReal = S7.GetLRealAt(Buffer, Pos); TxtValue.Text = System.Convert.ToString(S7LReal); break; } case 14: { Int32 TimeElapsed = S7.GetDIntAt(Buffer, Pos); // TIME type is a 32 signed number of ms elapsed // Can be added to a DateTime or used as Value. TxtValue.Text = "T#" + System.Convert.ToString(TimeElapsed) + "MS"; break; } case 15: { Int64 TimeElapsed = S7.GetLIntAt(Buffer, Pos); // LTIME type is a 64 signed number of ns elapsed // Can be added (after a conversion) to a DateTime or used as Value. TxtValue.Text = "LT#" + System.Convert.ToString(TimeElapsed) + "NS"; break; } case 16: { DateTime DATE = S7.GetDateAt(Buffer, Pos); TxtValue.Text = DATE.ToString("D#yyyy-MM-dd"); break; } case 17: { DateTime TOD = S7.GetTODAt(Buffer, Pos); TxtValue.Text = TOD.ToString("TOD#HH:mm:ss.fff"); break; } case 18: { DateTime DT = S7.GetDateTimeAt(Buffer, Pos); TxtValue.Text = DT.ToString("DT#yyyy-MM-dd-HH:mm:ss.fff"); break; } case 19: { DateTime LTOD = S7.GetLTODAt(Buffer, Pos); TxtValue.Text = LTOD.ToString("LTOD#HH:mm:ss.fffffff"); break; } case 20: { DateTime DTL = S7.GetDTLAt(Buffer, Pos); TxtValue.Text = DTL.ToString("DTL#yyyy-MM-dd-HH:mm:ss.fffffff"); break; } case 21: { DateTime LDT = S7.GetLDTAt(Buffer, Pos); TxtValue.Text = LDT.ToString("LDT#yyyy-MM-dd-HH:mm:ss.fffffff"); break; } } }
public void TestGetDWordAt(byte[] buffer, int pos, uint expected) { S7.GetDWordAt(buffer, pos).ShouldBe(expected); }
public DatiJson connect() { DatiJson commessa = new DatiJson(); int result = this.Client.ConnectTo("192.168.0.100", Rack, Slot); if (result != 0) { Console.WriteLine("Connection failed: " + this.Client.ErrorText(result).ToString()); return(commessa); } else { Console.WriteLine("Connect: " + result.ToString()); result = this.Client.DBRead(10, 0, 224, dbBuffer); // lettura codice int x = 0; for (int i = 0; i < 25; i++) { commessa.codice += S7.GetWordAt(dbBuffer, x); x += 2; } // lettura Articolo for (int i = 0; i < 25; i++) { commessa.articolo += S7.GetWordAt(dbBuffer, x); x += 2; } //lettura parziale pezzi commessa.parzialeDiProduzione = Convert.ToInt32(S7.GetDWordAt(dbBuffer, x)); x += 4; //lettura pezzi buoni commessa.PezziBuoni = Convert.ToInt32(S7.GetDWordAt(dbBuffer, x)); x += 4; //lettura pezzi Scarto commessa.PezziScarto = Convert.ToInt32(S7.GetDWordAt(dbBuffer, x)); x += 4; //lettura stato Macchina for (int i = 0; i < commessa.statoMacchina.Length; i++) { commessa.statoMacchina[i] = S7.GetBitAt(dbBuffer, x, i); } x += 2; //lettura velocità macchina commessa.velocitàMacchina = Convert.ToInt32(S7.GetWordAt(dbBuffer, x)); x += 2; //lettura variabile non utilizzata... commessa.out1 = Convert.ToInt32(S7.GetDWordAt(dbBuffer, x)); x += 4; //lettura variabile non utilizzata... commessa.out2 = Convert.ToInt32(S7.GetDWordAt(dbBuffer, x)); x += 4; //lettura avviso per uffici for (int i = 0; i < 25; i++) { commessa.avvisoPerUffici += S7.GetDWordAt(dbBuffer, x); x += 4; } return(commessa); } }
static void Main(string[] args) { //-------------- Create and connect the client var client = new S7Client(); int result = client.ConnectTo("127.0.0.1", 0, 1); if (result == 0) { Console.WriteLine("Connected to 127.0.0.1"); } else { Console.WriteLine(client.ErrorText(result)); Console.ReadKey(); return; } //-------------- Read db1 Console.WriteLine("\n---- Read DB 1"); byte[] db1Buffer = new byte[18]; result = client.DBRead(1, 0, 18, db1Buffer); if (result != 0) { Console.WriteLine("Error: " + client.ErrorText(result)); } int db1dbw2 = S7.GetIntAt(db1Buffer, 2); Console.WriteLine("DB1.DBW2: " + db1dbw2); double db1dbd4 = S7.GetRealAt(db1Buffer, 4); Console.WriteLine("DB1.DBD4: " + db1dbd4); double db1dbd8 = S7.GetDIntAt(db1Buffer, 8); Console.WriteLine("DB1.DBD8: " + db1dbd8); double db1dbd12 = S7.GetDWordAt(db1Buffer, 12); Console.WriteLine("DB1.DBD12: " + db1dbd12); double db1dbw16 = S7.GetWordAt(db1Buffer, 16); Console.WriteLine("DB1.DBD16: " + db1dbw16); //-------------- Read DB3 Console.WriteLine("\n---- Read DB 3"); byte[] db3Buffer = new byte[18]; result = client.DBRead(3, 0, 18, db3Buffer); if (result != 0) { Console.WriteLine("Error: " + client.ErrorText(result)); } int db3dbw2 = S7.GetIntAt(db3Buffer, 2); Console.WriteLine("DB3.DBW2: " + db3dbw2); double db3dbd4 = S7.GetRealAt(db3Buffer, 4); Console.WriteLine("DB3.DBD4: " + db3dbd4); double db3dbd8 = S7.GetDIntAt(db3Buffer, 8); Console.WriteLine("DB3.DBD8: " + db3dbd8); uint db3dbd12 = S7.GetDWordAt(db3Buffer, 12); Console.WriteLine("DB3.DBD12: " + db3dbd12); ushort db3dbd16 = S7.GetWordAt(db3Buffer, 16); Console.WriteLine("DB3.DBD16: " + db3dbd16); //-------------- Write Db1 Console.WriteLine("\n---- Write BD 1"); db1Buffer = new byte[12]; const int START_INDEX = 4; S7.SetRealAt(db1Buffer, 4 - START_INDEX, (float)54.36); S7.SetDIntAt(db1Buffer, 8 - START_INDEX, 555666); S7.SetDWordAt(db1Buffer, 12 - START_INDEX, 123456); result = client.DBWrite(1, START_INDEX, db1Buffer.Length, db1Buffer); if (result != 0) { Console.WriteLine("Error: " + client.ErrorText(result)); } //-------------- Read multi vars var s7MultiVar = new S7MultiVar(client); byte[] db1 = new byte[18]; s7MultiVar.Add(S7Consts.S7AreaDB, S7Consts.S7WLByte, 1, 0, db1.Length, ref db1); byte[] db3 = new byte[18]; s7MultiVar.Add(S7Consts.S7AreaDB, S7Consts.S7WLByte, 3, 0, db3.Length, ref db3); result = s7MultiVar.Read(); if (result != 0) { Console.WriteLine("Error on s7MultiVar.Read()"); } db1dbw2 = S7.GetIntAt(db1, 2); Console.WriteLine("DB1.DBW2.0 = {0}", db1dbw2); db1dbd4 = S7.GetRealAt(db1, 4); Console.WriteLine("DB1.DBW4.0 = {0}", db1dbd4); db1dbd8 = S7.GetDIntAt(db1, 8); Console.WriteLine("DB1.DBW8.0 = {0}", db1dbd8); db3dbw2 = S7.GetIntAt(db3, 2); Console.WriteLine("DB3.DBW2.0 = {0}", db3dbw2); db3dbd4 = S7.GetRealAt(db3, 4); Console.WriteLine("DB3.DBW4.0 = {0}", db3dbd4); db3dbd8 = S7.GetDIntAt(db3, 8); Console.WriteLine("DB3.DBW8.0 = {0}", db3dbd8); //-------------- Write multi vars s7MultiVar = new S7MultiVar(client); const int DB1_START_INDEX = 2; db1 = new byte[10]; S7.SetIntAt(db1, 2 - DB1_START_INDEX, 50); S7.SetRealAt(db1, 4 - DB1_START_INDEX, (float)36.5); S7.SetDIntAt(db1, 8 - DB1_START_INDEX, 123456); s7MultiVar.Add(S7Consts.S7AreaDB, S7Consts.S7WLByte, 1, DB1_START_INDEX, db1.Length, ref db1); const int DB3_START_INDEX = 2; db3 = new byte[10]; S7.SetIntAt(db3, 2 - DB3_START_INDEX, -50); S7.SetRealAt(db3, 4 - DB3_START_INDEX, (float)-25.36); S7.SetDIntAt(db3, 8 - DB3_START_INDEX, -123456); s7MultiVar.Add(S7Consts.S7AreaDB, S7Consts.S7WLByte, 3, DB3_START_INDEX, db3.Length, ref db3); result = s7MultiVar.Write(); if (result != 0) { Console.WriteLine("Error on s7MultiVar.Read()"); } //-------------- Disconnect the client client.Disconnect(); Console.ReadKey(); }
// Thread to Process PLC Read Queue static void ProcessPLC(S7PLC plc) { do { try { System.Threading.Thread.Sleep(5000); S7Client client = new S7Client(); client.SetConnectionType(System.Convert.ToUInt16(plc.connection_type)); client.SetConnectionParams(plc.ip, System.Convert.ToUInt16(plc.local_tsap), System.Convert.ToUInt16(plc.remote_tsap)); Console.WriteLine("Try to connect " + plc.server_name); int res = client.Connect(); if (res != 0 || client.Connected == false) { continue; } Console.WriteLine("Connected " + plc.server_name + " IP:" + plc.ip); S7Client.S7CpuInfo Info = new S7Client.S7CpuInfo(); res = client.GetCpuInfo(ref Info); if (res == 0) { Console.WriteLine(plc.server_name + " Module Type Name : " + Info.ModuleTypeName); Console.WriteLine(plc.server_name + " Serial Number : " + Info.SerialNumber); Console.WriteLine(plc.server_name + " AS Name : " + Info.ASName); Console.WriteLine(plc.server_name + " Module Name : " + Info.ModuleName); } ; System.Threading.Thread.Sleep(1000); while (client.Connected) { foreach (S7RW read in plc.reads) { CheckCommand(client, plc); byte[] Buffer = new byte[1024]; int BytesRead = 0; res = client.ReadArea( System.Convert.ToInt32(read.data_area), System.Convert.ToInt32(read.db), System.Convert.ToInt32(read.offset), System.Convert.ToInt32(read.amount), System.Convert.ToInt32(StringToWordLengthCode(read.data_type)), Buffer, ref BytesRead); if (res == 0) { // HexDump(Buffer, BytesRead); for (int i = 0; i < read.amount; i++) { int bytecnt; double value = 0; switch (read.data_type) { case "BIT": bytecnt = i / 8; value = System.Convert.ToDouble(S7.GetBitAt(Buffer, bytecnt, i % 8)); break; case "BYTE": bytecnt = i; value = S7.GetByteAt(Buffer, bytecnt); break; case "CHAR": bytecnt = i; value = S7.GetByteAt(Buffer, bytecnt); break; case "WORD": bytecnt = i * 2; value = S7.GetWordAt(Buffer, bytecnt); break; case "DWORD": bytecnt = i * 4; value = S7.GetDWordAt(Buffer, bytecnt); break; case "INT": bytecnt = i * 2; value = S7.GetIntAt(Buffer, bytecnt); break; case "DINT": bytecnt = i * 4; value = S7.GetDIntAt(Buffer, bytecnt); break; case "REAL": bytecnt = i * 4; value = S7.GetRealAt(Buffer, bytecnt); break; case "COUNTER": bytecnt = i * 2; value = S7.GetCounter((ushort)((Buffer[bytecnt + 1] << 8) + (Buffer[bytecnt]))); break; case "TIMER": bytecnt = i * 2; value = (ushort)((Buffer[bytecnt + 1] << 8) + (Buffer[bytecnt])); break; default: Console.WriteLine("Unsupported data type: " + read.data_type); break; } SendUdp(Encoding.ASCII.GetBytes( "[{\"point_key\":" + (read.point_number + i) + ",\"value\":" + value + ",\"failed\":false" + "}]")); if (logread) { Console.WriteLine(plc.server_name + " " + read.name + " OSHMI_POINT_NUMBER=" + (read.point_number + i) + " VALUE=" + value + " " + read.data_type); } } } else { Console.WriteLine(plc.server_name + " Error " + read.name); } System.Threading.Thread.Sleep(System.Convert.ToInt32(read.delay_ms)); } } // client.Disconnect(); Console.WriteLine("Disconnected " + plc.server_name); } catch (Exception e) { // EXCEPTION HANDLER Console.WriteLine("Exception " + plc.server_name); Console.WriteLine(e); } System.Threading.Thread.Sleep(10000); } while (true); }
private bool GetValue(int S7Type, int Pos, byte[] Buffer, ref string TxtValue) { /* * 0 Byte 8 Bit Word (All) * 1 Word 16 Bit Word (All) * 2 DWord 32 Bit Word (All) * 3 LWord 64 Bit Word (S71500) * 4 USint 8 Bit Unsigned Integer (S71200/1500) * 5 UInt 16 Bit Unsigned Integer (S71200/1500) * 6 UDInt 32 Bit Unsigned Integer (S71200/1500) * 7 ULint 64 Bit Unsigned Integer (S71500) * 8 Sint 8 Bit Signed Integer (S71200/1500) * 9 Int 16 Bit Signed Integer (All) * 10 DInt 32 Bit Signed Integer (S71200/1500) * 11 LInt 64 Bit Signed Integer (S71500) * 12 Real 32 Bit Floating point (All) * 13 LReal 64 Bit Floating point (S71200/1500) * 14 Time 32 Bit Time elapsed ms (All) * 15 LTime 64 Bit Time Elapsed ns (S71500) * 16 Date 16 Bit days from 1990/1/1 (All) * 17 TOD 32 Bit ms elapsed from midnight (All) * 18 DT 8 Byte Date and Time (All) * 19 LTOD 64 Bit time of day (ns) (S71500) * 20 DTL 12 Byte Date and Time Long (S71200/1500) * 21 LDT 64 Bit ns elapsed from 1970/1/1 (S71500) * 22 Bit */ //When WordLen = S7WLBit the Offset(Start) must be expressed in bits.Ex.The Start for DB4.DBX 10.3 is (10 * 8) + 3 = 83. switch (S7Type) { case 0: { TxtValue = System.Convert.ToString(Buffer[Pos], 10).ToUpper(); break; } case 1: { UInt16 Word = S7.GetWordAt(Buffer, Pos); TxtValue = System.Convert.ToString(Word, 10).ToUpper(); break; } case 2: { UInt32 DWord = S7.GetDWordAt(Buffer, Pos); TxtValue = System.Convert.ToString(DWord, 10).ToUpper(); break; } case 3: { UInt64 LWord = S7.GetLWordAt(Buffer, Pos); TxtValue = System.Convert.ToString((Int64)LWord, 10).ToUpper(); // <-- Convert.ToString does not handle UInt64 break; } case 4: { UInt16 USInt = S7.GetUSIntAt(Buffer, Pos); TxtValue = System.Convert.ToString(USInt); break; } case 5: { UInt16 UInt = S7.GetUIntAt(Buffer, Pos); TxtValue = System.Convert.ToString(UInt); break; } case 6: { UInt32 UDInt = S7.GetDWordAt(Buffer, Pos); TxtValue = System.Convert.ToString(UDInt); break; } case 7: { UInt64 ULInt = S7.GetLWordAt(Buffer, Pos); TxtValue = System.Convert.ToString(ULInt); break; } case 8: { int SInt = S7.GetSIntAt(Buffer, Pos); TxtValue = System.Convert.ToString(SInt); break; } case 9: { int S7Int = S7.GetIntAt(Buffer, Pos); TxtValue = System.Convert.ToString(S7Int); break; } case 10: { int DInt = S7.GetDIntAt(Buffer, Pos); TxtValue = System.Convert.ToString(DInt); break; } case 11: { Int64 LInt = S7.GetLIntAt(Buffer, Pos); TxtValue = System.Convert.ToString(LInt); break; } case 12: { Single S7Real = S7.GetRealAt(Buffer, Pos); TxtValue = System.Convert.ToString(S7Real); break; } case 13: { Double S7LReal = S7.GetLRealAt(Buffer, Pos); TxtValue = System.Convert.ToString(S7LReal); break; } case 14: { Int32 TimeElapsed = S7.GetDIntAt(Buffer, Pos); // TIME type is a 32 signed number of ms elapsed // Can be added to a DateTime or used as Value. TxtValue = System.Convert.ToString(TimeElapsed) + "MS"; break; } case 15: { Int64 TimeElapsed = S7.GetLIntAt(Buffer, Pos); // LTIME type is a 64 signed number of ns elapsed // Can be added (after a conversion) to a DateTime or used as Value. TxtValue = System.Convert.ToString(TimeElapsed) + "NS"; break; } case 16: { DateTime DATE = S7.GetDateAt(Buffer, Pos); TxtValue = DATE.ToString("D#yyyy-MM-dd"); break; } case 17: { DateTime TOD = S7.GetTODAt(Buffer, Pos); TxtValue = TOD.ToString("TOD#HH:mm:ss.fff"); break; } case 18: { DateTime DT = S7.GetDateTimeAt(Buffer, Pos); TxtValue = DT.ToString("DT#yyyy-MM-dd-HH:mm:ss.fff"); break; } case 19: { DateTime LTOD = S7.GetLTODAt(Buffer, Pos); TxtValue = LTOD.ToString("LTOD#HH:mm:ss.fffffff"); break; } case 20: { DateTime DTL = S7.GetDTLAt(Buffer, Pos); TxtValue = DTL.ToString("DTL#yyyy-MM-dd-HH:mm:ss.fffffff"); break; } case 21: { DateTime LDT = S7.GetLDTAt(Buffer, Pos); TxtValue = LDT.ToString("LDT#yyyy-MM-dd-HH:mm:ss.fffffff"); break; } case 22: { bool bit = S7.GetBitAt(Buffer, Pos, 0); TxtValue = bit.ToString(); break; } default: return(false); } return(true); }