RTE RBC 2oo2 Reference Application 0.1.0 build 0006685
SIL 4 2oo2 Dual-Site Fault-Tolerant ERTMS Radio Block Centre Reference Architecture
Loading...
Searching...
No Matches
ab_gp_ga_hooks.c File Reference

See ab_gp_ga_hooks.h and ga_interface.h's own "functions GP calls into GA with" section. More...

#include "ab_gp_ga_hooks.h"
#include "rte/utils/buffer/rte_buffer.h"
#include "rte/utils/lifecycle/rte_lifecycle.h"
#include "rte/utils/notify/rte_notify.h"
#include "rte/oal/memory/rte_mem_util.h"
#include "rbc_wire_types.h"
Include dependency graph for ab_gp_ga_hooks.c:

Go to the source code of this file.

CTC_ALARM wire encoding - GP's own now (moved from GA)

Own copy of the fixed-offset RBC envelope wire layout for this ONE kind, same "duplicated per domain, must stay byte-for-byte identical to SimCore's Python mirror" posture every other domain's own wire codec already takes (see AB/GP/train/ab_gp_train.c's own train_wire_encode(), AB/ctc/ab_ga_ctc.c's own ctc_wire_encode()) - this is genuinely a subset of that same layout (alarm never sets the RBC_MSG_CTC_TRAIN_INFO-only nid_lrbg/v_train/m_mode fields, and has no train_id - see rbc_wire_types.h's own file doc for the full layout).

#define AB_GP_CTC_ALARM_WIRE_HEADER_SIZE   12U
#define AB_GP_CTC_ALARM_WIRE_L_MESSAGE   36U
void ab_gp_build_ctc_alarm (uint8_t out[RBC_ENVELOPE_WIRE_SIZE], rbc_alarm_severity_t severity, uint32_t code, uint32_t cycle, uint32_t timestamp_ms)
 Builds and wire-encodes an outbound CTC_ALARM envelope - GP's own now (moved from GA, "GP shall provide API to generate alarm", later session, on direct request: raising an alarm is GP's own decision, not something that needs a GA round trip). See ab_gp_ga_hooks.c's own doc for the wire layout.

IL envelope handler - single slot

static ab_gp_il_envelope_handler_list_t g_il_envelope_handler
 RTE_DECLARE_CALLBACK_LIST (ab_gp_il_envelope_handler_list_t, ab_gp_il_envelope_handler_fn, 1U)
rte_status_t ab_gp_register_il_envelope_handler (ab_gp_il_envelope_handler_fn fn, const void *context)
bool ab_gp_dispatch_il_envelope (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)
 Calls the registered IL envelope handler, if any - see ab_gp_register_il_envelope_handler()'s own doc, ga_interface.h.

IL output producer - single slot

static ab_gp_il_output_producer_list_t g_il_output_producer
static ab_gp_il_output_confirm_fn g_il_output_confirm_fn = NULL
 RTE_DECLARE_CALLBACK_LIST (ab_gp_il_output_producer_list_t, ab_gp_il_output_producer_fn, 1U)
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)
uint8_t ab_gp_drain_il_outputs (ab_gp_il_pending_output_t out[AB_GP_IL_MAX_PENDING_OUTPUTS])
 Calls the registered IL output producer, if any - see ab_gp_register_il_output_producer()'s own doc, ga_interface.h.
void ab_gp_confirm_il_outputs_sent (void)
 Calls the registered IL output producer's own confirm callback, if any - see ab_gp_il_output_confirm_fn's own doc, ga_interface.h. post_execute.c must call this ONLY on the cycle it actually forwards the outputs ab_gp_drain_il_outputs() just built to C - never unconditionally right after draining.

CTC output producer - single slot

static ab_gp_ctc_output_producer_list_t g_ctc_output_producer
static ab_gp_ctc_output_confirm_fn g_ctc_output_confirm_fn = NULL
 RTE_DECLARE_CALLBACK_LIST (ab_gp_ctc_output_producer_list_t, ab_gp_ctc_output_producer_fn, 1U)
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)
uint8_t ab_gp_drain_ctc_outputs (ab_gp_ctc_pending_output_t out[AB_GP_CTC_MAX_PENDING_OUTPUTS])
 Calls the registered CTC output producer, if any - see ab_gp_register_ctc_output_producer()'s own doc, ga_interface.h.
void ab_gp_confirm_ctc_outputs_sent (void)
 Calls the registered CTC output producer's own confirm callback, if any - same contract as ab_gp_confirm_il_outputs_sent() above.

Detailed Description

See ab_gp_ga_hooks.h and ga_interface.h's own "functions GP calls into GA with" section.

Three single-slot registrations (one GA instance per channel, so one slot is all that's ever needed - same posture AB/GP/ma_logic/ab_gp_logic.c's own ab_gp_ga_register_init() already takes), plus this project's own CTC_ALARM wire encoder (moved here from GA - "GP shall provide API to generate alarm", later session, on direct request - alarm-raising is GP's own decision, not something that needs a GA round trip at all).

Definition in file ab_gp_ga_hooks.c.

Macro Definition Documentation

◆ AB_GP_CTC_ALARM_WIRE_HEADER_SIZE

#define AB_GP_CTC_ALARM_WIRE_HEADER_SIZE   12U

Definition at line 179 of file ab_gp_ga_hooks.c.

◆ AB_GP_CTC_ALARM_WIRE_L_MESSAGE

#define AB_GP_CTC_ALARM_WIRE_L_MESSAGE   36U

Definition at line 180 of file ab_gp_ga_hooks.c.

Function Documentation

◆ RTE_DECLARE_CALLBACK_LIST() [1/3]

