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:
@@ -242,4 +242,89 @@ EquipmentDescriptor load_equipment(const std::string& path, gem::EquipmentDataMo
|
||||
return desc;
|
||||
}
|
||||
|
||||
ProcessJobStateConfig load_process_job_state(const std::string& path) {
|
||||
YAML::Node root = load(path);
|
||||
|
||||
// NoState is a sentinel for "no PJ" used in the synthetic create
|
||||
// notification; it must never appear in the FSM table or as the
|
||||
// initial state.
|
||||
auto reject_nostate = [&path](const std::string& where, gem::ProcessJobState s) {
|
||||
if (s == gem::ProcessJobState::NoState)
|
||||
fail(where, "`NoState` is a sentinel, not a valid table state");
|
||||
};
|
||||
|
||||
ProcessJobStateConfig cfg;
|
||||
if (auto initial = root["initial"]) {
|
||||
auto parsed = gem::parse_process_job_state(initial.as<std::string>());
|
||||
if (!parsed) fail(path, "unknown initial state `" + initial.as<std::string>() + "`");
|
||||
reject_nostate(path + " initial", *parsed);
|
||||
cfg.initial = *parsed;
|
||||
}
|
||||
|
||||
const auto transitions = root["transitions"];
|
||||
if (!transitions || !transitions.IsSequence())
|
||||
fail(path, "missing or non-sequence `transitions`");
|
||||
|
||||
for (std::size_t i = 0; i < transitions.size(); ++i) {
|
||||
const auto& row = transitions[i];
|
||||
const auto where = path + " transitions[" + std::to_string(i) + "]";
|
||||
|
||||
auto from = gem::parse_process_job_state(req_as<std::string>(row["from"], where, "from"));
|
||||
auto on = gem::parse_process_job_event(req_as<std::string>(row["on"], where, "on"));
|
||||
if (!from) fail(where, "unknown `from` state");
|
||||
if (!on) fail(where, "unknown `on` event");
|
||||
reject_nostate(where + " from", *from);
|
||||
|
||||
gem::ProcessJobTransition t{*from, *on, std::nullopt, std::nullopt};
|
||||
if (auto to = row["to"]) {
|
||||
auto s = gem::parse_process_job_state(to.as<std::string>());
|
||||
if (!s) fail(where, "unknown `to` state");
|
||||
reject_nostate(where + " to", *s);
|
||||
t.to = *s;
|
||||
}
|
||||
if (auto ack = row["ack"]) {
|
||||
t.ack_code = static_cast<uint8_t>(parse_hcack(ack.as<std::string>(), where));
|
||||
}
|
||||
cfg.table.add(t);
|
||||
}
|
||||
return cfg;
|
||||
}
|
||||
|
||||
ControlJobStateConfig load_control_job_state(const std::string& path) {
|
||||
YAML::Node root = load(path);
|
||||
|
||||
ControlJobStateConfig cfg;
|
||||
if (auto initial = root["initial"]) {
|
||||
auto parsed = gem::parse_control_job_state(initial.as<std::string>());
|
||||
if (!parsed) fail(path, "unknown initial state `" + initial.as<std::string>() + "`");
|
||||
cfg.initial = *parsed;
|
||||
}
|
||||
|
||||
const auto transitions = root["transitions"];
|
||||
if (!transitions || !transitions.IsSequence())
|
||||
fail(path, "missing or non-sequence `transitions`");
|
||||
|
||||
for (std::size_t i = 0; i < transitions.size(); ++i) {
|
||||
const auto& row = transitions[i];
|
||||
const auto where = path + " transitions[" + std::to_string(i) + "]";
|
||||
|
||||
auto from = gem::parse_control_job_state(req_as<std::string>(row["from"], where, "from"));
|
||||
auto on = gem::parse_control_job_event(req_as<std::string>(row["on"], where, "on"));
|
||||
if (!from) fail(where, "unknown `from` state");
|
||||
if (!on) fail(where, "unknown `on` event");
|
||||
|
||||
gem::ControlJobTransition t{*from, *on, std::nullopt, std::nullopt};
|
||||
if (auto to = row["to"]) {
|
||||
auto s = gem::parse_control_job_state(to.as<std::string>());
|
||||
if (!s) fail(where, "unknown `to` state");
|
||||
t.to = *s;
|
||||
}
|
||||
if (auto ack = row["ack"]) {
|
||||
t.ack_code = static_cast<uint8_t>(parse_hcack(ack.as<std::string>(), where));
|
||||
}
|
||||
cfg.table.add(t);
|
||||
}
|
||||
return cfg;
|
||||
}
|
||||
|
||||
} // namespace secsgem::config
|
||||
|
||||
Reference in New Issue
Block a user