a1f7da4a7d
Per-EXID exception lifecycle for E5 §9. States mirror the wire flow: Posted equipment sent S5F9, awaiting host or autonomous clear Recovering host's S5F13 accepted; equipment running recovery RecoverFailed S5F15 reported a failed result; host may retry Cleared terminal — store removes the row Events: Created synthetic NoState->Posted observer signal Recover host's S5F13 (Posted/RecoverFailed -> Recovering) RecoveryComplete equipment internal (Recovering -> Cleared) RecoveryFailed equipment internal (Recovering -> RecoverFailed) RecoveryAbort host's S5F17 (Recovering -> Posted) Clear equipment internal (Posted/RecoverFailed -> Cleared) ExceptionStore mirrors ProcessJobStore: per-EXID FSMs heap-allocated via unique_ptr, non-movable to keep `this`-captures safe, synthetic Created fires after the row lands so observers can decide whether to emit S5F9 out of band. on_recover validates EXRECVRA against the candidates the post advertised. The store joins EquipmentDataModel alongside process_jobs / control_jobs. S5F9-F18 server-side dispatch lands in C2. Tests (12 cases) cover FSM transitions including retry, abort, and autonomous clear, plus store-level duplicate-rejection, EXRECVRA validation, and Cleared-removes-the-row semantics. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
106 lines
3.3 KiB
CMake
106 lines
3.3 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)
|
|
|
|
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/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/host_handler.cpp
|
|
src/config/loader.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)
|
|
|
|
# --- 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_hsms.cpp
|
|
tests/test_hsms_connection.cpp
|
|
tests/test_secsi.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_exceptions.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)
|