Exemple #1
0
 public ItemData <string> ReadString(DeviceAddress address, ushort size)
 {
     byte[] data = WriteSyncData(XGTFENETMessage.ReadHoldingRegistersMessage((byte)address.Area, Convert.ToString(address.Start), (ushort)address.DBNumber));
     if (Extract(data, data.Length).ToArray() == null)
     {
         return(new ItemData <string>(string.Empty, 0, QUALITIES.QUALITY_BAD));
     }
     else
     {
         return(new ItemData <string>(Encoding.ASCII.GetString(Extract(data, data.Length).ToArray(), 0, data.Length), 0, QUALITIES.QUALITY_GOOD));//是否考虑字节序问题?
     }
 }
Exemple #2
0
 public unsafe ItemData <float> ReadFloat(DeviceAddress address)
 {
     byte[] data = WriteSyncData(XGTFENETMessage.ReadHoldingRegistersMessage((byte)address.Area, Convert.ToString(address.Start), (ushort)address.DBNumber));
     if (Extract(data, data.Length).ToArray() == null)
     {
         return(new ItemData <float>(0.0f, 0, QUALITIES.QUALITY_BAD));
     }
     else
     {
         return(new ItemData <float>(IPAddress.HostToNetworkOrder(BitConverter.ToInt32(Extract(data, data.Length).ToArray(), 0)), 0, QUALITIES.QUALITY_GOOD));
     }
 }
Exemple #3
0
 public ItemData <byte> ReadByte(DeviceAddress address)
 {
     byte[] data = WriteSyncData(XGTFENETMessage.ReadHoldingRegistersMessage((byte)address.Area, Convert.ToString(address.Start), (ushort)address.DBNumber));
     if (Extract(data, data.Length).ToArray() == null)
     {
         return(new ItemData <byte>(0, 0, QUALITIES.QUALITY_BAD));
     }
     else
     {
         return(new ItemData <byte>(Extract(data, data.Length).ToArray()[0], 0, QUALITIES.QUALITY_GOOD));
     }
 }