|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
Functions | |
| dict | _toml_load (Path path) |
| _parse_value (str s) | |
| dict | load_config (Optional[Path] path=None) |
| Path | get_repo_root () |
| dict | get_network_config () |
| dict | get_database_config () |
| Dict[str, dict] | get_boards () |
| Optional[dict] | get_board_by_type (str board_type) |
| List[dict] | get_boards_by_type (str board_type) |
| List[int] | active_connectors (dict board) |
| Optional[tuple] | decode_board_namespaced_low (int low) |
| Optional[int] | packet_ch_for_board_connector (str stype, int board_slot, int connector) |
| Dict[tuple, tuple] | build_channel_to_orchestrator_key () |
| bool | is_current_loop_board (dict board) |
| Dict[int, dict] | get_hp_pt_packet_channels () |
| Dict[tuple, int] | build_orchestrator_key_to_packet_ch () |
| dict | get_calibration_config (str sensor_type) |
| int | get_sensor_port () |
| dict | get_display_config () |
| Dict[str, Any] | get_abort_pts () |
| Path | resolve_path (str rel_path) |
| print_config_summary () | |
Variables | |
| _THIS_DIR = Path(__file__).resolve().parent | |
| Optional | _REPO_ROOT = None |
| Optional | CONFIG_PATH = _REPO_ROOT / "config" / "config.toml" |
| _toml_load = None | |
| Optional | _cached_config = None |
Shared configuration loader for the calibration stack.
Reads config/config.toml (the single source of truth) and exposes board IPs,
ports, sensor counts, calibration paths, and network settings so that every
calibration script derives its parameters from the same place.
Usage:
from config_loader import load_config, get_board_by_type, get_calibration_config, get_abort_pts
cfg = load_config() # full dict
pt = get_board_by_type("PT") # {ip, send_port, active_connectors, …}
cal = get_calibration_config("pt") # {json_dir, csv_paths}
abort_pts = get_abort_pts() # {"Fuel Upstream": 400, …} (PSI)
|
protected |
Definition at line 107 of file config_loader.py.
References _parse_value().
Referenced by _parse_value(), and _toml_load().
|
protected |
Minimal TOML parser — enough for config.toml.
Definition at line 43 of file config_loader.py.
References _parse_value(), and split().
| List[int] config_loader.active_connectors | ( | dict | board | ) |
The connectors this board samples. ``active_connectors`` is the config's only statement of which channels exist — config_broadcast packs exactly this list into the board's SensorConfigPacket, and the firmware's ``num_sensors`` byte is just its length. There is no separate count to expand into a 1..N range, so an empty list means the board samples nothing.
Definition at line 205 of file config_loader.py.
Referenced by build_channel_to_orchestrator_key(), build_orchestrator_key_to_packet_ch(), get_hp_pt_packet_channels(), and packet_ch_for_board_connector().
| Dict[tuple, tuple] config_loader.build_channel_to_orchestrator_key | ( | ) |
Build mapping (stype, packet_channel_id) → (stype, unique_ch) for relay packets. Packet channel id is the local connector (1–10), matching daq_bridge / Elodin low-byte scheme. unique_ch = board_id * 100 + connector_id. Returns dict for PT, TC, RTD, LC.
Definition at line 263 of file config_loader.py.
References active_connectors(), and get_boards_by_type().
| Dict[tuple, int] config_loader.build_orchestrator_key_to_packet_ch | ( | ) |
Reverse: (stype, unique_ch) → packet_ch for legacy JSON keying.
Definition at line 320 of file config_loader.py.
References active_connectors(), and get_boards_by_type().
| Optional[tuple] config_loader.decode_board_namespaced_low | ( | int | low | ) |
Decode daq_bridge / Elodin low byte: (board_slot, connector_1_10, is_raw). Matches web-gui elodin-protocol decodeLow (PT/TC/RTD/LC 0x20–0x23). Returns None if not a valid raw/cal sensor slot.
Definition at line 225 of file config_loader.py.
| Dict[str, Any] config_loader.get_abort_pts | ( | ) |
Return [abort_pts] section: sensor role name → pressure threshold (PSI). Used when building ACTUATOR_CONFIG (threshold is converted to ADC code per PT calibration).
Definition at line 354 of file config_loader.py.
References load_config().
| Optional[dict] config_loader.get_board_by_type | ( | str | board_type | ) |
Return the first enabled board matching the given type (PT, TC, RTD, LC, ACTUATOR). Returns None if no matching enabled board is found.
Definition at line 182 of file config_loader.py.
References get_boards().
| Dict[str, dict] config_loader.get_boards | ( | ) |
Return all [boards.*] as {board_name: {type, ip, …}}.
Definition at line 176 of file config_loader.py.
References load_config().
Referenced by get_board_by_type(), get_boards_by_type(), and print_config_summary().
| List[dict] config_loader.get_boards_by_type | ( | str | board_type | ) |
Return all boards matching the given type.
Definition at line 196 of file config_loader.py.
References get_boards().
Referenced by build_channel_to_orchestrator_key(), build_orchestrator_key_to_packet_ch(), get_hp_pt_packet_channels(), and packet_ch_for_board_connector().
| dict config_loader.get_calibration_config | ( | str | sensor_type | ) |
Return [calibration.<sensor_type>] section. sensor_type is case-insensitive (pt, tc, rtd, lc).
Definition at line 335 of file config_loader.py.
References load_config().
Referenced by print_config_summary().
| dict config_loader.get_database_config | ( | ) |
Return [database] section.
Definition at line 170 of file config_loader.py.
References load_config().
Referenced by print_config_summary().
| dict config_loader.get_display_config | ( | ) |
Return [display] section.
Definition at line 348 of file config_loader.py.
References load_config().
| Dict[int, dict] config_loader.get_hp_pt_packet_channels | ( | ) |
Return {connector: {full_scale_psi, sense_resistor_ohms, adc_ref_voltage}} for 4-20 mA PT
channels. Used when the robust stack excludes HP PTs — calibration_server applies the
4-20 mA linear conversion.
The ADC reference is set once per board, so every active connector on a current-loop board
is a loop channel. Keys are local connector ids, so two current-loop boards would collide
here; board-namespacing this layer is tracked separately.
Definition at line 295 of file config_loader.py.
References active_connectors(), get_boards_by_type(), and is_current_loop_board().
| dict config_loader.get_network_config | ( | ) |
Return [network] section.
Definition at line 164 of file config_loader.py.
References load_config().
Referenced by get_sensor_port(), and print_config_summary().
| Path config_loader.get_repo_root | ( | ) |
Definition at line 160 of file config_loader.py.
| int config_loader.get_sensor_port | ( | ) |
Return the UDP port boards send sensor data to (default 5006).
Definition at line 343 of file config_loader.py.
References get_network_config().
| bool config_loader.is_current_loop_board | ( | dict | board | ) |
True when a PT board's sensors are 4-20 mA current-loop transmitters. `pt_type` is authoritative and matches what the C++ calibration service and the backend read. A board written before pt_type existed is still recognised from its legacy hp_pt_* keys.
Definition at line 282 of file config_loader.py.
Referenced by get_hp_pt_packet_channels().
| dict config_loader.load_config | ( | Optional[Path] | path = None | ) |
Load and cache the full config dict from config.toml.
Definition at line 148 of file config_loader.py.
References _toml_load.
Referenced by get_abort_pts(), get_boards(), get_calibration_config(), get_database_config(), get_display_config(), get_network_config(), and print_config_summary().
| Optional[int] config_loader.packet_ch_for_board_connector | ( | str | stype, |
| int | board_slot, | ||
| int | connector ) |
Map physical board slot + connector to packet channel id (local connector 1–10; same as Elodin/daq_bridge).
Definition at line 242 of file config_loader.py.
References active_connectors(), and get_boards_by_type().
| config_loader.print_config_summary | ( | ) |
Print a human-readable summary of the loaded config.
Definition at line 373 of file config_loader.py.
References format(), get_boards(), get_calibration_config(), get_database_config(), get_network_config(), load_config(), and print_config_summary().
Referenced by print_config_summary().
| Path config_loader.resolve_path | ( | str | rel_path | ) |
Resolve a repo-relative path from config to an absolute path.
Definition at line 362 of file config_loader.py.
|
protected |
Definition at line 145 of file config_loader.py.
|
protected |
Definition at line 26 of file config_loader.py.
|
protected |
Definition at line 25 of file config_loader.py.
|
protected |
Minimal TOML parser — enough for config.toml.
Definition at line 39 of file config_loader.py.
Referenced by load_config().
| Optional config_loader.CONFIG_PATH = _REPO_ROOT / "config" / "config.toml" |
Definition at line 36 of file config_loader.py.