Innovenergy_trunk/csharp/Lib/Devices/Trumpf/SystemControl/SystemControlDevice.cs

29 lines
966 B
C#

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