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

46 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-08-18 13:57:00 +00:00
public class Battery48TlDevice : ModbusDevice<Battery48TlRecord>
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
(
2023-06-13 10:53:52 +00:00
channel: new RemoteSerialChannel(host, tty, BaudRate, Parity, DataBits, StopBits),
2023-05-06 13:41:59 +00:00
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
{
2023-06-13 10:53:52 +00:00
null => new SerialPortChannel ( tty, BaudRate, Parity, DataBits, StopBits),
_ => new RemoteSerialChannel(host, tty, BaudRate, Parity, DataBits, StopBits)
2023-05-06 13:41:59 +00:00
},
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
{
}
}