32#ifndef RTE_EXAMPLE_AB_GP_DB_H
33#define RTE_EXAMPLE_AB_GP_DB_H
38#include "rte/utils/status/rte_status.h"
51#ifndef AB_GP_DB_ROUTE_IL_STATUS_T_DEFINED
52#define AB_GP_DB_ROUTE_IL_STATUS_T_DEFINED
130#ifndef AB_GP_DB_T_DEFINED
131#define AB_GP_DB_T_DEFINED
132typedef struct ab_gp_db_s
259 uint16_t *out_start_signal, uint16_t *out_end_signal,
260 uint8_t *out_train_id,
bool *out_used_in_ma);
307#ifndef AB_GP_ROUTE_UPDATE_TYPE_T_DEFINED
308#define AB_GP_ROUTE_UPDATE_TYPE_T_DEFINED
328#ifndef AB_GP_ROUTE_CONTEXT_T_DEFINED
329#define AB_GP_ROUTE_CONTEXT_T_DEFINED
344#ifndef AB_GP_DB_ROUTE_NOTIFY_FN_DEFINED
345#define AB_GP_DB_ROUTE_NOTIFY_FN_DEFINED
358#define AB_GP_DB_MAX_ROUTE_CONTEXT_SUBSCRIBERS 4U
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...
bool ab_gp_db_train_is_connected(const ab_gp_db_t *db, uint8_t train_id)
Checks if a train has an active connection session in the DB.
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,...
rte_status_t ab_gp_db_decode(ab_gp_db_t *db, const uint8_t *in_bytes, uint32_t in_size)
Decodes the full route and train database from a deterministic wire format.
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_train_get_routes(const ab_gp_db_t *db, uint8_t train_id, uint16_t out_routes[RTE_EXAMPLE_MAX_ROUTES_PER_TRAIN], uint8_t *out_count)
Retrieves routes currently allocated to a train.
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.
uint8_t ab_gp_db_route_get_count(const ab_gp_db_t *db)
Returns total number of active routes currently in the GP database.
bool ab_gp_db_route_set_type(ab_gp_db_t *db, uint16_t route_id, uint32_t route_type)
rte_status_t ab_gp_db_encode(const ab_gp_db_t *db, uint8_t *out_bytes, uint32_t out_capacity, uint32_t *out_written)
Encodes the full route and train database into a deterministic wire format.
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_get_by_index(const ab_gp_db_t *db, uint8_t index, uint16_t *out_route_id, uint16_t *out_start_signal, uint16_t *out_end_signal, uint8_t *out_train_id, bool *out_used_in_ma)
Retrieves route snapshot by table index for GA/GP route list synchronization.
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
#define RTE_EXAMPLE_MAX_ROUTES_PER_TRAIN
#define RTE_EXAMPLE_MAX_ROUTES
#define RTE_EXAMPLE_MAX_TRAINS
ab_gp_db_route_il_status_t
One track section A/B's simplified layout knows about.
ab_gp_db_route_il_status_t il_status
ab_gp_db_route_t routes[RTE_EXAMPLE_MAX_ROUTES]
ab_gp_db_train_t trains[RTE_EXAMPLE_MAX_TRAINS]
One train A/B's simplified database knows about.
uint16_t route_ids[RTE_EXAMPLE_MAX_ROUTES_PER_TRAIN]
ab_gp_db_route_il_status_t il_status