|
|
@ -11,9 +11,6 @@ public static class ModbusDecoder
|
|
|
|
|
|
|
|
|
|
|
|
public static T Decode<T>(byte[] bytes, T t) where T : class, new()
|
|
|
|
public static T Decode<T>(byte[] bytes, T t) where T : class, new()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<object?> fields = t.GetType().GetProperties()
|
|
|
|
List<object?> fields = t.GetType().GetProperties()
|
|
|
|
.Where(it => it.PropertyType.GetGenericTypeDefinition() == typeof(ModbusProperty<>))
|
|
|
|
.Where(it => it.PropertyType.GetGenericTypeDefinition() == typeof(ModbusProperty<>))
|
|
|
|
.Select(p => p.GetValue(t)).ToList();
|
|
|
|
.Select(p => p.GetValue(t)).ToList();
|
|
|
@ -113,11 +110,6 @@ public static class ModbusDecoder
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return t;
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|