31 lines
728 B
C#
31 lines
728 B
C#
|
|
|
|
namespace InnovEnergy.Lib.Protocols.Modbus.Reflection.Attributes;
|
|
|
|
public abstract class ModbusRegisterAttribute : ModbusAttribute
|
|
{
|
|
public Double Scale { get; init; } = 1;
|
|
public Double Offset { get; init; } = 0;
|
|
|
|
protected ModbusRegisterAttribute(UInt16 address, TypeCode modbusType) : base(address, modbusType)
|
|
{
|
|
if (!SupportedTypes.Contains(modbusType))
|
|
throw new ArgumentException(nameof(modbusType));
|
|
}
|
|
|
|
|
|
internal static readonly TypeCode[] SupportedTypes =
|
|
{
|
|
TypeCode.UInt16,
|
|
TypeCode.Int16,
|
|
TypeCode.UInt32,
|
|
TypeCode.Int32,
|
|
TypeCode.UInt64,
|
|
TypeCode.Int64,
|
|
TypeCode.Single,
|
|
TypeCode.Double
|
|
};
|
|
|
|
}
|
|
|