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.h File Reference

GP's own dispatch side of the "GP calls into GA" surface - see ga_interface.h's own "functions GP calls into GA with" section for the registration functions GA calls (ab_gp_register_il_envelope_handler()/_il_output_producer()/ _ctc_output_producer()) and the real storage/dispatch behind them (ab_gp_ga_hooks.c). The three functions below are what AB/GP/main/pre_execute.c and post_execute.c call INSTEAD of the old bare ab_ga_il_apply_envelope()/ab_ga_il_build_outputs()/ ab_ga_ctc_build_outputs() calls - each is a thin "is a handler registered? if so, call it; if not, no-op" wrapper, so a channel whose GA setup hasn't run yet (or failed) degrades to doing nothing here rather than crashing on a NULL function pointer. More...

#include <stdbool.h>
#include <stdint.h>
#include "../ga_interface/ga_interface.h"
#include "rbc_wire_types.h"
Include dependency graph for ab_gp_ga_hooks.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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.
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.
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.
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.

Detailed Description

GP's own dispatch side of the "GP calls into GA" surface - see ga_interface.h's own "functions GP calls into GA with" section for the registration functions GA calls (ab_gp_register_il_envelope_handler()/_il_output_producer()/ _ctc_output_producer()) and the real storage/dispatch behind them (ab_gp_ga_hooks.c). The three functions below are what AB/GP/main/pre_execute.c and post_execute.c call INSTEAD of the old bare ab_ga_il_apply_envelope()/ab_ga_il_build_outputs()/ ab_ga_ctc_build_outputs() calls - each is a thin "is a handler registered? if so, call it; if not, no-op" wrapper, so a channel whose GA setup hasn't run yet (or failed) degrades to doing nothing here rather than crashing on a NULL function pointer.

Definition in file ab_gp_ga_hooks.h.

Function Documentation

◆ 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.

◆ 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.

◆ 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.