public override void OnExit() { if (mCurrentState != null) { mCurrentState.OnExit(); } if (mMotorControllerArduino != null) { if (mMotorControllerArduino.TelemetryActive) { mMotorControllerArduino.TelemetryToggle(0); } mMotorControllerArduino.Disconnected -= OnArduinoPrematureDisconnect; mMotorControllerArduino.StopArduinoComms(true); mMotorControllerArduino.TelemetryUpdate -= UpdateMotorTelemetry; mMotorControllerArduino = null; } if (mSensorNodeArduino != null) { if (mSensorNodeArduino.TelemetryActive) { mSensorNodeArduino.TelemetryToggle(0); } mSensorNodeArduino.Disconnected -= OnArduinoPrematureDisconnect; mSensorNodeArduino.StopArduinoComms(true); mSensorNodeArduino.TelemetryUpdate -= UpdateSensorTelemetry; mSensorNodeArduino = null; } }
public void Terminate(string reason) { mLogger.LogMessage(Logger.LoggerChannels.StateMachine, string.Format("State machine terminated because: {0}", reason)); mSocketConnection.Stop(); mMachineActiveWait.Set(); if (mCurrentState != null) { mCurrentState.OnExit(); } mRunning = false; }