using System.Collections.Concurrent; using DotNetty.Buffers; using DotNetty.Transport.Channels; using HybirdFrameworkDriver.ModbusTcpMaster; using log4net; namespace HybirdFrameworkDriver.Session; public class ModbusSession { private static readonly ILog Log = LogManager.GetLogger(typeof(ModbusSession)); public ModbusTcpMaster.ModbusTcpMaster ModbusTcpMaster; private String IpAddr { get; } public String Key { get; set; } public ConcurrentDictionary BusinessMap { get;set; } public ModbusSession(ModbusTcpMaster.ModbusTcpMaster modbusTcpMaster) { this.ModbusTcpMaster = modbusTcpMaster; this.IpAddr = modbusTcpMaster.Ip; this.Key = modbusTcpMaster.connectId; } public bool Write(ModbusProperty property) { return ModbusTcpMaster.WriteValue(property); } public byte[]? Read(int registerNo, int length) { return ModbusTcpMaster.BatchRead(registerNo,length); } }