From fadf539aeedfd01e99f400a5ade498dca3c5e7d5 Mon Sep 17 00:00:00 2001 From: CZ Date: Wed, 15 May 2024 16:39:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=89=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ModbusTcpMaster/ModbusDecoder.cs | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) 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; }