14#include "rte/app/appmanager/rte_appmanager.h"
15#include "rte/oal/log/rte_log.h"
16#include "rte/redundancy/watchdog/rte_watchdog.h"
43 rte_status_t stage_status;
49 RTE_CHECKPOINT_MARK();
51 if (stage_status == RTE_STATUS_OK)
53 RTE_EXAMPLE_LOG(
"[%s] cycle %u: dual transfer staged sample (%zu bytes) for peer\n",
54 ctx->
role_tag, cycle,
sizeof(out_bytes));
56 ctx->
is_role_a ?
"B" :
"A",
"DUAL_TRANSFER",
"sample staged for peer",
"size=343");
95 bool should_forward_to_c;
103 if (!should_forward_to_c)
153 for (k = 0U; k < train_count; k++)
155 RTE_CHECKPOINT_MARK();
159 for (k = 0U; k < ctc_count; k++)
161 RTE_CHECKPOINT_MARK();
165 for (k = 0U; k < il_count; k++)
167 RTE_CHECKPOINT_MARK();
179 if (train_count > 0U || ctc_count > 0U || il_count > 0U)
181 char extra_payload[96];
182 (void)snprintf(extra_payload,
sizeof(extra_payload),
"train_count=%u ctc_count=%u il_count=%u",
183 (
unsigned int)train_count, (
unsigned int)ctc_count, (
unsigned int)il_count);
184 RTE_EXAMPLE_LOG(
"[%s] cycle %u: staged outputs for C (train=%u, ctc=%u, il=%u)\n",
185 ctx->
role_tag, cycle, (
unsigned int)train_count, (
unsigned int)ctc_count, (
unsigned int)il_count);
187 "OUTPUT_FORWARD",
"staged outputs for C", extra_payload);
216 return RTE_STATUS_INVALID_PARAM;
234 (void)rte_watchdog_kick(ctx->
watchdog);
241 return RTE_STATUS_OK;
259 return RTE_STATUS_INVALID_PARAM;
268 return RTE_STATUS_OK;
rte_status_t ab_gp_channel_send_peer(ab_gp_channel_handle_t handle, const uint8_t *bytes, size_t size)
Sends a frame over the A<->B peer channel.
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.
Shared declarations for the four rte_appmanager_operations_t cyclic-executive hooks this component's ...
rte_status_t ab_gp_channel_post_execute(void *context)
rte_status_t ab_gp_channel_on_checkpoint_result(void *context, bool committed)
rte_appmanager_operations_t::on_checkpoint_result for the AB channel (ADR-034) - flushes or discards ...
void ab_gp_channel_negotiate_sync_standby(ab_gp_channel_context_t *ctx, uint32_t cycle)
ONLINE only: send this cycle's post-compute snapshot to STANDBY and wait (bounded by the link's ack t...
This channel's own West<->East inter-site negotiation link - see ab_gp_channel.c's file header for ho...
void ab_gp_channel_payload_encode_ab_sample(uint8_t out[AB_SAMPLE_WIRE_SIZE], uint32_t cycle, const void *const sources[AB_GP_CHANNEL_PAYLOAD_MAX_COLLECTORS])
Encodes an A<->B peer-link sample: {cycle, every registered collector's own bytes in registration ord...
Generic, data-blind wire framing for the A<->B peer link's AB_SAMPLE frame (CRC-64-protected,...
#define AB_GP_CHANNEL_PAYLOAD_MAX_COLLECTORS
void ab_gp_channel_discard_pending_sends(ab_gp_channel_handle_t handle)
Discards every send queued this cycle without transmitting it, then clears the queue.
rte_status_t ab_gp_channel_stage_crosscompare(ab_gp_channel_handle_t handle, uint8_t kind, const uint8_t *payload, size_t size)
Queues a crosscompare-link send for this cycle - does not transmit yet.
rte_status_t ab_gp_channel_commit_pending_sends(ab_gp_channel_handle_t handle)
Transmits every send queued this cycle (through the real ab_gp_channel_send_peer()/_send_relay()),...
rte_status_t ab_gp_channel_stage_relay(ab_gp_channel_handle_t handle, rte_example_relay_kind_t kind, uint8_t index, const uint8_t *bytes, size_t size)
Queues a relay-link send for this cycle - does not transmit yet.
Stage-then-commit output queue for this cycle's own DECISION output (ADR-034): the peer AB_SAMPLE and...
Modular type definitions for AB channel components (Com, Train, DB, Redundancy).
#define PEER_WIRE_FRAME_SIZE
#define PEER_MSG_KIND_AB_SAMPLE
#define PEER_MSG_KIND_SITE_STATE
uint8_t ab_gp_drain_ctc_outputs(ab_gp_ctc_pending_output_t out[AB_GP_CTC_MAX_PENDING_OUTPUTS])
Calls the registered CTC output producer, if any - see ab_gp_register_ctc_output_producer()'s own doc...
void ab_gp_confirm_il_outputs_sent(void)
Calls the registered IL output producer's own confirm callback, if any - see ab_gp_il_output_confirm_...
void ab_gp_confirm_ctc_outputs_sent(void)
Calls the registered CTC output producer's own confirm callback, if any - same contract as ab_gp_conf...
uint8_t ab_gp_drain_il_outputs(ab_gp_il_pending_output_t out[AB_GP_IL_MAX_PENDING_OUTPUTS])
Calls the registered IL output producer, if any - see ab_gp_register_il_output_producer()'s own doc,...
GP's own dispatch side of the "GP calls into GA" surface - see ga_interface.h's own "functions GP cal...
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...
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...
ADR-038: this A/B channel's periodic status - a self log line plus a PUBLISH(STATUS) rbc_util_frame_t...
uint8_t ab_gp_train_build_outputs(const ab_gp_train_session_t sessions[], const uint32_t cyc_msg_type_due[], const bool cyc_position_reply_due[], ab_gp_train_pending_output_t out[AB_GP_TRAIN_MAX_PENDING_OUTPUTS])
Decides which trains need a Train-directed envelope THIS cycle and builds all of them - see this file...
uint32_t ab_gp_train_payload_collector_id(void)
A/B's own train lifecycle handling against db/'s runtime table.
#define AB_GP_TRAIN_MAX_PENDING_OUTPUTS
#define RTE_EXAMPLE_LOG(...)
#define RTE_EXAMPLE_SINGLE_MODE_FLAG_DUAL
#define RBC_ENVELOPE_WIRE_SIZE
#define RTE_EXAMPLE_MAX_TRAINS
#define RTE_EXAMPLE_SINGLE_MODE_FLAG_SINGLE
#define AB_GP_IL_MAX_PENDING_OUTPUTS
#define AB_GP_CTC_MAX_PENDING_OUTPUTS
static void send_site_state(ab_gp_channel_context_t *ctx, ab_gp_channel_handle_t handle)
Step 4: send site state - protocol/negotiation-level state echo, not this cycle's own decision output...
static void build_and_stage_outputs_to_c(ab_gp_channel_context_t *ctx, ab_gp_channel_handle_t handle, uint32_t cycle)
Step 3: build this cycle's train/CTC/IL outputs and, if agreed (or single mode), stage them to C.
static void send_il_keepalive_if_online(ab_gp_channel_context_t *ctx, ab_gp_channel_handle_t handle)
Step 2: send IL keepalives if online - link-liveness traffic, not this cycle's own decision output,...
static void stage_peer_sample_if_online(ab_gp_channel_context_t *ctx, ab_gp_channel_handle_t handle, uint32_t cycle)
Step 1: stage this cycle's dual-transfer sample for the peer, if online.
static void rbc_envelope_write_keepalive(uint8_t out[RBC_ENVELOPE_WIRE_SIZE])
Fills out with a keepalive frame (RBC_MSG_RELAY_KEEPALIVE in byte 0, every other byte zero) - see tha...
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_CTC
@ RTE_EXAMPLE_RELAY_KIND_IL
@ RTE_EXAMPLE_RELAY_KIND_TRAIN
Central application context owned by composition root (main.c).
ab_gp_train_session_t sessions[RTE_EXAMPLE_MAX_TRAINS]
bool cyc_position_reply_due[RTE_EXAMPLE_MAX_TRAINS]
uint32_t cyc_msg_type_due[RTE_EXAMPLE_MAX_TRAINS]
bool cyc_have_channel_data
bool position_reply_pending
bool ctc_ma_notify_pending