Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
rte_dual_negotiator.c File Reference

Dual state negotiator of ADR-020 - see rte_dual_negotiator.h. More...

Include dependency graph for rte_dual_negotiator.c:

Go to the source code of this file.

Functions

static bool negotiator_decide_online (uint32_t own_id, uint64_t own_ts, uint32_t peer_id, uint64_t peer_ts)
 Older-timestamp-wins tie-break, own_id/peer_id as the deterministic fallback on an exact tie - same rule safeAPIRBC2oo2's site.c decide_online() uses today.
static void negotiator_process_peer_frame (rte_dual_negotiator_t *negotiator, const rte_dual_state_frame_t *frame)
static void negotiator_update_states (rte_dual_negotiator_t *negotiator)
rte_status_t rte_dual_negotiator_init (rte_dual_negotiator_t *negotiator, const rte_dual_negotiator_config_t *config)
 Initializes a rte_dual_negotiator_t. Captures this instance's own startup timestamp once (rte_timer_now(), degrading to 0 if no timer OSAdapter is registered - same best-effort posture as rte_log_write_event()'s Timestamp field) for use on every beacon this negotiator ever sends - see rte_dual_state_frame_t's own doc on why this must stay fixed - UNLESS config->resume_own_state/resume_own_startup_timestamp_ms opt into resuming a prior identity instead (see their own doc). peer_state always starts at RTE_DUAL_STATE_IDLE; own_state does too unless a resume was requested.
rte_status_t rte_dual_negotiator_execute (rte_dual_negotiator_t *negotiator, rte_duration_ms_t receive_timeout_ms)
 Drives one round of state negotiation: refreshes own_channel_degraded from the attached channel's current rte_dual_channel_get_status(), sends this instance's own beacon, drains and processes every currently-pending inbound STATE frame, then recomputes both own and peer rte_dual_state_t:
rte_dual_state_t rte_dual_negotiator_get_own_state (const rte_dual_negotiator_t *negotiator)
 Returns this instance's own current rte_dual_state_t.
rte_dual_state_t rte_dual_negotiator_get_peer_state (const rte_dual_negotiator_t *negotiator)
 Returns this instance's last-known view of the peer's rte_dual_state_t.
uint64_t rte_dual_negotiator_get_own_startup_timestamp_ms (const rte_dual_negotiator_t *negotiator)
 Returns this instance's own startup timestamp (captured at rte_dual_negotiator_init() time, or resumed from config - see rte_dual_negotiator_config_t::resume_own_startup_timestamp_ms). Diagnostic use (e.g. logging alongside the peer's own, below) - never itself consulted by this module's own tie-break logic after init.
uint64_t rte_dual_negotiator_get_peer_startup_timestamp_ms (const rte_dual_negotiator_t *negotiator)
 Returns this instance's last-known view of the peer's own startup timestamp (0/unset until the first valid STATE frame arrives). Diagnostic use only, same posture as rte_dual_negotiator_get_own_startup_timestamp_ms() above.
uint32_t rte_dual_negotiator_get_own_id (const rte_dual_negotiator_t *negotiator)
 Returns this instance's own tie-break identifier (rte_dual_negotiator_config_t::own_id at init time). Diagnostic use only.
uint32_t rte_dual_negotiator_get_peer_id (const rte_dual_negotiator_t *negotiator)
 Returns the expected peer's tie-break identifier (rte_dual_negotiator_config_t::peer_id at init time). Diagnostic use only.

Detailed Description

Dual state negotiator of ADR-020 - see rte_dual_negotiator.h.

Definition in file rte_dual_negotiator.c.

Function Documentation

◆ negotiator_decide_online()

bool negotiator_decide_online ( uint32_t own_id,
uint64_t own_ts,
uint32_t peer_id,
uint64_t peer_ts )
static

Older-timestamp-wins tie-break, own_id/peer_id as the deterministic fallback on an exact tie - same rule safeAPIRBC2oo2's site.c decide_online() uses today.

Definition at line 15 of file rte_dual_negotiator.c.

◆ negotiator_process_peer_frame()

void negotiator_process_peer_frame ( rte_dual_negotiator_t * negotiator,
const rte_dual_state_frame_t * frame )
static

Definition at line 24 of file rte_dual_negotiator.c.

◆ negotiator_update_states()

void negotiator_update_states ( rte_dual_negotiator_t * negotiator)
static

Definition at line 37 of file rte_dual_negotiator.c.