2023-05-04 07:32:35 +00:00
|
|
|
using InnovEnergy.Lib.Protocols.Modbus.Channels;
|
|
|
|
using InnovEnergy.Lib.Protocols.Modbus.Clients;
|
|
|
|
|
2024-06-07 08:36:15 +00:00
|
|
|
/*namespace InnovEnergy.Lib.Protocols.Modbus.Slaves;
|
2023-05-04 07:32:35 +00:00
|
|
|
|
|
|
|
public static class ModbusSlave
|
|
|
|
{
|
|
|
|
|
|
|
|
public static Func<Byte, ModbusTcpClient> ModbusTcp(this Channel channel)
|
|
|
|
{
|
|
|
|
ModbusTcpClient SlaveId(Byte slaveId) => new ModbusTcpClient(channel, slaveId);
|
|
|
|
return SlaveId;
|
|
|
|
}
|
2024-06-07 08:36:15 +00:00
|
|
|
|
2023-05-04 07:32:35 +00:00
|
|
|
public static Func<Byte, ModbusRtuClient> ModbusRtu(this Channel channel)
|
|
|
|
{
|
|
|
|
ModbusRtuClient SlaveId(Byte slaveId) => new ModbusRtuClient(channel, slaveId);
|
|
|
|
return SlaveId;
|
|
|
|
}
|
2024-06-07 08:36:15 +00:00
|
|
|
|
|
|
|
|
2023-05-04 07:32:35 +00:00
|
|
|
public static Func<Byte, ModbusTcpClient> ModbusTcp<R>(this Channel channel) where R : notnull, new()
|
|
|
|
{
|
|
|
|
ModbusTcpClient SlaveId(Byte slaveId)
|
|
|
|
{
|
|
|
|
return new ModbusTcpClient(channel, slaveId);
|
|
|
|
}
|
|
|
|
|
|
|
|
return SlaveId;
|
|
|
|
}
|
2024-06-07 08:36:15 +00:00
|
|
|
|
2023-05-04 07:32:35 +00:00
|
|
|
public static Func<Byte, ModbusRtuClient> ModbusRtu<R>(this Channel channel) where R : notnull, new()
|
|
|
|
{
|
|
|
|
ModbusRtuClient SlaveId(Byte slaveId) => new ModbusRtuClient(channel, slaveId);
|
|
|
|
return SlaveId;
|
|
|
|
}
|
2024-06-07 08:36:15 +00:00
|
|
|
|
2023-05-04 07:32:35 +00:00
|
|
|
public static ModbusDevice<T> TcpSlave<T>(this Channel channel, Byte slaveId) where T : notnull, new()
|
|
|
|
{
|
|
|
|
var client = new ModbusTcpClient(channel, slaveId);
|
|
|
|
return new ModbusDevice<T>(client);
|
|
|
|
}
|
2024-06-07 08:36:15 +00:00
|
|
|
|
2023-05-04 07:32:35 +00:00
|
|
|
public static ModbusDevice<T> RtuSlave<T>(this Channel channel, Byte slaveId) where T : notnull, new()
|
|
|
|
{
|
|
|
|
var client = new ModbusRtuClient(channel, slaveId);
|
|
|
|
return new ModbusDevice<T>(client);
|
|
|
|
}
|
2024-06-07 08:36:15 +00:00
|
|
|
|
2023-05-04 07:32:35 +00:00
|
|
|
public static ModbusDevice<T> Slave<T>(this ModbusClient modbusClient) where T : notnull, new()
|
|
|
|
{
|
|
|
|
return new ModbusDevice<T>(modbusClient);
|
|
|
|
}
|
2024-06-07 08:36:15 +00:00
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
using InnovEnergy.Lib.Protocols.Modbus.Channels;
|
|
|
|
using InnovEnergy.Lib.Protocols.Modbus.Clients;
|
|
|
|
|
|
|
|
namespace InnovEnergy.Lib.Protocols.Modbus.Slaves
|
|
|
|
{
|
|
|
|
public static class ModbusSlave
|
|
|
|
{
|
|
|
|
public static Func<byte, ModbusTcpClient> ModbusTcp(this Channel channel)
|
|
|
|
{
|
|
|
|
ModbusTcpClient SlaveId(byte slaveId) => new ModbusTcpClient((TcpChannel)channel, slaveId);
|
|
|
|
return SlaveId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Func<byte, ModbusRtuClient> ModbusRtu(this Channel channel)
|
|
|
|
{
|
|
|
|
ModbusRtuClient SlaveId(byte slaveId) => new ModbusRtuClient(channel, slaveId);
|
|
|
|
return SlaveId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Func<byte, ModbusTcpClient> ModbusTcp<R>(this Channel channel) where R : notnull, new()
|
|
|
|
{
|
|
|
|
ModbusTcpClient SlaveId(byte slaveId)
|
|
|
|
{
|
|
|
|
return new ModbusTcpClient((TcpChannel)channel, slaveId);
|
|
|
|
}
|
|
|
|
|
|
|
|
return SlaveId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Func<byte, ModbusRtuClient> ModbusRtu<R>(this Channel channel) where R : notnull, new()
|
|
|
|
{
|
|
|
|
ModbusRtuClient SlaveId(byte slaveId) => new ModbusRtuClient(channel, slaveId);
|
|
|
|
return SlaveId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ModbusDevice<T> TcpSlave<T>(this Channel channel, byte slaveId) where T : notnull, new()
|
|
|
|
{
|
|
|
|
var client = new ModbusTcpClient((TcpChannel)channel, slaveId);
|
|
|
|
return new ModbusDevice<T>(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ModbusDevice<T> RtuSlave<T>(this Channel channel, byte slaveId) where T : notnull, new()
|
|
|
|
{
|
|
|
|
var client = new ModbusRtuClient(channel, slaveId);
|
|
|
|
return new ModbusDevice<T>(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ModbusDevice<T> Slave<T>(this ModbusClient modbusClient) where T : notnull, new()
|
|
|
|
{
|
|
|
|
return new ModbusDevice<T>(modbusClient);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|