10using namespace vtable::builder;
18 auto buf = Msg(msg).encode_vec();
20 std::cerr <<
"[DatabaseConfig] Failed to encode message" << std::endl;
23 return client.send_msg({0, 0}, buf);
27 const std::vector<BoardChannels>& boards) {
29 for (
const auto&
board : boards) {
30 if (
board.board_id == 0 ||
31 std::find(
board.channels.begin(),
board.channels.end(), 1) ==
board.channels.end())
33 const std::string entity =
"ENV" + std::to_string(
board.board_id);
34 const std::string prefix = entity +
".";
35 auto vt = builder::vtable({
36 raw_field(0, 8, schema(PrimType::U64(), {}, component(prefix +
"timestamp_ns"))),
37 raw_field(8, 4, schema(PrimType::F32(), {}, component(prefix +
"temperature_c"))),
38 raw_field(12, 4, schema(PrimType::U32(), {}, component(prefix +
"pressure_pa"))),
39 raw_field(16, 4, schema(PrimType::F32(), {}, component(prefix +
"humidity_rh"))),
40 raw_field(20, 4, schema(PrimType::U32(), {}, component(prefix +
"sample_ts_ms"))),
42 if (!
send_msg(client, VTableMsg{.id = {0x25,
board.board_id}, .vtable = vt})) {
46 for (
const char* field :
47 {
"timestamp_ns",
"temperature_c",
"pressure_pa",
"humidity_rh",
"sample_ts_ms"})
48 ok =
send_msg(client, set_component_name(prefix + field)) &&
ok;
49 ok =
send_msg(client, set_entity_name((0x25u << 8) |
board.board_id, entity)) &&
ok;
62 const std::string& entity_name,
63 const std::string& adc_field_name
65 std::string prefix = entity_name +
".";
67 auto vt = builder::vtable({
68 raw_field(0, 8, schema(PrimType::U64(), {}, component(prefix +
"timestamp_ns"))),
69 raw_field(8, 1, schema(PrimType::U8(), {}, component(prefix +
"channel_id"))),
71 raw_field(12, 4, schema(PrimType::U32(), {}, component(prefix + adc_field_name))),
72 raw_field(16, 4, schema(PrimType::U32(), {}, component(prefix +
"sample_ts_ms"))),
73 raw_field(20, 1, schema(PrimType::U8(), {}, component(prefix +
"status"))),
76 if (!
send_msg(client, VTableMsg{.id = {type_hi, channel_id}, .vtable = vt})) {
77 std::cerr <<
"[DatabaseConfig] ❌ VTable failed: " << entity_name << std::endl;
82 send_msg(client, set_component_name(prefix +
"timestamp_ns"));
83 send_msg(client, set_component_name(prefix +
"channel_id"));
84 send_msg(client, set_component_name(prefix + adc_field_name));
85 send_msg(client, set_component_name(prefix +
"sample_ts_ms"));
86 send_msg(client, set_component_name(prefix +
"status"));
89 send_msg(client, set_entity_name(entity_id, entity_name));
102 uint64_t entity_id,
const std::string& entity_name,
103 const std::string& cal_field_name,
104 const std::string& raw_field_name
106 std::string prefix = entity_name +
".";
108 auto vt = builder::vtable({
109 raw_field(0, 8, schema(PrimType::U64(), {}, component(prefix +
"timestamp_ns"))),
110 raw_field(8, 1, schema(PrimType::U8(), {}, component(prefix +
"channel_id"))),
112 raw_field(12, 4, schema(PrimType::F32(), {}, component(prefix + cal_field_name))),
113 raw_field(16, 4, schema(PrimType::U32(), {}, component(prefix + raw_field_name))),
114 raw_field(20, 1, schema(PrimType::U8(), {}, component(prefix +
"cal_status"))),
117 if (!
send_msg(client, VTableMsg{.id = {type_hi, pkt_lo}, .vtable = vt})) {
118 std::cerr <<
"[DatabaseConfig] ❌ Calibrated VTable failed: " << entity_name << std::endl;
122 send_msg(client, set_component_name(prefix +
"timestamp_ns"));
123 send_msg(client, set_component_name(prefix +
"channel_id"));
124 send_msg(client, set_component_name(prefix + cal_field_name));
125 send_msg(client, set_component_name(prefix + raw_field_name));
126 send_msg(client, set_component_name(prefix +
"cal_status"));
127 send_msg(client, set_entity_name(entity_id, entity_name));
135 uint8_t channel_id, uint64_t entity_id,
136 const std::string& entity_name) {
137 std::string prefix = entity_name +
".";
139 auto vt = builder::vtable({
140 raw_field(0, 8, schema(PrimType::U64(), {}, component(prefix +
"timestamp_ns"))),
141 raw_field(8, 1, schema(PrimType::U8(), {}, component(prefix +
"channel_id"))),
142 raw_field(9, 1, schema(PrimType::U8(), {}, component(prefix +
"actuator_state"))),
145 if (!
send_msg(client, VTableMsg{.id = {type_hi, channel_id}, .vtable = vt})) {
146 std::cerr <<
"[DatabaseConfig] ❌ Actuator state VTable failed: " << entity_name
151 send_msg(client, set_component_name(prefix +
"timestamp_ns"));
152 send_msg(client, set_component_name(prefix +
"channel_id"));
153 send_msg(client, set_component_name(prefix +
"actuator_state"));
154 send_msg(client, set_entity_name(entity_id, entity_name));
166 const std::vector<BoardChannels>& boards, uint8_t type_hi, uint8_t offset) {
167 for (
const auto&
board : boards)
168 for (uint8_t
ch :
board.channels)
170 {type_hi,
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 + offset +
ch)});
175 const std::vector<BoardChannels>& pt_boards,
const std::vector<BoardChannels>& act_boards,
176 const std::vector<BoardChannels>& tc_boards,
const std::vector<BoardChannels>& rtd_boards,
177 const std::vector<BoardChannels>& lc_boards,
const std::vector<BoardChannels>& enc_boards) {
178 std::vector<std::pair<uint8_t, uint8_t>> t;
179 appendTables(t, pt_boards, 0x20, 0x00);
180 appendTables(t, act_boards, 0x30, 0x00);
181 appendTables(t, tc_boards, 0x21, 0x00);
182 appendTables(t, rtd_boards, 0x22, 0x00);
183 appendTables(t, lc_boards, 0x23, 0x00);
184 appendTables(t, enc_boards, 0x24, 0x00);
189 const std::vector<BoardChannels>& pt_boards,
const std::vector<BoardChannels>& tc_boards,
190 const std::vector<BoardChannels>& rtd_boards,
const std::vector<BoardChannels>& lc_boards,
191 const std::vector<BoardChannels>& enc_boards,
const std::vector<BoardChannels>& act_boards) {
192 std::vector<std::pair<uint8_t, uint8_t>> t;
193 appendTables(t, pt_boards, 0x20, 0x10);
194 appendTables(t, tc_boards, 0x21, 0x10);
195 appendTables(t, rtd_boards, 0x22, 0x10);
196 appendTables(t, lc_boards, 0x23, 0x10);
197 appendTables(t, enc_boards, 0x24, 0x10);
198 appendTables(t, act_boards, 0x31, 0x10);
205 const char* value_field,
const char* u32_field, PrimType u32_type,
206 const char* status_field) {
207 const std::string prefix = entity +
".";
208 auto vt = builder::vtable({
209 raw_field(0, 8, schema(PrimType::U64(), {}, component(prefix +
"timestamp_ns"))),
210 raw_field(8, 1, schema(PrimType::U8(), {}, component(prefix +
"channel_id"))),
211 raw_field(12, 4, schema(PrimType::F32(), {}, component(prefix + value_field))),
212 raw_field(16, 4, schema(u32_type, {}, component(prefix + u32_field))),
213 raw_field(20, 1, schema(PrimType::U8(), {}, component(prefix + status_field))),
215 if (!
send_msg(client, VTableMsg{.id = {0x26, lo}, .vtable = vt})) {
216 std::cerr <<
"[DatabaseConfig] T7 VTable failed: " << entity << std::endl;
220 for (
const char* field : {
"timestamp_ns",
"channel_id", value_field, u32_field, status_field})
221 ok =
send_msg(client, set_component_name(prefix + field)) &&
ok;
222 return send_msg(client, set_entity_name((
static_cast<uint64_t
>(0x26) << 8) | lo, entity)) &&
ok;
227 const std::vector<uint8_t>& ains,
bool cjc) {
229 const uint8_t base =
static_cast<uint8_t
>((slot - 1) * 0x20);
230 const std::string
n = std::to_string(slot);
231 for (uint8_t ain : ains)
232 ok = register_t7_vtable(client,
static_cast<uint8_t
>(base + ain),
233 "T7" +
n +
".AIN" + std::to_string(ain),
"volts",
"sample_ts_ms",
234 PrimType::U32(),
"status") &&
237 ok = register_t7_vtable(client,
static_cast<uint8_t
>(base + 0x0F),
"T7" +
n +
".CJC",
238 "temperature_c",
"sample_ts_ms", PrimType::U32(),
"status") &&
244 const std::vector<T7Table>&
tables) {
246 const uint8_t base =
static_cast<uint8_t
>((slot - 1) * 0x20 + 0x10);
247 const std::string
n = std::to_string(slot);
248 for (
const auto& t :
tables)
249 ok = register_t7_vtable(client,
static_cast<uint8_t
>(base + t.ain),
250 "T7" +
n +
"_Cal.AIN" + std::to_string(t.ain), t.cal_field.c_str(),
251 "raw_uv", PrimType::I32(),
"cal_status") &&
257 const std::vector<BoardChannels>& pt_boards,
258 const std::vector<BoardChannels>& act_boards,
259 const std::vector<BoardChannels>& tc_boards,
260 const std::vector<BoardChannels>& rtd_boards,
261 const std::vector<BoardChannels>& lc_boards,
262 const std::vector<BoardChannels>& enc_boards) {
263 std::cout <<
"[DatabaseConfig] Registering RAW VTables (board-namespaced)..." << std::endl;
265 int pt_count = 0, act_count = 0, tc_count = 0, rtd_count = 0, lc_count = 0, enc_count = 0;
267 for (
const auto&
board : pt_boards) {
268 for (uint8_t
ch :
board.channels) {
270 "PT" + std::to_string(
board.board_number) +
".CH" + std::to_string(
ch);
271 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 +
ch);
272 uint64_t entity_id = (
static_cast<uint64_t
>(0x20) << 8) | lo;
280 for (
const auto&
board : act_boards) {
281 for (uint8_t
ch :
board.channels) {
283 "ACT" + std::to_string(
board.board_number) +
".CH" + std::to_string(
ch);
284 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 +
ch);
285 uint64_t entity_id = (
static_cast<uint64_t
>(0x30) << 8) | lo;
293 for (
const auto&
board : tc_boards) {
294 for (uint8_t
ch :
board.channels) {
296 "TC" + std::to_string(
board.board_number) +
".CH" + std::to_string(
ch);
297 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 +
ch);
298 uint64_t entity_id = (
static_cast<uint64_t
>(0x21) << 8) | lo;
306 for (
const auto&
board : rtd_boards) {
307 for (uint8_t
ch :
board.channels) {
309 "RTD" + std::to_string(
board.board_number) +
".CH" + std::to_string(
ch);
310 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 +
ch);
311 uint64_t entity_id = (
static_cast<uint64_t
>(0x22) << 8) | lo;
313 "raw_resistance_counts")) {
320 for (
const auto&
board : lc_boards) {
321 for (uint8_t
ch :
board.channels) {
323 "LC" + std::to_string(
board.board_number) +
".CH" + std::to_string(
ch);
324 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 +
ch);
325 uint64_t entity_id = (
static_cast<uint64_t
>(0x23) << 8) | lo;
333 for (
const auto&
board : enc_boards) {
334 for (uint8_t
ch :
board.channels) {
336 "ENC" + std::to_string(
board.board_number) +
".CH" + std::to_string(
ch);
337 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 +
ch);
338 uint64_t entity_id = (
static_cast<uint64_t
>(0x24) << 8) | lo;
346 std::cout <<
"[DatabaseConfig] ✅ Registered " << registered <<
" RAW VTables (" << pt_count
347 <<
" PT, " << act_count <<
" ACT, " << tc_count <<
" TC, " << rtd_count <<
" RTD, "
348 << lc_count <<
" LC, " << enc_count <<
" ENC)" << std::endl;
349 return registered > 0;
357 const std::vector<BoardChannels>& pt_boards,
358 const std::vector<BoardChannels>& tc_boards,
359 const std::vector<BoardChannels>& rtd_boards,
360 const std::vector<BoardChannels>& lc_boards,
361 const std::vector<BoardChannels>& enc_boards,
362 const std::vector<BoardChannels>& act_boards) {
363 std::cout <<
"[DatabaseConfig] Registering CALIBRATED VTables..." << std::endl;
366 for (
const auto&
board : pt_boards) {
367 for (uint8_t
ch :
board.channels) {
369 "PT" + std::to_string(
board.board_number) +
"_Cal.CH" + std::to_string(
ch);
370 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 + 0x10 +
ch);
371 uint64_t entity_id = (
static_cast<uint64_t
>(0x20) << 8) | lo;
378 for (
const auto&
board : tc_boards) {
379 for (uint8_t
ch :
board.channels) {
381 "TC" + std::to_string(
board.board_number) +
"_Cal.CH" + std::to_string(
ch);
382 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 + 0x10 +
ch);
383 uint64_t entity_id = (
static_cast<uint64_t
>(0x21) << 8) | lo;
390 for (
const auto&
board : rtd_boards) {
391 for (uint8_t
ch :
board.channels) {
393 "RTD" + std::to_string(
board.board_number) +
"_Cal.CH" + std::to_string(
ch);
394 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 + 0x10 +
ch);
395 uint64_t entity_id = (
static_cast<uint64_t
>(0x22) << 8) | lo;
402 for (
const auto&
board : lc_boards) {
403 for (uint8_t
ch :
board.channels) {
405 "LC" + std::to_string(
board.board_number) +
"_Cal.CH" + std::to_string(
ch);
406 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 + 0x10 +
ch);
407 uint64_t entity_id = (
static_cast<uint64_t
>(0x23) << 8) | lo;
414 for (
const auto&
board : enc_boards) {
415 for (uint8_t
ch :
board.channels) {
417 "ENC" + std::to_string(
board.board_number) +
"_Cal.CH" + std::to_string(
ch);
418 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 + 0x10 +
ch);
419 uint64_t entity_id = (
static_cast<uint64_t
>(0x24) << 8) | lo;
427 for (
const auto&
board : act_boards) {
428 for (uint8_t
ch :
board.channels) {
430 "ACT" + std::to_string(
board.board_number) +
"_Cal.CH" + std::to_string(
ch);
431 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 + 0x10 +
ch);
432 uint64_t entity_id = (
static_cast<uint64_t
>(0x31) << 8) | lo;
439 std::cout <<
"[DatabaseConfig] ✅ Registered " << registered <<
" CALIBRATED VTables"
441 return registered > 0;
449 const std::vector<uint8_t>& board_ids) {
450 std::cout <<
"[DatabaseConfig] Registering BOARD_HEARTBEAT VTables (" << board_ids.size()
451 <<
" boards)..." << std::endl;
457 for (uint8_t
board_id : board_ids) {
458 std::string entity =
"BOARD.HB_" + std::to_string(
board_id);
459 std::string prefix = entity +
".";
461 auto vt = builder::vtable({
462 raw_field(0, 8, schema(PrimType::U64(), {}, component(prefix +
"timestamp_ns"))),
463 raw_field(8, 1, schema(PrimType::U8(), {}, component(prefix +
"board_id"))),
464 raw_field(9, 1, schema(PrimType::U8(), {}, component(prefix +
"board_type"))),
465 raw_field(10, 1, schema(PrimType::U8(), {}, component(prefix +
"engine_state"))),
466 raw_field(11, 1, schema(PrimType::U8(), {}, component(prefix +
"board_state"))),
467 raw_field(12, 4, schema(PrimType::U32(), {}, component(prefix +
"packet_ts_ms"))),
470 uint64_t entity_id = 0x1000 +
board_id;
472 std::cerr <<
"[DatabaseConfig] ❌ Heartbeat VTable failed: " << entity << std::endl;
476 send_msg(client, set_component_name(prefix +
"timestamp_ns"));
477 send_msg(client, set_component_name(prefix +
"board_id"));
478 send_msg(client, set_component_name(prefix +
"board_type"));
479 send_msg(client, set_component_name(prefix +
"engine_state"));
480 send_msg(client, set_component_name(prefix +
"board_state"));
481 send_msg(client, set_component_name(prefix +
"packet_ts_ms"));
482 send_msg(client, set_entity_name(entity_id, entity));
486 std::cout <<
"[DatabaseConfig] ✅ Registered " << registered <<
" HEARTBEAT VTables"
488 return registered > 0;
498 std::string entity =
"SELF_TEST.BOARD_" + std::to_string(
board_id);
499 std::string prefix = entity +
".s" + std::to_string(sensor_id) +
".";
501 auto vt = builder::vtable({
502 raw_field(0, 8, schema(PrimType::U64(), {}, component(prefix +
"timestamp_ns"))),
503 raw_field(8, 1, schema(PrimType::U8(), {}, component(prefix +
"sensor_id"))),
504 raw_field(9, 1, schema(PrimType::U8(), {}, component(prefix +
"result"))),
508 uint64_t entity_id = (
static_cast<uint64_t
>(high) << 8) |
board_id;
512 send_msg(client, set_component_name(prefix +
"timestamp_ns"));
513 send_msg(client, set_component_name(prefix +
"sensor_id"));
514 send_msg(client, set_component_name(prefix +
"result"));
515 send_msg(client, set_entity_name(entity_id, entity));
520 const std::vector<uint8_t>& board_ids) {
521 std::cout <<
"[DatabaseConfig] Registering SELF_TEST VTables (" << board_ids.size()
524 for (uint8_t
board_id : board_ids) {
530 std::cout <<
"[DatabaseConfig] ✅ Registered " << registered <<
" SELF_TEST VTables"
532 return registered > 0;
539 auto vt1 = builder::vtable({
540 raw_field(0, 8, schema(PrimType::U64(), {}, component(
"SEQUENCER.state.timestamp_ns"))),
541 raw_field(8, 1, schema(PrimType::U8(), {}, component(
"SEQUENCER.state.current_state"))),
542 raw_field(12, 4, schema(PrimType::U32(), {}, component(
"SEQUENCER.state.allowed_bitmask"))),
543 raw_field(16, 1, schema(PrimType::U8(), {}, component(
"SEQUENCER.state.debug_mode"))),
545 if (!
send_msg(client, VTableMsg{.id = {0x50, 0x00}, .vtable = vt1}))
547 send_msg(client, set_component_name(
"SEQUENCER.state.timestamp_ns"));
548 send_msg(client, set_component_name(
"SEQUENCER.state.current_state"));
549 send_msg(client, set_component_name(
"SEQUENCER.state.allowed_bitmask"));
550 send_msg(client, set_component_name(
"SEQUENCER.state.debug_mode"));
551 send_msg(client, set_entity_name(0x5000,
"SEQUENCER.state"));
554 auto vt2 = builder::vtable({
555 raw_field(0, 8, schema(PrimType::U64(), {}, component(
"CONTROLLER.state.timestamp_ns"))),
556 raw_field(8, 1, schema(PrimType::U8(), {}, component(
"CONTROLLER.state.from_state"))),
557 raw_field(9, 1, schema(PrimType::U8(), {}, component(
"CONTROLLER.state.to_state"))),
558 raw_field(10, 1, schema(PrimType::U8(), {}, component(
"CONTROLLER.state.reason"))),
560 if (!
send_msg(client, VTableMsg{.id = {0x43, 0x00}, .vtable = vt2}))
562 send_msg(client, set_component_name(
"CONTROLLER.state.timestamp_ns"));
563 send_msg(client, set_component_name(
"CONTROLLER.state.from_state"));
564 send_msg(client, set_component_name(
"CONTROLLER.state.to_state"));
565 send_msg(client, set_component_name(
"CONTROLLER.state.reason"));
566 send_msg(client, set_entity_name(0x4300,
"CONTROLLER.state"));
578 auto vt = builder::vtable({
579 raw_field(0, 8, schema(PrimType::U64(), {}, component(
"CALIBRATION.command.timestamp_ns"))),
580 raw_field(8, 1, schema(PrimType::U8(), {}, component(
"CALIBRATION.command.type"))),
581 raw_field(10, 2, schema(PrimType::U16(), {}, component(
"CALIBRATION.command.sensor_id"))),
583 schema(PrimType::F32(), {}, component(
"CALIBRATION.command.reference_value"))),
585 if (!
send_msg(client, VTableMsg{.id = {0x46, 0x00}, .vtable = vt}))
587 send_msg(client, set_component_name(
"CALIBRATION.command.timestamp_ns"));
588 send_msg(client, set_component_name(
"CALIBRATION.command.type"));
589 send_msg(client, set_component_name(
"CALIBRATION.command.sensor_id"));
590 send_msg(client, set_component_name(
"CALIBRATION.command.reference_value"));
591 send_msg(client, set_entity_name(0x4600,
"CALIBRATION.command"));
600 const std::vector<BoardChannels>& bv_boards) {
601 std::vector<std::pair<uint8_t, uint8_t>> t;
607 const std::vector<BoardChannels>& bv_boards) {
608 std::vector<std::pair<uint8_t, uint8_t>> t;
614 const std::vector<BoardChannels>& bv_boards) {
615 std::vector<std::pair<uint8_t, uint8_t>> t;
621 const std::vector<BoardChannels>& bv_boards) {
623 for (
const auto&
board : bv_boards)
624 for (uint8_t
ch :
board.channels) {
626 "BV" + std::to_string(
board.board_number) +
".CH" + std::to_string(
ch);
627 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 +
ch);
628 uint64_t entity_id = (
static_cast<uint64_t
>(
kBallValveRawHi) << 8) | lo;
637 ElodinClient& client,
const std::vector<BoardChannels>& bv_boards) {
639 for (
const auto&
board : bv_boards)
640 for (uint8_t
ch :
board.channels) {
642 "BV" + std::to_string(
board.board_number) +
"_Cal.CH" + std::to_string(
ch);
643 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 + 0x10 +
ch);
644 uint64_t entity_id = (
static_cast<uint64_t
>(
kBallValveCalHi) << 8) | lo;
646 "position_pct",
"raw_adc") &&
653 const std::vector<BoardChannels>& bv_boards) {
655 for (
const auto&
board : bv_boards)
656 for (uint8_t
ch :
board.channels) {
657 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 +
ch);
659 "BV_CMD.B" + std::to_string(
board.board_number) +
".CH" + std::to_string(
ch);
660 uint64_t entity_id = (
static_cast<uint64_t
>(
kBallValveCmdHi) << 8) | lo;
668 const std::vector<BoardChannels>& act_boards) {
676 int act_cmd_count = 0;
677 if (!act_boards.empty()) {
678 for (
const auto&
board : act_boards) {
679 for (uint8_t
ch :
board.channels) {
680 uint8_t lo =
static_cast<uint8_t
>((
board.board_number - 1) * 0x20 +
ch);
681 std::string entity_name =
682 "ACT_CMD.B" + std::to_string(
board.board_number) +
".CH" + std::to_string(
ch);
683 uint64_t entity_id = (
static_cast<uint64_t
>(0x32) << 8) | lo;
690 for (
int bn = 1; bn <= 4; ++bn) {
691 for (
int ch = 1;
ch <= 10; ++
ch) {
692 uint8_t lo =
static_cast<uint8_t
>((bn - 1) * 0x20 +
ch);
693 std::string entity_name =
694 "ACT_CMD.B" + std::to_string(bn) +
".CH" + std::to_string(
ch);
695 uint64_t entity_id = (
static_cast<uint64_t
>(0x32) << 8) | lo;
701 if (act_cmd_count > 0)
702 std::cout <<
"[DatabaseConfig] ✅ Registered " << act_cmd_count
703 <<
" actuator commanded VTables [0x32]" << std::endl;
706 std::cout <<
"[DatabaseConfig] ✅ Registered Sequencer/Controller VTables" << std::endl;
static bool register_ball_valve_calibrated_tables(ElodinClient &client, const std::vector< BoardChannels > &bv_boards)
Register ball valve CALIBRATED position VTables [0x34] (calibration_service).
static bool register_calibrated_tables(ElodinClient &client, const std::vector< BoardChannels > &pt_boards, const std::vector< BoardChannels > &tc_boards, const std::vector< BoardChannels > &rtd_boards, const std::vector< BoardChannels > &lc_boards, const std::vector< BoardChannels > &enc_boards, const std::vector< BoardChannels > &act_boards)
Register CALIBRATED VTables.
static bool register_non_sensor_tables(ElodinClient &client, const std::vector< BoardChannels > &act_boards={})
Register sequencer/controller and ACT_CMD tables.
static bool register_environmental_tables(ElodinClient &client, const std::vector< BoardChannels > &boards)
static bool register_heartbeat_tables(ElodinClient &client, const std::vector< uint8_t > &board_ids)
Register BOARD_HEARTBEAT VTables for specific board IDs.
static bool register_tables(ElodinClient &client, const std::vector< BoardChannels > &pt_boards, const std::vector< BoardChannels > &act_boards, const std::vector< BoardChannels > &tc_boards, const std::vector< BoardChannels > &rtd_boards, const std::vector< BoardChannels > &lc_boards, const std::vector< BoardChannels > &enc_boards)
Register RAW sensor / actuator VTables.
static bool register_self_test_tables(ElodinClient &client, const std::vector< uint8_t > &board_ids)
Register SELF_TEST VTables for specific board IDs.
static bool register_ball_valve_cmd_tables(ElodinClient &client, const std::vector< BoardChannels > &bv_boards)
Register ball valve commanded-state VTables [0x35] (sequencer_service).
static bool register_t7_raw_tables(ElodinClient &client, uint8_t slot, const std::vector< uint8_t > &ains, bool cjc)
Register one LabJack T7's RAW VTables (t7_bridge).
static bool register_t7_calibrated_tables(ElodinClient &client, uint8_t slot, const std::vector< T7Table > &tables)
static bool register_ball_valve_tables(ElodinClient &client, const std::vector< BoardChannels > &bv_boards)
Register ball valve RAW position VTables [0x33] (daq_bridge).
Standalone Elodin database client.
void appendTables(std::vector< std::pair< uint8_t, uint8_t > > &out, const std::vector< BoardChannels > &boards, uint8_t type_hi, uint8_t offset)
Append (type_hi, (board_number-1)*0x20 + offset + ch) for every active channel.
bool register_t7_vtable(ElodinClient &client, uint8_t lo, const std::string &entity, const char *value_field, const char *u32_field, PrimType u32_type, const char *status_field)
static bool register_actuator_state_vtable(ElodinClient &client, uint8_t type_hi, uint8_t channel_id, uint64_t entity_id, const std::string &entity_name)
static constexpr uint8_t SELF_TEST_HIGH_BASE
static bool send_msg(ElodinClient &client, T msg)
std::vector< std::pair< uint8_t, uint8_t > > ball_valve_calibrated_tables(const std::vector< BoardChannels > &bv_boards)
constexpr uint8_t kBallValveCmdHi
static bool register_self_test_vtable(ElodinClient &client, uint8_t board_id, uint8_t sensor_id)
static bool register_calibration_command_vtable(ElodinClient &client)
constexpr uint8_t kBallValveCalHi
std::vector< std::pair< uint8_t, uint8_t > > ball_valve_cmd_tables(const std::vector< BoardChannels > &bv_boards)
std::vector< std::pair< uint8_t, uint8_t > > raw_sensor_tables(const std::vector< BoardChannels > &pt_boards, const std::vector< BoardChannels > &act_boards, const std::vector< BoardChannels > &tc_boards, const std::vector< BoardChannels > &rtd_boards, const std::vector< BoardChannels > &lc_boards, const std::vector< BoardChannels > &enc_boards)
Elodin table ids (hi, lo) for the RAW sensor VTables the given boards publish.
static bool register_sequencer_vtable(ElodinClient &client)
std::vector< std::pair< uint8_t, uint8_t > > calibrated_sensor_tables(const std::vector< BoardChannels > &pt_boards, const std::vector< BoardChannels > &tc_boards, const std::vector< BoardChannels > &rtd_boards, const std::vector< BoardChannels > &lc_boards, const std::vector< BoardChannels > &enc_boards, const std::vector< BoardChannels > &act_boards)
Elodin table ids for the CALIBRATED VTables, matching register_calibrated_tables() (same encoding as ...
static bool register_raw_sensor_vtable(ElodinClient &client, uint8_t type_hi, uint8_t channel_id, uint64_t entity_id, const std::string &entity_name, const std::string &adc_field_name)
constexpr uint8_t kBallValveRawHi
Ball valve boards (BALL_VALVE) have their own type_hi bytes, so a valve never shares a key with an AC...
static constexpr uint8_t SELF_TEST_MAX_SENSOR
std::vector< std::pair< uint8_t, uint8_t > > ball_valve_raw_tables(const std::vector< BoardChannels > &bv_boards)
static bool register_calibrated_vtable(ElodinClient &client, uint8_t type_hi, uint8_t pkt_lo, uint64_t entity_id, const std::string &entity_name, const std::string &cal_field_name, const std::string &raw_field_name)
Motorized ball valve position: raw ADC counts -> % open.
*brief user defined string literal for JSON values *sa std::size_t n
std::string board(const std::string &name, const std::string &id, bool enabled=true)
static SlugTables tables()
The tables every case validates against.
static std::string ch(int ain, const std::string &kind, const std::string &extra="", const std::string &board="lj")