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_handover.c
Go to the documentation of this file.
1
5
6
#include "
ab_gp_proc_handover.h
"
7
#include "rte/oal/memory/rte_mem_util.h"
8
9
/* REQ-ID: RBC_ERTMS_HO_001 - Handover Context Initialization */
10
void
ab_gp_proc_handover_init
(
ab_gp_ertms_train_context_t
*ctx)
11
{
12
if
(ctx == NULL)
13
{
14
return
;
15
}
16
17
ctx->
handover
.
state
=
AB_GP_HANDOVER_STATE_NONE
;
18
ctx->
handover
.
target_nid_c
= 0U;
19
ctx->
handover
.
target_nid_rbc
= 0U;
20
ctx->
handover
.
target_nid_radio
= 0ULL;
21
ctx->
handover
.
d_rbctr_m
= 0U;
22
ctx->
handover
.
order_sent
=
false
;
23
}
24
25
/* REQ-ID: RBC_ERTMS_HO_002 - Announce Handover Boundary */
26
bool
ab_gp_proc_handover_announce
(
ab_gp_ertms_train_context_t
*ctx,
27
uint16_t target_nid_c,
28
uint16_t target_nid_rbc,
29
uint64_t target_nid_radio,
30
uint32_t d_rbctr_m)
31
{
32
if
((ctx == NULL) || (target_nid_rbc == 0U))
33
{
34
return
false
;
35
}
36
37
ctx->
handover
.
state
=
AB_GP_HANDOVER_STATE_ANNOUNCED
;
38
ctx->
handover
.
target_nid_c
= target_nid_c;
39
ctx->
handover
.
target_nid_rbc
= target_nid_rbc;
40
ctx->
handover
.
target_nid_radio
= target_nid_radio;
41
ctx->
handover
.
d_rbctr_m
= d_rbctr_m;
42
ctx->
handover
.
order_sent
=
false
;
43
44
return
true
;
45
}
46
47
/* REQ-ID: RBC_ERTMS_HO_003 - Packet 131 Generation */
48
bool
ab_gp_proc_handover_generate_packet_131
(
ab_gp_ertms_train_context_t
*ctx,
49
rbc_packet_131_rbc_transition_t
*out_p131)
50
{
51
if
((ctx == NULL) || (out_p131 == NULL))
52
{
53
return
false
;
54
}
55
56
if
((ctx->
handover
.
state
!=
AB_GP_HANDOVER_STATE_ANNOUNCED
) &&
57
(ctx->
handover
.
state
!=
AB_GP_HANDOVER_STATE_ORDERED
))
58
{
59
return
false
;
60
}
61
62
out_p131->
d_rbctr
= ctx->
handover
.
d_rbctr_m
;
63
out_p131->
nid_c
= ctx->
handover
.
target_nid_c
;
64
out_p131->
nid_rbc
= ctx->
handover
.
target_nid_rbc
;
65
out_p131->
nid_radio
= ctx->
handover
.
target_nid_radio
;
66
out_p131->
q_sleepingsession
=
false
;
67
68
ctx->
handover
.
state
=
AB_GP_HANDOVER_STATE_ORDERED
;
69
ctx->
handover
.
order_sent
=
true
;
70
71
return
true
;
72
}
73
74
/* REQ-ID: RBC_ERTMS_HO_004 - Handover Completion */
75
bool
ab_gp_proc_handover_complete
(
ab_gp_ertms_train_context_t
*ctx)
76
{
77
if
(ctx == NULL)
78
{
79
return
false
;
80
}
81
82
ctx->
handover
.
state
=
AB_GP_HANDOVER_STATE_COMPLETED
;
83
return
true
;
84
}
85
86
/* REQ-ID: RBC_ERTMS_HO_005 - Handover State Query */
87
ab_gp_ertms_handover_state_t
ab_gp_proc_handover_get_state
(
const
ab_gp_ertms_train_context_t
*ctx)
88
{
89
if
(ctx == NULL)
90
{
91
return
AB_GP_HANDOVER_STATE_NONE
;
92
}
93
94
return
ctx->
handover
.
state
;
95
}
96
ab_gp_proc_handover_init
void ab_gp_proc_handover_init(ab_gp_ertms_train_context_t *ctx)
Initializes handover context for a train slot.
Definition
ab_gp_proc_handover.c:10
ab_gp_proc_handover_announce
bool ab_gp_proc_handover_announce(ab_gp_ertms_train_context_t *ctx, uint16_t target_nid_c, uint16_t target_nid_rbc, uint64_t target_nid_radio, uint32_t d_rbctr_m)
Announces an upcoming boundary transition to a neighboring RBC.
Definition
ab_gp_proc_handover.c:26
ab_gp_proc_handover_get_state
ab_gp_ertms_handover_state_t ab_gp_proc_handover_get_state(const ab_gp_ertms_train_context_t *ctx)
Returns current handover state for a train.
Definition
ab_gp_proc_handover.c:87
ab_gp_proc_handover_complete
bool ab_gp_proc_handover_complete(ab_gp_ertms_train_context_t *ctx)
Completes the handover and marks session transferred.
Definition
ab_gp_proc_handover.c:75
ab_gp_proc_handover_generate_packet_131
bool ab_gp_proc_handover_generate_packet_131(ab_gp_ertms_train_context_t *ctx, rbc_packet_131_rbc_transition_t *out_p131)
Generates an ERTMS Packet 131 (RBC transition order) payload.
Definition
ab_gp_proc_handover.c:48
ab_gp_proc_handover.h
ERTMS Subset-026 ยง5.11 RBC-to-RBC Handover Procedure (Packet 131).
ab_gp_ertms_handover_state_t
ab_gp_ertms_handover_state_t
Handover execution state machine.
Definition
ab_gp_ertms_types.h:207
AB_GP_HANDOVER_STATE_ORDERED
@ AB_GP_HANDOVER_STATE_ORDERED
Definition
ab_gp_ertms_types.h:210
AB_GP_HANDOVER_STATE_ANNOUNCED
@ AB_GP_HANDOVER_STATE_ANNOUNCED
Definition
ab_gp_ertms_types.h:209
AB_GP_HANDOVER_STATE_NONE
@ AB_GP_HANDOVER_STATE_NONE
Definition
ab_gp_ertms_types.h:208
AB_GP_HANDOVER_STATE_COMPLETED
@ AB_GP_HANDOVER_STATE_COMPLETED
Definition
ab_gp_ertms_types.h:211
ab_gp_ertms_handover_record_t::d_rbctr_m
uint32_t d_rbctr_m
Definition
ab_gp_ertms_types.h:223
ab_gp_ertms_handover_record_t::target_nid_rbc
uint16_t target_nid_rbc
Definition
ab_gp_ertms_types.h:221
ab_gp_ertms_handover_record_t::target_nid_c
uint16_t target_nid_c
Definition
ab_gp_ertms_types.h:220
ab_gp_ertms_handover_record_t::order_sent
bool order_sent
Definition
ab_gp_ertms_types.h:224
ab_gp_ertms_handover_record_t::state
ab_gp_ertms_handover_state_t state
Definition
ab_gp_ertms_types.h:219
ab_gp_ertms_handover_record_t::target_nid_radio
uint64_t target_nid_radio
Definition
ab_gp_ertms_types.h:222
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::handover
ab_gp_ertms_handover_record_t handover
Definition
ab_gp_ertms_types.h:248
rbc_packet_131_rbc_transition_t
Definition
ab_gp_ertms_train_packets.h:233
rbc_packet_131_rbc_transition_t::nid_rbc
uint16_t nid_rbc
Definition
ab_gp_ertms_train_packets.h:236
rbc_packet_131_rbc_transition_t::nid_c
uint16_t nid_c
Definition
ab_gp_ertms_train_packets.h:235
rbc_packet_131_rbc_transition_t::d_rbctr
rbc_distance_m_t d_rbctr
Definition
ab_gp_ertms_train_packets.h:234
rbc_packet_131_rbc_transition_t::nid_radio
uint64_t nid_radio
Definition
ab_gp_ertms_train_packets.h:237
rbc_packet_131_rbc_transition_t::q_sleepingsession
bool q_sleepingsession
Definition
ab_gp_ertms_train_packets.h:238
src
application
AB
GP
ertms_procedures
ab_gp_proc_handover.c
Generated by
1.18.0