diff --git a/HybirdFrameworkDriver/ModbusTcpMaster/ModbusDecoder.cs b/HybirdFrameworkDriver/ModbusTcpMaster/ModbusDecoder.cs index 6406245..063a51b 100644 --- a/HybirdFrameworkDriver/ModbusTcpMaster/ModbusDecoder.cs +++ b/HybirdFrameworkDriver/ModbusTcpMaster/ModbusDecoder.cs @@ -11,9 +11,6 @@ public static class ModbusDecoder public static T Decode(byte[] bytes, T t) where T : class, new() { - try - { - List fields = t.GetType().GetProperties() .Where(it => it.PropertyType.GetGenericTypeDefinition() == typeof(ModbusProperty<>)) .Select(p => p.GetValue(t)).ToList(); @@ -77,46 +74,41 @@ public static class ModbusDecoder case ModbusProperty ushortProperty: { SetPropertyValue(startRegisterNo, ushortProperty, decodeUseBytes); - // SetPropertyValue(ushortProperty.RegisterNo, ushortProperty, decodeUseBytes); + // SetPropertyValue(ushortProperty.RegisterNo, ushortProperty, decodeUseBytes); break; } case ModbusProperty intProperty: { SetPropertyValue(startRegisterNo, intProperty, decodeUseBytes); - // SetPropertyValue(intProperty.RegisterNo, intProperty, decodeUseBytes); + // SetPropertyValue(intProperty.RegisterNo, intProperty, decodeUseBytes); break; } case ModbusProperty uintProperty: { SetPropertyValue(startRegisterNo, uintProperty, decodeUseBytes); - // SetPropertyValue(uintProperty.RegisterNo, uintProperty, decodeUseBytes); + // SetPropertyValue(uintProperty.RegisterNo, uintProperty, decodeUseBytes); break; } case ModbusProperty floatProperty: { SetPropertyValue(startRegisterNo, floatProperty, decodeUseBytes); - // SetPropertyValue(floatProperty.RegisterNo, floatProperty, decodeUseBytes); + // SetPropertyValue(floatProperty.RegisterNo, floatProperty, decodeUseBytes); break; } case ModbusProperty doubleProperty: { SetPropertyValue(startRegisterNo, doubleProperty, decodeUseBytes); - // SetPropertyValue(doubleProperty.RegisterNo, doubleProperty, decodeUseBytes); + // SetPropertyValue(doubleProperty.RegisterNo, doubleProperty, decodeUseBytes); break; } case ModbusProperty stringProperty: { SetPropertyValue(startRegisterNo, stringProperty, decodeUseBytes); - // SetPropertyValue(stringProperty.RegisterNo, stringProperty, decodeUseBytes); + // SetPropertyValue(stringProperty.RegisterNo, stringProperty, decodeUseBytes); break; } } - } - } - catch (Exception ex) - { - } return t; }