Innovenergy_trunk/csharp/Lib/Devices/Battery48TL/Battery48TLDevice.cs

47 lines
1.3 KiB
C#
Raw Normal View History

2023-05-06 13:41:59 +00:00
using System.IO.Ports;
using InnovEnergy.Lib.Protocols.Modbus.Channels;
2023-02-16 12:57:06 +00:00
using InnovEnergy.Lib.Protocols.Modbus.Clients;
2023-05-06 13:41:59 +00:00
using InnovEnergy.Lib.Protocols.Modbus.Slaves;
using InnovEnergy.Lib.Utils;
using static System.IO.Ports.Parity;
2023-02-16 12:57:06 +00:00
namespace InnovEnergy.Lib.Devices.Battery48TL;
2023-05-06 13:41:59 +00:00
public class Battery48TlDevice: ModbusDevice<Battery48TlRegisters>
2023-02-16 12:57:06 +00:00
{
2023-05-06 13:41:59 +00:00
public const Parity Parity = Odd;
public const Int32 StopBits = 1;
public const Int32 BaudRate = 115200;
public const Int32 DataBits = 8;
public Battery48TlDevice(String tty, Byte slaveId, SshHost host) : this
(
channel: new RemoteSerialChannel(host, tty, BaudRate, Parity, StopBits, DataBits),
slaveId
)
{}
2023-02-16 12:57:06 +00:00
2023-05-06 13:41:59 +00:00
public Battery48TlDevice(String tty, Byte slaveId, String? host = null) : this
(
channel: host switch
{
null => new SerialPortChannel ( tty, BaudRate, Parity, StopBits, DataBits),
_ => new RemoteSerialChannel(host, tty, BaudRate, Parity, StopBits, DataBits)
},
slaveId
)
{}
2023-02-16 12:57:06 +00:00
2023-05-06 13:41:59 +00:00
public Battery48TlDevice(Channel channel, Byte slaveId) : this
(
client: new ModbusRtuClient(channel, slaveId)
)
{}
2023-02-16 12:57:06 +00:00
2023-05-06 13:41:59 +00:00
public Battery48TlDevice(ModbusClient client): base(client)
2023-02-16 12:57:06 +00:00
{
}
}