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

56 lines
1.2 KiB
C#
Raw Normal View History

2024-06-12 12:05:29 +00:00
using InnovEnergy.Lib.Protocols.Modbus.Channels;
2023-07-11 12:06:53 +00:00
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)
{
}
2024-06-04 10:23:19 +00:00
private Iem3KGridMeterDevice(Channel channel, Byte slaveId = 1) : base(new ModbusTcpClient(channel, slaveId))
2023-07-11 12:06:53 +00:00
{
}
2024-06-07 08:36:15 +00:00
2023-07-11 12:06:53 +00:00
public Iem3KGridMeterDevice(ModbusClient client) : base(client)
{
}
public new Iem3KGridMeterRegisters? Read()
{
try
{
return base.Read();
}
2024-06-07 08:36:15 +00:00
catch
2023-07-11 12:06:53 +00:00
{
// TODO: Log
$"Failed to read data from {nameof(Iem3KGridMeterDevice)}".WriteLine();
return null;
}
}
public new void Write(Iem3KGridMeterRegisters registers)
{
try
{
base.Write(registers);
}
2024-06-07 08:36:15 +00:00
catch
2023-07-11 12:06:53 +00:00
{
// TODO: Log
$"Failed to write data to {nameof(Iem3KGridMeterDevice)}".WriteLine();
}
}
2024-06-04 10:23:19 +00:00
2024-06-07 08:36:15 +00:00
}