feat(daemon): alarms by name + RequestControlState + WatchHealth (Phase A complete)
A2 — alarms: optional 'name:' on alarm config (a LOCAL key — SEMI only
defines numeric ALID + freetext ALTX; field appended last so existing
{id, text, category} brace-inits compile unchanged), parsed by the loader,
checked by the validator, shipped in equipment.yaml. SetAlarm/ClearAlarm
RPCs resolve config name OR stringified ALID via a constructor snapshot.
A3 — control state + health: RequestControlState fires operator events on
the io thread (read_sync) and reports what the E30 table actually did —
ACCEPT iff the equipment landed in the requested state, CANNOT_DO_NOW naming
the actual state otherwise (the shipped table has no operator path to
EquipmentOffline; the test pins that honesty). ATTEMPT_ONLINE is rejected as
transient. WatchHealth streams an immediate snapshot then pushes on link/
control-state changes via service observers (add_link_observer +
add_control_state_observer — the HandlerSlot work paying off), spool depth
sampled at the 500ms poll; ends on cancel or engine stop.
Tests: daemon suite 61 -> 101 assertions (alarm lifecycle by name/id/unknown,
WatchHealth initial + change push, all four RequestControlState semantics);
loader test for the alarm name (present + absent fallback); core 467/3055.
Interop now 15 checks incl. gRPC SetAlarm -> host receives S5F1 ALCD=0x84
ALID=1, and RequestControlState(HOST_OFFLINE) -> GetControlState confirms.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
@@ -144,3 +145,24 @@ TEST_CASE("loader: control_job_state.yaml -> non-empty table") {
|
||||
REQUIRE(row->to.has_value());
|
||||
CHECK(*row->to == gem::ControlJobState::Completed);
|
||||
}
|
||||
|
||||
TEST_CASE("alarm optional name: parsed when present, empty when absent") {
|
||||
gem::EquipmentDataModel m;
|
||||
config::load_equipment(SECSGEM_DATA_DIR "/equipment.yaml", m);
|
||||
// data/equipment.yaml names both alarms.
|
||||
CHECK(m.alarms.get(1)->name == "chiller_temp_high");
|
||||
CHECK(m.alarms.get(2)->name == "door_open");
|
||||
|
||||
// A config without `name:` yields an empty name (back-compat).
|
||||
const auto path = std::filesystem::temp_directory_path() / "alarm_noname.yaml";
|
||||
{
|
||||
std::ofstream f(path);
|
||||
f << "device: {id: 0, model_name: M, software_rev: R}\n"
|
||||
"alarms:\n"
|
||||
" - {id: 9, text: \"Unnamed\", category: 1}\n";
|
||||
}
|
||||
gem::EquipmentDataModel m2;
|
||||
config::load_equipment(path.string(), m2);
|
||||
CHECK(m2.alarms.get(9)->name.empty());
|
||||
std::filesystem::remove(path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user