STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
LoadActiveBoards.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <map>
5#include <string>
6#include <vector>
7
9
10namespace fsw {
11namespace config {
12
13/** Board kinds from [boards.*] in config.toml (order matches prior daq_bridge enum).
14 *
15 * BALL_VALVE is a motorized ball valve board (firmware/Hotfire_Code/BallValve_Hotfire): commanded
16 * like an actuator through [actuator_roles], but its SENSOR_DATA is a 4-20 mA position, not a
17 * current sense, and it has its own Elodin namespace (0x33-0x35) so it never shares keys with an
18 * ACTUATOR board on the same board_id % 10 slot. */
30
31/**
32 * Sensor interface of a PT board, declared by `pt_type` in its [boards.*] section.
33 *
34 * The board hardware is identical; what differs is the sensor interface and therefore the ADC
35 * reference, which is set once per board and so cannot be mixed across connectors.
36 */
37enum class PtInterface : uint8_t {
38 RATIOMETRIC_0_5V, ///< 0-5V ratiometric: excitation is the reference, ratio cancels in HW.
39 CURRENT_LOOP_4_20MA, ///< 4-20 mA absolute: supply-independent loop across a shunt resistor.
40 ABSOLUTE_0_5V, ///< 0-5V absolute. Not implemented in firmware; see load_pt_boards().
41};
42
43/** Per-board 4-20 mA conversion parameters, keyed by Elodin slot (board_number). */
45 uint8_t board_id = 0;
46 uint8_t board_number = 0; ///< Elodin slot: board_id % 10, with 0 mapping to 10.
48 double full_scale_psi = 5000.0;
49 double sense_resistor_ohms = 120.0;
50 double adc_ref_voltage = 2.5;
51};
52
53/** True when this board's channels convert through the 4-20 mA current-loop path. */
54inline bool is_current_loop(const PtBoardConfig& b) {
55 return b.interface == PtInterface::CURRENT_LOOP_4_20MA;
56}
57
58/**
59 * Parse [boards.*] sections: enabled boards, board_id, channels / active_connectors.
60 * Used by daq_bridge (full table registration) and sequencer_service (ACT_CMD registration).
61 *
62 * Also validates Elodin slot assignment (see check_board_slots) and logs to stderr on conflict.
63 */
64std::map<ActiveBoardKind, std::vector<elodin::BoardChannels>> load_active_boards(
65 const std::string& config_path);
66
67/**
68 * Parse the PT boards' sensor interface and 4-20 mA conversion parameters, keyed by Elodin slot.
69 *
70 * `pt_type` is authoritative. A board that predates it is treated as 4-20 mA if it carries the
71 * legacy hp_pt_* keys, so a deployed config keeps working; that fallback logs a deprecation once.
72 */
73std::map<uint8_t, PtBoardConfig> load_pt_boards(const std::string& config_path);
74
75} // namespace config
76} // namespace fsw
*brief create JSON pointer *sa reference_tokens const string_t const string_t & b
Definition json.hpp:13878
std::map< ActiveBoardKind, std::vector< elodin::BoardChannels > > load_active_boards(const std::string &config_path)
Parse [boards.
std::map< uint8_t, PtBoardConfig > load_pt_boards(const std::string &config_path)
Parse the PT boards' sensor interface and 4-20 mA conversion parameters, keyed by Elodin slot.
bool is_current_loop(const PtBoardConfig &b)
True when this board's channels convert through the 4-20 mA current-loop path.
ActiveBoardKind
Board kinds from [boards.
PtInterface
Sensor interface of a PT board, declared by pt_type in its [boards.
@ CURRENT_LOOP_4_20MA
4-20 mA absolute: supply-independent loop across a shunt resistor.
@ ABSOLUTE_0_5V
0-5V absolute. Not implemented in firmware; see load_pt_boards().
@ RATIOMETRIC_0_5V
0-5V ratiometric: excitation is the reference, ratio cancels in HW.
Motorized ball valve position: raw ADC counts -> % open.
Per-board 4-20 mA conversion parameters, keyed by Elodin slot (board_number).
uint8_t board_number
Elodin slot: board_id % 10, with 0 mapping to 10.