Files
secs-gem/clients/cpp/examples/mini_tool.cpp
T
raphael b30443089f
tests / build-and-test (push) Successful in 2m54s
tests / thread-sanitizer (push) Successful in 3m48s
tests / tshark-dissector (push) Successful in 2m24s
tests / secs4j-interop (push) Successful in 1m44s
tests / python-interop (push) Successful in 3m10s
tests / libfuzzer (push) Successful in 3m38s
feat(clients)+test(interop): C++ client + Java validation of the daemon (B7)
B7 — the daemon's HSMS face under the Java reference: Dockerfile.server now
bakes secs_gemd alongside secs_server (grpc deps in both stages), and
secs4j_validate.sh gains TARGET=gemd to point the 55-check secs4java8 suite
at the daemon instead. Result: 55/55 green. With secsgem-py already
validating both faces, byte-identical GEM between secs_server and secs_gemd
is now proven by both reference implementations, not inferred from shared
code. CI runs the daemon target as an extra step (image layers shared).

Second client — clients/cpp: a header-only C++ twin of the Python client
over the same proto. eq.set("ChamberPressure", 2.5) with bare literals
(integral/floating dispatch avoids variant ambiguity), get/fire/alarm/
clear, control_state/request_control_state/health, on("START", fn) +
listen()/listen_async()/stop() with auto-CompleteCommand, SecsGemError
carrying the daemon's message. cpp_mini_tool (~30 lines) mirrors the
Python mini_tool. Tested end-to-end over real loopback TCP against the
service inside secs_gemd_tests — now 4 cases / 141 assertions — including
set/get round-trips, error text, alarm-by-name into the model, health,
and the full HCACK-4 command loop with parameters.

(Build note: two grpc-heavy TUs at -O3 OOM even at -j2 on Docker Desktop;
built -j1. Known environment limitation, roadmap-documented.)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 23:37:14 +02:00

29 lines
837 B
C++

// A complete GEM tool in ~30 lines of C++ — the twin of
// clients/python/examples/mini_tool.py. Run secs_gemd, then this.
#include <chrono>
#include <iostream>
#include <random>
#include <thread>
#include "secsgem_client/equipment.hpp"
int main() {
secsgem_client::Equipment eq("localhost:50051");
eq.on("START", [&](const secsgem_client::Command& cmd) {
std::cout << "host says START (id " << cmd.id << ")\n";
eq.fire("ProcessStarted");
});
eq.listen_async();
std::mt19937 rng{std::random_device{}()};
std::uniform_real_distribution<double> pressure(1.0, 3.0);
while (true) {
const double p = pressure(rng);
eq.set("ChamberPressure", p);
if (p > 2.9) eq.alarm("chiller_temp_high");
else eq.clear("chiller_temp_high");
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}