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

Synchronous, statically-wired event dispatch for GP's per-entity procedure state machines (state_machines/). More...

#include <stdbool.h>
#include "ab_gp_event.h"
#include "../ertms_procedures/ab_gp_ertms_types.h"
Include dependency graph for ab_gp_dispatch.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef bool(*) ab_gp_fsm_handler_fn(ab_gp_ertms_train_context_t *ctx, ab_gp_event_t event)
 One FSM's event entry point. Every per-entity FSM under state_machines/ exposes exactly this signature so it can appear in the dispatcher's subscription table.

Functions

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.

Detailed Description

Synchronous, statically-wired event dispatch for GP's per-entity procedure state machines (state_machines/).

A procedure in ertms_procedures/ raises an ab_gp_event_t (ab_gp_event.h) by calling ab_gp_dispatch() - it does NOT call any one FSM by name. The dispatcher walks a single compile-time subscription table (s_subscriptions[] in ab_gp_dispatch.c) and invokes, in table order, every FSM handler subscribed to that event, each run-to-completion.

Deliberately NOT an HSM / event queue / runtime pub-sub:

  • Synchronous: every handler runs and returns before ab_gp_dispatch() returns, within the same GP cyclic-executive step that raised the event. No buffering, so no queue-overflow policy and no cross-cycle latency to account for in the timing analysis (docs/TIMING_AND_DATA_LOSS_ANALYSIS.md).
  • Static wiring: the (event -> handlers) map is one const table a reviewer reads top to bottom; there is no subscribe() call, so a MISRA / static-analysis pass sees every subscriber of an event without tracing registration order.
  • Flat: each subscriber is an independent (state, event) -> state table (ab_gp_session_fsm.c, ab_gp_train_data_fsm.c, ...), not a nested state hierarchy. "One train owns its procedures" is expressed by ab_gp_ertms_train_context_t composing every procedure's own record, not by superstates.

Definition in file ab_gp_dispatch.h.

Typedef Documentation

◆ ab_gp_fsm_handler_fn

typedef bool(*) ab_gp_fsm_handler_fn(ab_gp_ertms_train_context_t *ctx, ab_gp_event_t event)

One FSM's event entry point. Every per-entity FSM under state_machines/ exposes exactly this signature so it can appear in the dispatcher's subscription table.

Parameters
[in,out]ctxTrain context this FSM reads/updates its own field of (ctx->session_state, ctx->train_data.state, ...).
[in]eventEvent being dispatched.
Returns
true if this handler applied a state change for (its current state, event); false if it left its state unchanged (event not applicable here, or ctx NULL).

Definition at line 52 of file ab_gp_dispatch.h.

Function Documentation

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