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_dispatch.c File Reference

See ab_gp_dispatch.h. Holds the one subscription table. More...

#include "ab_gp_dispatch.h"
#include "session/ab_gp_session_fsm.h"
#include "train_data/ab_gp_train_data_fsm.h"
#include "ma/ab_gp_ma_fsm.h"
#include "shunting/ab_gp_shunting_fsm.h"
#include "emergency_stop/ab_gp_emergency_stop_fsm.h"
#include "position/ab_gp_position_fsm.h"
#include "eom/ab_gp_eom_fsm.h"
#include "handover/ab_gp_handover_fsm.h"
#include "tsr/ab_gp_tsr_fsm.h"
#include "text_message/ab_gp_text_message_fsm.h"
#include "rte/oal/log/rte_log.h"
#include "rte/utils/string/rte_string.h"
Include dependency graph for ab_gp_dispatch.c:

Go to the source code of this file.

Data Structures

struct  [struct].s_subscriptions
 The (event -> FSM handler) subscription table: the single place that says which state machine(s) react to a given event. One row per (event, subscriber) pair; an event with two subscribers has two rows (see AB_GP_SESSION_EVENT_TRAIN_DATA_VALIDATED below). Rows are visited top to bottom, so ordering here is the handler call order for a multi-subscriber event - keep the more "primary" FSM first (session before the procedure-specific one) so ab_gp_dispatch()'s aggregate bool still tracks the session FSM's own result where a caller relies on that. More...

Macros

#define AB_GP_DISPATCH_SUBSCRIPTION_COUNT   (sizeof(s_subscriptions) / sizeof(s_subscriptions[0]))

Functions

static void log_dispatch (const ab_gp_ertms_train_context_t *ctx, ab_gp_event_t event, uint32_t reached, uint32_t changed)
bool ab_gp_dispatch (ab_gp_ertms_train_context_t *ctx, ab_gp_event_t event)
 Raises event to every state machine subscribed to it, in subscription-table order, synchronously.

Variables

static const struct  s_subscriptions []

Detailed Description

See ab_gp_dispatch.h. Holds the one subscription table.

Definition in file ab_gp_dispatch.c.

Macro Definition Documentation

◆ AB_GP_DISPATCH_SUBSCRIPTION_COUNT

#define AB_GP_DISPATCH_SUBSCRIPTION_COUNT   (sizeof(s_subscriptions) / sizeof(s_subscriptions[0]))

Definition at line 106 of file ab_gp_dispatch.c.

Function Documentation

◆ log_dispatch()

void log_dispatch ( const ab_gp_ertms_train_context_t * ctx,
ab_gp_event_t event,
uint32_t reached,
uint32_t changed )
static

Debug-level line per dispatch: which event, how many subscribers it reached, and how many of those reported a state change. Built with rte_string's bounded API (ADR-006), same posture as ab_gp_session_fsm.c's own log_event(); a formatting failure silently skips the line rather than emit a truncated one.

Definition at line 114 of file ab_gp_dispatch.c.

◆ ab_gp_dispatch()

bool ab_gp_dispatch ( ab_gp_ertms_train_context_t * ctx,
ab_gp_event_t event )

Raises event to every state machine subscribed to it, in subscription-table order, synchronously.

Parameters
[in,out]ctxTrain context. A NULL ctx dispatches to nothing and returns false.
[in]eventEvent to raise. An out-of-range value dispatches to nothing and returns false.
Returns
true if at least one subscribed handler reported a state change; false if every subscriber left its state unchanged (or there were none). For an event with a single subscriber - which is the case for every session-lifecycle event today - this is exactly that one FSM's own result, so a caller that used to check ab_gp_session_fsm_handle_event()'s bool can check this instead with identical meaning.

Definition at line 140 of file ab_gp_dispatch.c.

Variable Documentation

◆ s_subscriptions

const struct [struct].s_subscriptions s_subscriptions[]