|
|
|
@ -34,14 +34,24 @@ namespace DataService |
|
|
|
return start.Area == end.Area && start.DBNumber == end.DBNumber ? start.Start - end.Start : ushort.MaxValue; |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<bool> ReadBit(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<bool>((_cache[address.CacheIndex] & (1 << address.Bit)) != 0, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<int> ReadInt32(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<int>(BitConverter.ToInt32(_cache, address.CacheIndex), 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<bool> ReadBit(DeviceAddress address) |
|
|
|
public ItemData<uint> ReadUInt32(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<bool>((_cache[address.CacheIndex] & (1 << address.Bit)) != 0, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
return new ItemData<uint>(BitConverter.ToUInt32(_cache, address.CacheIndex), 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<ushort> ReadUInt16(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<ushort>(BitConverter.ToUInt16(_cache, address.CacheIndex), 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<short> ReadInt16(DeviceAddress address) |
|
|
|
@ -90,6 +100,24 @@ namespace DataService |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteUInt16(DeviceAddress address, ushort value) |
|
|
|
{ |
|
|
|
fixed (byte* p1 = _cache) |
|
|
|
{ |
|
|
|
Marshal.WriteInt16((IntPtr)(p1 + address.CacheIndex), (short)value); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteUInt32(DeviceAddress address, uint value) |
|
|
|
{ |
|
|
|
fixed (byte* p1 = _cache) |
|
|
|
{ |
|
|
|
Marshal.WriteInt32((IntPtr)(p1 + address.CacheIndex), (int)value); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteInt32(DeviceAddress address, int value) |
|
|
|
{ |
|
|
|
fixed (byte* p1 = _cache) |
|
|
|
@ -168,14 +196,24 @@ namespace DataService |
|
|
|
return start.Area == end.Area && start.DBNumber == end.DBNumber ? start.Start - end.Start : ushort.MaxValue; |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<bool> ReadBit(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<bool>((_cache[address.CacheIndex] & (1 << address.Bit)) != 0, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<int> ReadInt32(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<int>(Utility.NetToInt32(_cache, address.CacheIndex), 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<bool> ReadBit(DeviceAddress address) |
|
|
|
public ItemData<uint> ReadUInt32(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<bool>((_cache[address.CacheIndex] & (1 << address.Bit)) != 0, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
return new ItemData<uint>((uint)Utility.NetToInt32(_cache, address.CacheIndex), 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<ushort> ReadUInt16(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<ushort>((ushort)Utility.NetToInt16(_cache, address.CacheIndex), 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<short> ReadInt16(DeviceAddress address) |
|
|
|
@ -224,6 +262,24 @@ namespace DataService |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteUInt16(DeviceAddress address, ushort value) |
|
|
|
{ |
|
|
|
fixed (byte* p1 = _cache) |
|
|
|
{ |
|
|
|
Marshal.WriteInt16((IntPtr)(p1 + address.CacheIndex), IPAddress.HostToNetworkOrder((short)value)); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteUInt32(DeviceAddress address, uint value) |
|
|
|
{ |
|
|
|
fixed (byte* p1 = _cache) |
|
|
|
{ |
|
|
|
Marshal.WriteInt32((IntPtr)(p1 + address.CacheIndex), IPAddress.HostToNetworkOrder((int)value)); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteInt32(DeviceAddress address, int value) |
|
|
|
{ |
|
|
|
fixed (byte* p1 = _cache) |
|
|
|
@ -318,6 +374,11 @@ namespace DataService |
|
|
|
return start.Area == end.Area && start.DBNumber == end.DBNumber ? start.Start - end.Start : ushort.MaxValue; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe ItemData<bool> ReadBit(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<bool>((_cache[address.CacheIndex] & (1 << address.Bit)) != 0, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<int> ReadInt32(DeviceAddress address) |
|
|
|
{ |
|
|
|
int startIndex = address.CacheIndex; |
|
|
|
@ -333,9 +394,9 @@ namespace DataService |
|
|
|
return new ItemData<int>(result, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe ItemData<bool> ReadBit(DeviceAddress address) |
|
|
|
public ItemData<uint> ReadUInt32(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<bool>((_cache[address.CacheIndex] & (1 << address.Bit)) != 0, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
return new ItemData<uint>((uint)ReadInt32(address).Value, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<short> ReadInt16(DeviceAddress address) |
|
|
|
@ -343,6 +404,11 @@ namespace DataService |
|
|
|
return new ItemData<short>(_cache[address.CacheIndex], 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<ushort> ReadUInt16(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<ushort>((ushort)_cache[address.CacheIndex], 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<byte> ReadByte(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<byte>((byte)_cache[address.CacheIndex], 0, QUALITIES.QUALITY_GOOD); |
|
|
|
@ -387,12 +453,27 @@ namespace DataService |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteInt16(DeviceAddress address, short value) |
|
|
|
public int WriteInt16(DeviceAddress address, short value) |
|
|
|
{ |
|
|
|
_cache[address.CacheIndex] = value; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public int WriteUInt16(DeviceAddress address, ushort value) |
|
|
|
{ |
|
|
|
_cache[address.CacheIndex] = (short)value; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteUInt32(DeviceAddress address, uint value) |
|
|
|
{ |
|
|
|
fixed (short* p1 = _cache) |
|
|
|
{ |
|
|
|
Marshal.WriteInt32((IntPtr)(p1 + address.CacheIndex), (int)value); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteInt32(DeviceAddress address, int value) |
|
|
|
{ |
|
|
|
fixed (short* p1 = _cache) |
|
|
|
@ -486,6 +567,11 @@ namespace DataService |
|
|
|
return start.Area == end.Area && start.DBNumber == end.DBNumber ? start.Start - end.Start : ushort.MaxValue; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe ItemData<bool> ReadBit(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<bool>((_cache[address.CacheIndex] & (1 << address.Bit)) != 0, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<int> ReadInt32(DeviceAddress address) |
|
|
|
{ |
|
|
|
int startIndex = address.CacheIndex; |
|
|
|
@ -501,9 +587,14 @@ namespace DataService |
|
|
|
return new ItemData<int>(result, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe ItemData<bool> ReadBit(DeviceAddress address) |
|
|
|
public ItemData<uint> ReadUInt32(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<bool>((_cache[address.CacheIndex] & (1 << address.Bit)) != 0, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
return new ItemData<uint>((uint)ReadInt32(address).Value, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<ushort> ReadUInt16(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<ushort>((ushort)IPAddress.HostToNetworkOrder(_cache[address.CacheIndex]), 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<short> ReadInt16(DeviceAddress address) |
|
|
|
@ -561,12 +652,18 @@ namespace DataService |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteInt16(DeviceAddress address, short value) |
|
|
|
public int WriteInt16(DeviceAddress address, short value) |
|
|
|
{ |
|
|
|
_cache[address.CacheIndex] = value; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public int WriteUInt16(DeviceAddress address, ushort value) |
|
|
|
{ |
|
|
|
_cache[address.CacheIndex] = (short)value; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteInt32(DeviceAddress address, int value) |
|
|
|
{ |
|
|
|
fixed (short* p1 = _cache) |
|
|
|
@ -576,6 +673,15 @@ namespace DataService |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteUInt32(DeviceAddress address, uint value) |
|
|
|
{ |
|
|
|
fixed (short* p1 = _cache) |
|
|
|
{ |
|
|
|
Marshal.WriteInt32((IntPtr)(p1 + address.CacheIndex), IPAddress.HostToNetworkOrder((int)value)); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteFloat(DeviceAddress address, float value) |
|
|
|
{ |
|
|
|
fixed (short* p1 = _cache) |
|
|
|
@ -661,15 +767,24 @@ namespace DataService |
|
|
|
return start.Area == end.Area && start.DBNumber == end.DBNumber ? start.Start - end.Start : ushort.MaxValue; |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<int> ReadInt32(DeviceAddress address) |
|
|
|
public unsafe ItemData<bool> ReadBit(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<bool>((_cache[address.CacheIndex] & (1 << address.Bit)) != 0, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<int> ReadInt32(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<int>(_cache[address.CacheIndex], 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe ItemData<bool> ReadBit(DeviceAddress address) |
|
|
|
public ItemData<uint> ReadUInt32(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<bool>((_cache[address.CacheIndex] & (1 << address.Bit)) != 0, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
return new ItemData<uint>((uint)_cache[address.CacheIndex], 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<ushort> ReadUInt16(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<ushort>((ushort)_cache[address.CacheIndex], 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<short> ReadInt16(DeviceAddress address) |
|
|
|
@ -718,6 +833,18 @@ namespace DataService |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteUInt16(DeviceAddress address, ushort value) |
|
|
|
{ |
|
|
|
_cache[address.CacheIndex] = value; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteUInt32(DeviceAddress address, uint value) |
|
|
|
{ |
|
|
|
_cache[address.CacheIndex] = (int)value; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteInt32(DeviceAddress address, int value) |
|
|
|
{ |
|
|
|
_cache[address.CacheIndex] = value; |
|
|
|
@ -809,15 +936,25 @@ namespace DataService |
|
|
|
return start.Area == end.Area && start.DBNumber == end.DBNumber ? start.Start - end.Start : ushort.MaxValue; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe ItemData<bool> ReadBit(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<bool>(((int)_cache[address.CacheIndex] & (1 << address.Bit)) != 0, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<int> ReadInt32(DeviceAddress address) |
|
|
|
{ |
|
|
|
|
|
|
|
return new ItemData<int>((int)_cache[address.CacheIndex], 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe ItemData<bool> ReadBit(DeviceAddress address) |
|
|
|
public ItemData<uint> ReadUInt32(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<bool>(((int)_cache[address.CacheIndex] & (1 << address.Bit)) != 0, 0, QUALITIES.QUALITY_GOOD); |
|
|
|
return new ItemData<uint>((uint)_cache[address.CacheIndex], 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<ushort> ReadUInt16(DeviceAddress address) |
|
|
|
{ |
|
|
|
return new ItemData<ushort>((ushort)_cache[address.CacheIndex], 0, QUALITIES.QUALITY_GOOD); |
|
|
|
} |
|
|
|
|
|
|
|
public ItemData<short> ReadInt16(DeviceAddress address) |
|
|
|
@ -859,19 +996,31 @@ namespace DataService |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteInt16(DeviceAddress address, short value) |
|
|
|
public int WriteInt16(DeviceAddress address, short value) |
|
|
|
{ |
|
|
|
_cache[address.CacheIndex] = value; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteInt32(DeviceAddress address, int value) |
|
|
|
public int WriteUInt16(DeviceAddress address, ushort value) |
|
|
|
{ |
|
|
|
_cache[address.CacheIndex] = value; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public unsafe int WriteFloat(DeviceAddress address, float value) |
|
|
|
public int WriteUInt32(DeviceAddress address, uint value) |
|
|
|
{ |
|
|
|
_cache[address.CacheIndex] = value; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public int WriteInt32(DeviceAddress address, int value) |
|
|
|
{ |
|
|
|
_cache[address.CacheIndex] = value; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
public int WriteFloat(DeviceAddress address, float value) |
|
|
|
{ |
|
|
|
_cache[address.CacheIndex] = value; |
|
|
|
return 0; |
|
|
|
|