|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
Parses state_transitions.csv and validates state transitions. More...
#include <StateMachine.hpp>
Public Member Functions | |
| bool | load (const std::string &csv_path) |
| Load from a state_transitions.csv file. | |
| bool | isAllowed (State from, State to) const |
| Returns true if transitioning from→to is allowed. | |
| std::vector< State > | allowedFrom (State state) const |
| Returns the list of states reachable from the given state. | |
| uint32_t | allowedBitmask (State state) const |
| Returns a bitmask where bit N is set if state N is reachable from the given state. | |
| bool | isLoaded () const |
Static Public Member Functions | |
| static void | loadStatesFromConfig (const std::string &config_content) |
| Adopt the [[states]] entries from a config as the source of truth for state names and semantics. | |
| static bool | isAbort (State s) |
| True if the state carries the abort semantics (config is_abort, else the built-in trio). | |
| static State | bootState () |
| The state to boot into (config is_boot, else Idle). | |
| static State | fromName (const std::string &name) |
| Translate a CSV name (e.g. | |
| static std::string | name (State s) |
| Human-readable name for a State (e.g. | |
| static uint8_t | stateId (const std::string &name) |
| Numeric id for a state name, or 255 if unknown. | |
Static Private Member Functions | |
| static const std::map< std::string, State > & | csvStateMap () |
Private Attributes | |
| std::map< State, std::set< State > > | transitions_ |
| bool | loaded_ {false} |
Parses state_transitions.csv and validates state transitions.
Thread-safe for concurrent reads after load().
Definition at line 43 of file StateMachine.hpp.
| uint32_t sequencer::StateMachine::allowedBitmask | ( | State | state | ) | const |
Returns a bitmask where bit N is set if state N is reachable from the given state.
Used for the [0x50, 0x00] Elodin VTable payload.
Definition at line 325 of file StateMachine.cpp.
| std::vector< State > sequencer::StateMachine::allowedFrom | ( | State | state | ) | const |
Returns the list of states reachable from the given state.
In debug mode, returns all known states.
Definition at line 315 of file StateMachine.cpp.
|
static |
The state to boot into (config is_boot, else Idle).
Definition at line 109 of file StateMachine.cpp.
|
staticprivate |
Definition at line 18 of file StateMachine.cpp.
|
static |
Translate a CSV name (e.g.
"Emergency Abort") to a State.
Definition at line 184 of file StateMachine.cpp.
Referenced by main().
|
static |
True if the state carries the abort semantics (config is_abort, else the built-in trio).
Definition at line 99 of file StateMachine.cpp.
| bool sequencer::StateMachine::isAllowed | ( | State | from, |
| State | to ) const |
Returns true if transitioning from→to is allowed.
In debug mode, always returns true.
Definition at line 308 of file StateMachine.cpp.
|
inline |
Definition at line 106 of file StateMachine.hpp.
| bool sequencer::StateMachine::load | ( | const std::string & | csv_path | ) |
Load from a state_transitions.csv file.
Tries the given path, then a set of fallback paths.
Definition at line 222 of file StateMachine.cpp.
|
static |
Adopt the [[states]] entries from a config as the source of truth for state names and semantics.
This is an OVERRIDE LAYER, deliberately: anything the config does not mention keeps its built-in name and behaviour. The state list was duplicated in eight places across C++, the shared TS types, the backend and six frontend label maps, several already disagreeing (the top bar rendered GSE Abort and Emergency Abort as "STATE 18"/"STATE 19"). Config becomes the one place to edit, without a partial or missing [[states]] being able to erase the machine's knowledge of its own states.
id is a stable key, not an ordering: it is written into Elodin run history as a raw u8 with no name table beside it, so an id must keep meaning the same state. Reordering, renaming, adding and removing are all fine; reusing an id for a different state is not.
Definition at line 72 of file StateMachine.cpp.
|
static |
Human-readable name for a State (e.g.
State::FIRE → "Fire").
Definition at line 128 of file StateMachine.cpp.
Referenced by sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::exec(), and refuses().
|
inlinestatic |
Numeric id for a state name, or 255 if unknown.
Lets a service that only needs the id (e.g. the controller's PWM gate) avoid carrying its own copy of the enum.
Definition at line 101 of file StateMachine.hpp.
Referenced by main().
|
private |
Definition at line 112 of file StateMachine.hpp.
|
private |
Definition at line 111 of file StateMachine.hpp.