|
|
|
@ -45,69 +45,69 @@ public static class ModbusDecoder
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var field in fields)
|
|
|
|
|
switch (field)
|
|
|
|
|
{
|
|
|
|
|
case ModbusProperty<bool> boolProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, boolProperty, decodeUseBytes);
|
|
|
|
|
//SetPropertyValue(boolProperty.RegisterNo, boolProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<byte> byteProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, byteProperty, decodeUseBytes);
|
|
|
|
|
//SetPropertyValue(byteProperty.RegisterNo, byteProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<sbyte> sbyteProperty:
|
|
|
|
|
{
|
|
|
|
|
//SetPropertyValue(sbyteProperty.RegisterNo, sbyteProperty, decodeUseBytes);
|
|
|
|
|
SetPropertyValue(startRegisterNo, sbyteProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<short> shortProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, shortProperty, decodeUseBytes);
|
|
|
|
|
//SetPropertyValue(shortProperty.RegisterNo, shortProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<ushort> ushortProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, ushortProperty, decodeUseBytes);
|
|
|
|
|
// SetPropertyValue(ushortProperty.RegisterNo, ushortProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<int> intProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, intProperty, decodeUseBytes);
|
|
|
|
|
// SetPropertyValue(intProperty.RegisterNo, intProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<uint> uintProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, uintProperty, decodeUseBytes);
|
|
|
|
|
// SetPropertyValue(uintProperty.RegisterNo, uintProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<float> floatProperty:
|
|
|
|
|
switch (field)
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, floatProperty, decodeUseBytes, true);
|
|
|
|
|
// SetPropertyValue(floatProperty.RegisterNo, floatProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
case ModbusProperty<bool> boolProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, boolProperty, decodeUseBytes);
|
|
|
|
|
//SetPropertyValue(boolProperty.RegisterNo, boolProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<byte> byteProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, byteProperty, decodeUseBytes);
|
|
|
|
|
//SetPropertyValue(byteProperty.RegisterNo, byteProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<sbyte> sbyteProperty:
|
|
|
|
|
{
|
|
|
|
|
//SetPropertyValue(sbyteProperty.RegisterNo, sbyteProperty, decodeUseBytes);
|
|
|
|
|
SetPropertyValue(startRegisterNo, sbyteProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<short> shortProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, shortProperty, decodeUseBytes);
|
|
|
|
|
//SetPropertyValue(shortProperty.RegisterNo, shortProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<ushort> ushortProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, ushortProperty, decodeUseBytes);
|
|
|
|
|
// SetPropertyValue(ushortProperty.RegisterNo, ushortProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<int> intProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, intProperty, decodeUseBytes);
|
|
|
|
|
// SetPropertyValue(intProperty.RegisterNo, intProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<uint> uintProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, uintProperty, decodeUseBytes);
|
|
|
|
|
// SetPropertyValue(uintProperty.RegisterNo, uintProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<float> floatProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, floatProperty, decodeUseBytes, true);
|
|
|
|
|
// SetPropertyValue(floatProperty.RegisterNo, floatProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<double> doubleProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, doubleProperty, decodeUseBytes);
|
|
|
|
|
// SetPropertyValue(doubleProperty.RegisterNo, doubleProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<string> stringProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, stringProperty, decodeUseBytes);
|
|
|
|
|
// SetPropertyValue(stringProperty.RegisterNo, stringProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<double> doubleProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, doubleProperty, decodeUseBytes);
|
|
|
|
|
// SetPropertyValue(doubleProperty.RegisterNo, doubleProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModbusProperty<string> stringProperty:
|
|
|
|
|
{
|
|
|
|
|
SetPropertyValue(startRegisterNo, stringProperty, decodeUseBytes);
|
|
|
|
|
// SetPropertyValue(stringProperty.RegisterNo, stringProperty, decodeUseBytes);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|