|
|
|
|
namespace HybirdFrameworkDriver.ModbusTcpMaster;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
public class ModbusProperty<T> : IModbusProperty
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="registerNo">寄存器编号</param>
|
|
|
|
|
/// <param name="start">根据类型:Register为第几个寄存器</param>
|
|
|
|
|
/// <param name="length">根据类型:Register 为 几个寄存器(2byte)</param>
|
|
|
|
|
/// <param name="type">Register/Bit</param>
|
|
|
|
|
/// <param name="scale">精度</param>
|
|
|
|
|
/// <param name="round">保留几位小数</param>
|
|
|
|
|
/// <param name="offset">偏移量</param>
|
|
|
|
|
public ModbusProperty(int registerNo, int start = 0, int length = 1, ModbusDataType type = ModbusDataType.Register,
|
|
|
|
|
double scale = 1, int round = 0, double offset = 0, T value=default)
|
|
|
|
|
{
|
|
|
|
|
RegisterNo = registerNo;
|
|
|
|
|
Start = start;
|
|
|
|
|
Length = length;
|
|
|
|
|
Type = type;
|
|
|
|
|
Scale = scale;
|
|
|
|
|
Round = round;
|
|
|
|
|
Offset = offset;
|
|
|
|
|
Value = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 寄存器编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int RegisterNo { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 数据起始地址
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Start { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 数据域长度
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Length { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 数据类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ModbusDataType Type { get; set; }
|
|
|
|
|
|
|
|
|
|
public double Scale { get; set; }
|
|
|
|
|
public int Round { get; set; }
|
|
|
|
|
public double Offset { get; set; }
|
|
|
|
|
public T Value { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int GetRegisterNo()
|
|
|
|
|
{
|
|
|
|
|
return RegisterNo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum ModbusDataType
|
|
|
|
|
{
|
|
|
|
|
Bit,
|
|
|
|
|
Register
|
|
|
|
|
}
|