70#ifndef RTE_EXAMPLE_GA_INTERFACE_H
71#define RTE_EXAMPLE_GA_INTERFACE_H
76#include "rte/app/appmanager/rte_appmanager.h"
77#include "rte/utils/status/rte_status.h"
91#ifndef RTE_EXAMPLE_MAX_ROUTES_PER_TRAIN
92#define RTE_EXAMPLE_MAX_ROUTES_PER_TRAIN 4U
97#ifndef AB_GP_DB_T_DEFINED
98#define AB_GP_DB_T_DEFINED
104#ifndef TRAIN_SESSION_T_DEFINED
105#define TRAIN_SESSION_T_DEFINED
112#ifndef AB_GP_DB_ROUTE_IL_STATUS_T_DEFINED
113#define AB_GP_DB_ROUTE_IL_STATUS_T_DEFINED
126#ifndef AB_GP_ROUTE_UPDATE_TYPE_T_DEFINED
127#define AB_GP_ROUTE_UPDATE_TYPE_T_DEFINED
137#ifndef AB_GP_ROUTE_CONTEXT_T_DEFINED
138#define AB_GP_ROUTE_CONTEXT_T_DEFINED
142 uint16_t start_signal;
151#ifndef AB_GP_DB_ROUTE_NOTIFY_FN_DEFINED
152#define AB_GP_DB_ROUTE_NOTIFY_FN_DEFINED
160#ifndef AB_GP_TRAIN_UPDATE_TYPE_T_DEFINED
161#define AB_GP_TRAIN_UPDATE_TYPE_T_DEFINED
172#ifndef AB_GP_TRAIN_CONTEXT_T_DEFINED
173#define AB_GP_TRAIN_CONTEXT_T_DEFINED
198#ifndef AB_GP_TRAIN_NOTIFY_FN_DEFINED
199#define AB_GP_TRAIN_NOTIFY_FN_DEFINED
204#ifndef AB_GP_LOGIC_ROUTE_VALIDATOR_FN_DEFINED
205#define AB_GP_LOGIC_ROUTE_VALIDATOR_FN_DEFINED
289 uint32_t granted_length);
325#ifndef AB_GP_LOGIC_SHUNTING_VALIDATOR_FN_DEFINED
326#define AB_GP_LOGIC_SHUNTING_VALIDATOR_FN_DEFINED
383 const char *role_tag);
391#ifndef AB_GP_IL_ENVELOPE_HANDLER_FN_DEFINED
392#define AB_GP_IL_ENVELOPE_HANDLER_FN_DEFINED
414#ifndef AB_GP_IL_PENDING_OUTPUT_T_DEFINED
415#define AB_GP_IL_PENDING_OUTPUT_T_DEFINED
423#ifndef AB_GP_IL_MAX_PENDING_OUTPUTS
428#define AB_GP_IL_MAX_PENDING_OUTPUTS (RTE_EXAMPLE_MAX_ROUTES * 2U)
430#ifndef AB_GP_IL_OUTPUT_PRODUCER_FN_DEFINED
431#define AB_GP_IL_OUTPUT_PRODUCER_FN_DEFINED
451 const void *context);
453#ifndef AB_GP_CTC_PENDING_OUTPUT_T_DEFINED
454#define AB_GP_CTC_PENDING_OUTPUT_T_DEFINED
461#ifndef AB_GP_CTC_MAX_PENDING_OUTPUTS
462#define AB_GP_CTC_MAX_PENDING_OUTPUTS ((uint8_t)(RTE_EXAMPLE_MAX_TRAINS * 3U))
464#ifndef AB_GP_CTC_OUTPUT_PRODUCER_FN_DEFINED
465#define AB_GP_CTC_OUTPUT_PRODUCER_FN_DEFINED
487#define AB_GA_CHECKPOINT_MARK() RTE_CHECKPOINT_MARK()
bool ab_gp_db_get_route_context(const ab_gp_db_t *db, uint16_t route_id, ab_gp_route_context_t *out_ctx)
One-shot pull equivalent of the push notification above - the SAME snapshot-building logic (real impl...
bool ab_gp_db_route_disconnect_train(ab_gp_db_t *db, uint16_t route_id)
Reverses ab_gp_db_route_connect_train(): clears the route's own used_in_ma/train_id and removes it fr...
rte_status_t ab_gp_db_register_route_context_notify(ab_gp_route_context_notify_fn fn, const void *context)
bool ab_gp_db_route_set_fsm_state(ab_gp_db_t *db, uint16_t route_id, uint32_t fsm_state)
Get/set the per-route FSM state (ab_ga_route_state_t, raw uint32_t - GA owns the value space,...
bool ab_gp_db_route_connect_train(ab_gp_db_t *db, uint16_t route_id, uint8_t train_id)
Connects route_id to train_id: appends the route to that train's own route_ids[] and marks the route ...
bool ab_gp_db_route_remove(ab_gp_db_t *db, uint16_t route_id)
Removes a tracked route from db->routes[], freeing its slot.
bool ab_gp_db_route_set_type(ab_gp_db_t *db, uint16_t route_id, uint32_t route_type)
bool ab_gp_db_route_add(ab_gp_db_t *db, uint16_t route_id, uint16_t start_signal, uint16_t end_signal)
Adds a new route to db->routes[]. New entry starts fully idle: occupied=false, il_status=AB_GP_DB_ROU...
bool ab_gp_db_route_exists(const ab_gp_db_t *db, uint16_t route_id)
bool ab_gp_db_route_set_status(ab_gp_db_t *db, uint16_t route_id, ab_gp_db_route_il_status_t status)
uint32_t ab_gp_db_route_get_fsm_state(const ab_gp_db_t *db, uint16_t route_id)
void(*) ab_gp_route_context_notify_fn(const void *context, const ab_gp_route_context_t *ctx, ab_gp_route_update_type_t update_type)
ab_gp_db_route_il_status_t
@ AB_GP_DB_ROUTE_IL_STATUS_LOCKED
@ AB_GP_DB_ROUTE_IL_STATUS_UNKNOWN
@ AB_GP_DB_ROUTE_IL_STATUS_RESERVED
@ AB_GP_DB_ROUTE_IL_STATUS_FREE
ab_gp_route_update_type_t
@ AB_ROUTE_STATUS_CHANGED
uint32_t ab_gp_proc_ma_remaining_length_m(const ab_site_ga_route_layout_t *route, uint32_t nid_lrbg, uint32_t d_lrbg_m)
Computes the Movement Authority length actually REMAINING from a train's own last-KNOWN balise to rou...
#define RTE_EXAMPLE_MAX_ROUTES_PER_TRAIN
#define RBC_ENVELOPE_WIRE_SIZE
bool(*) ab_gp_il_envelope_handler_fn(const void *context, ab_gp_train_session_t *sessions, ab_gp_db_t *db, const uint8_t env_bytes[RBC_ENVELOPE_WIRE_SIZE], uint32_t cycle, rte_example_site_t site, const char *role_tag)
uint8_t(*) ab_gp_ctc_output_producer_fn(const void *context, ab_gp_ctc_pending_output_t out[AB_GP_CTC_MAX_PENDING_OUTPUTS])
rte_status_t ab_gp_register_train_context_notify(ab_gp_train_context_notify_fn fn, const void *context)
bool ab_gp_train_session_set_ctc_ma_granted_sent(ab_gp_train_session_t *sessions, uint8_t train_id, bool sent)
bool ab_gp_train_session_set_ctc_connected_sent(ab_gp_train_session_t *sessions, uint8_t train_id, bool sent)
bool ab_gp_train_session_set_ma_pending_send(ab_gp_train_session_t *sessions, uint8_t train_id, bool pending)
void(*) ab_gp_il_output_confirm_fn(const void *context)
void ab_gp_train_notify_context_changed(const ab_gp_train_session_t *sessions, const ab_gp_db_t *db, uint8_t train_id, ab_gp_train_update_type_t update_type)
void(*) ab_gp_train_context_notify_fn(const void *context, const ab_gp_train_context_t *ctx, ab_gp_train_update_type_t update_type)
bool ab_gp_train_get_last_position(const ab_gp_db_t *db, uint8_t train_id, uint32_t *out_nid_lrbg)
#define AB_GP_IL_MAX_PENDING_OUTPUTS
uint8_t(*) ab_gp_il_output_producer_fn(const void *context, ab_gp_il_pending_output_t out[AB_GP_IL_MAX_PENDING_OUTPUTS])
bool ab_gp_train_session_set_ma_acked(ab_gp_train_session_t *sessions, uint8_t train_id, bool acked)
bool ab_gp_train_set_has_ma(ab_gp_db_t *db, uint8_t train_id, bool has_ma)
bool(*) ab_gp_logic_shunting_validator_fn(void *context, uint8_t train_id)
bool ab_gp_train_session_increment_ma_seq(ab_gp_train_session_t *sessions, uint8_t train_id)
bool ab_gp_train_session_add_granted_length(ab_gp_train_session_t *sessions, uint8_t train_id, uint32_t delta)
void(*) ab_gp_ctc_output_confirm_fn(const void *context)
#define AB_GP_CTC_MAX_PENDING_OUTPUTS
bool ab_gp_train_session_set_ctc_ma_notify_pending(ab_gp_train_session_t *sessions, uint8_t train_id, bool pending)
bool ab_gp_train_session_set_granted_length(ab_gp_train_session_t *sessions, uint8_t train_id, uint32_t granted_length)
rte_status_t ab_gp_ga_register_shunting_validator(ab_gp_logic_shunting_validator_fn fn, void *context)
ab_gp_train_update_type_t
@ AB_TRAIN_EMERGENCY_REACTION_RAISED
bool(*) ab_gp_logic_route_validator_fn(void *context, uint16_t route_id, uint8_t train_id)
rte_status_t ab_gp_ga_register_init(ab_gp_logic_route_validator_fn fn, void *context)
rte_status_t ab_gp_register_ctc_output_producer(ab_gp_ctc_output_producer_fn fn, ab_gp_ctc_output_confirm_fn confirm_fn, const void *context)
bool ab_gp_get_train_context(const ab_gp_train_session_t *sessions, const ab_gp_db_t *db, uint8_t train_id, ab_gp_train_context_t *out_ctx)
rte_status_t ab_gp_register_il_output_producer(ab_gp_il_output_producer_fn fn, ab_gp_il_output_confirm_fn confirm_fn, const void *context)
rte_status_t ab_ga_ma_adaptation_init(ab_gp_train_session_t *sessions, ab_gp_db_t *db, rte_example_site_t site, const char *role_tag)
GA's own single entry point - registers this channel's route- connection validator (ab_gp_ga_register...
rte_status_t ab_gp_register_il_envelope_handler(ab_gp_il_envelope_handler_fn fn, const void *context)
West/East site identity and the per-site config derived from it (ports, container host lookup) - see ...
uint8_t bytes[RBC_ENVELOPE_WIRE_SIZE]
uint8_t bytes[RBC_ENVELOPE_WIRE_SIZE]
bool ctc_ma_notify_pending
uint16_t route_ids[RTE_EXAMPLE_MAX_ROUTES_PER_TRAIN]