private void userButton41_Click(object sender, EventArgs e) { // 读取操作,这里的M100可以替换成I100,Q100,DB20.100效果时一样的 bool M100_7 = siemensTcpNet.ReadBool("M100.7").Content; // 读取M100.7是否通断 byte byte_M100 = siemensTcpNet.ReadByte("M100").Content; // 读取M100的值 short short_M100 = siemensTcpNet.ReadInt16("M100").Content; // 读取M100-M101组成的字 ushort ushort_M100 = siemensTcpNet.ReadUInt16("M100").Content; // 读取M100-M101组成的无符号的值 int int_M100 = siemensTcpNet.ReadInt32("M100").Content; // 读取M100-M103组成的有符号的数据 uint uint_M100 = siemensTcpNet.ReadUInt32("M100").Content; // 读取M100-M103组成的无符号的值 float float_M100 = siemensTcpNet.ReadFloat("M100").Content; // 读取M100-M103组成的单精度值 long long_M100 = siemensTcpNet.ReadInt64("M100").Content; // 读取M100-M107组成的大数据值 ulong ulong_M100 = siemensTcpNet.ReadUInt64("M100").Content; // 读取M100-M107组成的无符号大数据 double double_M100 = siemensTcpNet.ReadDouble("M100").Content; // 读取M100-M107组成的双精度值 string str_M100 = siemensTcpNet.ReadString("M100", 10).Content; // 读取M100-M109组成的ASCII字符串数据 MachineInfoTwo machine100 = siemensTcpNet.ReadCustomer <MachineInfoTwo>("D100").Content; // 读取自定义的对象 // 写入操作,这里的M100可以替换成I100,Q100,DB20.100效果时一样的 siemensTcpNet.Write("M100.7", true); // 写位 siemensTcpNet.Write("M100", (byte)0x33); // 写单个字节 siemensTcpNet.Write("M100", (short)12345); // 写双字节有符号 siemensTcpNet.Write("M100", (ushort)45678); // 写双字节无符号 siemensTcpNet.Write("M100", 123456789); // 写双字有符号 siemensTcpNet.Write("M100", (uint)3456789123); // 写双字无符号 siemensTcpNet.Write("M100", 123.456f); // 写单精度 siemensTcpNet.Write("M100", 1234556434534545L); // 写大整数有符号 siemensTcpNet.Write("M100", 523434234234343UL); // 写大整数无符号 siemensTcpNet.Write("M100", 123.456d); // 写双精度 siemensTcpNet.Write("M100", "K123456789"); // 写ASCII字符串 siemensTcpNet.WriteCustomer <MachineInfoTwo>("M100", machine100); // 写入自定义的对象 }