using System;
namespace AMWD.Protocols.Modbus.Common
{
///
/// Represents a holding register.
///
public class HoldingRegister : ModbusObject
{
///
public override ModbusObjectType Type => ModbusObjectType.HoldingRegister;
///
/// Gets or sets the value of the holding register.
///
public ushort Value
{
get
{
return new[] { HighByte, LowByte }.GetBigEndianUInt16();
}
set
{
var blob = value.ToBigEndianBytes();
HighByte = blob[0];
LowByte = blob[1];
}
}
///
public override string ToString()
=> $"Holding Register #{Address} | {Value} | HI: {HighByte:X2}, LO: {LowByte:X2}";
}
}