Safe API Framework
0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Toggle main menu visibility
Loading...
Searching...
No Matches
rte_election.h
Go to the documentation of this file.
1
48
#ifndef RTE_ELECTION_H
49
#define RTE_ELECTION_H
50
51
#include <stdbool.h>
52
#include <stdint.h>
53
54
#include "
rte/redundancy/config/rte_redundancy_config.h
"
55
#include "
rte/redundancy/dual/rte_dual_types.h
"
56
#include "
rte/utils/status/rte_status.h
"
57
58
#ifdef __cplusplus
59
extern
"C"
{
60
#endif
61
68
typedef
struct
69
{
73
uint32_t
id
;
76
uint64_t
startup_timestamp_ms
;
80
bool
degraded
;
81
}
rte_election_candidate_t
;
82
87
typedef
struct
rte_election_s
88
{
89
uint32_t own_id;
90
rte_dual_state_t
own_last_state;
91
92
uint32_t winner_id;
93
bool
have_winner;
94
}
rte_election_t
;
95
97
typedef
struct
98
{
104
uint32_t
own_id
;
105
}
rte_election_config_t
;
106
114
rte_status_t
rte_election_init
(
rte_election_t
*election,
const
rte_election_config_t
*config);
115
131
rte_status_t
rte_election_execute
(
rte_election_t
*election,
const
rte_election_candidate_t
*candidates,
132
uint32_t candidate_count);
133
141
rte_dual_state_t
rte_election_get_own_state
(
const
rte_election_t
*election);
142
151
rte_status_t
rte_election_get_winner_id
(
const
rte_election_t
*election, uint32_t *out_id);
152
153
#ifdef __cplusplus
154
}
155
#endif
156
157
#endif
/* RTE_ELECTION_H */
158
rte_dual_state_t
rte_dual_state_t
State of one instance in a dual (two-redundant-instance) relationship, as decided by rte_dual_negotia...
Definition
rte_dual_types.h:38
rte_election_get_own_state
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.
Definition
rte_election.c:83
rte_election_init
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).
Definition
rte_election.c:21
rte_election_get_winner_id
rte_status_t rte_election_get_winner_id(const rte_election_t *election, uint32_t *out_id)
Returns the last-elected winner's id.
Definition
rte_election.c:92
rte_election_execute
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 thro...
Definition
rte_election.c:36
rte_status_t
rte_status_t
Common result/status codes.
Definition
rte_status.h:27
rte_dual_types.h
Shared enums for the rte_dual module (ADR-020): dual-instance state negotiation and the redundant,...
rte_redundancy_config.h
Application-level redundancy topology configuration (2oo2 / 2oo2 with redundancy / 2oo3 / NMR),...
rte_status.h
Common status/error codes returned by every Safe API Framework function. Shared across all OS Abstrac...
rte_election_candidate_t
One candidate's info for one rte_election_execute() call. The caller builds this array fresh each cal...
Definition
rte_election.h:69
rte_election_candidate_t::startup_timestamp_ms
uint64_t startup_timestamp_ms
Definition
rte_election.h:76
rte_election_candidate_t::degraded
bool degraded
Definition
rte_election.h:80
rte_election_candidate_t::id
uint32_t id
Definition
rte_election.h:73
rte_election_config_t
Configuration for rte_election_init().
Definition
rte_election.h:98
rte_election_config_t::own_id
uint32_t own_id
Definition
rte_election.h:104
rte_election_t
One rte_election_t instance's state. Caller-owned storage; every field is private - reach it only thr...
Definition
rte_election.h:88
include
rte
redundancy
election
rte_election.h
Generated by
1.18.0