11#include "rte/oal/log/rte_log.h"
12#include "rte/redundancy/dual/rte_dual_negotiator.h"
19#define AB_GP_STATUS_EVERY_CYCLES \
20 ((uint32_t)RTE_EXAMPLE_STATUS_PERIOD_MS / (uint32_t)RTE_EXAMPLE_AB_CYCLE_PERIOD_MS)
43 rte_dual_state_t own_state;
44 rte_dual_state_t peer_state;
48 static uint32_t s_status_last_cycle = 0U;
61 s_status_last_cycle = cycle;
63 rte_site_role_get_negotiator_states(&ctx->
site_role, &own_state, &peer_state);
69 (void)snprintf(payload,
sizeof(payload),
70 "unit=%s up=1 role=%s site=%s other=%s peer=%d trains=%u single=%d",
73 rte_dual_state_to_string(own_state),
74 rte_dual_state_to_string(peer_state),
82 uint32_t challenge = 0U;
83 size_t used = strlen(payload);
85 if (rte_site_role_takeover_challenge(&ctx->
site_role, &challenge))
87 (void)snprintf(&payload[used],
sizeof(payload) - used,
" tko=%08x", (
unsigned int)challenge);
94 size_t used = strlen(payload);
102 "STATUS",
"self", payload);
rte_status_t ab_gp_channel_send_relay(ab_gp_channel_handle_t handle, rte_example_relay_kind_t kind, uint8_t index, const uint8_t *bytes, size_t size)
Sends an envelope over a specific C relay channel.
struct ab_gp_channel_context_s * ab_gp_channel_handle_t
Opaque handle over this component's own static per-process context.
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)
The site status monitor: collects, in one struct, the facts that decide and explain this channel's si...
static uint8_t connected_train_count(const ab_gp_channel_context_t *ctx)
void ab_gp_status_tick(ab_gp_channel_handle_t handle, const ab_gp_channel_context_t *ctx, uint32_t cycle)
Call once per cyclic-executive cycle from post_execute. Emits a status self line and publishes a STAT...
#define AB_GP_STATUS_EVERY_CYCLES
ADR-038: this A/B channel's periodic status - a self log line plus a PUBLISH(STATUS) rbc_util_frame_t...
#define RTE_EXAMPLE_MAX_TRAINS
ADR-038: the wire frame for the A/B<->C util side channel (RTE_EXAMPLE_RELAY_KIND_UTIL) and the C-sid...
static void rbc_util_frame_encode(uint8_t out[RBC_UTIL_FRAME_SIZE], rbc_util_msg_type_t msg_type, uint8_t source_id, uint16_t topic_id, uint8_t seq, const char *payload)
Encodes a util frame into a fixed RBC_UTIL_FRAME_SIZE buffer.
#define RBC_UTIL_FRAME_SIZE
#define RBC_UTIL_PAYLOAD_MAX
#define RBC_UTIL_TOPIC_STATUS
Topic ids (byte 2..3).
const char * site_config_name(rte_example_site_t site)
West/East site identity and the per-site config derived from it (ports, container host lookup) - see ...
@ RTE_EXAMPLE_RELAY_KIND_UTIL
Central application context owned by composition root (main.c).
rte_site_role_t site_role
ab_gp_train_session_t sessions[RTE_EXAMPLE_MAX_TRAINS]
uint32_t last_peer_sample_cycle