Ejemplo n.º 1
0
        private void ReadFromServer(int head_code)
        {
            OperateResultString result = net_simplify_client.ReadFromServer(head_code);

            if (result.IsSuccess)
            {
                logNetAnalysisControl1.SetLogNetSource(result.Content);
            }
            else
            {
                MessageBox.Show(result.ToMessageShowString());
            }
        }
Ejemplo n.º 2
0
 private void userButton2_Click(object sender, EventArgs e)
 {
     // 远程通知服务器启动设备
     HslCommunication.OperateResult <string> operate = simplifyClient.ReadFromServer(1, "");
     if (operate.IsSuccess)
     {
         MessageBox.Show(operate.Content);
     }
     else
     {
         MessageBox.Show("启动失败!");
     }
 }
        private void button3_Click(object sender, EventArgs e)
        {
            // 数据发送
            NetHandle handle = new NetHandle( );

            if (textBox5.Text.IndexOf('.') >= 0)
            {
                string[] values = textBox5.Text.Split('.');
                handle = new NetHandle(byte.Parse(values[0]), byte.Parse(values[1]), ushort.Parse(values[2]));
            }
            else
            {
                handle = int.Parse(textBox5.Text);
            }


            int      count = int.Parse(textBox6.Text);
            DateTime start = DateTime.Now;

            for (int i = 0; i < count; i++)
            {
                OperateResult <string> read = simplifyClient.ReadFromServer(handle, textBox4.Text);
                if (read.IsSuccess)
                {
                    textBox8.AppendText(read.Content + Environment.NewLine);
                }
                else
                {
                    MessageBox.Show("读取失败:" + read.ToMessageShowString( ));
                }
            }

            textBox7.Text = (DateTime.Now - start).TotalMilliseconds.ToString("F2");
        }
Ejemplo n.º 4
0
        public ActionResult StopPlc()
        {
            NetSimplifyClient simplifyClient = new NetSimplifyClient("127.0.0.1", 23457);

            HslCommunication.OperateResult <string> operate = simplifyClient.ReadFromServer(2, "");
            if (operate.IsSuccess)
            {
                return(Content(operate.Content));
            }
            else
            {
                return(Content("停止失败!" + operate.Message));
            }
        }
Ejemplo n.º 5
0
        private void FormNodeView_Shown(object sender, EventArgs e)
        {
            simplifyClient = new NetSimplifyClient(ipAddress, port);
            if (!simplifyClient.ConnectServer().IsSuccess)
            {
                MessageBox.Show("连接服务器失败!请稍候重新连接");
                Close();
                return;
            }


            // 请求配置文件信息
            var resultXml = simplifyClient.ReadFromServer(0, "");

            if (!resultXml.IsSuccess)
            {
                MessageBox.Show("请求配置文件异常,准备退出!");
                Close();
                return;
            }

            ParseFromXmlResourse(resultXml.Content);
        }