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_election.c File Reference

See rte_election.h. More...

#include "rte/redundancy/election/rte_election.h"
#include <stddef.h>
Include dependency graph for rte_election.c:

Go to the source code of this file.

Functions

static bool find_own_index (const rte_election_candidate_t *candidates, uint32_t candidate_count, uint32_t own_id, uint32_t *out_index)
static uint32_t find_winner_index (const rte_election_candidate_t *candidates, uint32_t candidate_count)
rte_status_t rte_election_init (rte_election_t *election, const rte_election_config_t *config)
 Initializes a rte_election_t. own_last_state starts at RTE_DUAL_STATE_IDLE (never yet evaluated).
rte_status_t rte_election_execute (rte_election_t *election, const rte_election_candidate_t *candidates, uint32_t candidate_count)
 Evaluates one round of election against the caller-supplied candidate snapshot (REQ-ELECTION-002 through -005). Empty snapshot (candidate_count == 0, or this instance's own_id not present in it) yields RTE_DUAL_STATE_UNKNOWN - no quorum to decide anything from, same "report, do not react" posture as rte_dual_negotiator_execute() on a lost peer.
rte_dual_state_t rte_election_get_own_state (const rte_election_t *election)
 Returns this instance's own current rte_dual_state_t, as of the last rte_election_execute() call.
rte_status_t rte_election_get_winner_id (const rte_election_t *election, uint32_t *out_id)
 Returns the last-elected winner's id.

Detailed Description

See rte_election.h.

Definition in file rte_election.c.

Function Documentation

◆ find_own_index()

bool find_own_index ( const rte_election_candidate_t * candidates,
uint32_t candidate_count,
uint32_t own_id,
uint32_t * out_index )
static

Local makros Local types declarations Local function declarations

Definition at line 108 of file rte_election.c.

◆ find_winner_index()

uint32_t find_winner_index ( const rte_election_candidate_t * candidates,
uint32_t candidate_count )
static

Definition at line 127 of file rte_election.c.