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

N-way voting engine (ADR-025): validates parameters, dispatches send/receive to every registered healthy channel, and - for receive - groups the responses by mutual agreement and picks the largest group meeting quorum. More...

Include dependency graph for sapi_voter.c:

Go to the source code of this file.

Functions

static bool voter_channel_count_matches_strategy (const sapi_voter_t *voter)
static uint32_t voter_required_quorum (const sapi_voter_t *voter)
static bool voter_data_equal (const sapi_voter_t *voter, const void *a, const void *b, size_t size)
static uint32_t voter_count_healthy (const sapi_voter_t *voter)
sapi_status_t sapi_voter_init (sapi_voter_storage_t *storage, const sapi_voter_config_t *config)
 Initializes a voter with zero registered channels.
sapi_status_t sapi_voter_register_channel (sapi_voter_t *voter, sapi_channel_t *channel)
 Registers one already-initialized channel with this voter.
sapi_status_t sapi_voter_send (sapi_voter_t *voter, const void *data, size_t data_size)
 Broadcasts data to every registered, healthy channel.
sapi_status_t sapi_voter_receive (sapi_voter_t *voter, void *data, size_t data_size, sapi_voting_result_t *result, size_t *bytes_received)
 Receives from every registered, healthy channel and votes.
sapi_status_t sapi_voter_get_aggregated_health (const sapi_voter_t *voter, uint32_t *healthy_count, uint32_t *total_disagreements)
 Aggregated health across every registered channel.
uint32_t sapi_voter_get_channel_count (const sapi_voter_t *voter)
 Number of channels currently registered with this voter.
sapi_channel_tsapi_voter_get_channel (const sapi_voter_t *voter, uint32_t index)
 Direct access to one registered channel, by index.
sapi_channel_tsapi_voter_get_channel_by_name (const sapi_voter_t *voter, const char *name)
 Direct access to one registered channel, by name (e.g. "ChannelAtoB") - the name each channel was given via sapi_channel_config_t::name at its own sapi_channel_init() time.
sapi_status_t sapi_voter_destroy (sapi_voter_t *voter)
 Destroys a voter instance.

Detailed Description

N-way voting engine (ADR-025): validates parameters, dispatches send/receive to every registered healthy channel, and - for receive - groups the responses by mutual agreement and picks the largest group meeting quorum.

Definition in file sapi_voter.c.

Function Documentation

◆ voter_channel_count_matches_strategy()

bool voter_channel_count_matches_strategy ( const sapi_voter_t * voter)
static

Definition at line 16 of file sapi_voter.c.

◆ voter_required_quorum()

uint32_t voter_required_quorum ( const sapi_voter_t * voter)
static

Definition at line 40 of file sapi_voter.c.

◆ voter_data_equal()

bool voter_data_equal ( const sapi_voter_t * voter,
const void * a,
const void * b,
size_t size )
static

Definition at line 65 of file sapi_voter.c.

◆ voter_count_healthy()

uint32_t voter_count_healthy ( const sapi_voter_t * voter)
static

Definition at line 80 of file sapi_voter.c.