STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
backend.run_config Namespace Reference

Functions

Path snapshot_path (str run_id)
dict load (str run_id)
int _slot (int board_id)
dict[int, str] _board_display_names (dict boards)
dict[str, str] entity_labels (dict cfg)
str label_for (str entity, dict[str, str] labels)
dict[int, str] state_names (dict cfg)
dict annotate (dict index, str run_id)

Variables

dict BUILTIN_STATES
 STATE_FIELDS = frozenset({"current_state", "from_state", "to_state"})
dict _ENTITY_PREFIX
dict _BOARD_TYPE_LABEL
int T7_CJC_AIN = 14
 _SELF_TEST_RE = re.compile(r"^(SELF_TEST\.BOARD_\d+)\.s(\d+)$")

Detailed Description

Human names for a run's numeric Elodin identities, from the run's config snapshot.

Elodin records only numeric identities — `PT1.CH5`, `ACT2.CH1`, `ACT_CMD.B2.CH1`,
`BOARD.HB_21` — and every state as a raw u8. The names live in config.toml, which the
backend copies beside the run dir as `<run_id>.toml` when the session starts
(service-controller.ts `snapshotRunConfig`). This module reads that snapshot back and
rebuilds the mapping, so a past run reads as "Ox Upstream" and "Fire" instead of
"PT1.CH5" and "16".

Everything here mirrors conventions that already exist elsewhere and must not drift:

* entity spelling — DatabaseConfig.cpp (`PT<n>.CH<c>`, `PT<n>_Cal.CH<c>`,
  `ACT_CMD.B<n>.CH<c>`, `BOARD.HB_<board_id>`, `SELF_TEST.BOARD_<board_id>`, and for a
  LabJack T7 `T7<n>.AIN<a>`, `T7<n>_Cal.AIN<a>`, `T7<n>.CJC` — register_t7_*_tables)
* Elodin slot `<n>` = `board_id % 10`, 0 → 10 — LoadActiveBoards.hpp / sensor-config.ts
* board display names — the config editor's `boardDisplayName` (app/config/page.tsx)

A run predating the snapshot has no `.toml` and keeps its numeric entity names. State
ids are the exception: they are stable by contract (see the `[[states]]` comment in
config_base.toml), so the built-in table below names them even with no snapshot, and
`[[states]]` overrides it the same way it overrides the C++ enum.

Function Documentation

◆ _board_display_names()

dict[int, str] backend.run_config._board_display_names ( dict boards)
protected
board_id → "PT Board #2", numbered by position among boards of the same type
(matching the config editor). A lone board of its type drops the ordinal.

Definition at line 112 of file run_config.py.

Referenced by entity_labels().

◆ _slot()

int backend.run_config._slot ( int board_id)
protected
Elodin slot for a board_id: the last digit, with 0 meaning 10.

Definition at line 107 of file run_config.py.

Referenced by entity_labels().

◆ annotate()

dict backend.run_config.annotate ( dict index,
str run_id )
Attach the run's names to a component index, in place.

Done at serve time rather than baked into the cached index: the snapshot is a
separate file from the parquet cache, so one dropped in later (or a config fix)
takes effect on the next open instead of needing the export thrown away.

Definition at line 243 of file run_config.py.

References entity_labels(), label_for(), load(), and state_names().

◆ entity_labels()

dict[str, str] backend.run_config.entity_labels ( dict cfg)
Entity name → the role it plays, for every entity config can name.

Definition at line 131 of file run_config.py.

References _board_display_names(), and _slot().

Referenced by annotate().

◆ label_for()

str backend.run_config.label_for ( str entity,
dict[str, str] labels )
The human name for one entity, or "" when config does not name it.

Definition at line 220 of file run_config.py.

Referenced by annotate().

◆ load()

dict backend.run_config.load ( str run_id)
Parse the run's config snapshot. Missing or malformed → {} (names degrade to
numbers; a viewer must never fail to open a run over its metadata).

Definition at line 96 of file run_config.py.

References snapshot_path().

Referenced by annotate().

◆ snapshot_path()

Path backend.run_config.snapshot_path ( str run_id)
The config copied beside the run dir at session start.

Definition at line 91 of file run_config.py.

Referenced by load().

◆ state_names()

dict[int, str] backend.run_config.state_names ( dict cfg)
State id → name. `[[states]]` overrides the built-in table entry by entry, so a
partial list cannot erase the machine's knowledge of its own states.

Definition at line 231 of file run_config.py.

Referenced by annotate().

Variable Documentation

◆ _BOARD_TYPE_LABEL

dict backend.run_config._BOARD_TYPE_LABEL
protected
Initial value:
1= {
2 "PT": "PT",
3 "ACTUATOR": "Actuator",
4 "BALL_VALVE": "Ball Valve",
5 "LC": "LC",
6 "TC": "TC",
7 "RTD": "RTD",
8 "ENCODER": "Encoder",
9 "T7": "LabJack T7",
10}

Definition at line 76 of file run_config.py.

◆ _ENTITY_PREFIX

dict backend.run_config._ENTITY_PREFIX
protected
Initial value:
1= {
2 "PT": "PT",
3 "TC": "TC",
4 "RTD": "RTD",
5 "LC": "LC",
6 "ACTUATOR": "ACT",
7 "ENCODER": "ENC",
8}

Definition at line 66 of file run_config.py.

◆ _SELF_TEST_RE

backend.run_config._SELF_TEST_RE = re.compile(r"^(SELF_TEST\.BOARD_\d+)\.s(\d+)$")
protected

Definition at line 217 of file run_config.py.

◆ BUILTIN_STATES

dict backend.run_config.BUILTIN_STATES
Initial value:
1= {
2 0: "Debug",
3 1: "Idle",
4 2: "Armed",
5 3: "Fuel Fill",
6 4: "Ox Fill",
7 5: "GN2 Low Press",
8 6: "GN2 Low Vent",
9 7: "Fuel Press",
10 8: "Fuel Vent",
11 9: "Ox Press",
12 10: "Ox Vent",
13 11: "GN2 High Press",
14 12: "GN2 High Vent",
15 13: "Vent",
16 14: "Calibrate",
17 15: "Ready",
18 16: "Fire",
19 17: "Engine Abort",
20 18: "GSE Abort",
21 19: "Emergency Abort",
22 20: "Press Standby",
23 255: "Unknown",
24}

Definition at line 35 of file run_config.py.

◆ STATE_FIELDS

backend.run_config.STATE_FIELDS = frozenset({"current_state", "from_state", "to_state"})

Definition at line 63 of file run_config.py.

◆ T7_CJC_AIN

int backend.run_config.T7_CJC_AIN = 14

Definition at line 88 of file run_config.py.