コード例 #1
0
        /// <summary>
        /// Handles the Click event of the buttonMove control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="ea">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ButtonMoveClick(object sender, EventArgs ea)
        {
            try
            {
                ProfilePositionMode ppm = _epos.Operation.ProfilePositionMode;

                ppm.ActivateProfilePositionMode();

                textBoxAOM.Text = _epos.Operation.OperationMode.GetOperationModeAsString();

                textBoxPositionStart.Text = string.Format("{0}", _epos.Operation.MotionInfo.GetPositionIs());

                ppm.MoveToPosition(Convert.ToInt32(textBoxTargetPosition.Text), radioButtonAbsoluteMove.Checked, true);
            }
            catch (DeviceException e)
            {
                StopRefresh();
                ShowMessageBox(e.ErrorMessage, e.ErrorCode);
            }
            catch (Exception e)
            {
                StopRefresh();

                MessageBox.Show(e.Message);
            }
        }
コード例 #2
0
        /// <summary>
        /// sets engine into <see cref="PositionMode"/>
        /// </summary>
        /// <returns>bool that indicates, if operation was successful</returns>
        private bool ActivatePositionMode()
        {
            //if engine is not in PositionMode, set PositionMode
            if (_engineMode == EngineMode.Position)
            {
                return(false);
            }

            //set PositionMode for both motors separately
            _ppm1.ActivateProfilePositionMode();
            _ppm2.ActivateProfilePositionMode();

            //PostionProfile is only set, when acceleration and deceleration are not 0
            if (ProfileAcceleration != 0 && ProfileDeceleration != 0)
            {
                _ppm1.SetPositionProfile(1000000, ProfileAcceleration, ProfileDeceleration);
                _ppm2.SetPositionProfile(1000000, ProfileAcceleration, ProfileDeceleration);
            }
            //set state machine to EngineMode.POSITION
            _engineMode = EngineMode.Position;

            //returns true, if ActivatePositionMode() was successful
            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Handles the Click event of the buttonHalt control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="ea">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ButtonHaltClick(object sender, EventArgs ea)
        {
            try
            {
                ProfilePositionMode ppm = _epos.Operation.ProfilePositionMode;

                ppm.ActivateProfilePositionMode();

                textBoxAOM.Text = _epos.Operation.OperationMode.GetOperationModeAsString();

                ppm.HaltPositionMovement();
            }
            catch (DeviceException e)
            {
                StopRefresh();
                ShowMessageBox(e.ErrorMessage, e.ErrorCode);
            }
            catch (Exception e)
            {
                StopRefresh();

                MessageBox.Show(e.Message);
            }
        }
コード例 #4
0
ファイル: EposMotor.cs プロジェクト: Brzobohaty/Robot
        /// <summary>
        /// Přepnutí módu motoru
        /// </summary>
        /// <param name="mode">mód</param>
        public void changeMode(MotorMode mode)
        {
            this.mode = mode;
            if (velocityHandler != null && positionHandler != null && homingHandler != null)
            {
                try
                {
                    switch (mode)
                    {
                    case MotorMode.velocity: velocityHandler.ActivateProfileVelocityMode(); break;

                    case MotorMode.position: positionHandler.ActivateProfilePositionMode(); break;

                    case MotorMode.homing: homingHandler.ActivateHomingMode(); break;
                    }
                }
                catch (DeviceException e)
                {
                    state = MotorState.error;
                    stateObserver.motorStateChanged(MotorState.error, String.Format("{0}\nError: {1}", e.ErrorMessage, errorDictionary.getComunicationErrorMessage(e.ErrorCode)), id, 0, 0, 0, 0);
                    motorErrorOccuredObserver();
                }
            }
        }
コード例 #5
0
        private void joy_update(object sender, EventArgs e)
        {
            if (ctrl != null && ctrl.IsConnected == true)
            {
                state   = ctrl.GetState();
                gamepad = ctrl.GetState().Gamepad;
                var joy     = new xbox_joy();
                var buttons = "";
                #region get joy data
                gamepad = ctrl.GetState().Gamepad;
                buttons = gamepad.Buttons.ToString();
                joy.A   = buttons.Contains("A");
                joy.B   = buttons.Contains("B");
                joy.X   = buttons.Contains("X");
                joy.Y   = buttons.Contains("Y");

                joy.start          = buttons.Contains("Start");
                joy.back           = buttons.Contains("Back");
                joy.left_shoulder  = buttons.Contains("LeftShoulder");
                joy.right_shoulder = buttons.Contains("RightShoulder");

                joy.rightthumb = buttons.Contains("RightThumb");
                joy.leftthumb  = buttons.Contains("LeftThumb");

                joy.dpadUp    = buttons.Contains("DPadUp");
                joy.dpadLeft  = buttons.Contains("DPadLeft");
                joy.dpadDown  = buttons.Contains("DPadDown");
                joy.dpadRight = buttons.Contains("DPadRight");

                joy.left_axis_x  = gamepad.LeftThumbX + 32768;
                joy.left_axis_y  = gamepad.LeftThumbY + 32768;
                joy.right_axis_x = gamepad.RightThumbX + 32768;
                joy.right_axis_y = gamepad.RightThumbY + 32768;

                joy.left_trigger  = gamepad.LeftTrigger;
                joy.right_trigger = gamepad.RightTrigger;
                #endregion

                this.label_left_trigger.Text  = joy.left_trigger.ToString();
                this.label_right_trigger.Text = joy.right_trigger.ToString();

                this.label_left_axis_x.Text  = joy.left_axis_x.ToString();
                this.label_left_axis_y.Text  = joy.left_axis_y.ToString();
                this.label_right_axis_x.Text = joy.right_axis_x.ToString();
                this.label_right_axis_y.Text = joy.right_axis_y.ToString();

                if (joy.start)
                {
                    this.checkBox_use_joy.Checked = true;
                }
                if (joy.back)
                {
                    this.checkBox_use_joy.Checked = false;
                }

                this.checkBox_use_joy.Visible = true;
                // MOVE !!!!
                if (checkBox_use_joy.Checked == true)
                {
                    try
                    {
                        ProfilePositionMode ppm = _epos_A.Operation.ProfilePositionMode;
                        ppm.ActivateProfilePositionMode();
                        textBoxAOM_A.Text = _epos_A.Operation.OperationMode.GetOperationModeAsString();
                        ppm.MoveToPosition(joy.left_axis_x, true, true);
                    }
                    catch { }

                    try
                    {
                        ProfilePositionMode ppm = _epos_B.Operation.ProfilePositionMode;
                        ppm.ActivateProfilePositionMode();
                        textBoxAOM_B.Text = _epos_B.Operation.OperationMode.GetOperationModeAsString();
                        ppm.MoveToPosition(joy.right_axis_x, true, true);
                    }
                    catch { }
                }
            }
            else
            {
                this.checkBox_use_joy.Visible = false;
            }
        }