SafeAPI RBC 2oo2 Generic Application
IL/CTC route and train logic for the safeAPIRBC2oo2 reference RBC
Loading...
Searching...
No Matches
ab_ga_ertms_il_interface.h
1
9
10#ifndef AB_GA_ERTMS_IL_INTERFACE_H
11#define AB_GA_ERTMS_IL_INTERFACE_H
12
13#include "../ab_ga_ertms_types.h"
14#include "ab_ga_ertms_il_types.h"
15
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/* ========================================================================= */
22/* Interlocking Vital Protocol Message Types */
23/* ========================================================================= */
24
25#define RBC_IL_MSG_KEEPALIVE_REQ 0x01U
26#define RBC_IL_MSG_KEEPALIVE_ACK 0x02U
27#define RBC_IL_MSG_ROUTE_STATUS_UPDATE 0x10U
28#define RBC_IL_MSG_TRACK_OCCUPANCY_UPDATE 0x11U
29#define RBC_IL_MSG_POINT_STATUS_UPDATE 0x12U
30#define RBC_IL_MSG_SIGNAL_ASPECT_UPDATE 0x13U
31#define RBC_IL_MSG_LX_STATUS_UPDATE 0x14U
32#define RBC_IL_MSG_EMERGENCY_STOP_COMMAND 0x1FU
33
34#define RBC_IL_MSG_TRAIN_FOOTPRINT_UPDATE 0x20U
35#define RBC_IL_MSG_SECTION_RELEASE_REQUEST 0x21U
36#define RBC_IL_MSG_MA_CONFIRMATION 0x22U
37#define RBC_IL_MSG_EMERGENCY_STOP_ACK 0x2FU
38
39/* ========================================================================= */
40/* Vital Message Header (EN 50159 / SIL 4 Safety Envelope) */
41/* ========================================================================= */
42typedef struct rbc_il_header_s
43{
44 rbc_nid_ixl_t nid_ixl;
45 rbc_nid_rbc_t nid_rbc;
46 uint32_t sequence_number;
47 rbc_timestamp_ms_t timestamp_ms;
48 uint8_t msg_type;
50
51/* ========================================================================= */
52/* Interlocking -> RBC Inbound Messages */
53/* ========================================================================= */
54
55typedef struct rbc_il_msg_route_status_s
56{
57 rbc_il_header_t header;
60
61typedef struct rbc_il_msg_track_occupancy_s
62{
63 rbc_il_header_t header;
64 uint8_t count;
65 rbc_il_section_status_t sections[RBC_IL_MAX_ROUTE_SECTIONS];
67
68typedef struct rbc_il_msg_point_status_s
69{
70 rbc_il_header_t header;
73
74typedef struct rbc_il_msg_signal_aspect_s
75{
76 rbc_il_header_t header;
79
80typedef struct rbc_il_msg_lx_status_s
81{
82 rbc_il_header_t header;
85
86typedef struct rbc_il_msg_emergency_stop_s
87{
88 rbc_il_header_t header;
89 rbc_nid_section_t section_id;
90 bool all_tracks;
92
93typedef struct rbc_il_msg_keepalive_s
94{
95 rbc_il_header_t header;
97
98/* ========================================================================= */
99/* RBC -> Interlocking Outbound Messages */
100/* ========================================================================= */
101
102typedef struct rbc_il_msg_train_footprint_s
103{
104 rbc_il_header_t header;
105 rbc_nid_engine_t nid_engine;
106 rbc_nid_section_t front_section;
107 rbc_nid_section_t rear_section;
108 bool train_integrity_confirmed;
110
111typedef struct rbc_il_msg_section_release_request_s
112{
113 rbc_il_header_t header;
114 rbc_nid_route_t route_id;
115 rbc_nid_section_t section_id;
116 rbc_nid_engine_t nid_engine;
118
119typedef struct rbc_il_msg_ma_confirmation_s
120{
121 rbc_il_header_t header;
122 rbc_nid_route_t route_id;
123 rbc_nid_engine_t nid_engine;
124 rbc_distance_m_t eoa_offset_m;
126
127/* ========================================================================= */
128/* Unified Generic Message Containers & Handlers */
129/* ========================================================================= */
130
131typedef struct rbc_il_inbound_msg_s
132{
133 uint8_t msg_type;
134 union
135 {
136 rbc_il_msg_keepalive_t keepalive;
137 rbc_il_msg_route_status_t route_status;
138 rbc_il_msg_track_occupancy_t track_occupancy;
139 rbc_il_msg_point_status_t point_status;
140 rbc_il_msg_signal_aspect_t signal_aspect;
141 rbc_il_msg_lx_status_t lx_status;
142 rbc_il_msg_emergency_stop_t emergency_stop;
143 } payload;
145
146typedef struct rbc_il_outbound_msg_s
147{
148 uint8_t msg_type;
149 union
150 {
151 rbc_il_msg_keepalive_t keepalive_ack;
152 rbc_il_msg_train_footprint_t train_footprint;
154 rbc_il_msg_ma_confirmation_t ma_confirmation;
155 } payload;
157
161typedef void (*rbc_il_on_message_received_fn)(const rbc_il_inbound_msg_t *msg, void *user_context);
162
166typedef int (*rbc_il_send_message_fn)(rbc_nid_ixl_t nid_ixl,
167 const rbc_il_outbound_msg_t *msg,
168 void *user_context);
169
170#ifdef __cplusplus
171}
172#endif
173
174#endif /* RBC_IL_INTERFACE_H */
rbc_timestamp_ms_t timestamp_ms