RTE RBC 2oo2 Reference Application
0.1.0 build 0006685
SIL 4 2oo2 Dual-Site Fault-Tolerant ERTMS Radio Block Centre Reference Architecture
Toggle main menu visibility
Loading...
Searching...
No Matches
ab_gp_proc_emergency_stop.c
Go to the documentation of this file.
1
5
6
#include "
ab_gp_proc_emergency_stop.h
"
7
#include "
../state_machines/ab_gp_dispatch.h
"
8
9
bool
ab_gp_proc_emergency_stop_issue_ues
(
ab_gp_ertms_train_context_t
*ctx, uint8_t nid_em)
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;
20
ctx->
emergency_stop
.
d_emergencystop_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. */
27
(void)
ab_gp_dispatch
(ctx,
AB_GP_SESSION_EVENT_EMERGENCY_STOP_ISSUED
);
28
return
true
;
29
}
30
31
bool
ab_gp_proc_emergency_stop_issue_ces
(
ab_gp_ertms_train_context_t
*ctx,
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
;
42
ctx->
emergency_stop
.
is_conditional
=
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. */
52
(void)
ab_gp_dispatch
(ctx,
AB_GP_SESSION_EVENT_EMERGENCY_STOP_ISSUED
);
53
return
true
;
54
}
55
56
bool
ab_gp_proc_emergency_stop_handle_ack
(
ab_gp_ertms_train_context_t
*ctx,
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
75
bool
ab_gp_proc_emergency_stop_revoke
(
ab_gp_ertms_train_context_t
*ctx, uint8_t nid_em)
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
{
95
(void)
ab_gp_dispatch
(ctx,
AB_GP_SESSION_EVENT_EMERGENCY_STOP_REVOKED_TO_FS
);
96
}
97
else
if
(ctx->
train_data
.
valid
)
98
{
99
(void)
ab_gp_dispatch
(ctx,
AB_GP_SESSION_EVENT_EMERGENCY_STOP_REVOKED_TO_STANDBY
);
100
}
101
else
102
{
103
(void)
ab_gp_dispatch
(ctx,
AB_GP_SESSION_EVENT_EMERGENCY_STOP_REVOKED_TO_ESTABLISHED
);
104
}
105
return
true
;
106
}
107
108
return
false
;
109
}
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,...
Definition
ab_gp_dispatch.c:140
ab_gp_dispatch.h
Synchronous, statically-wired event dispatch for GP's per-entity procedure state machines (state_mach...
AB_GP_SESSION_EVENT_EMERGENCY_STOP_ISSUED
@ AB_GP_SESSION_EVENT_EMERGENCY_STOP_ISSUED
Definition
ab_gp_event.h:62
AB_GP_SESSION_EVENT_EMERGENCY_STOP_REVOKED_TO_ESTABLISHED
@ AB_GP_SESSION_EVENT_EMERGENCY_STOP_REVOKED_TO_ESTABLISHED
Definition
ab_gp_event.h:65
AB_GP_SESSION_EVENT_EMERGENCY_STOP_REVOKED_TO_STANDBY
@ AB_GP_SESSION_EVENT_EMERGENCY_STOP_REVOKED_TO_STANDBY
Definition
ab_gp_event.h:64
AB_GP_SESSION_EVENT_EMERGENCY_STOP_REVOKED_TO_FS
@ AB_GP_SESSION_EVENT_EMERGENCY_STOP_REVOKED_TO_FS
Definition
ab_gp_event.h:63
ab_gp_proc_emergency_stop_revoke
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.
Definition
ab_gp_proc_emergency_stop.c:75
ab_gp_proc_emergency_stop_issue_ues
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.
Definition
ab_gp_proc_emergency_stop.c:9
ab_gp_proc_emergency_stop_handle_ack
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).
Definition
ab_gp_proc_emergency_stop.c:56
ab_gp_proc_emergency_stop_issue_ces
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.
Definition
ab_gp_proc_emergency_stop.c:31
ab_gp_proc_emergency_stop.h
ERTMS Subset-026 ยง5.7 Emergency Stop Management Procedure.
ab_gp_ertms_emergency_stop_t::d_emergencystop_m
uint32_t d_emergencystop_m
Definition
ab_gp_ertms_types.h:160
ab_gp_ertms_emergency_stop_t::active
bool active
Definition
ab_gp_ertms_types.h:156
ab_gp_ertms_emergency_stop_t::is_conditional
bool is_conditional
Definition
ab_gp_ertms_types.h:157
ab_gp_ertms_emergency_stop_t::nid_em
uint8_t nid_em
Definition
ab_gp_ertms_types.h:158
ab_gp_ertms_emergency_stop_t::acknowledged
bool acknowledged
Definition
ab_gp_ertms_types.h:161
ab_gp_ertms_emergency_stop_t::ack_time_ms
uint32_t ack_time_ms
Definition
ab_gp_ertms_types.h:162
ab_gp_ertms_emergency_stop_t::d_ref_m
uint32_t d_ref_m
Definition
ab_gp_ertms_types.h:159
ab_gp_ertms_ma_record_t::has_active_ma
bool has_active_ma
Definition
ab_gp_ertms_types.h:108
ab_gp_ertms_train_context_t
Complete ERTMS state and procedure context for one train slot.
Definition
ab_gp_ertms_types.h:235
ab_gp_ertms_train_context_t::emergency_stop
ab_gp_ertms_emergency_stop_t emergency_stop
Definition
ab_gp_ertms_types.h:243
ab_gp_ertms_train_context_t::train_data
ab_gp_ertms_train_data_t train_data
Definition
ab_gp_ertms_types.h:240
ab_gp_ertms_train_context_t::ma
ab_gp_ertms_ma_record_t ma
Definition
ab_gp_ertms_types.h:241
ab_gp_ertms_train_data_t::valid
bool valid
Definition
ab_gp_ertms_types.h:82
src
application
AB
GP
ertms_procedures
ab_gp_proc_emergency_stop.c
Generated by
1.18.0