Innovenergy_trunk/csharp/Lib/Protocols/Modbus/Clients/ModbusClient.cs

39 lines
1.6 KiB
C#

using InnovEnergy.Lib.Protocols.Modbus.Channels;
using InnovEnergy.Lib.Protocols.Modbus.Protocol.Frames.Accessors;
namespace InnovEnergy.Lib.Protocols.Modbus.Clients;
using Booleans = IReadOnlyCollection<Boolean>;
using UInt16s = IReadOnlyCollection<UInt16>;
// TODO: ModbusClient = Framer(TCP/RTU) + Connection(Serial/TCP) + Encoder(binary/ascii) + quirk(+1/0)
// Transport
public abstract class ModbusClient
{
public Byte SlaveId { get; }
internal Channel Channel { get; }
internal Endian Endian { get; }
// TODO: add additional functions: coils...
public abstract MbData ReadCoils (UInt16 readAddress, UInt16 nValues);
public abstract MbData ReadDiscreteInputs (UInt16 readAddress, UInt16 nValues);
public abstract MbData ReadInputRegisters (UInt16 readAddress, UInt16 nValues);
public abstract MbData ReadHoldingRegisters(UInt16 readAddress, UInt16 nValues);
public abstract UInt16 WriteCoils (UInt16 writeAddress, Booleans coils);
public abstract UInt16 WriteRegisters (UInt16 writeAddress, UInt16s values);
public abstract MbData ReadWriteRegisters (UInt16 readAddress,
UInt16 nbToRead,
UInt16 writeAddress,
UInt16s registersToWrite);
protected ModbusClient(Channel channel, Byte slaveId, Endian endian = Endian.Little)
{
Channel = channel;
SlaveId = slaveId;
Endian = endian;
}
}