Innovenergy_trunk/csharp/Lib/Devices/IEM3kGridMeter/IEM3kGridMeterDevice.cs

50 lines
1.2 KiB
C#

using InnovEnergy.Lib.Protocols.Modbus.Channels;
using InnovEnergy.Lib.Protocols.Modbus.Clients;
using InnovEnergy.Lib.Protocols.Modbus.Slaves;
using InnovEnergy.Lib.Utils;
namespace InnovEnergy.Lib.Devices.IEM3kGridMeter;
public class Iem3KGridMeterDevice: ModbusDevice<Iem3KGridMeterRegisters>
{
public Iem3KGridMeterDevice(String hostname, UInt16 port = 502, Byte slaveId = 1) : this(new TcpChannel(hostname, port), slaveId)
{
}
public Iem3KGridMeterDevice(Channel channel, Byte slaveId = 1) : base(new ModbusTcpClient(channel, slaveId))
{
}
public Iem3KGridMeterDevice(ModbusClient client) : base(client)
{
}
public new Iem3KGridMeterRegisters? Read()
{
try
{
return base.Read();
}
catch
{
// TODO: Log
$"Failed to read data from {nameof(Iem3KGridMeterDevice)}".WriteLine();
return null;
}
}
public new void Write(Iem3KGridMeterRegisters registers)
{
try
{
base.Write(registers);
}
catch
{
// TODO: Log
$"Failed to write data to {nameof(Iem3KGridMeterDevice)}".WriteLine();
}
}
}