SafeAPI RBC 2oo2 Generic Application
IL/CTC route and train logic for the safeAPIRBC2oo2 reference RBC
Loading...
Searching...
No Matches
ab_ga_dispatch.c File Reference

GA's single GP-notification subscriber AND registration point for everything GP calls into GA with - see ab_ga_dispatch.h. More...

#include "ab_ga_dispatch.h"
#include "ga_interface.h"
#include "../il/ab_ga_il.h"
#include "../ctc/ab_ga_ctc.h"
Include dependency graph for ab_ga_dispatch.c:

Go to the source code of this file.

Data Structures

struct  ga_channel_ctx_t

Functions

static void on_route_context_changed (const void *context, const ab_gp_route_context_t *ctx, ab_gp_route_update_type_t update_type)
static void on_train_context_changed (const void *context, const ab_gp_train_context_t *ctx, ab_gp_train_update_type_t update_type)
static uint8_t il_output_producer_trampoline (const void *context, ab_gp_il_pending_output_t out[AB_GP_IL_MAX_PENDING_OUTPUTS])
static uint8_t ctc_output_producer_trampoline (const void *context, ab_gp_ctc_pending_output_t out[AB_GP_CTC_MAX_PENDING_OUTPUTS])
sapi_status_t ab_ga_dispatch_init (ab_gp_train_session_t *sessions, ab_gp_db_t *db)
 Registers every GA<->GP subscription this process needs, in one place: route-context notify, train-context notify, the IL envelope handler, the IL output producer, and the CTC output producer (all declared in ga_interface.h, first failure wins). Setup-phase only (same contract as those registration functions) - call once from AB/ma_logic_adaptation/ab_ga_ma_logic_adaptation.c's own ab_ga_ma_adaptation_init(), GA's own single entry point GP calls (AB/GP/com/ab_gp_channel.c's own ab_gp_channel_ga_setup()) - not from GP directly.

Variables

static ga_channel_ctx_t g_channel_ctx

Detailed Description

GA's single GP-notification subscriber AND registration point for everything GP calls into GA with - see ab_ga_dispatch.h.

Definition in file ab_ga_dispatch.c.

Function Documentation

◆ ab_ga_dispatch_init()

sapi_status_t ab_ga_dispatch_init ( ab_gp_train_session_t * sessions,
ab_gp_db_t * db )

Registers every GA<->GP subscription this process needs, in one place: route-context notify, train-context notify, the IL envelope handler, the IL output producer, and the CTC output producer (all declared in ga_interface.h, first failure wins). Setup-phase only (same contract as those registration functions) - call once from AB/ma_logic_adaptation/ab_ga_ma_logic_adaptation.c's own ab_ga_ma_adaptation_init(), GA's own single entry point GP calls (AB/GP/com/ab_gp_channel.c's own ab_gp_channel_ga_setup()) - not from GP directly.

Global functions

Parameters
sessions/

param db This channel's own long-lived Train session table/Train-Route database (both opaque to GA) - captured in this module's own static storage (one GA instance per process/ channel, so one copy is all that's ever needed) and handed to the CTC output producer as its registration context (the IL output producer needs neither; the IL envelope handler receives its own sessions/db as ordinary call parameters from GP instead, per-call, not through this capture - see ab_gp_il_envelope_handler_fn's own doc, ga_interface.h).

Returns
SAPI_STATUS_OK on success; whatever the first failing registration call itself returned otherwise.

Definition at line 36 of file ab_ga_dispatch.c.

◆ ctc_output_producer_trampoline()

uint8_t ctc_output_producer_trampoline ( const void * context,
ab_gp_ctc_pending_output_t out[AB_GP_CTC_MAX_PENDING_OUTPUTS] )
static

GP's own registered CTC output producer - unpacks this module's own captured sessions/db (g_channel_ctx, set at ab_ga_dispatch_init()) from context and forwards to ab_ga_ctc_build_outputs(), which still takes them as ordinary parameters (unchanged real signature).

Definition at line 116 of file ab_ga_dispatch.c.

◆ il_output_producer_trampoline()

uint8_t il_output_producer_trampoline ( const void * context,
ab_gp_il_pending_output_t out[AB_GP_IL_MAX_PENDING_OUTPUTS] )
static

GP's own registered IL output producer - ab_ga_il_build_outputs() itself needs no sessions/db (see that function's own doc), so this is a pure signature-matching trampoline, nothing more.

Definition at line 105 of file ab_ga_dispatch.c.

◆ on_route_context_changed()

void on_route_context_changed ( const void * context,
const ab_gp_route_context_t * ctx,
ab_gp_route_update_type_t update_type )
static

Local function declarations

GP's own registered route-context subscriber - fans out to every GA sibling module that cares (il always; ctc only for AB_ROUTE_CONNECTED

  • see each module's own on_route_context_changed() doc for which update_type values it actually acts on, the rest are no-ops there). context is this module's own captured g_channel_ctx (registered below) - il's own on_route_context_changed() now needs sessions/db to grant/shrink Movement Authority itself (later session, on direct request - see ab_ga_il.h's own doc for the full reasoning: route<-> train connection, and the MA effect of it, is GP/GA's own decision now, not IL's).

Definition at line 83 of file ab_ga_dispatch.c.

◆ on_train_context_changed()

void on_train_context_changed ( const void * context,
const ab_gp_train_context_t * ctx,
ab_gp_train_update_type_t update_type )
static

GP's own registered train-context subscriber - fans out to ctc (the only GA module that reacts to train-context changes today; il's own route bookkeeping is driven by route-context changes instead, above).

Definition at line 95 of file ab_ga_dispatch.c.

Variable Documentation

◆ g_channel_ctx

ga_channel_ctx_t g_channel_ctx
static

Definition at line 23 of file ab_ga_dispatch.c.