4#include <condition_variable>
79 bool init(
const std::string& config_path =
"config/config.toml");
88 bool transitionTo(
const std::string& state_name, uint32_t requested_hold_ms,
89 std::string* refusal_reason =
nullptr);
108 bool transitionTo(
State to, uint32_t requested_hold_ms, std::string* refusal_reason =
nullptr);
129 bool manualActuator(
const std::string& name,
int pos, std::string* refusal_reason =
nullptr);
160 std::function<bool()>
fn;
163 std::shared_ptr<std::promise<bool>>
result;
188 std::string* refusal_reason =
nullptr);
190 bool doManualActuator(
const std::string& name,
int pos, std::string* refusal_reason =
nullptr);
Standalone Elodin database client.
Sends ABORT / ABORT_DONE / CLEAR_ABORT UDP broadcast packets (PacketHeader only — 6 bytes) to the con...
Sends UDP actuator commands based on state transitions.
A cancellable hold of an exact length, and nothing else.
Live calibrated pressures, by ROLE NAME, for the sequencer.
Runs one dynamic state's script on its own thread.
bool setDebugMode(bool enabled)
Enable or disable debug mode.
uint32_t fire_duration_ms_
std::map< State, DynamicState > dynamic_states_
Dynamic states whose scripts loaded and validated.
std::atomic< bool > cmd_stop_
bool sequencer_owns_valves_
[controller_service].sequencer_owns_valves.
bool tryConnectElodin()
Connect to Elodin and do everything that depends on the connection: register the ACT_CMD VTables,...
bool applyConfig(const fsw::config::Config &cfg)
Everything a config load has to apply, in the one order that works.
bool init(const std::string &config_path="config/config.toml")
Load config, CSVs, connect to Elodin.
void notifyControllerFire(bool active)
Send FIRE_START / FIRE_STOP to controller_service.
State currentState() const
static constexpr int kElodinRetrySeconds
static constexpr uint32_t kAbortDoneDelayMs
Delay between ABORT and ABORT_DONE.
std::condition_variable cmd_cv_
StateMachine state_machine_
std::string daq_bind_address_
Local address board-facing UDP leaves from, resolved once in init().
void enqueueDetached(std::function< bool()> fn)
Post work and return immediately.
std::string config_content_
fsw::elodin::ElodinClient elodin_
std::deque< Command > cmd_queue_
bool transitionTo(const std::string &state_name)
Request a state transition by name (e.g.
std::string controller_host_
std::string scriptStatusReport() const
What this process made of its dynamic states at startup, as newline-terminated text.
bool manualActuator(const std::string &name, int pos, std::string *refusal_reason=nullptr)
Debug mode only: manual OPEN/CLOSE for one role.
PressureFeed pressure_feed_
Live calibrated pressures for pressure(), on its own Elodin connection.
bool doTransitionTo(State to, uint32_t requested_hold_ms=0, std::string *refusal_reason=nullptr)
ScriptEnv makeScriptEnv(const DynamicState &ds)
Build the callbacks a script is allowed to reach the world through.
ActuatorCommander actuator_commander_
static constexpr int kCommandTimeoutSeconds
How long a caller waits for its command to run before giving up and reporting failure.
std::string configDir() const
Directory containing config_path_, or "." — where scripts/ is resolved against.
bool notifyControllerFireOnce(bool active)
One attempt: connect, send, wait for the controller's "OK".
bool enqueueAndWait(std::function< bool()> fn)
Post work and block until the worker has run it.
std::atomic< State > current_state_
std::atomic< bool > debug_mode_
ScriptRunner script_runner_
void publishStateTransition(State from, State to)
bool doSetDebugMode(bool enabled)
std::atomic< bool > elodin_retry_stop_
std::vector< fsw::elodin::BoardChannels > ball_valve_boards_
static bool isAbortState(State s)
AbortBroadcaster abort_broadcaster_
std::thread elodin_retry_thread_
uint32_t fire_extended_ms_
uint16_t controller_port_
std::map< State, std::string > refused_states_
States that declare a script which did NOT hold up, with the reason.
bool doManualActuator(const std::string &name, int pos, std::string *refusal_reason=nullptr)
std::map< State, HoldRule > hold_rules_
Holdable states, by target.
std::vector< fsw::elodin::BoardChannels > actuator_boards_
SequencerService()=default
bool loadConfig(const std::string &path)
bool extendFire()
Extend the FIRE window (only valid while in FIRE state).
Parses state_transitions.csv and validates state transitions.
Motorized ball valve position: raw ADC counts -> % open.
State
System state IDs — must match the TypeScript SystemState enum in web-gui/shared/types....
The whole parsed config.toml, restricted to what C++ consumes.
One dynamic state, resolved and proven usable.
What a running script is allowed to do to the world.
std::shared_ptr< std::promise< bool > > result
std::function< bool()> fn
One state's timed hold: how long, where it lands, and whether a client may set the length.
uint32_t gate_close_delay_ms
The same actuator's delay in the RETURN state's column.
uint32_t extended_ms
What EXTEND_FIRE restarts at.
uint32_t gate_open_delay_ms
Milliseconds the gate actuator waits after the transition before it opens, from the delays CSV.
std::string gate_actuator