4#include <condition_variable>
25 std::function<void(
const std::string& role,
int pos)>
set_valve;
45 std::function<bool(
const std::string& role,
double& psi)>
read_pressure;
81 using Clock = std::chrono::steady_clock;
110 std::condition_variable
cv_;
std::atomic< bool > active_
std::atomic< bool > stop_
ScriptRunner(const ScriptRunner &)=delete
std::chrono::steady_clock Clock
ScriptRunner & operator=(const ScriptRunner &)=delete
void stop()
Cancel and reap.
std::condition_variable cv_
void start(const DynamicState &ds, ScriptEnv env)
Begin running ds.
double elapsedSeconds() const
Seconds since start(), which is what elapsed() reports.
Clock::time_point started_at_
State
System state IDs — must match the TypeScript SystemState enum in web-gui/shared/types....
One dynamic state, resolved and proven usable.
What a running script is allowed to do to the world.
std::function< void(const std::string &role, int pos)> set_valve
Command one valve by canonical config name.
std::function< bool(const std::string &role, double &psi)> read_pressure
Read a calibrated pressure by canonical role name.
std::function< void(State target)> transition
Leave the state.
std::string state_name
Where the script's log lines are attributed.