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_shunting.c
Go to the documentation of this file.
1
5
8#include "../state_machines/session/ab_gp_session_fsm.h" /* ab_gp_session_fsm_can_handle() */
9#include "../ma_logic/ab_gp_logic.h" /* ab_gp_logic_shunting_allowed() - GA veto */
10
11#include "rte/oal/memory/rte_mem_util.h"
12
14{
15 if (ctx == NULL)
16 {
17 return false;
18 }
19
20 ctx->shunting_requested = true;
21 return true;
22}
23
25{
26 if (ctx == NULL)
27 {
28 return false;
29 }
30
31 ctx->shunting_requested = false;
32
33 if (authorized)
34 {
35 /* Handled from ESTABLISHED/DATA_VALIDATED/STANDBY/FS
36 * (ab_gp_session_fsm.c's own table - ESTABLISHED included for the
37 * same reason ab_gp_proc_ma_compute() needs it, see that function's
38 * own doc: this codebase's real connect path never reaches
39 * DATA_VALIDATED at all) - a real, deliberate tightening versus the
40 * old unconditional assignment: shunting can no longer be
41 * authorized for a train with no session at all (IDLE/INITIATED),
42 * mid-emergency-stop, or mid-termination. Reports failure back to
43 * the caller instead of silently claiming authorization that was
44 * never actually granted. */
46 {
47 ctx->shunting_authorized = false;
48 return false;
49 }
50 ctx->shunting_authorized = true;
51 return true;
52 }
53
54 ctx->shunting_authorized = false;
55 /* No outer guard needed - the table only defines an outcome for this
56 * event from SHUNTING, so it is a harmless no-op from anywhere else. */
58 return true;
59}
60
62 uint32_t v_train_kmh)
63{
64 if (ctx == NULL)
65 {
67 }
68
70
71 /* A repeated Msg 130 (the train did not get the first answer) is answered again, with no state change. */
73 {
74 ctx->shunting_requested = false;
76 }
77
78 /* Msg 130 needs a communication session. The session table also lets IDLE take SHUNTING_AUTHORIZED, for the
79 * flat-scheme connect path; an ERTMS request from a train with no session is refused here instead. */
81 {
82 ctx->shunting_requested = false;
84 }
85
86 /* The on-board lets the driver select SH only at standstill; the RBC checks the reported speed as well. */
87 if (v_train_kmh != 0U)
88 {
89 ctx->shunting_requested = false;
91 }
92
94 {
95 ctx->shunting_requested = false;
97 }
98
99 if (!ab_gp_logic_shunting_allowed(train_id))
100 {
101 ctx->shunting_requested = false;
103 }
104
105 if (!ab_gp_proc_shunting_authorize(ctx, true))
106 {
108 }
110}
111
113 rbc_timestamp_ms_t t_train_request, rbc_nid_lrbg_t nid_lrbg,
115{
117
118 if (out == NULL)
119 {
120 return false;
121 }
122
123 rte_mem_set(out, 0, sizeof(*out));
124 if (decision == AB_GP_SHUNTING_AUTHORISED)
125 {
127 out->payload.msg_28.t_train_ref = t_train_request;
128 header = &out->payload.msg_28.header;
129 }
130 else
131 {
133 out->payload.msg_27.t_train_ref = t_train_request;
134 header = &out->payload.msg_27.header;
135 }
136 header->nid_message = out->nid_message;
137 header->t_train = t_train_reply;
139 header->nid_lrbg = nid_lrbg;
140 return true;
141}
142
144{
145 switch (decision)
146 {
147 case AB_GP_SHUNTING_AUTHORISED: return "AUTHORISED";
148 case AB_GP_SHUNTING_REFUSED_NO_SESSION: return "NO_SESSION";
149 case AB_GP_SHUNTING_REFUSED_NOT_AT_STANDSTILL: return "NOT_AT_STANDSTILL";
150 case AB_GP_SHUNTING_REFUSED_SESSION_STATE: return "SESSION_STATE";
151 case AB_GP_SHUNTING_REFUSED_BY_GA: return "REFUSED_BY_GA";
152 case AB_GP_SHUNTING_REFUSED_INVALID: return "INVALID";
153 default: return "UNKNOWN";
154 }
155}
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...
#define RBC_MSG_TRACK_TO_TRAIN_SH_REFUSED
#define RBC_MSG_TRACK_TO_TRAIN_SH_AUTHORISED
@ AB_GP_SESSION_EVENT_SHUNTING_AUTHORIZED
Definition ab_gp_event.h:60
@ AB_GP_SESSION_EVENT_SHUNTING_DEAUTHORIZED
Definition ab_gp_event.h:61
bool ab_gp_logic_shunting_allowed(uint8_t train_id)
Asks every registered shunting validator about train_id.
Definition ab_gp_logic.c:92
A/B's own RBC decision logic - today's slice: connect a train's currently-reported route to that trai...
const char * ab_gp_proc_shunting_decision_name(ab_gp_shunting_decision_t decision)
bool ab_gp_proc_shunting_build_reply(ab_gp_shunting_decision_t decision, rbc_timestamp_ms_t t_train_reply, rbc_timestamp_ms_t t_train_request, rbc_nid_lrbg_t nid_lrbg, rbc_train_outbound_msg_t *out)
Builds the answer to a Msg 130: Msg 28 SH Authorised or Msg 27 SH Refused.
ab_gp_shunting_decision_t ab_gp_proc_shunting_handle_request(ab_gp_ertms_train_context_t *ctx, uint8_t train_id, uint32_t v_train_kmh)
Decides one Msg 130 Request for Shunting and applies the outcome.
bool ab_gp_proc_shunting_request(ab_gp_ertms_train_context_t *ctx)
Handles inbound Shunting Request (Msg 130).
bool ab_gp_proc_shunting_authorize(ab_gp_ertms_train_context_t *ctx, bool authorized)
Authorizes or rejects shunting mode for the train.
ERTMS Subset-026 5.6 Shunting initiated by driver (Level 2).
ab_gp_shunting_decision_t
@ AB_GP_SHUNTING_REFUSED_SESSION_STATE
@ AB_GP_SHUNTING_REFUSED_INVALID
@ AB_GP_SHUNTING_AUTHORISED
@ AB_GP_SHUNTING_REFUSED_NO_SESSION
@ AB_GP_SHUNTING_REFUSED_NOT_AT_STANDSTILL
@ AB_GP_SHUNTING_REFUSED_BY_GA
bool ab_gp_session_fsm_can_handle(ab_gp_ertms_session_state_t from, ab_gp_session_event_t event, ab_gp_ertms_session_state_t *out_to)
Read-only lookup, no side effect: what event does from a given state produce, if anything.
Event-driven legal-transition table for ab_gp_ertms_session_state_t (Subset-026 Chapter 5's various p...
@ RBC_M_ACK_NOT_REQUIRED
uint64_t rbc_timestamp_ms_t
Timestamp in milliseconds (POSIX or ETCS T_TRAIN / T_RBC scale).
@ AB_GP_ERTMS_SESSION_SHUNTING
@ AB_GP_ERTMS_SESSION_INITIATED
@ AB_GP_ERTMS_SESSION_IDLE
Complete ERTMS state and procedure context for one train slot.
ab_gp_ertms_session_state_t session_state
Last Relevant Balise Group (Country + BG identifier).
union rbc_train_outbound_msg_t::@072257326371153356142277360163235337000010176256 payload