nppilot/roverif/supervisor.h

53 lines
971 B
C
Raw Permalink Normal View History

/*
* Supervises access to the control surfaces.
*/
#pragma once
#include <stdint.h>
#include <timer.h>
#include <switch.h>
class Supervisor {
public:
2013-12-29 21:09:31 +01:00
enum class InControl {
Invalid,
Initial,
2013-12-29 21:09:31 +01:00
None,
Remote,
Pilot,
};
Supervisor();
void init();
2013-12-29 21:09:31 +01:00
void update_remote(bool throttle_high, bool pilot_allowed);
void update_pilot(bool want_control);
2013-12-29 21:09:31 +01:00
bool pilot_allowed() const { return pilot_allowed_; }
bool in_shutdown() const { return in_shutdown_; }
bool remote_ok() const { return remote_ok_; }
InControl in_control() const { return in_control_; }
void tick();
private:
2013-12-29 21:09:31 +01:00
void check();
void change(InControl next);
void shutdown();
void changed();
2013-12-29 21:09:31 +01:00
InControl in_control_;
bool remote_ok_;
bool pilot_ok_;
bool pilot_allowed_;
bool pilot_wants_;
2013-12-29 21:09:31 +01:00
bool throttle_high_;
bool in_shutdown_;
Timer remote_seen_;
Timer pilot_seen_;
};