E40 Process Jobs + E94 Control Jobs + E30 communication state

GEM300 layer: SEMI E40-0705 Process Job and E94-0705 Control Job
state machines, plus the E30 §6.1 communication-state machine that
sits between HSMS SELECT and full GEM communication. Data-driven
via data/process_job_state.yaml and data/control_job_state.yaml,
mirroring the existing control_state.yaml pattern.

Wire coverage:
  S14F9/F10   CreateObject (CJ)              host -> equipment
  S14F11/F12  DeleteObject (CJ)              host -> equipment
  S16F5/F6    PRJobCommand                   host -> equipment
  S16F9       PRJobAlert                     equipment -> host
  S16F11/F12  PRJobCreate (simplified body)  host -> equipment
  S16F13/F14  PRJobDequeue                   host -> equipment
  S16F27/F28  CJobCommand                    host -> equipment

Process Job FSM exposes 8 states matching PRJOBSTATE bytes (E40 §10.3.2);
HOQ is reorder-aware (move-to-head against an insertion-order vector);
Stop/Abort on a Queued PJ routes through ABORTING so the host observes
PRJOBSTATE=7 on the wire (§6.3); alert_enabled is settable per-PJ for
PRALERT control; FSM dispatches through ProcessJobStore::on_change_
dynamically so a late set_state_change_handler() reaches existing PJs.

Hardening: loader rejects NoState (sentinel) as initial/from/to and
rejects `on: created` rows; static_asserts pin enum values to wire
bytes; ProcessJobStore is non-movable to keep the per-PJ this-capture
safe.

Server simulator cascades the full CJ -> PJ lifecycle on CJSTART so
the wire trace exercises every legal state. CEIDs 400/401 fire on CJ
state changes via the existing event-report pipeline.

Tests: 60+ new assertions across test_process_jobs, test_control_jobs,
test_communication_state, test_hsms_connection, plus loader and
messages round-trip coverage.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 21:00:32 +02:00
parent 1f67aad985
commit 90c177b7ce
33 changed files with 3122 additions and 62 deletions
+47 -1
View File
@@ -47,9 +47,11 @@ TEST_CASE("equipment.yaml populates SVIDs, ECIDs, CEIDs, alarms, recipes, comman
CHECK(m.ecids.all().size() == 2);
CHECK(m.ecids.get(10)->value == s2::Item::u4(uint32_t{1}));
CHECK(m.events.all_events().size() == 3);
CHECK(m.events.all_events().size() >= 3);
CHECK(m.events.has_event(100));
CHECK(m.events.has_event(300));
CHECK(m.events.has_event(400)); // E94 CJ Executing
CHECK(m.events.has_event(401)); // E94 CJ Completed
CHECK(m.alarms.all().size() == 2);
CHECK(m.alarms.get(1)->text == "Chiller Temp High");
@@ -98,3 +100,47 @@ TEST_CASE("loader surfaces YAML errors with file path") {
CHECK_THROWS_AS(config::load_equipment("/tmp/does-not-exist.yaml", *new gem::EquipmentDataModel),
config::ConfigError);
}
TEST_CASE("loader: process_job_state.yaml -> non-empty table") {
auto cfg = config::load_process_job_state(
std::string(SECSGEM_DATA_DIR) + "/process_job_state.yaml");
CHECK(cfg.initial == gem::ProcessJobState::Queued);
CHECK(cfg.table.size() >= 18);
// Spot-check: Queued + Select -> SettingUp.
const auto* row = cfg.table.find(gem::ProcessJobState::Queued,
gem::ProcessJobEvent::Select);
REQUIRE(row != nullptr);
REQUIRE(row->to.has_value());
CHECK(*row->to == gem::ProcessJobState::SettingUp);
}
TEST_CASE("loader: NoState rejected in PJ state table") {
const std::string path = "/tmp/pj_nostate.yaml";
std::ofstream(path) << "initial: NoState\ntransitions: []\n";
CHECK_THROWS_AS(config::load_process_job_state(path), config::ConfigError);
std::ofstream(path) << "initial: Queued\ntransitions:\n"
<< " - {from: NoState, on: select, to: SettingUp}\n";
CHECK_THROWS_AS(config::load_process_job_state(path), config::ConfigError);
std::ofstream(path) << "initial: Queued\ntransitions:\n"
<< " - {from: Queued, on: select, to: NoState}\n";
CHECK_THROWS_AS(config::load_process_job_state(path), config::ConfigError);
// `created` is the synthetic observer event — never legal in the table.
std::ofstream(path) << "initial: Queued\ntransitions:\n"
<< " - {from: Queued, on: created, to: SettingUp}\n";
CHECK_THROWS_AS(config::load_process_job_state(path), config::ConfigError);
}
TEST_CASE("loader: control_job_state.yaml -> non-empty table") {
auto cfg = config::load_control_job_state(
std::string(SECSGEM_DATA_DIR) + "/control_job_state.yaml");
CHECK(cfg.initial == gem::ControlJobState::Queued);
CHECK(cfg.table.size() >= 18);
const auto* row = cfg.table.find(gem::ControlJobState::Executing,
gem::ControlJobEvent::AllJobsComplete);
REQUIRE(row != nullptr);
REQUIRE(row->to.has_value());
CHECK(*row->to == gem::ControlJobState::Completed);
}