示例#1
0
 void CloseAxes()
 {
     if (motorManager != null)
     {
         motorManager.Close();
     }
 }
示例#2
0
        public bool Connect()
        {
            try
            {
                motorManager = MotorManager.getInstance();
                if (motorManager.Open() && motorManager.GoToHome(GlobalVariables.motorSettings.HomingBuffer))
                {
                    if (GlobalVariables.motorSettings.UseSimulator)
                    {
                        XInPosition = true;
                        YInPosition = true;
                        ZInPosition = true;
                    }
                    motorManager.MotorStateChanged    += OnMotorStateChanged;
                    motorManager.MotorPositionChanged += OnMotorPositionChanged;
                    motorManager.LaserStateChanged    += OnLaserStateChanged;
                    motorManager.LedStateChanged      += OnLedStateChanged;
                    motorManager.AxisLimitChanged     += OnAxisLimitChanged;

                    // initial motor profile after buffer homing finished
                    {
                        Thread.Sleep(200);
                        while (!XInPosition || !YInPosition || !ZInPosition)
                        {
                            Thread.Sleep(500);
                        }
                        InitialMotorProfile();

                        // move to saved ref position
                        Homing();
                    }

                    return(true);
                }
                else
                {
                    throw new Exception("Could not connect to motor manager");
                }
            }
            catch (Exception ex)
            {
                motorManager.Close();
                MessageBox.Show(ex.Message, "Error");
            }

            return(false);
        }