public SocketDriverASCII(String module, String IP, int Port) { _mouldeID = module; receiveSock = new CSerialDriver(); SendSock = new CSerialDriver(); _ip = IP; receivePort = Port; sendPort = Port + 1; receiveSock.Name = module + "_" + receivePort.ToString(); receiveSock.OnReceived += RecvreceiveSock_OnReceived; receiveSock.ConnectionStateChanged += Sock_ConnectionStateChanged; SendSock.Name = module + "_" + sendPort.ToString(); SendSock.OnReceived += SendSock_OnReceived; SendSock.ConnectionStateChanged += Sock_ConnectionStateChanged; receiveSock.EnableLog(false, false); }
public void SocketConnected(string module, int socketCount, string IP, int Port, bool isActive) { if (String.IsNullOrEmpty(IP)) { return; } int iPort = Port; sock_dic = new Dictionary <string, CSerialDriver>(); EqpId = module; for (int i = 1; i <= socketCount; i++) { CSerialDriver serialDrv = new CSerialDriver(); serialDrv.Name = module + "_" + iPort.ToString(); serialDrv.ConnectionStateChanged += Sock_ConnectionStateChanged; serialDrv.OnReceivedBytes += Recv_sock_OnReceivedBytes; if (isActive) { serialDrv.ConnectionInfoString = string.Format("MODE=TCP_ACTIVE, IP={0}, PORT={1}, KEEP_ALIVE=1", IP, iPort); serialDrv.ActiveOpen(); } else { serialDrv.ConnectionInfoString = string.Format("MODE=TCP_PASSIVE, PORT={0}, KEEP_ALIVE=1", iPort); serialDrv.Open(); } serialDrv.EnableLog(false, false); sock_dic.Add(serialDrv.Name, serialDrv); iPort++; } _byteModule = new byte[EqpId.Length]; for (int i = 0; i < EqpId.Length; i++) { _byteModule[i] = Convert.ToByte(EqpId[i]); } }
public SocketDriverIPS(String module, String IP, int Port) { _sock = new CSerialDriver(); _ip = IP; _port = Port; sock_dic = new Dictionary <string, CSerialDriver>(); _sock.Name = module; _sock.OnReceived += Recv_sock_OnReceived; _sock.ConnectionStateChanged += Sock_ConnectionStateChanged; _mouldeID = module; heartbeatTimer = new System.Timers.Timer(); heartbeatTimer.Interval = IpsTelegram.HEARTBEAT_INTERVAL; heartbeatTimer.Elapsed += new System.Timers.ElapsedEventHandler(HeartbeatTimer_Elapsed); _sock.EnableLog(false, false); sock_dic.Add(_sock.Name, _sock); }
public void EnableLog(bool bLog) { _sock.EnableLog(bLog, bLog); }
public void EnableLog(bool bLog) { receiveSock.EnableLog(bLog, bLog); SendSock.EnableLog(bLog, bLog); }