1#ifndef BASE_STATE_MACHINE_H
2#define BASE_STATE_MACHINE_H
72 struct StateCallbackRegistration {
78 std::size_t callbackCount_ = 0;
79 std::array<StateCallbackRegistration, kMaxStateEntryCallbacks> onStateEntryCallbacks_{};
virtual ~BaseStateMachine()=default
virtual uint8_t getState() const
Current discrete state identifier.
bool registerOnStateEntry(FlightState targetState, StateEntryCallback functionPtr)
Register a callback to invoke each time a target state is entered.
bool changeState(FlightState newState)
Transition to a new state and trigger registered on-entry callbacks.
static constexpr std::size_t getMaxStateEntryCallbacks()
virtual int update(const AccelerationTriplet &accel, const DataPoint &alt)=0
Advance the state machine with the latest measurements.
void(*)() StateEntryCallback
static constexpr std::size_t kMaxStateEntryCallbacks
FlightState getFlightState() const
Current state as FlightState enum.
BaseStateMachine(FlightState initialState=STATE_UNARMED)
Timestamped float measurement container.