コード例 #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     // 断开连接
     fujiSPB.ConnectClose( );
     button2.Enabled = false;
     button1.Enabled = true;
     panel2.Enabled  = false;
 }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!int.TryParse(textBox2.Text, out int port))
            {
                MessageBox.Show(DemoUtils.PortInputWrong);
                return;
            }

            fujiSPB?.ConnectClose( );
            fujiSPB           = new FujiSPHNet( );
            fujiSPB.IpAddress = textBox1.Text;
            fujiSPB.Port      = port;

            try
            {
                fujiSPB.ConnectionID = byte.Parse(textBox15.Text);
                OperateResult connect = fujiSPB.ConnectServer( );
                if (connect.IsSuccess)
                {
                    MessageBox.Show(HslCommunication.StringResources.Language.ConnectedSuccess);

                    button2.Enabled = true;
                    button1.Enabled = false;
                    panel2.Enabled  = true;

                    userControlReadWriteOp1.SetReadWriteNet(fujiSPB, "M1.1000", true);
                }
                else
                {
                    MessageBox.Show(HslCommunication.StringResources.Language.ConnectedFailed);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }