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_dispatch.c File Reference

See ab_gp_proc_dispatch.h. More...

#include "ab_gp_proc_dispatch.h"
#include "ab_gp_ertms_engine.h"
#include "../ertms/train/ab_gp_ertms_train_message_codec.h"
#include "../state_machines/ab_gp_dispatch.h"
#include "../com/ab_gp_channel.h"
#include "../com/ab_gp_channel_stage.h"
#include "../com/ab_gp_saf_train.h"
#include "../../common/common_config.h"
#include "../../common/rbc_wire_types.h"
#include "../../common/site_config.h"
#include "rte/oal/memory/rte_mem_util.h"
#include "rte/oal/log/rte_log.h"
Include dependency graph for ab_gp_proc_dispatch.c:

Go to the source code of this file.

Functions

static rbc_timestamp_ms_t inbound_t_train (const rbc_train_inbound_msg_t *in)
static bool build_and_stage_reply (ab_gp_channel_handle_t channel, uint8_t train_id, const rbc_train_outbound_msg_t *out_msg)
 Builds the RBC_MSG_ERTMS_ENVELOPE wire frame (2-byte kind+train_id prefix + the codec's own encoded bytes, zero-padded to the full fixed RBC_TRAIN_ENVELOPE_WIRE_SIZE slot - same "always the full fixed size, zero-padded past whatever's meaningful" convention the flat scheme's own train_wire_encode() already uses) and stages it.
static void build_config_msg_24 (rbc_msg_24_general_message_t *m24, rbc_nid_engine_t nid_engine)
 The one-time (per session) Msg 24 reply to Msg 155/136's own "confirm train data, inject config" step (FR-RBC-SOM-001/003).
static void handle_msg_155 (ab_gp_channel_handle_t channel, ab_gp_train_session_t *session, ab_gp_db_t *db, uint8_t train_id, ab_gp_ertms_train_context_t *ctx, const rbc_msg_155_init_session_t *m155, uint32_t cycle, uint32_t timestamp_ms)
static void handle_msg_129 (const rbc_msg_129_validated_train_data_t *m129, ab_gp_ertms_train_context_t *ctx, uint8_t train_id, uint32_t timestamp_ms)
static void handle_msg_130 (ab_gp_channel_handle_t channel, uint8_t train_id, ab_gp_ertms_train_context_t *ctx, const rbc_msg_130_request_for_shunting_t *m130, uint32_t cycle, uint32_t timestamp_ms)
 Msg 130 Request for Shunting (Subset-026 5.6): position update, decision (ab_gp_proc_shunting_handle_request()), then Msg 28 SH Authorised or Msg 27 SH Refused.
static void handle_msg_136 (ab_gp_channel_handle_t channel, ab_gp_train_session_t *session, ab_gp_db_t *db, uint8_t train_id, ab_gp_ertms_train_context_t *ctx, const rbc_msg_136_position_report_t *m136, uint32_t cycle, uint32_t timestamp_ms)
static void handle_msg_132 (ab_gp_channel_handle_t channel, ab_gp_train_session_t *session, ab_gp_db_t *db, uint8_t train_id, ab_gp_ertms_train_context_t *ctx)
bool ab_gp_proc_dispatch_train_inbound (ab_gp_channel_handle_t channel, ab_gp_train_session_t sessions[], ab_gp_db_t *db, uint8_t train_id, const uint8_t *payload, size_t payload_len, uint32_t cycle, uint32_t timestamp_ms)
 Decodes one RBC_MSG_ERTMS_ENVELOPE payload and dispatches it into the ertms_procedures/ engine, staging any resulting reply via ab_gp_channel_stage_relay() (ADR-034: staged, not sent - only actually transmitted once this cycle's A/B checkpoint agrees, same gate every other Train-channel send goes through).

Variables

static rbc_timestamp_ms_t s_reply_t_train = 0U

Detailed Description

Function Documentation

◆ inbound_t_train()

rbc_timestamp_ms_t inbound_t_train ( const rbc_train_inbound_msg_t * in)
static

Definition at line 28 of file ab_gp_proc_dispatch.c.

◆ build_and_stage_reply()

bool build_and_stage_reply ( ab_gp_channel_handle_t channel,
uint8_t train_id,
const rbc_train_outbound_msg_t * out_msg )
static

Builds the RBC_MSG_ERTMS_ENVELOPE wire frame (2-byte kind+train_id prefix + the codec's own encoded bytes, zero-padded to the full fixed RBC_TRAIN_ENVELOPE_WIRE_SIZE slot - same "always the full fixed size, zero-padded past whatever's meaningful" convention the flat scheme's own train_wire_encode() already uses) and stages it.

Returns
true if the codec accepted out_msg and the frame was queued; false on a codec encode failure or a full staging queue (ab_gp_channel_stage_relay()'s own return contract) - either way logged by the caller, never silently swallowed.

Definition at line 57 of file ab_gp_proc_dispatch.c.

◆ build_config_msg_24()

void build_config_msg_24 ( rbc_msg_24_general_message_t * m24,
rbc_nid_engine_t nid_engine )
static

The one-time (per session) Msg 24 reply to Msg 155/136's own "confirm train data, inject config" step (FR-RBC-SOM-001/003).

  • Packet 3 (National Values), Packet 57 (MA-request params), Packet 58 (position-report params). Values below are this project's own placeholder defaults (no real site-specific national-values source exists yet), not tied to site data, same posture ab_gp_proc_ma.c's own MA/gradient computation takes toward real route data vs. these still-fixed values.

Definition at line 101 of file ab_gp_proc_dispatch.c.

◆ handle_msg_155()

void handle_msg_155 ( ab_gp_channel_handle_t channel,
ab_gp_train_session_t * session,
ab_gp_db_t * db,
uint8_t train_id,
ab_gp_ertms_train_context_t * ctx,
const rbc_msg_155_init_session_t * m155,
uint32_t cycle,
uint32_t timestamp_ms )
static

Definition at line 125 of file ab_gp_proc_dispatch.c.

◆ handle_msg_129()

void handle_msg_129 ( const rbc_msg_129_validated_train_data_t * m129,
ab_gp_ertms_train_context_t * ctx,
uint8_t train_id,
uint32_t timestamp_ms )
static

Definition at line 177 of file ab_gp_proc_dispatch.c.

◆ handle_msg_130()

void handle_msg_130 ( ab_gp_channel_handle_t channel,
uint8_t train_id,
ab_gp_ertms_train_context_t * ctx,
const rbc_msg_130_request_for_shunting_t * m130,
uint32_t cycle,
uint32_t timestamp_ms )
static

Msg 130 Request for Shunting (Subset-026 5.6): position update, decision (ab_gp_proc_shunting_handle_request()), then Msg 28 SH Authorised or Msg 27 SH Refused.

Definition at line 188 of file ab_gp_proc_dispatch.c.

◆ handle_msg_136()

void handle_msg_136 ( ab_gp_channel_handle_t channel,
ab_gp_train_session_t * session,
ab_gp_db_t * db,
uint8_t train_id,
ab_gp_ertms_train_context_t * ctx,
const rbc_msg_136_position_report_t * m136,
uint32_t cycle,
uint32_t timestamp_ms )
static

Definition at line 212 of file ab_gp_proc_dispatch.c.

◆ handle_msg_132()

void handle_msg_132 ( ab_gp_channel_handle_t channel,
ab_gp_train_session_t * session,
ab_gp_db_t * db,
uint8_t train_id,
ab_gp_ertms_train_context_t * ctx )
static

Definition at line 286 of file ab_gp_proc_dispatch.c.

◆ ab_gp_proc_dispatch_train_inbound()

bool ab_gp_proc_dispatch_train_inbound ( ab_gp_channel_handle_t channel,
ab_gp_train_session_t sessions[],
ab_gp_db_t * db,
uint8_t train_id,
const uint8_t * payload,
size_t payload_len,
uint32_t cycle,
uint32_t timestamp_ms )

Decodes one RBC_MSG_ERTMS_ENVELOPE payload and dispatches it into the ertms_procedures/ engine, staging any resulting reply via ab_gp_channel_stage_relay() (ADR-034: staged, not sent - only actually transmitted once this cycle's A/B checkpoint agrees, same gate every other Train-channel send goes through).

Parameters
channelHandle to stage a reply through - see ab_gp_channel_stage_relay()'s own doc.
sessionsTrain sessions array to maintain 2oo2 crosscompare and CTC indications sync.
dbTrain/route database - route lookups for Msg 132's MA-request glue, same teardown primitives RBC_MSG_TRAIN_DISCONNECT's own handler already uses for Msg 156.
train_idThis wrapper's own train_id byte (session-slot index, 1..RTE_EXAMPLE_MAX_TRAINS) - NOT the codec's own decoded nid_engine field. See RBC_MSG_ERTMS_ENVELOPE's own doc for why routing uses the wrapper's byte, not an nid_engine lookup.
payloadThe codec's own frame, starting at its nid_message byte - the wrapper's 2-byte kind+train_id prefix already stripped by the caller.
payload_lenRemaining buffer length available to the codec (the fixed physical slot size minus the 2-byte prefix) - NOT how many bytes are "real"; the codec's own l_message header field says that.
cycleCurrent AB execution cycle (passed through to the engine - REQ-CHECKPOINT determinism: never derive this from wall-clock time here).
timestamp_msCurrent cycle timestamp in milliseconds.
Returns
true if a real, known nid_message was decoded and dispatched (whether or not a reply was warranted this cycle); false on a decode failure or an unrecognized nid_message - REQ-RBC-002: rejected and logged by the caller, never silently ignored.

Definition at line 390 of file ab_gp_proc_dispatch.c.

Variable Documentation

◆ s_reply_t_train

rbc_timestamp_ms_t s_reply_t_train = 0U
static

T_TRAIN for the replies to the train message being dispatched: the train's own time stamp from that message, not this channel's clock. Subset-026 track-to-train messages carry the onboard time reference; and both 2oo2 channels see the same train message, so their replies come out byte-identical - with each channel's own cycle clock they differed, which the gateway could not deduplicate and which a SaF-protected train rejects as a replayed sequence number. Set once per inbound message by ab_gp_proc_dispatch_train_inbound() (single-threaded, per channel).

Definition at line 26 of file ab_gp_proc_dispatch.c.