// Change control state of the robot
        private void shapeConnected_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            // Check if state ready
            if ((_robotControllerState == RobotControllerState.Connected) && SerialPortController.IsReady)
            {
                // Change the appearance and state
                _robotControllerState = RobotControllerState.OnControl;
                shapeConnected.Dispatcher.Invoke(new Action(() => { shapeConnected.Stroke = Brushes.Orange; }));
                shapeConnected.Dispatcher.Invoke(new Action(() => { shapeConnected.Fill = Brushes.Orange; }));

                // Initialize the Miniquad
                Miniquad.Miniquad.Initialize();

                // Start receiving data
                _ctrlConfigChangedHandler();
            }
            else if (_robotControllerState == RobotControllerState.OnControl)
            {
                // Change the appearance and state
                _robotControllerState = RobotControllerState.Disconnected;
                BrushConverter converter = new BrushConverter();
                shapeConnected.Dispatcher.Invoke(new Action(() => { shapeConnected.Stroke = (Brush)converter.ConvertFromString("#FF808080"); }));
                shapeConnected.Dispatcher.Invoke(new Action(() => { shapeConnected.Fill = null; }));

                // Start receiving data
                _ctrlConfigChangedHandler();

                // Stop the Miniquad
                Miniquad.Miniquad.SetThrottleOutputs_PC(0, 0, 0, 0);
            }
        }
Esempio n. 2
0
        private void ShowState(RobotControllerState state)
        {
            switch (state)
            {
            case RobotControllerState.Idle:
                startButton.Enabled = true;
                stopButton.Enabled  = false;
                pauseButton.Enabled = false;
                break;

            case RobotControllerState.Suspended:
                startButton.Enabled = true;
                stopButton.Enabled  = false;
                pauseButton.Enabled = false;
                break;

            case RobotControllerState.Working:
                startButton.Enabled = false;
                stopButton.Enabled  = true;
                pauseButton.Enabled = true;
                break;
            }

            UpdateRuntimeParametersLabel();
        }
Esempio n. 3
0
 private void SetState(RobotControllerState state)
 {
     if (_contoller.State != state)
     {
         _contoller.SetStateAsync(state);
     }
 }
Esempio n. 4
0
 private void Contoller_StateUpdated(object sender, RobotControllerState e)
 {
     Invoke(new Action(() => ShowState(_contoller.State)));
 }