private void TcpClientRecvData(object sender, TCPClient.ReceiveDataEventArgs e) { if (InvokeRequired) { this.BeginInvoke(new Action(() => TcpClientRecvData(sender, e))); } else { lock (objClientRecvLock) { string data = e.DataConvertedByBytesReceived; data = data.Replace("\0", ""); data = data.Replace("\r", ""); data = data.Replace("\n", ""); if (data == "RLG START") { UpdateControlsSize(); Form_Communication.Instance.tcpClientCtrl_Slave.Send(data); } else if (data == "RLG STOP") { Form_Communication.Instance.tcpClientCtrl_Slave.Send(data); } else if (data == "RLG QSTATUS NOTEST") { //老化平台软件打开,但还没开始测试时,处于NOTEST状态 } else if (data == "RLG QSTATUS TESTING") { } else if (data == "RLG QSTATUS STOP") { if (!timer1.Enabled) { timer1.Interval = Form_Set.Instance.m_SysParam.m_ReadAgeResultWhatTime; timer1.Enabled = true; } } } } }
private void TcpSlaveRecvData(object sender, TCPClient.ReceiveDataEventArgs e) { if (InvokeRequired) { this.BeginInvoke(new Action(() => TcpSlaveRecvData(sender, e))); } else { lock (objSlaveRecvLock) { string data = e.DataConvertedByBytesReceived; data = data.Replace("\0", ""); data = data.Replace("\r", ""); data = data.Replace("\n", ""); if (data == "RLG START" || data == "RLG STOP" || data == "RLG QSTATUS") { emCmdType cmdType = emCmdType.Stop; if (data == "RLG STOP") { cmdType = emCmdType.Stop; } else if (data == "RLG START") { cmdType = emCmdType.Start; } else if (data == "RLG QSTATUS") { cmdType = emCmdType.Query; } DoTest(cmdType); } else if (data == "Online") { Form_Communication.Instance.tcpClientCtrl_Slave.Send("Online"); } } } }