/// <summary> /// emergency stop /// </summary> /// <returns>bool that indicates, if operation was successful</returns> public bool StopImmediately() { try { //motor must be in PositionMode to set velocity of wheels to 0 ActivatePositionMode(); //velocity of motors is set to 0 _ppm1.HaltPositionMovement(); _ppm2.HaltPositionMovement(); //returns true, if StopImmediately() was successful return(true); } //an error may occur catch (Exception e) { ConsoleFormatter.Error("Failed to stop the engine.", "Message: " + e.Message); //returns false, if StopImmediately() fails return(false); } }
/// <summary> /// Zastaví motor /// </summary> public void halt() { try { switch (mode) { case MotorMode.position: positionHandler.HaltPositionMovement(); break; case MotorMode.velocity: velocityHandler.HaltVelocityMovement(); 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(); } }
/// <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); } }