RTE RBC 2oo2 Generic Application 0.1.0 build 308eda7
IL/CTC route and train logic for the RBC_GP reference RBC
Loading...
Searching...
No Matches
ab_ga_ma_logic_adaptation.c File Reference

GA's own single entry point (ab_ga_ma_adaptation_init(), declared in ga_interface.h) - see ab_ga_ma_logic_adaptation.h. More...

#include "ab_ga_ma_logic_adaptation.h"
#include "rte/oal/log/rte_log.h"
#include "common_config.h"
#include "ab_siteGA.h"
#include "../main/ab_ga_dispatch.h"
#include "../il/ab_ga_il.h"
Include dependency graph for ab_ga_ma_logic_adaptation.c:

Go to the source code of this file.

Data Structures

struct  ab_ga_shunting_context_t

Functions

static bool train_holds_preceding_route (const ab_gp_db_t *db, const ab_site_ga_route_layout_t *layout, uint8_t train_id)
 Checks if the given train already holds a preceding route connecting to layout.
static bool validate_route_assignment (void *context, uint16_t route_id, uint8_t train_id)
static bool validate_shunting_request (void *context, uint8_t train_id)
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)

Variables

static ab_ga_shunting_context_t g_shunting_context
const char * g_ga_role_tag = ""

Detailed Description

GA's own single entry point (ab_ga_ma_adaptation_init(), declared in ga_interface.h) - see ab_ga_ma_logic_adaptation.h.

Definition in file ab_ga_ma_logic_adaptation.c.

Function Documentation

◆ ab_ga_ma_adaptation_init()

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 )

Global functions

Definition at line 44 of file ab_ga_ma_logic_adaptation.c.

◆ train_holds_preceding_route()

bool train_holds_preceding_route ( const ab_gp_db_t * db,
const ab_site_ga_route_layout_t * layout,
uint8_t train_id )
static

Checks if the given train already holds a preceding route connecting to layout.

Local function declarations

Definition at line 83 of file ab_ga_ma_logic_adaptation.c.

◆ validate_route_assignment()

bool validate_route_assignment ( void * context,
uint16_t route_id,
uint8_t train_id )
static

GP's own registered route validator (see ab_ga_ma_logic_adaptation_init()) - GP calls this once per candidate route<->train connection, before it connects anything. context is the ab_gp_db_t* passed to ab_ga_ma_logic_adaptation_init(). Purely "is route_id itself a real, valid site route" - the "not already used_in_ma by a different train" check already lives inside ga_interface.h's own ab_gp_db_route_connect_train() (called separately, only if this validator approves), so this validator does not need train_id itself; kept in the signature for symmetry with a future GA validator that might. Same behavior this codebase has had since before the GA/GP split - genuinely relocated, not reinterpreted.

Definition at line 129 of file ab_ga_ma_logic_adaptation.c.

◆ validate_shunting_request()

bool validate_shunting_request ( void * context,
uint8_t train_id )
static

GP's registered shunting validator (Subset-026 5.6, Msg 130). Adaptation rule: a train that holds a route or an active MA is refused Shunting mode - in SH the on-board drops its MA, which would leave a locked route held by a train no longer supervised on it; the route is released first (End of Mission or route release). Refuses when the train context cannot be read (fail-closed). context is &g_shunting_context.

Definition at line 187 of file ab_ga_ma_logic_adaptation.c.

Variable Documentation

◆ g_ga_role_tag

const char* g_ga_role_tag = ""

Global variables declarations

GA-wide role tag, set once at ab_ga_ma_logic_adaptation_init() - see that file's own g_ga_role_tag definition. Used here for logging only, same as every other GA module.

Definition at line 35 of file ab_ga_ma_logic_adaptation.c.

◆ g_shunting_context

ab_ga_shunting_context_t g_shunting_context
static

Local variables declarations

Definition at line 32 of file ab_ga_ma_logic_adaptation.c.