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

See gateway_c_selfstatus.h. More...

#include "gateway_c_selfstatus.h"
#include <stdio.h>
#include <string.h>
#include "rte/oal/log/rte_log.h"
#include "rte/oal/timer/rte_timer.h"
#include "rte/redundancy/channel_service/rte_channel_service.h"
#include "common/common_config.h"
#include "common/rbc_util_frame.h"
#include "common/site_config.h"
Include dependency graph for gateway_c_selfstatus.c:

Go to the source code of this file.

Functions

void gateway_c_selfstatus_init (const char *broker_channel_name)
 Setup the broker CONNECT link. broker_channel_name is one of "c-broker-train"/"-il"/"-ctc". Best-effort - a failure is logged, not fatal (status is non-safety).
void gateway_c_selfstatus_tick (const gateway_c_context_t *ctx, uint32_t cycle, const char *log_tag, uint8_t src_id)
 Call once per cycle. Every RTE_EXAMPLE_STATUS_PERIOD_MS (and on cycle 1) logs [unit] [-] [STATUS] [self] [unit=GW-<tag>/<site> up=1] and publishes the same payload to the broker.
void gateway_c_selfstatus_publish (uint8_t src_id, const char *payload)
 Republish a foreign unit's status to the C broker as a PUBLISH(STATUS) with source id src_id (rbc_util_source_t). Used by the train/il/ctc handlers to forward a sim's own-perspective status (RBC_MSG_SIM_STATUS, received on the sim link) into the broker. No-op when no broker link is set up or payload is NULL.
void gateway_c_selfstatus_shutdown (void)

Variables

static rte_channel_service_t s_broker
static bool s_have_broker
static rte_timestamp_ms_t s_last_ms
static uint8_t s_seq

Detailed Description

Function Documentation

◆ gateway_c_selfstatus_init()

void gateway_c_selfstatus_init ( const char * broker_channel_name)

Setup the broker CONNECT link. broker_channel_name is one of "c-broker-train"/"-il"/"-ctc". Best-effort - a failure is logged, not fatal (status is non-safety).

Definition at line 23 of file gateway_c_selfstatus.c.

◆ gateway_c_selfstatus_tick()

void gateway_c_selfstatus_tick ( const gateway_c_context_t * ctx,
uint32_t cycle,
const char * log_tag,
uint8_t src_id )

Call once per cycle. Every RTE_EXAMPLE_STATUS_PERIOD_MS (and on cycle 1) logs [unit] [-] [STATUS] [self] [unit=GW-<tag>/<site> up=1] and publishes the same payload to the broker.

Parameters
ctxGateway context (site + log tag via the def).
cycleThis service's cycle counter.
log_tagThe service's log tag ("TRAIN"/"IL"/"CTC").
src_idrbc_util_source_t for this service.

Definition at line 42 of file gateway_c_selfstatus.c.

◆ gateway_c_selfstatus_publish()

void gateway_c_selfstatus_publish ( uint8_t src_id,
const char * payload )

Republish a foreign unit's status to the C broker as a PUBLISH(STATUS) with source id src_id (rbc_util_source_t). Used by the train/il/ctc handlers to forward a sim's own-perspective status (RBC_MSG_SIM_STATUS, received on the sim link) into the broker. No-op when no broker link is set up or payload is NULL.

Definition at line 76 of file gateway_c_selfstatus.c.

◆ gateway_c_selfstatus_shutdown()

void gateway_c_selfstatus_shutdown ( void )

Definition at line 89 of file gateway_c_selfstatus.c.

Variable Documentation

◆ s_broker

rte_channel_service_t s_broker
static

Definition at line 18 of file gateway_c_selfstatus.c.

◆ s_have_broker

bool s_have_broker
static

Definition at line 19 of file gateway_c_selfstatus.c.

◆ s_last_ms

rte_timestamp_ms_t s_last_ms
static

Definition at line 20 of file gateway_c_selfstatus.c.

◆ s_seq

uint8_t s_seq
static

Definition at line 21 of file gateway_c_selfstatus.c.