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_emergency_stop.c
Go to the documentation of this file.
1
5
8
10{
11 if (ctx == NULL)
12 {
13 return false;
14 }
15
16 ctx->emergency_stop.active = true;
17 ctx->emergency_stop.is_conditional = false;
18 ctx->emergency_stop.nid_em = (nid_em == 0U) ? 1U : nid_em;
19 ctx->emergency_stop.d_ref_m = 0U;
21 ctx->emergency_stop.acknowledged = false;
22
23 /* Handled from EVERY state (ab_gp_session_fsm.c's own table,
24 * deliberately - see that file's own header doc) - an emergency stop
25 * command must never be rejectable, so this can only fail on
26 * ctx == NULL, already excluded above. */
28 return true;
29}
30
32 uint8_t nid_em,
33 uint32_t d_ref_m,
34 uint32_t d_emergencystop_m)
35{
36 if (ctx == NULL)
37 {
38 return false;
39 }
40
41 ctx->emergency_stop.active = true;
43 ctx->emergency_stop.nid_em = (nid_em == 0U) ? 1U : nid_em;
44 ctx->emergency_stop.d_ref_m = d_ref_m;
45 ctx->emergency_stop.d_emergencystop_m = d_emergencystop_m;
46 ctx->emergency_stop.acknowledged = false;
47
48 /* Handled from EVERY state (ab_gp_session_fsm.c's own table,
49 * deliberately - see that file's own header doc) - an emergency stop
50 * command must never be rejectable, so this can only fail on
51 * ctx == NULL, already excluded above. */
53 return true;
54}
55
57 uint8_t nid_em,
58 uint32_t timestamp_ms)
59{
60 if (ctx == NULL || !ctx->emergency_stop.active)
61 {
62 return false;
63 }
64
65 if (nid_em == ctx->emergency_stop.nid_em || nid_em == 0U)
66 {
67 ctx->emergency_stop.acknowledged = true;
68 ctx->emergency_stop.ack_time_ms = timestamp_ms;
69 return true;
70 }
71
72 return false;
73}
74
76{
77 if (ctx == NULL || !ctx->emergency_stop.active)
78 {
79 return false;
80 }
81
82 if (nid_em == ctx->emergency_stop.nid_em || nid_em == 0U)
83 {
84 ctx->emergency_stop.active = false;
85 ctx->emergency_stop.acknowledged = false;
86
87 /* Which of the three revoke outcomes applies is THIS procedure's
88 * own domain decision (has_active_ma / train_data.valid), not the
89 * state machine's - it fires the one matching event; the table
90 * only says each is handled from EMERGENCY_STOP (ab_gp_session_fsm.c's
91 * own table), so each call can only fail on ctx == NULL, already
92 * excluded above. */
93 if (ctx->ma.has_active_ma)
94 {
96 }
97 else if (ctx->train_data.valid)
98 {
100 }
101 else
102 {
104 }
105 return true;
106 }
107
108 return false;
109}
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_SESSION_EVENT_EMERGENCY_STOP_ISSUED
Definition ab_gp_event.h:62
@ AB_GP_SESSION_EVENT_EMERGENCY_STOP_REVOKED_TO_ESTABLISHED
Definition ab_gp_event.h:65
@ AB_GP_SESSION_EVENT_EMERGENCY_STOP_REVOKED_TO_STANDBY
Definition ab_gp_event.h:64
@ AB_GP_SESSION_EVENT_EMERGENCY_STOP_REVOKED_TO_FS
Definition ab_gp_event.h:63
bool ab_gp_proc_emergency_stop_revoke(ab_gp_ertms_train_context_t *ctx, uint8_t nid_em)
Revokes an active Emergency Stop (Msg 18) once hazard is cleared.
bool ab_gp_proc_emergency_stop_issue_ues(ab_gp_ertms_train_context_t *ctx, uint8_t nid_em)
Issues an Unconditional Emergency Stop (UES - Msg 16) to the train.
bool ab_gp_proc_emergency_stop_handle_ack(ab_gp_ertms_train_context_t *ctx, uint8_t nid_em, uint32_t timestamp_ms)
Handles inbound Emergency Stop Acknowledgement (Msg 147).
bool ab_gp_proc_emergency_stop_issue_ces(ab_gp_ertms_train_context_t *ctx, uint8_t nid_em, uint32_t d_ref_m, uint32_t d_emergencystop_m)
Issues a Conditional Emergency Stop (CES - Msg 15) to the train.
ERTMS Subset-026 ยง5.7 Emergency Stop Management Procedure.
Complete ERTMS state and procedure context for one train slot.
ab_gp_ertms_emergency_stop_t emergency_stop
ab_gp_ertms_train_data_t train_data
ab_gp_ertms_ma_record_t ma