STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
ScriptConfig.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5
6#include "config/Config.hpp"
8
9/**
10 * The bridge between config and the script language.
11 *
12 * Kept out of StateScript.hpp on purpose: the language itself is pure — strings in, diagnostics
13 * out, no config, no I/O, no clock — which is what lets it be tested exhaustively and linked into
14 * a hermetic checker binary. This header is where it learns what a real rig declares.
15 */
16namespace fsw {
17namespace script {
18
19/** A name that could not be turned into a usable slug, reported so config can refuse it loudly. */
20struct BadSlug {
21 std::string canonical; // the config spelling
22 std::string slug; // what slugify produced
23 std::string where; // "actuator" / "sensor" / "state"
24};
25
26/** Two config names in one namespace that slug to the same identifier — genuinely ambiguous. */
28 std::string slug;
29 std::string first;
30 std::string second;
31 std::string where;
32};
33
34struct TableBuild {
36 std::vector<BadSlug> bad;
37 std::vector<SlugCollision> collisions;
38
39 bool ok() const {
40 return bad.empty() && collisions.empty();
41 }
42};
43
44/**
45 * Build the actuator / sensor / state slug tables from a loaded config.
46 *
47 * `allowed_transitions` is left empty — it depends on which state owns the script and on
48 * state_transitions.csv, neither of which this library reads. The caller fills it.
49 *
50 * Collisions are reported per namespace only. Across namespaces they are expected and harmless:
51 * on the shipped `server` profile FUEL_VENT is both a valve and a state, and on `digital-twin`
52 * FUEL_UPSTREAM is both a valve and a sensor. Positional resolution is what makes that fine, and a
53 * blanket collision rule would refuse config that runs today.
54 */
55TableBuild build_slug_tables(const fsw::config::Config& cfg);
56
57} // namespace script
58} // namespace fsw
TableBuild build_slug_tables(const fsw::config::Config &cfg)
Build the actuator / sensor / state slug tables from a loaded config.
Motorized ball valve position: raw ADC counts -> % open.
The whole parsed config.toml, restricted to what C++ consumes.
Definition Config.hpp:264
A name that could not be turned into a usable slug, reported so config can refuse it loudly.
Two config names in one namespace that slug to the same identifier — genuinely ambiguous.
What a script's slugs are allowed to name, built from the loaded config.
std::vector< SlugCollision > collisions
std::vector< BadSlug > bad