Browse Source

CacheIndex是WORD为单位,因此进行byte转换时要 * 2

pull/22/head
Kevin 8 years ago
parent
commit
05e500ffad
  1. 16
      SCADA/Program/DataService/CacheReader.cs

16
SCADA/Program/DataService/CacheReader.cs

@ -139,8 +139,8 @@ namespace DataService
public int WriteString(DeviceAddress address, string str)
{
byte[] b = Encoding.ASCII.GetBytes(str);
int index = address.CacheIndex;
Array.Copy(b, 0, _cache, index, b.Length);
int index = address.CacheIndex * 2;
Buffer.BlockCopy(b, 0, _cache, index, b.Length);
return 0;
}
@ -301,8 +301,8 @@ namespace DataService
public int WriteString(DeviceAddress address, string str)
{
byte[] b = Encoding.ASCII.GetBytes(str);
int index = address.CacheIndex;
Array.Copy(b, 0, _cache, index, b.Length);
int index = address.CacheIndex * 2;
Buffer.BlockCopy(b, 0, _cache, index, b.Length);
return 0;
}
@ -495,7 +495,7 @@ namespace DataService
public int WriteString(DeviceAddress address, string str)
{
byte[] b = Encoding.ASCII.GetBytes(str);
int index = address.CacheIndex;
int index = address.CacheIndex * 2;
Buffer.BlockCopy(b, 0, _cache, index, b.Length);
return 0;
}
@ -694,7 +694,7 @@ namespace DataService
public int WriteString(DeviceAddress address, string str)
{
byte[] b = Encoding.ASCII.GetBytes(str);
int index = address.CacheIndex;
int index = address.CacheIndex * 2;
Buffer.BlockCopy(b, 0, _cache, index, b.Length);
return 0;
}
@ -863,7 +863,7 @@ namespace DataService
public int WriteString(DeviceAddress address, string str)
{
byte[] b = Encoding.ASCII.GetBytes(str);
int index = address.CacheIndex;
int index = address.CacheIndex * 2;
Buffer.BlockCopy(b, 0, _cache, index, b.Length);
return 0;
}
@ -1029,7 +1029,7 @@ namespace DataService
public int WriteString(DeviceAddress address, string str)
{
byte[] b = Encoding.ASCII.GetBytes(str);
int index = address.CacheIndex;
int index = address.CacheIndex * 2;
Buffer.BlockCopy(b, 0, _cache, index, b.Length);
return 0;
}

Loading…
Cancel
Save