Closes spooling. S6F25 (NUM-MSG) goes into the catalog; S6F26 (ACKC6) likewise. The server's on_selected handler now checks the spool on entering SELECTED — if there's queued data, it auto-emits S6F25 so the host can decide what to do (S6F23 Transmit vs Purge). The happy-path demo never drops TCP so the auto-trigger doesn't fire there, but the canonical re-SELECT path is wired. Client gains a handler for inbound S6F25 that logs the count and acks S6F26. COMPLIANCE.md: Spooling Additional capability flips from 🟡 to ✅. Remaining out of scope for spooling: persistent on-disk spool so restarts don't lose queued events. Demo + tests don't need it; real fab equipment would. Tests: 83 cases / 481 assertions. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -96,6 +96,12 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
return gem::s6f12_event_report_ack(gem::EventReportAck::Accept);
|
||||
}
|
||||
// S6F25: spool-data-ready notification (E30 §6.22).
|
||||
if (msg.stream == 6 && msg.function == 25) {
|
||||
auto n = gem::parse_s6f25(msg);
|
||||
logfn("SPOOL READY: " + std::to_string(n.value_or(0)) + " queued messages");
|
||||
return gem::s6f26_spool_data_ready_ack(gem::EventReportAck::Accept);
|
||||
}
|
||||
// S5F1: alarm send from equipment.
|
||||
if (msg.stream == 5 && msg.function == 1) {
|
||||
auto a = gem::parse_s5f1(msg);
|
||||
|
||||
+15
-2
@@ -435,13 +435,26 @@ int main(int argc, char** argv) {
|
||||
logfn("registered " + std::to_string(router.size()) + " (stream,function) handlers");
|
||||
|
||||
// ---- Wire the router into accepted connections -----------------------
|
||||
server.on_connection([sm, model, logfn, active_conn, &router, desc](
|
||||
server.on_connection([&io, sm, model, logfn, active_conn, &router, desc](
|
||||
std::shared_ptr<Connection> conn) {
|
||||
*active_conn = conn;
|
||||
conn->set_closed_handler([active_conn](const std::string&) { active_conn->reset(); });
|
||||
|
||||
conn->set_selected_handler([logfn, sm]() {
|
||||
// E30 §6.22: on entering SELECTED, if there's spooled data, notify
|
||||
// the host via S6F25 so it can decide (S6F23 Transmit vs Purge).
|
||||
// Our happy-path demo never drops the link so this branch doesn't
|
||||
// fire there — but the wiring is the canonical re-SELECT trigger.
|
||||
conn->set_selected_handler([logfn, sm, model, &io, active_conn]() {
|
||||
logfn(std::string("host is online; control=") + gem::control_state_name(sm->state()));
|
||||
if (model->spool.size() == 0) return;
|
||||
asio::post(io, [active_conn, model, logfn]() {
|
||||
auto c = active_conn->lock();
|
||||
if (!c) return;
|
||||
const uint32_t n = static_cast<uint32_t>(model->spool.size());
|
||||
logfn("spool: notifying host of " + std::to_string(n) + " queued messages");
|
||||
c->send_request(gem::s6f25_spool_data_ready(n),
|
||||
[](std::error_code, const s2::Message&) {});
|
||||
});
|
||||
});
|
||||
|
||||
// Wrap router.dispatch so we can emit S9F3 / S9F5 when an inbound
|
||||
|
||||
Reference in New Issue
Block a user