Пример #1
0
        private void connectController()
        {
            ControllerInfoCollection controllers = scanner.Controllers;

            foreach (ControllerInfo info in controllers)
            {
                if (comboBox1.Text.Equals(info.ControllerName + " / " + info.IPAddress.ToString()))
                {
                    if (info.Availability == Availability.Available)
                    {
                        if (myRobot != null)
                        {
                            myRobot.Dispose(); // = LogOff
                            myRobot = null;
                        }
                        myRobot = new RobotClass(ControllerFactory.CreateFrom(info));
                        myRobot.StartRapidProgram();
                        //myRobot.Controller.ConnectionChanged += new EventHandler<ConnectionChangedEventArgs>(ConnectionChanged);

                        break;
                    }
                }
                {
                    MessageBox.Show("Selected controller not available.");
                }
            }
            if (myRobot == null)
            {
                MessageBox.Show("Selected controller not available. (comboBox String != controller info)");
            }
        }
Пример #2
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (myRobot != null)
     {
         myRobot.Dispose(); // = LogOff
         myRobot = null;
         // myRobot.Controller.ConnectionChanged += new EventHandler<ConnectionChangedEventArgs>(ConnectionChanged);
     }
 }