6aa4427186
A fictional Physical Vapor Deposition tool wired end-to-end.
examples/pvd_tool/ is the template a real customer should fork.
Files:
- equipment.yaml: 32 SVIDs (chamber pressure, temperature, source
power, gas flows, cooling water, wafer counters, recipe step
state, EPT name, 4 load ports), 5 DVIDs, 7 ECIDs (setpoints
+ T_CRA/T_DELAY + cleaning interval + retry count), 17 CEIDs
(control state, alarms, process lifecycle, material movement,
EPT), 12 alarms with realistic categories (safety, error,
warning, attention), 3 multi-step recipes (Al / Ti / Cu),
9 host commands.
- main.cpp (~860 lines): the vendor-side application:
§1 helpers + constants
§2 sensor simulator — 4 sensors at 10 Hz + 1 Hz cadences,
random-walk around step-targeted setpoints, asio::post-on-strand
thread-safety pattern
§3 recipe runner — parses recipe body (STEP NAME duration=120s
power=2500W gas=Argon flow=50sccm), walks each step at 1s
per declared-second, fires step-started/completed CEIDs,
drives PJ FSM through ProcessComplete
§4 alarm threshold monitor — chamber-pressure-over-setpoint and
cleaning-interval logic, continuous evaluation, set/clear
emission gated on alarm-enable
§5 EPT cycler — Standby ↔ Productive ↔ UnscheduledDowntime
based on PJ activity + safety alarms
§6 Prometheus exporter on :9090 (pvd_messages_total,
pvd_chamber_pressure_torr, pvd_spool_depth, pvd_events_total,
pvd_alarm_set_total)
§7 Router handlers — full E30 set (~40 handlers) so a host can
do real work
§8 main() — YAML validation, model construction, server wiring,
periodic gauge updates
- README.md: section-by-section walkthrough, what's the same as
apps/secs_server.cpp, what this adds (simulator + recipe runner
+ alarm monitor + EPT cycler + metrics), what's not here
(persistence + E84 + real I/O), and what to change for your tool.
Verification: 47/47 conformance harness checks PASS against the
PVD tool — same as the demo server.
CMakeLists.txt adds the pvd_tool target.
README's documentation map points at examples/pvd_tool/.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
213 lines
7.5 KiB
CMake
213 lines
7.5 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
project(secsgem LANGUAGES CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
endif()
|
|
|
|
add_compile_options(-Wall -Wextra -Wpedantic)
|
|
|
|
# --- libFuzzer (opt-in) ---------------------------------------------------
|
|
# Build with -DSECSGEM_FUZZ=ON to instrument every target with
|
|
# AddressSanitizer + UndefinedBehaviorSanitizer + libFuzzer coverage
|
|
# tracking. Adds two fuzz executables (apps/fuzz_*.cpp) that feed
|
|
# arbitrary input to the SECS-II decoder and the SML parser
|
|
# respectively. CI runs each for ~5 minutes in a dedicated job;
|
|
# customers don't build with this flag.
|
|
#
|
|
# Requires clang (libFuzzer is a clang feature). CMake will switch to
|
|
# clang automatically — invoke with CC=clang CXX=clang++ to be explicit.
|
|
option(SECSGEM_FUZZ "Build libFuzzer harnesses" OFF)
|
|
if(SECSGEM_FUZZ)
|
|
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
message(FATAL_ERROR "SECSGEM_FUZZ requires clang; re-configure with CXX=clang++")
|
|
endif()
|
|
message(STATUS "libFuzzer enabled — -fsanitize=fuzzer-no-link,address,undefined")
|
|
add_compile_options(-fsanitize=fuzzer-no-link,address,undefined
|
|
-g -O1 -fno-omit-frame-pointer)
|
|
add_link_options(-fsanitize=address,undefined)
|
|
endif()
|
|
|
|
# --- ThreadSanitizer (opt-in) ---------------------------------------------
|
|
# Build with -DSECSGEM_TSAN=ON to instrument every target with TSan.
|
|
# Catches data races in EquipmentDataModel access from the io_context
|
|
# thread vs. application threads — the contract documented in
|
|
# INTEGRATION.md §3. CI runs the threading-relevant tests under this
|
|
# flag in a separate lane; the default (release, no sanitizer) is what
|
|
# customers build.
|
|
option(SECSGEM_TSAN "Build with ThreadSanitizer" OFF)
|
|
if(SECSGEM_TSAN)
|
|
message(STATUS "ThreadSanitizer enabled — debug symbols + -fsanitize=thread")
|
|
add_compile_options(-fsanitize=thread -g -O1 -fno-omit-frame-pointer)
|
|
add_link_options(-fsanitize=thread)
|
|
endif()
|
|
|
|
find_package(Threads REQUIRED)
|
|
find_package(yaml-cpp REQUIRED)
|
|
|
|
# --- Asio (standalone, header-only; from libasio-dev) ---------------------
|
|
find_path(ASIO_INCLUDE_DIR asio.hpp)
|
|
if(NOT ASIO_INCLUDE_DIR)
|
|
message(FATAL_ERROR "asio.hpp not found. Install libasio-dev.")
|
|
endif()
|
|
|
|
add_library(asio INTERFACE)
|
|
target_include_directories(asio INTERFACE ${ASIO_INCLUDE_DIR})
|
|
target_compile_definitions(asio INTERFACE ASIO_STANDALONE ASIO_NO_DEPRECATED)
|
|
target_link_libraries(asio INTERFACE Threads::Threads)
|
|
|
|
# --- Core library ---------------------------------------------------------
|
|
# --- Codegen: SECS-II message catalog -> messages.hpp ---------------------
|
|
set(MESSAGES_HPP ${CMAKE_BINARY_DIR}/generated/secsgem/gem/messages.hpp)
|
|
add_custom_command(
|
|
OUTPUT ${MESSAGES_HPP}
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/generated/secsgem/gem
|
|
COMMAND python3 ${CMAKE_SOURCE_DIR}/tools/gen_messages.py
|
|
--catalog ${CMAKE_SOURCE_DIR}/data/messages.yaml
|
|
--out ${MESSAGES_HPP}
|
|
DEPENDS ${CMAKE_SOURCE_DIR}/tools/gen_messages.py
|
|
${CMAKE_SOURCE_DIR}/data/messages.yaml
|
|
COMMENT "Generating SECS-II messages.hpp from data/messages.yaml"
|
|
VERBATIM
|
|
)
|
|
add_custom_target(generate_messages DEPENDS ${MESSAGES_HPP})
|
|
|
|
add_library(secsgem
|
|
src/secs2/codec.cpp
|
|
src/secs2/sml.cpp
|
|
src/hsms/header.cpp
|
|
src/hsms/connection.cpp
|
|
src/secsi/header.cpp
|
|
src/secsi/block.cpp
|
|
src/secsi/protocol.cpp
|
|
src/secsi/tcp_transport.cpp
|
|
src/gem/control_state.cpp
|
|
src/gem/communication_state.cpp
|
|
src/gem/process_job_state.cpp
|
|
src/gem/control_job_state.cpp
|
|
src/gem/exception_state.cpp
|
|
src/gem/carrier_state.cpp
|
|
src/gem/load_port_state.cpp
|
|
src/gem/substrate_state.cpp
|
|
src/gem/ept_state.cpp
|
|
src/gem/cem_objects.cpp
|
|
src/gem/module_state.cpp
|
|
src/gem/e84_state.cpp
|
|
src/gem/host_handler.cpp
|
|
src/config/loader.cpp
|
|
src/config/validate.cpp
|
|
src/endpoint.cpp
|
|
)
|
|
add_dependencies(secsgem generate_messages)
|
|
target_include_directories(secsgem PUBLIC
|
|
include
|
|
${CMAKE_BINARY_DIR}/generated
|
|
)
|
|
target_link_libraries(secsgem PUBLIC asio yaml-cpp)
|
|
|
|
# --- Demo executables -----------------------------------------------------
|
|
add_executable(secs_server apps/secs_server.cpp)
|
|
target_link_libraries(secs_server PRIVATE secsgem)
|
|
|
|
add_executable(secs_client apps/secs_client.cpp)
|
|
target_link_libraries(secs_client PRIVATE secsgem)
|
|
|
|
add_executable(secs_interop_probe apps/secs_interop_probe.cpp)
|
|
target_link_libraries(secs_interop_probe PRIVATE secsgem)
|
|
|
|
add_executable(secs_conformance apps/secs_conformance.cpp)
|
|
target_link_libraries(secs_conformance PRIVATE secsgem)
|
|
|
|
add_executable(secs_bench apps/secs_bench.cpp)
|
|
target_link_libraries(secs_bench PRIVATE secsgem)
|
|
|
|
# Worked vendor example: ACME-PVD-3000. Reads its own YAML, runs
|
|
# sensor simulators + a recipe runner + alarm monitors + EPT cycling
|
|
# + a Prometheus metrics exporter. See examples/pvd_tool/README.md.
|
|
add_executable(pvd_tool examples/pvd_tool/main.cpp)
|
|
target_link_libraries(pvd_tool PRIVATE secsgem)
|
|
|
|
if(SECSGEM_FUZZ)
|
|
# libFuzzer entry-point targets. Each owns its own `main` via the
|
|
# `-fsanitize=fuzzer` link flag; do NOT also link them into the
|
|
# regular test binary.
|
|
add_executable(fuzz_secs2_decode apps/fuzz_secs2_decode.cpp)
|
|
target_link_libraries(fuzz_secs2_decode PRIVATE secsgem)
|
|
target_link_options(fuzz_secs2_decode PRIVATE -fsanitize=fuzzer)
|
|
|
|
add_executable(fuzz_sml_parse apps/fuzz_sml_parse.cpp)
|
|
target_link_libraries(fuzz_sml_parse PRIVATE secsgem)
|
|
target_link_options(fuzz_sml_parse PRIVATE -fsanitize=fuzzer)
|
|
endif()
|
|
|
|
# --- Tests ----------------------------------------------------------------
|
|
enable_testing()
|
|
include(FetchContent)
|
|
FetchContent_Declare(
|
|
doctest
|
|
GIT_REPOSITORY https://github.com/doctest/doctest.git
|
|
GIT_TAG v2.4.11
|
|
)
|
|
FetchContent_MakeAvailable(doctest)
|
|
|
|
add_executable(secsgem_tests
|
|
tests/test_main.cpp
|
|
tests/test_secs2.cpp
|
|
tests/test_fuzz.cpp
|
|
tests/test_hsms.cpp
|
|
tests/test_hsms_connection.cpp
|
|
tests/test_hsms_timers.cpp
|
|
tests/test_hsms_s9.cpp
|
|
tests/test_hsms_gs.cpp
|
|
tests/test_secsi.cpp
|
|
tests/test_secsi_timers.cpp
|
|
tests/test_secsi_tcp.cpp
|
|
tests/test_host_handler.cpp
|
|
tests/test_control_state.cpp
|
|
tests/test_communication_state.cpp
|
|
tests/test_data_model.cpp
|
|
tests/test_messages.cpp
|
|
tests/test_loader.cpp
|
|
tests/test_process_jobs.cpp
|
|
tests/test_control_jobs.cpp
|
|
tests/test_job_persistence.cpp
|
|
tests/test_exceptions.cpp
|
|
tests/test_exception_persistence.cpp
|
|
tests/test_carrier_state.cpp
|
|
tests/test_carriers.cpp
|
|
tests/test_carrier_persistence.cpp
|
|
tests/test_substrates.cpp
|
|
tests/test_substrate_persistence.cpp
|
|
tests/test_ept.cpp
|
|
tests/test_cem_objects.cpp
|
|
tests/test_modules.cpp
|
|
tests/test_sml.cpp
|
|
tests/test_s9_fallback.cpp
|
|
tests/test_e84.cpp
|
|
tests/test_e84_ports.cpp
|
|
tests/test_e84_timers.cpp
|
|
tests/test_e84_asio_timers.cpp
|
|
tests/test_e42_formatted_pp.cpp
|
|
tests/test_gem300_scenario.cpp
|
|
tests/test_wire_ceid_emission.cpp
|
|
tests/test_live_gem300.cpp
|
|
tests/test_e87_wire_scenarios.cpp
|
|
tests/test_identifier_wildcards.cpp
|
|
tests/test_concurrency.cpp
|
|
tests/test_thread_safety.cpp
|
|
tests/test_persistence_upgrade.cpp
|
|
tests/test_config_validate.cpp
|
|
tests/test_metrics_prometheus.cpp
|
|
tests/test_hsms_gs_integration.cpp
|
|
tests/test_robustness_fuzz.cpp
|
|
tests/test_e5_kat.cpp
|
|
)
|
|
target_link_libraries(secsgem_tests PRIVATE secsgem doctest::doctest)
|
|
target_compile_definitions(secsgem_tests PRIVATE
|
|
SECSGEM_DATA_DIR="${CMAKE_SOURCE_DIR}/data")
|
|
add_test(NAME secsgem_tests COMMAND secsgem_tests)
|