Exemplo n.º 1
0
        private void SimplifyServer_ReceiveStringEvent(AppSession session, HslCommunication.NetHandle handle, string data)
        {
            if (handle == 0)
            {
                // 请求配置文件
                simplifyServer.SendMessage(session, handle, xElementSettings != null ? xElementSettings.ToString( ) : string.Empty);
            }
            else if (handle == 1)
            {
                // 请求设备的所有数据
                string[] nodePath = data.Split(new char[] { '\\', ':', '-', '.', '_', '/' });
                string   response = string.Empty;

                for (int i = 0; i < deviceCores.Count; i++)
                {
                    if (deviceCores[i].IsCurrentDevice(nodePath))
                    {
                        response = deviceCores[i].GetValueByName(nodePath);
                        break;
                    }
                }

                logNet?.WriteDebug("请求设备信息:" + data);
                simplifyServer.SendMessage(session, handle, response);
            }
            else
            {
                simplifyServer.SendMessage(session, handle, data);
            }
        }
Exemplo n.º 2
0
 private void ComplexClient_AcceptByte(AsyncStateOne stateOne, HslCommunication.NetHandle handle, byte[] buffer)
 {
     // 接收到服务器发送过来的字节数据时触发
     if (handle == 1)
     {
         // 该buffer是读取到的西门子数据
         ShowReadContent(buffer);
     }
 }
Exemplo n.º 3
0
 private void SimplifyServer_ReceiveStringEvent(AppSession session, HslCommunication.NetHandle handle, string value)
 {
     if (handle == 1)
     {
         // 当收到客户端发来的信号1的时候进行操作的消息
         simplifyServer.SendMessage(session, handle, "这是测试信号:" + value);
     }
     else if (handle < 100)
     {
         simplifyServer.SendMessage(session, handle, "这是测试信号:" + handle);
     }
     else
     {
         simplifyServer.SendMessage(session, handle, "不支持的消息");
     }
 }
Exemplo n.º 4
0
        private void ComplexClient_AcceptByte(AsyncStateOne stateOne, HslCommunication.NetHandle handle, byte[] buffer)
        {
            // 接收到服务器发送过来的字节数据时触发
            if (handle == 1)
            {
                // 该buffer是读取到的西门子数据
                if (isClientIni)
                {
                    ShowReadContent(buffer);
                }
            }
            else if (handle == 2)
            {
                // 初始化的数据
                ShowHistory(buffer);

                isClientIni = true;
            }
        }
Exemplo n.º 5
0
 private void NetSimplify_ReceiveStringEvent(AsyncStateOne state, HslCommunication.NetHandle handle, string msg)
 {
     if (handle == 1)
     {
         // 远程启动设备
         string back = siemensTcpNet.WriteIntoPLC("M102", (byte)1).IsSuccess ? "成功启动" : "失败启动";
         netSimplify.SendMessage(state, handle, back);
     }
     else if (handle == 2)
     {
         // 远程停止设备
         string back = siemensTcpNet.WriteIntoPLC("M102", (byte)0).IsSuccess ? "成功停止" : "失败停止";
         netSimplify.SendMessage(state, handle, back);
     }
     else
     {
         netSimplify.SendMessage(state, handle, msg);
     }
 }
Exemplo n.º 6
0
        private void ComplexClient_AcceptByte(AppSession session, HslCommunication.NetHandle handle, byte[] buffer)
        {
            // 接收到服务器发送过来的字节数据时触发
            if (handle == 1)
            {
                // 该buffer是读取到的西门子数据
                //if (isClientIni)
                //{
                //    ShowReadContent( buffer );
                //}
            }
            else if (handle == 2)
            {
                // 初始化的数据
                ShowHistory(buffer);

                isClientIni = true;
            }
        }
Exemplo n.º 7
0
 private void NetSimplify_ReceiveStringEvent(AppSession session, HslCommunication.NetHandle handle, string msg)
 {
     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
     {
         netSimplify.SendMessage(session, handle, msg);
     }
 }
Exemplo n.º 8
0
        private void SimplifyServer_ReceiveStringEvent(AppSession session, HslCommunication.NetHandle handle, string value)
        {
            if (handle == 1)
            {
                // 当收到客户端发来的信号1的时候进行操作的消息
                simplifyServer.SendMessage(session, handle, "这是测试信号:" + value);
            }
            else if (handle < 100)
            {
                simplifyServer.SendMessage(session, handle, "这是测试信号:" + handle);
            }
            else
            {
                simplifyServer.SendMessage(session, handle, "不支持的消息");
            }


            // 显示出来,谁发的,发了什么
            textBox2.Invoke(new Action(() => {
                textBox2.AppendText($"[{session}] [{handle}] {value}" + Environment.NewLine);
            }));
        }
Exemplo n.º 9
0
 private void ComplexClient_AcceptString(AsyncStateOne stateOne, HslCommunication.NetHandle handle, string data)
 {
     // 接收到服务器发送过来的字符串数据时触发
 }
Exemplo n.º 10
0
 private void NetComplex_AcceptString(AsyncStateOne stateone, HslCommunication.NetHandle handle, string data)
 {
     // 接收到客户端发来的数据时触发
 }
Exemplo n.º 11
0
 private void ComplexClient_AcceptString(AppSession session, HslCommunication.NetHandle handle, string data)
 {
     // 接收到服务器发送过来的字符串数据时触发
 }