a1f7da4a7d
Per-EXID exception lifecycle for E5 §9. States mirror the wire flow: Posted equipment sent S5F9, awaiting host or autonomous clear Recovering host's S5F13 accepted; equipment running recovery RecoverFailed S5F15 reported a failed result; host may retry Cleared terminal — store removes the row Events: Created synthetic NoState->Posted observer signal Recover host's S5F13 (Posted/RecoverFailed -> Recovering) RecoveryComplete equipment internal (Recovering -> Cleared) RecoveryFailed equipment internal (Recovering -> RecoverFailed) RecoveryAbort host's S5F17 (Recovering -> Posted) Clear equipment internal (Posted/RecoverFailed -> Cleared) ExceptionStore mirrors ProcessJobStore: per-EXID FSMs heap-allocated via unique_ptr, non-movable to keep `this`-captures safe, synthetic Created fires after the row lands so observers can decide whether to emit S5F9 out of band. on_recover validates EXRECVRA against the candidates the post advertised. The store joins EquipmentDataModel alongside process_jobs / control_jobs. S5F9-F18 server-side dispatch lands in C2. Tests (12 cases) cover FSM transitions including retry, abort, and autonomous clear, plus store-level duplicate-rejection, EXRECVRA validation, and Cleared-removes-the-row semantics. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
70 lines
2.7 KiB
C++
70 lines
2.7 KiB
C++
#pragma once
|
|
|
|
#include "secsgem/gem/store/alarms.hpp"
|
|
#include "secsgem/gem/store/clock.hpp"
|
|
#include "secsgem/gem/store/control_jobs.hpp"
|
|
#include "secsgem/gem/store/equipment_constants.hpp"
|
|
#include "secsgem/gem/store/event_reports.hpp"
|
|
#include "secsgem/gem/store/exceptions.hpp"
|
|
#include "secsgem/gem/store/host_commands.hpp"
|
|
#include "secsgem/gem/store/limits.hpp"
|
|
#include "secsgem/gem/store/process_jobs.hpp"
|
|
#include "secsgem/gem/store/recipes.hpp"
|
|
#include "secsgem/gem/store/spool.hpp"
|
|
#include "secsgem/gem/store/status_variables.hpp"
|
|
#include "secsgem/gem/store/trace.hpp"
|
|
|
|
namespace secsgem::gem {
|
|
|
|
// Composite over the focused stores covering every GEM data category.
|
|
// Each store is independently testable and independently usable — the
|
|
// application can keep a reference to just `alarms` and ignore the rest
|
|
// if that's all it needs. Variable lookups span SVIDs and DVIDs through
|
|
// this composite (the host's view per E30 §6.11).
|
|
struct EquipmentDataModel {
|
|
StatusVariableStore svids;
|
|
DataVariableStore dvids;
|
|
EquipmentConstantStore ecids;
|
|
EventReportSubscriptions events;
|
|
AlarmRegistry alarms;
|
|
RecipeStore recipes;
|
|
Clock clock;
|
|
HostCommandRegistry commands;
|
|
SpoolStore spool;
|
|
LimitMonitorStore limits;
|
|
TraceStore traces;
|
|
ProcessJobStore process_jobs;
|
|
ControlJobStore control_jobs;
|
|
ExceptionStore exceptions;
|
|
|
|
// Convenience: VID -> value lookup spanning SVIDs and DVIDs.
|
|
std::optional<s2::Item> vid_value(uint32_t vid) const {
|
|
if (auto v = svids.value(vid)) return v;
|
|
if (auto v = dvids.value(vid)) return v;
|
|
return std::nullopt;
|
|
}
|
|
bool vid_exists(uint32_t vid) const {
|
|
return svids.has(vid) || dvids.has(vid);
|
|
}
|
|
|
|
// Sugar that adapts the EventReportSubscriptions API to the host-supplied
|
|
// VID list shape (matches what parse_s2f33 / parse_s2f35 yield).
|
|
DefineReportAck define_reports(
|
|
const std::vector<std::pair<uint32_t, std::vector<uint32_t>>>& rows) {
|
|
return events.define_reports(rows, [this](uint32_t vid) { return vid_exists(vid); });
|
|
}
|
|
LinkEventAck link_event_reports(
|
|
const std::vector<std::pair<uint32_t, std::vector<uint32_t>>>& rows) {
|
|
return events.link_event_reports(rows);
|
|
}
|
|
EnableEventAck enable_events(bool enable, const std::vector<uint32_t>& ceids) {
|
|
return events.enable_events(enable, ceids);
|
|
}
|
|
bool is_event_enabled(uint32_t ceid) const { return events.is_enabled(ceid); }
|
|
std::vector<ReportData> compose_reports_for(uint32_t ceid) const {
|
|
return events.compose_for(ceid, [this](uint32_t vid) { return vid_value(vid); });
|
|
}
|
|
};
|
|
|
|
} // namespace secsgem::gem
|