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.h
Go to the documentation of this file.
1
46#ifndef RTE_DUAL_NEGOTIATOR_H
47#define RTE_DUAL_NEGOTIATOR_H
48
49#include <stdbool.h>
50#include <stdint.h>
51
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
72 rte_dual_state_t old_own_state,
73 rte_dual_state_t new_peer_state,
74 rte_dual_state_t old_peer_state, void *user_ctx);
75
81typedef struct rte_dual_negotiator_s
82{
83 rte_dual_channel_t *channel;
84 uint32_t own_id;
85 uint32_t peer_id;
86 rte_duration_ms_t peer_lost_timeout_ms;
88 void *state_change_callback_ctx;
89
90 uint64_t own_startup_timestamp_ms;
91 bool own_channel_degraded;
92
93 bool have_peer_startup_timestamp;
94 uint64_t peer_startup_timestamp_ms;
95 bool peer_channel_degraded;
96
97 rte_dual_state_t own_state;
98 rte_dual_state_t peer_state;
99
100 bool have_last_peer_seen;
101 rte_timestamp_ms_t last_peer_seen_ms;
103
147
164 const rte_dual_negotiator_config_t *config);
165
215
223
232
244
254
262uint32_t rte_dual_negotiator_get_own_id(const rte_dual_negotiator_t *negotiator);
263
272
273#ifdef __cplusplus
274}
275#endif
276
277#endif /* RTE_DUAL_NEGOTIATOR_H */
278
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_n...
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)....
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)...
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.
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 cur...
void(*) rte_dual_negotiator_state_change_callback_t(rte_dual_state_t new_own_state, rte_dual_state_t old_own_state, rte_dual_state_t new_peer_state, rte_dual_state_t old_peer_state, void *user_ctx)
Optional callback invoked whenever either the own or the peer rte_dual_state_t changes,...
rte_dual_state_t
State of one instance in a dual (two-redundant-instance) relationship, as decided by rte_dual_negotia...
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,...
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.
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 ...
rte_status_t
Common result/status codes.
Definition rte_status.h:27
uint32_t rte_duration_ms_t
Definition rte_types.h:27
uint64_t rte_timestamp_ms_t
Definition rte_types.h:30
"DualChannel" layer of ADR-020: wraps 1..N redundant rte_dual_msgchannel_t links for fault-tolerant,...
Shared enums for the rte_dual module (ADR-020): dual-instance state negotiation and the redundant,...
Common status/error codes returned by every Safe API Framework function. Shared across all OS Abstrac...
Common fixed-width types and the caller-owned-storage handle pattern used by every OAL service (see A...
One rte_dual_channel_t instance's state. Caller-owned storage; every field is private - reach it only...
Configuration for rte_dual_negotiator_init().
rte_dual_negotiator_state_change_callback_t state_change_callback
One rte_dual_negotiator_t instance's state. Caller-owned storage; every field is private - reach it o...