47 lines
1.0 KiB
C#
47 lines
1.0 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.Doepke;
|
|
|
|
public class DoepkeDevice : ModbusDevice<DoepkeRegisters>
|
|
{
|
|
|
|
public DoepkeDevice(String hostname, Byte slaveId = 0, UInt16 port = 502) :
|
|
this(new TcpChannel(hostname, port), slaveId)
|
|
{
|
|
|
|
}
|
|
|
|
public DoepkeDevice(Channel channel, Byte slaveId = 0) : base(new ModbusTcpClient(channel, slaveId))
|
|
{
|
|
}
|
|
|
|
public new DoepkeRegisters? Read()
|
|
{
|
|
try
|
|
{
|
|
return base.Read();
|
|
}
|
|
catch
|
|
{
|
|
"Failed to read data from Doepke".WriteLine();
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
public new void Write(DoepkeRegisters registers)
|
|
{
|
|
try
|
|
{
|
|
base.Write(registers);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// TODO: Log
|
|
Console.WriteLine(e);
|
|
}
|
|
}
|
|
} |