using HybirdFrameworkDriver.ModbusTcpMaster; using log4net; using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HybirdFrameworkDriver.TcpServer { public class ModbusSession { private 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); } } }