private void ProcessStateTransitions(NavigationState state) { if (state.HasFlag(NavigationState.Bootstrap)) { _commandQueue.Flush(); var configuration = new DroneConfiguration(); configuration.General.NavdataDemo.ChangeTo(false); configuration.SendTo(this); Send(new ControlCommand(ControlMode.NoControlMode)); } if (state.HasFlag(NavigationState.Watchdog)) { Trace.TraceWarning("Communication Watchdog!"); } switch (_stateRequest) { case StateRequest.None: return; case StateRequest.Emergency: if (state.HasFlag(NavigationState.Flying)) Send(new RefCommand(RefMode.Emergency)); else _stateRequest = StateRequest.None; break; case StateRequest.ResetEmergency: Send(new RefCommand(RefMode.Emergency)); _stateRequest = StateRequest.None; break; case StateRequest.Land: if (state.HasFlag(NavigationState.Flying) && state.HasFlag(NavigationState.Landing) == false) { Send(new RefCommand(RefMode.Land)); } else _stateRequest = StateRequest.None; break; case StateRequest.Fly: if (state.HasFlag(NavigationState.Landed) && state.HasFlag(NavigationState.Takeoff) == false && state.HasFlag(NavigationState.Emergency) == false) { Send(new RefCommand(RefMode.Takeoff)); } else _stateRequest = StateRequest.None; break; default: throw new ArgumentOutOfRangeException(); } }
private void ProcessStateTransitions(NavigationState state) { if (state.HasFlag(NavigationState.Bootstrap)) { _commandQueue.Flush(); var settings = new Settings(); settings.General.NavdataDemo = false; Send(settings); } if (state.HasFlag(NavigationState.Watchdog)) { Trace.TraceWarning("Communication Watchdog!"); } switch (_stateRequest) { case StateRequest.None: return; case StateRequest.Emergency: if (state.HasFlag(NavigationState.Flying)) Send(RefCommand.Emergency); else _stateRequest = StateRequest.None; break; case StateRequest.ResetEmergency: Send(RefCommand.Emergency); _stateRequest = StateRequest.None; break; case StateRequest.Land: if (state.HasFlag(NavigationState.Flying) && state.HasFlag(NavigationState.Landing) == false) { Send(RefCommand.Land); } else _stateRequest = StateRequest.None; break; case StateRequest.Fly: if (state.HasFlag(NavigationState.Landed) && state.HasFlag(NavigationState.Takeoff) == false && state.HasFlag(NavigationState.Emergency) == false) { Send(RefCommand.Takeoff); } else _stateRequest = StateRequest.None; break; default: throw new ArgumentOutOfRangeException(); } }