cb85199f49
- name_index: add resolve_event(name) -> CEID (unit-tested). - equipment_service.hpp: extract the gRPC service + value/state conversion into a shared header; add FireEvent (optional per-fire variable values, then trigger the collection event by name). secs_gemd slims to main(). - test_daemon_service: real in-process gRPC integration test (client stub -> service -> EquipmentRuntime) proving SetVariables lands in the model, GetControlState reports the state, FireEvent and unknown-name paths behave. Separate secs_gemd_tests target (links grpc++/proto), gated on the daemon. Core suite 459/459 (2799 assertions); daemon gRPC tests 15/15. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
36 lines
1.3 KiB
C++
36 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
#include "secsgem/gem/data_model.hpp"
|
|
|
|
namespace secsgem::gem {
|
|
|
|
// Resolve a human variable name to its numeric VID, spanning SVIDs and DVIDs
|
|
// (one VID space). SVIDs win on a name collision. nullopt if unknown.
|
|
//
|
|
// This is the name->id half of the vendor-facing binding layer: the daemon and
|
|
// any language client address items by the names from equipment.yaml, and the
|
|
// engine stays numeric. Best-effort by design — duplicate names simply resolve
|
|
// to the first match rather than erroring (see secsgem-vendor-accessibility).
|
|
inline std::optional<uint32_t> resolve_variable(const EquipmentDataModel& m,
|
|
const std::string& name) {
|
|
for (const auto& sv : m.svids.all())
|
|
if (sv.name == name) return sv.id;
|
|
for (const auto& dv : m.dvids.all())
|
|
if (dv.name == name) return dv.id;
|
|
return std::nullopt;
|
|
}
|
|
|
|
// Resolve a collection-event name to its CEID. nullopt if unknown.
|
|
inline std::optional<uint32_t> resolve_event(const EquipmentDataModel& m,
|
|
const std::string& name) {
|
|
for (const auto& e : m.events.all_events())
|
|
if (e.name == name) return e.id;
|
|
return std::nullopt;
|
|
}
|
|
|
|
} // namespace secsgem::gem
|