using HslCommunication; using HslCommunication.ModBus; using HybirdFrameworkDriver.ModbusTcpMaster; using HybirdFrameworkDriver.TcpServer; using HybirdFrameworkServices.Plc; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HybirdFrameworkServices.Init.Entity { public class PlcInfo { #region 字段 /// /// ModbusTcp客户端 /// //public ModbusTcpNet _client = null; /// /// 设备编号 /// private string _devNo = "001"; /// /// 设备名称 /// private string _devname = "换电PLC"; /// /// 服务端连接IP /// private string _ipaddr = "172.0.20.48"; /// /// 服务端连接端口 /// private int _port = 502; /// /// 站号 /// private byte _site = 0x01; /// /// 连接超时时间。单位秒 /// private int _connecttimeout = 10; /// /// 保持活跃时间。单位秒 /// private int _keepalive = 30; /// /// 连接状态 /// private ConnectState _connect_state = ConnectState.NOCONNECT; #endregion 字段 public string ChannelId; public int EqmSn; public HostToPlc hostToPlc=new HostToPlc(); public PlcToHost plcToHost =new PlcToHost(); public PlcFault plcFault = new PlcFault(); public PlcInfo(string channelId, int eqmSn) { ChannelId = channelId; EqmSn = eqmSn; } public bool WriteUint16(ModbusProperty value) { bool bResult = false; ModbusSession session = SessionMgr.GetModbusSession(ChannelId); bResult = session.Write(value); return bResult; } public bool Writeint16(ModbusProperty value) { bool bResult = false; ModbusSession session = SessionMgr.GetModbusSession(ChannelId); bResult = session.Write(value); return bResult; } } }