#pragma once #include #include #include #include #include #include // E30 §6.12 Trace Data Collection. // // Host sends S2F23 with (TRID, DSPER, TOTSMP, REPGSZ, SVID list); equipment // is supposed to sample those SVIDs every DSPER, batch them in groups of // REPGSZ, and emit each batch as S6F1. This store keeps the *configuration* // for each active TRID — the periodic sampling itself is intentionally left // to the application so equipment vendors can hook into whatever clock / // scheduler they already use. namespace secsgem::gem { enum class TraceAck : uint8_t { // S2F24 TIAACK Accept = 0, TooManySvids = 1, NoMoreTracesAllowed = 2, InvalidPeriod = 3, UnknownVid = 4, }; struct TraceConfig { uint32_t trid; std::string dsper; // sample period (E5: ASCII, e.g. "1000" = ms) uint32_t totsmp; // total samples to collect uint32_t repgsz; // samples per S6F1 batch std::vector svids; }; class TraceStore { public: void add(TraceConfig c) { by_trid_.insert_or_assign(c.trid, std::move(c)); } std::optional get(uint32_t trid) const { auto it = by_trid_.find(trid); if (it == by_trid_.end()) return std::nullopt; return it->second; } void remove(uint32_t trid) { by_trid_.erase(trid); } std::vector all() const { std::vector out; out.reserve(by_trid_.size()); for (const auto& [_, c] : by_trid_) out.push_back(c); return out; } std::size_t size() const { return by_trid_.size(); } private: std::map by_trid_; }; } // namespace secsgem::gem