Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
sapi_dual_negotiator.h
Go to the documentation of this file.
1
46#ifndef SAPI_DUAL_NEGOTIATOR_H
47#define SAPI_DUAL_NEGOTIATOR_H
48
49#include <stdbool.h>
50#include <stdint.h>
51
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
72 sapi_dual_state_t old_own_state,
73 sapi_dual_state_t new_peer_state,
74 sapi_dual_state_t old_peer_state, void *user_ctx);
75
81typedef struct sapi_dual_negotiator_s
82{
83 sapi_dual_channel_t *channel;
84 uint32_t own_id;
85 uint32_t peer_id;
86 sapi_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 sapi_dual_state_t own_state;
98 sapi_dual_state_t peer_state;
99
100 bool have_last_peer_seen;
101 sapi_timestamp_ms_t last_peer_seen_ms;
103
130
144 const sapi_dual_negotiator_config_t *config);
145
195
203
212
213#ifdef __cplusplus
214}
215#endif
216
217#endif /* SAPI_DUAL_NEGOTIATOR_H */
218
sapi_dual_state_t sapi_dual_negotiator_get_own_state(const sapi_dual_negotiator_t *negotiator)
Returns this instance's own current sapi_dual_state_t.
void(*) sapi_dual_negotiator_state_change_callback_t(sapi_dual_state_t new_own_state, sapi_dual_state_t old_own_state, sapi_dual_state_t new_peer_state, sapi_dual_state_t old_peer_state, void *user_ctx)
Optional callback invoked whenever either the own or the peer sapi_dual_state_t changes,...
sapi_dual_state_t
State of one instance in a dual (two-redundant-instance) relationship, as decided by sapi_dual_negoti...
sapi_status_t sapi_dual_negotiator_execute(sapi_dual_negotiator_t *negotiator, sapi_duration_ms_t receive_timeout_ms)
Drives one round of state negotiation: refreshes own_channel_degraded from the attached channel's cur...
sapi_status_t sapi_dual_negotiator_init(sapi_dual_negotiator_t *negotiator, const sapi_dual_negotiator_config_t *config)
Initializes a sapi_dual_negotiator_t. Captures this instance's own startup timestamp once (sapi_timer...
sapi_dual_state_t sapi_dual_negotiator_get_peer_state(const sapi_dual_negotiator_t *negotiator)
Returns this instance's last-known view of the peer's sapi_dual_state_t.
sapi_status_t
Common result/status codes.
Definition sapi_status.h:27
uint32_t sapi_duration_ms_t
Definition sapi_types.h:27
uint64_t sapi_timestamp_ms_t
Definition sapi_types.h:30
"DualChannel" layer of ADR-020: wraps 1..N redundant sapi_dual_msgchannel_t links for fault-tolerant,...
Shared enums for the sapi_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 sapi_dual_channel_t instance's state. Caller-owned storage; every field is private - reach it onl...
Configuration for sapi_dual_negotiator_init().
sapi_dual_negotiator_state_change_callback_t state_change_callback
One sapi_dual_negotiator_t instance's state. Caller-owned storage; every field is private - reach it ...