mirror of
https://github.com/S7NetPlus/s7netplus.git
synced 2026-02-17 22:38:27 +08:00
Fixes a bug that couldn't write correctly negative values when writing short or int.
Signed-off-by: Michele Cattafesta <michele.cattafesta@mesta-automation.com>
This commit is contained in:
@@ -593,10 +593,24 @@ namespace S7.Net
|
||||
objValue = Convert.ChangeType(value, typeof(byte));
|
||||
return Write(DataType.DataBlock, mDB, dbIndex, (byte)objValue);
|
||||
case "DBW":
|
||||
objValue = Convert.ChangeType(value, typeof(UInt16));
|
||||
if (value is short)
|
||||
{
|
||||
objValue = ((short)value).ConvertToUshort();
|
||||
}
|
||||
else
|
||||
{
|
||||
objValue = Convert.ChangeType(value, typeof(UInt16));
|
||||
}
|
||||
return Write(DataType.DataBlock, mDB, dbIndex, (UInt16)objValue);
|
||||
case "DBD":
|
||||
objValue = Convert.ChangeType(value, typeof(UInt32));
|
||||
if (value is int)
|
||||
{
|
||||
return Write(DataType.DataBlock, mDB, dbIndex, (Int32)value);
|
||||
}
|
||||
else
|
||||
{
|
||||
objValue = Convert.ChangeType(value, typeof(UInt32));
|
||||
}
|
||||
return Write(DataType.DataBlock, mDB, dbIndex, (UInt32)objValue);
|
||||
case "DBX":
|
||||
mByte = dbIndex;
|
||||
|
||||
Reference in New Issue
Block a user