You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
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<String, Object> BusinessMap { get; set; }
|
|
public ModbusSession(ModbusTcpMaster.ModbusTcpMaster modbusTcpMaster)
|
|
{
|
|
this.ModbusTcpMaster = modbusTcpMaster;
|
|
this.IpAddr = modbusTcpMaster.Ip;
|
|
this.Key = modbusTcpMaster.connectId;
|
|
}
|
|
|
|
|
|
public bool Write<T>(ModbusProperty<T> property)
|
|
{
|
|
return ModbusTcpMaster.WriteValue(property);
|
|
}
|
|
public byte[]? Read(int registerNo, int length)
|
|
{
|
|
return ModbusTcpMaster.BatchRead(registerNo, length);
|
|
}
|
|
|
|
|
|
}
|
|
}
|