RTE_DECLARE_CALLBACK_LIST ( ab_gp_il_envelope_handler_list_t ,
ab_gp_il_envelope_handler_fn ,
1U  )

◆ ab_gp_register_il_envelope_handler()

rte_status_t ab_gp_register_il_envelope_handler ( ab_gp_il_envelope_handler_fn fn,
const void * context )
Returns
RTE_STATUS_OK on success; RTE_STATUS_INVALID_PARAM if fn is NULL; RTE_STATUS_INVALID_STATE if the setup phase is already locked; RTE_STATUS_RESOURCE_EXHAUSTED if the one slot is already taken (one handler per channel, same as ab_gp_ga_register_init()).

Definition at line 28 of file ab_gp_ga_hooks.c.

◆ ab_gp_dispatch_il_envelope()

bool ab_gp_dispatch_il_envelope ( 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 )

Calls the registered IL envelope handler, if any - see ab_gp_register_il_envelope_handler()'s own doc, ga_interface.h.

Returns
false if no handler is registered, or the handler itself returned false (envelope not consumed); true if the registered handler consumed it.

Definition at line 52 of file ab_gp_ga_hooks.c.

◆ RTE_DECLARE_CALLBACK_LIST() [2/3]

RTE_DECLARE_CALLBACK_LIST ( ab_gp_il_output_producer_list_t ,
ab_gp_il_output_producer_fn ,
1U  )

◆ ab_gp_register_il_output_producer()

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 )

Definition at line 76 of file ab_gp_ga_hooks.c.

◆ ab_gp_drain_il_outputs()

uint8_t ab_gp_drain_il_outputs ( ab_gp_il_pending_output_t out[AB_GP_IL_MAX_PENDING_OUTPUTS])

Calls the registered IL output producer, if any - see ab_gp_register_il_output_producer()'s own doc, ga_interface.h.

Returns
0 if no producer is registered; otherwise the producer's own return value (0..AB_GP_IL_MAX_PENDING_OUTPUTS).

Definition at line 101 of file ab_gp_ga_hooks.c.

◆ ab_gp_confirm_il_outputs_sent()

void ab_gp_confirm_il_outputs_sent ( void )

Calls the registered IL output producer's own confirm callback, if any - see ab_gp_il_output_confirm_fn's own doc, ga_interface.h. post_execute.c must call this ONLY on the cycle it actually forwards the outputs ab_gp_drain_il_outputs() just built to C - never unconditionally right after draining.

Definition at line 110 of file ab_gp_ga_hooks.c.

◆ RTE_DECLARE_CALLBACK_LIST() [3/3]

RTE_DECLARE_CALLBACK_LIST ( ab_gp_ctc_output_producer_list_t ,
ab_gp_ctc_output_producer_fn ,
1U  )

◆ ab_gp_register_ctc_output_producer()

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 )

Definition at line 126 of file ab_gp_ga_hooks.c.

◆ ab_gp_drain_ctc_outputs()

uint8_t ab_gp_drain_ctc_outputs ( ab_gp_ctc_pending_output_t out[AB_GP_CTC_MAX_PENDING_OUTPUTS])

Calls the registered CTC output producer, if any - see ab_gp_register_ctc_output_producer()'s own doc, ga_interface.h.

Returns
0 if no producer is registered; otherwise the producer's own return value (0..AB_GP_CTC_MAX_PENDING_OUTPUTS).

Definition at line 151 of file ab_gp_ga_hooks.c.

◆ ab_gp_confirm_ctc_outputs_sent()

void ab_gp_confirm_ctc_outputs_sent ( void )

Calls the registered CTC output producer's own confirm callback, if any - same contract as ab_gp_confirm_il_outputs_sent() above.

Definition at line 160 of file ab_gp_ga_hooks.c.

◆ ab_gp_build_ctc_alarm()

void ab_gp_build_ctc_alarm ( uint8_t out[RBC_ENVELOPE_WIRE_SIZE],
rbc_alarm_severity_t severity,
uint32_t code,
uint32_t cycle,
uint32_t timestamp_ms )

Builds and wire-encodes an outbound CTC_ALARM envelope - GP's own now (moved from GA, "GP shall provide API to generate alarm", later session, on direct request: raising an alarm is GP's own decision, not something that needs a GA round trip). See ab_gp_ga_hooks.c's own doc for the wire layout.

Parameters
severityAlarm severity (rbc_alarm_severity_t).
codeCaller-supplied numeric alarm code.
cycleThis channel's own current cycle number, or 0 if not applicable.
timestamp_msCaller-supplied origination timestamp.
outDestination, exactly RBC_ENVELOPE_WIRE_SIZE bytes. Must not be NULL.

Definition at line 184 of file ab_gp_ga_hooks.c.

Variable Documentation

◆ g_il_envelope_handler

ab_gp_il_envelope_handler_list_t g_il_envelope_handler
static

Definition at line 26 of file ab_gp_ga_hooks.c.

◆ g_il_output_producer

ab_gp_il_output_producer_list_t g_il_output_producer
static

Definition at line 68 of file ab_gp_ga_hooks.c.

◆ g_il_output_confirm_fn

ab_gp_il_output_confirm_fn g_il_output_confirm_fn = NULL
static

Definition at line 74 of file ab_gp_ga_hooks.c.

◆ g_ctc_output_producer

ab_gp_ctc_output_producer_list_t g_ctc_output_producer
static

Definition at line 122 of file ab_gp_ga_hooks.c.

◆ g_ctc_output_confirm_fn

ab_gp_ctc_output_confirm_fn g_ctc_output_confirm_fn = NULL
static

Definition at line 124 of file ab_gp_ga_hooks.c.