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_proc_train_data.c
Go to the documentation of this file.
1
5
8
9#define RBC_MAX_ALLOWED_TRAIN_LENGTH_M 5000U
10#define RBC_MAX_ALLOWED_TRAIN_SPEED_KMH 350U
11
13 uint32_t l_train_m,
14 uint32_t v_maxtrain_kmh,
15 uint8_t m_axleload,
16 uint8_t m_loadinggauge,
17 bool m_airtight,
18 uint32_t timestamp_ms)
19{
20 if (ctx == NULL)
21 {
22 return false;
23 }
24
25 /* Msg 129 is in hand - raise it before running the checks so the
26 * train-data FSM (state_machines/train_data/) records RECEIVED. Both
27 * this and the two events below go through ab_gp_dispatch(): the
28 * subscription table decides who reacts, not this call site. */
30
31 /* Defensive parameter checks (SIL 4) - a failure now raises
32 * TRAIN_DATA_REJECTED (train-data FSM -> REJECTED, which also clears
33 * the derived .valid mirror). Behaviour refinement vs. the previous
34 * bare `return false`: a re-validation that fails no longer leaves a
35 * stale .valid == true from an earlier success (the FSM's own
36 * VALIDATED + REJECTED guard still protects data that was good and is
37 * only being re-checked, i.e. no preceding RECEIVED). */
38 if (l_train_m == 0U || l_train_m > RBC_MAX_ALLOWED_TRAIN_LENGTH_M)
39 {
41 return false;
42 }
43 if (v_maxtrain_kmh == 0U || v_maxtrain_kmh > RBC_MAX_ALLOWED_TRAIN_SPEED_KMH)
44 {
46 return false;
47 }
48
49 ctx->train_data.l_train_m = l_train_m;
50 ctx->train_data.v_maxtrain_kmh = v_maxtrain_kmh;
51 ctx->train_data.m_axleload = m_axleload;
52 ctx->train_data.m_loadinggauge = m_loadinggauge;
53 ctx->train_data.m_airtight = m_airtight;
54 ctx->train_data.t_train_data_ack = timestamp_ms;
55
56 /* Reaches BOTH the session FSM (INITIATED/ESTABLISHED -> DATA_VALIDATED,
57 * a no-op from any other session state) AND the train-data FSM
58 * (-> VALIDATED, which sets the derived .valid mirror). .valid is no
59 * longer written directly here - the train-data FSM owns it. */
61
62 return true;
63}
64
66{
67 if (ctx == NULL)
68 {
69 return false;
70 }
71 return ctx->train_data.valid;
72}
73
75 uint32_t *out_t_train_ack)
76{
77 if (ctx == NULL || out_t_train_ack == NULL || !ctx->train_data.valid)
78 {
79 return false;
80 }
81 *out_t_train_ack = ctx->train_data.t_train_data_ack;
82 return true;
83}
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,...
Synchronous, statically-wired event dispatch for GP's per-entity procedure state machines (state_mach...
@ AB_GP_EVENT_TRAIN_DATA_REJECTED
Definition ab_gp_event.h:73
@ AB_GP_SESSION_EVENT_TRAIN_DATA_VALIDATED
Definition ab_gp_event.h:57
@ AB_GP_EVENT_TRAIN_DATA_RECEIVED
Definition ab_gp_event.h:72
#define RBC_MAX_ALLOWED_TRAIN_SPEED_KMH
bool ab_gp_proc_train_data_validate(ab_gp_ertms_train_context_t *ctx, uint32_t l_train_m, uint32_t v_maxtrain_kmh, uint8_t m_axleload, uint8_t m_loadinggauge, bool m_airtight, uint32_t timestamp_ms)
Validates inbound Train Data (Msg 129 + Packet 11) against site topology limits.
bool ab_gp_proc_train_data_is_valid(const ab_gp_ertms_train_context_t *ctx)
Checks if train data has been successfully validated.
#define RBC_MAX_ALLOWED_TRAIN_LENGTH_M
bool ab_gp_proc_train_data_get_ack_timestamp(const ab_gp_ertms_train_context_t *ctx, uint32_t *out_t_train_ack)
Retrieves the timestamp for Msg 8 (Ack of Train Data) generation.
ERTMS Subset-026 §5.4 & §5.2 Validated Train Data and Start of Mission Procedure.
Complete ERTMS state and procedure context for one train slot.
ab_gp_ertms_train_data_t train_data