Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!int.TryParse(textBox2.Text, out int port))
            {
                MessageBox.Show(DemoUtils.PortInputWrong);
                return;
            }

            omronCipNet?.ConnectClose( );
            omronCipNet = new OmronConnectedCipNet(textBox1.Text, port);

            omronCipNet.SetPersistentConnection( );

            try
            {
                OperateResult connect = omronCipNet.ConnectServer( );
                if (connect.IsSuccess)
                {
                    MessageBox.Show(HslCommunication.StringResources.Language.ConnectedSuccess);
                    button2.Enabled = true;
                    button1.Enabled = false;
                    panel2.Enabled  = true;
                    userControlReadWriteOp1.SetReadWriteNet(omronCipNet, "A1", true, 1);
                }
                else
                {
                    MessageBox.Show(StringResources.Language.ConnectedFailed + connect.ToMessageShowString( ));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
 private void button2_Click(object sender, EventArgs e)
 {
     // 断开连接
     omronCipNet.ConnectClose( );
     button2.Enabled = false;
     button1.Enabled = true;
     panel2.Enabled  = false;
 }