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:
2026-06-10 19:47:31 +02:00
parent 83593bb508
commit 1da56f973f
9 changed files with 326 additions and 15 deletions
+38
View File
@@ -99,6 +99,8 @@ def run(grpc_addr: str, hsms_host: str, hsms_port: int, session_id: int,
ceid300 = threading.Event()
last_s6f11 = {}
s5f1_seen = threading.Event()
last_s5f1 = {}
def on_s6f11(_handler, message):
decoded = client.settings.streams_functions.decode(message)
@@ -110,7 +112,17 @@ def run(grpc_addr: str, hsms_host: str, hsms_port: int, session_id: int,
ceid300.set()
client.send_response(F.SecsS06F12(0), message.header.system)
def on_s5f1(_handler, message):
decoded = client.settings.streams_functions.decode(message)
body = decoded.get()
LOG.info("[alm] S5F1 body=%r", body)
if isinstance(body, dict):
last_s5f1.update(body)
s5f1_seen.set()
client.send_response(F.SecsS05F02(0), message.header.system)
client.register_stream_function(6, 11, on_s6f11)
client.register_stream_function(5, 1, on_s5f1)
client.enable()
try:
@@ -172,6 +184,32 @@ def run(grpc_addr: str, hsms_host: str, hsms_port: int, session_id: int,
for v in vals)
check("S6F11 report carries ChamberPressure=2.5 (value flowed end-to-end)",
near, f"scalars={vals}")
# --- alarms: host enables ALID 1 (S5F3), gRPC raises it BY NAME,
# host receives the unsolicited S5F1 with set-bit + ALID 1 ---
client.send_and_waitfor_response(
F.SecsS05F03({"ALED": 0x80, "ALID": 1}))
ack = stub.SetAlarm(pb.Alarm(name="chiller_temp_high"))
check("gRPC SetAlarm(chiller_temp_high) -> ACCEPT",
ack.code == pb.Ack.ACCEPT, pb.Ack.Code.Name(ack.code))
got_alarm = s5f1_seen.wait(timeout=10)
check("host received S5F1 (gRPC SetAlarm bridged to HSMS)", got_alarm)
if got_alarm:
check("S5F1 carries ALID 1 with the set bit",
last_s5f1.get("ALID") == 1
and (int(last_s5f1.get("ALCD") or 0) & 0x80) != 0,
f"body={last_s5f1}")
stub.ClearAlarm(pb.Alarm(name="chiller_temp_high"))
# --- operator-panel control state: take the tool offline via gRPC ---
ack = stub.RequestControlState(pb.ControlStateRequest(
desired=pb.ControlState.HOST_OFFLINE))
check("gRPC RequestControlState(HOST_OFFLINE) -> ACCEPT",
ack.code == pb.Ack.ACCEPT, pb.Ack.Code.Name(ack.code))
cs = stub.GetControlState(pb.Empty())
check("control state is HOST_OFFLINE after operator request",
cs.state == pb.ControlState.HOST_OFFLINE,
pb.ControlState.State.Name(cs.state))
finally:
client.disable()