2023-04-05 11:05:38 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2023-06-13 11:01:01 +00:00
|
|
|
using InnovEnergy.Lib.Protocols.Modbus.Channels;
|
2023-04-05 11:05:38 +00:00
|
|
|
using InnovEnergy.Lib.Protocols.Modbus.Clients;
|
2023-06-13 11:01:01 +00:00
|
|
|
using InnovEnergy.Lib.Protocols.Modbus.Slaves;
|
2023-04-05 11:05:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace InnovEnergy.Lib.Devices.Trumpf.SystemControl;
|
|
|
|
|
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
|
|
|
public class SystemControlDevice
|
|
|
|
{
|
2023-06-13 11:01:01 +00:00
|
|
|
private readonly ModbusDevice<SystemControlRegisters> _SystemControlSlave;
|
|
|
|
public Channel Channel { get; }
|
2023-04-05 11:05:38 +00:00
|
|
|
|
2023-06-13 11:01:01 +00:00
|
|
|
public SystemControlDevice(String hostname, Int32 port = 502) : this(new TcpChannel(hostname, port))
|
2023-04-05 11:05:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-06-13 11:01:01 +00:00
|
|
|
public SystemControlDevice(Channel channel)
|
2023-04-05 11:05:38 +00:00
|
|
|
{
|
2023-06-13 11:01:01 +00:00
|
|
|
Channel = channel;
|
|
|
|
|
|
|
|
var tcpClient = new ModbusTcpClient(channel, 0);
|
|
|
|
_SystemControlSlave = new ModbusDevice<SystemControlRegisters>(tcpClient);
|
2023-04-05 11:05:38 +00:00
|
|
|
}
|
|
|
|
|
2023-06-13 11:01:01 +00:00
|
|
|
public void Write(SystemControlRegisters c) => _SystemControlSlave.Write(c);
|
|
|
|
public SystemControlRegisters Read() => _SystemControlSlave.Read();
|
2023-04-05 11:05:38 +00:00
|
|
|
}
|