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

rte_appmanager_operations_t::pre_execute for the AB channel. More...

#include "ab_gp_channel_cycle_hooks.h"
#include <stdio.h>
#include <string.h>
#include "rte/oal/log/rte_log.h"
#include "rte/oal/memory/rte_mem_util.h"
#include "rte/utils/safestate/rte_safestate.h"
#include "rte/oal/timer/rte_timer.h"
#include "rte/redundancy/watchdog/rte_watchdog.h"
#include "../../common/common_config.h"
#include "../../common/site_config.h"
#include "../com/ab_gp_channel.h"
#include "../com/ab_gp_channel_crosscompare.h"
#include "../com/ab_gp_channel_stage.h"
#include "../com/ab_gp_channel_dual.h"
#include "../com/ab_gp_channel_negotiate.h"
#include "../com/ab_gp_channel_payload.h"
#include "../com/ab_gp_channel_types.h"
#include "../com/ab_gp_km114_client.h"
#include "../com/ab_gp_saf_train.h"
#include "../com/ab_gp_sibling_state.h"
#include "../train/ab_gp_train.h"
#include "../ertms_procedures/ab_gp_proc_dispatch.h"
#include "ab_gp_ga_hooks.h"
Include dependency graph for pre_execute.c:

Go to the source code of this file.

Data Structures

struct  relay_poll_context_t
struct  peer_poll_context_t

Functions

static uint32_t saf_now_ms (const ab_gp_channel_context_t *ctx)
 The channel's cycle clock in ms - the same time base ab_gp_proc_dispatch_train_inbound() is given.
static void saf_stage_to_train (ab_gp_channel_context_t *ctx, uint8_t train_id, const uint8_t *frame, size_t len)
 Stages a SaF frame for a train on the Train relay (committed with this cycle's other outputs, ADR-034).
static void saf_apply_result (ab_gp_channel_context_t *ctx, relay_poll_context_t *poll_ctx, uint8_t train_id, const ab_gp_saf_result_t *res)
 Acts on the outcome of one SaF frame (from the train or, for B, A's shared RB).
static void on_saf_envelope (relay_poll_context_t *poll_ctx, const uint8_t *bytes)
static void on_relay_envelope_received (void *user_ctx, rte_example_relay_kind_t kind, uint8_t index, const uint8_t *bytes)
static void on_crosscompare_frame_received (void *user_ctx, uint8_t kind, const uint8_t *payload, size_t size)
static void on_peer_frame_received (void *user_ctx, uint8_t kind, const uint8_t *payload, size_t size)
static void log_role_transition (ab_gp_channel_context_t *ctx, uint32_t cycle)
 Log and record an ONLINE/STANDBY role transition, if one happened this cycle.
static void decode_and_apply_peer_sample (ab_gp_channel_context_t *ctx, peer_poll_context_t *peer_poll)
 Decode this cycle's dual-transfer peer sample (if any) and apply it to ctx.
static void check_dual_transfer_timeout (ab_gp_channel_context_t *ctx, uint32_t cycle)
 Declare a dual-transfer loss if no peer sample has arrived within the configured timeout.
rte_status_t ab_gp_channel_pre_execute (void *context)

Detailed Description

rte_appmanager_operations_t::pre_execute for the AB channel.

Orchestrates gathering of cycle inputs from the environment and peer channel using pure transport polling and callbacks, conforming to Single Responsibility Principle (SRP) and CENELEC EN 50128 SIL 4.

Definition in file pre_execute.c.

Function Documentation

◆ saf_now_ms()

uint32_t saf_now_ms ( const ab_gp_channel_context_t * ctx)
static

The channel's cycle clock in ms - the same time base ab_gp_proc_dispatch_train_inbound() is given.

Definition at line 51 of file pre_execute.c.

◆ saf_stage_to_train()

void saf_stage_to_train ( ab_gp_channel_context_t * ctx,
uint8_t train_id,
const uint8_t * frame,
size_t len )
static

Stages a SaF frame for a train on the Train relay (committed with this cycle's other outputs, ADR-034).

Definition at line 57 of file pre_execute.c.

◆ saf_apply_result()

void saf_apply_result ( ab_gp_channel_context_t * ctx,
relay_poll_context_t * poll_ctx,
uint8_t train_id,
const ab_gp_saf_result_t * res )
static

Acts on the outcome of one SaF frame (from the train or, for B, A's shared RB).

Definition at line 71 of file pre_execute.c.

◆ on_saf_envelope()

void on_saf_envelope ( relay_poll_context_t * poll_ctx,
const uint8_t * bytes )
static

Definition at line 112 of file pre_execute.c.

◆ on_relay_envelope_received()

void on_relay_envelope_received ( void * user_ctx,
rte_example_relay_kind_t kind,
uint8_t index,
const uint8_t * bytes )
static

Definition at line 130 of file pre_execute.c.

◆ on_crosscompare_frame_received()

void on_crosscompare_frame_received ( void * user_ctx,
uint8_t kind,
const uint8_t * payload,
size_t size )
static

Definition at line 226 of file pre_execute.c.

◆ on_peer_frame_received()

void on_peer_frame_received ( void * user_ctx,
uint8_t kind,
const uint8_t * payload,
size_t size )
static

Definition at line 242 of file pre_execute.c.

◆ log_role_transition()

void log_role_transition ( ab_gp_channel_context_t * ctx,
uint32_t cycle )
static

Log and record an ONLINE/STANDBY role transition, if one happened this cycle.

Pure side effect (logging + ctx->was_online bookkeeping); does not change ctx->is_online itself, which is ab_gp_channel_negotiate_execute()'s decision.

Definition at line 319 of file pre_execute.c.

◆ decode_and_apply_peer_sample()

void decode_and_apply_peer_sample ( ab_gp_channel_context_t * ctx,
peer_poll_context_t * peer_poll )
static

Decode this cycle's dual-transfer peer sample (if any) and apply it to ctx.

A CRC-64 mismatch is a vital data-corruption event and enters SAFE state directly, matching the original inline behaviour exactly. Sets ctx->cyc_crc_ok, ctx->cyc_peer_sessions[], ctx->cyc_have_peer_data, ctx->cyc_peer_cycle and ctx->cyc_agree (always cleared here; the cross-comparator sets it later in the cycle).

Definition at line 344 of file pre_execute.c.

◆ check_dual_transfer_timeout()

void check_dual_transfer_timeout ( ab_gp_channel_context_t * ctx,
uint32_t cycle )
static

Declare a dual-transfer loss if no peer sample has arrived within the configured timeout.

Definition at line 396 of file pre_execute.c.

◆ ab_gp_channel_pre_execute()

rte_status_t ab_gp_channel_pre_execute ( void * context)

rte_appmanager_operations_t::pre_execute - see pre_execute.c.

Definition at line 413 of file pre_execute.c.