private void NetSimplify_ReceiveStringEvent(AppSession session, HslCommunication.NetHandle handle, string msg) { #region 之前 //if (handle == 0) //{ // hostComputerCommand.WriteOpenCommand(siemensTcpNetNew);//启动PLC //} //else if (handle == 1) //{ // string tmp = StartPLC(); // LogNet?.WriteInfo(tmp); // // 远程启动设备 // netSimplify.SendMessage(session, handle, tmp); //} //else if (handle == 2) //{ // string tmp = StopPLC(); // LogNet?.WriteInfo(tmp); // // 远程停止设备 // netSimplify.SendMessage(session, handle, tmp); //} //else if (handle == 301) //{ // MessageBox.Show("夹具"); //} //else //{ // netSimplify.SendMessage(session, handle, msg); //} #endregion #region 收到客户端发送的指令代码 switch (handle) { case 301: //MessageBox.Show("开始"); InsLogNet.WriteInfo("301"); //netSimplify.SendMessage(session, handle, "301"); //hostComputerCommand.WriteThreeZeroOneCommand(siemensTcpNetNew, ++counter, 301, 1); //MessageBox.Show("结束"); break; case 302: InsLogNet.WriteInfo("302"); hostComputerCommand.WriteThreeZeroOneCommand(siemensTcpNetNew, ++counter, 301, 2); break; case 303: InsLogNet.WriteInfo("303"); hostComputerCommand.WriteThreeZeroOneCommand(siemensTcpNetNew, ++counter, 301, 3); break; default: InsLogNet.WriteInfo("无指令"); break; } #endregion }
private void NetComplex_AcceptString(AppSession stateone, HslCommunication.NetHandle handle, string data) { // 接收到客户端发来的数据时触发 switch (data) { case "启动": hostComputerCommand.WriteRunCommand(siemensTcpNetNew); break; case "停止": hostComputerCommand.WriteStopCommand(siemensTcpNetNew);; break; case "夹具": MessageBox.Show("收到夹具命令"); break; default: MessageBox.Show("收到命令"); break; } }
private void SimplifyServer_ReceiveStringEvent(HslCommunication.Core.Net.AppSession session, HslCommunication.NetHandle handle, string data) { // 示例情况,接收到数据后返回消息 simplifyServer.SendMessage(session, handle, "Back:" + data); }