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_site_status.c
Go to the documentation of this file.
1
5#include "ab_gp_site_status.h"
6
7#include <stdio.h>
8
10{
11 const bool relay_recent = (ctx->cyc_cycle >= ctx->last_relay_rx_cycle) && ((ctx->cyc_cycle - ctx->last_relay_rx_cycle) <= 10U) &&
12 (ctx->last_relay_rx_cycle > 0U);
13
14 /* The inter-site negotiation link is deliberately not part of readiness: a dispatcher-confirmed takeover happens
15 * exactly when that link is silent, and serving trains needs the Gateway relay, not the negotiation link. */
16 return relay_recent;
17}
18
20{
21 rte_site_role_status_t role;
22
23 rte_site_role_get_status(&ctx->site_role, &role);
24 out->role_online = ctx->is_online;
25 out->role_faulted = ctx->own_faulted;
26 out->link_up = role.link_up;
27 out->peer_answering = role.peer_answering;
28 out->peer_online_now = role.peer_online_now;
30 out->sibling_online = ctx->peer_site_state.known && (ctx->peer_site_state.bytes[0] != 0U);
31 out->standby_warm = role.standby_warm;
32 out->standby_healthy = role.standby_healthy;
33 out->last_reason = role.last_reason;
34 if (!ctx->is_online && !ctx->own_faulted && role.peer_unresponsive)
35 {
37 }
38 else if (!ctx->is_online && (role.last_reason == RTE_SITE_ROLE_REASON_WAITING_READY))
39 {
41 }
42 else if (!role.link_up)
43 {
45 }
46 else
47 {
49 }
50}
51
52size_t ab_gp_site_status_append_text(const ab_gp_site_status_t *st, char *buf, size_t size)
53{
54 const char *wait = "none";
55 int n;
56
58 {
59 wait = "dispatcher";
60 }
61 else if (st->waiting_for == AB_GP_SITE_WAIT_LINK)
62 {
63 wait = "link";
64 }
65 else if (st->waiting_for == AB_GP_SITE_WAIT_READY)
66 {
67 wait = "ready";
68 }
69 n = snprintf(buf, size, " site_wait=%s site_why=%s", wait, rte_site_role_reason_token(st->last_reason));
70 return ((n > 0) && ((size_t)n < size)) ? (size_t)n : 0U;
71}
size_t ab_gp_site_status_append_text(const ab_gp_site_status_t *st, char *buf, size_t size)
Appends " site_wait=<none|dispatcher|link> site_why=<short reason>" to a status payload.
void ab_gp_site_status_collect(const ab_gp_channel_context_t *ctx, ab_gp_site_status_t *out)
bool ab_gp_site_status_ready_for_online(const ab_gp_channel_context_t *ctx)
Whether this channel confirms it is ready to be ONLINE: the Gateway relay delivered a frame within th...
The site status monitor: collects, in one struct, the facts that decide and explain this channel's si...
@ AB_GP_SITE_WAIT_READY
@ AB_GP_SITE_WAIT_NOTHING
@ AB_GP_SITE_WAIT_DISPATCHER
@ AB_GP_SITE_WAIT_LINK
Central application context owned by composition root (main.c).
ab_gp_sibling_state_t peer_site_state
uint8_t bytes[RTE_EXAMPLE_AB_SITE_STATE_WIRE_SIZE]
rte_site_role_reason_t last_reason
ab_gp_site_wait_t waiting_for