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
redundancy_multi_site.h File Reference

Multi-Site 2oo2 Redundancy with Active/Standby Failover. More...

#include <stdint.h>
#include <stdbool.h>
Include dependency graph for redundancy_multi_site.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  train_command_t
struct  site_channels_t
struct  site_stats_t
struct  site_context_t
struct  multi_site_config_t
struct  multi_site_voter_t

Enumerations

enum  site_id_t { SITE_WEST = 0 , SITE_EAST = 1 }
enum  site_state_t { SITE_STATE_ONLINE = 0 , SITE_STATE_STANDBY = 1 , SITE_STATE_ISOLATED = 2 , SITE_STATE_FAULTY = 3 }

Functions

int multi_site_voter_init (multi_site_voter_t *voter, const multi_site_config_t *config)
 Initialize multi-site voter with West online, East standby.
int multi_site_vote_cycle (multi_site_voter_t *voter, site_id_t site, const train_command_t *cmd_a, const train_command_t *cmd_b)
 Process voting cycle on one site.
site_id_t multi_site_heartbeat (multi_site_voter_t *voter)
 Check heartbeat between sites and trigger failover if needed.
int multi_site_failover_request (multi_site_voter_t *voter, site_id_t new_active)
 Trigger manual failover (for maintenance).
int multi_site_get_active_command (multi_site_voter_t *voter, train_command_t *cmd_out)
 Get voted command from currently active site.
int multi_site_get_service_output (multi_site_voter_t *voter, char *output_buf, uint32_t buf_size)
 Get service output from active site (for printf, logging).
void multi_site_print_stats (const multi_site_voter_t *voter)
 Print multi-site statistics for diagnostics.
int multi_site_voter_shutdown (multi_site_voter_t *voter)
 Shutdown multi-site voter.

Detailed Description

Multi-Site 2oo2 Redundancy with Active/Standby Failover.

Implements geographic redundancy for railway control systems:

  • West site (ONLINE): Active processing channel
  • East site (STANDBY): Backup ready to take over
  • Each site has 2oo2 voting (channels A, B) + service channel C
  • Automatic failover on site failure

Typical deployment: ERTMS RBC with dual control centers

  • West: Primary RBC (Madrid)
  • East: Backup RBC (Barcelona) - standby, synced via heartbeat

Definition in file redundancy_multi_site.h.

Enumeration Type Documentation

◆ site_id_t

enum site_id_t

Definition at line 32 of file redundancy_multi_site.h.

◆ site_state_t

enum site_state_t

Definition at line 37 of file redundancy_multi_site.h.

Function Documentation

◆ multi_site_voter_init()

int multi_site_voter_init ( multi_site_voter_t * voter,
const multi_site_config_t * config )

Initialize multi-site voter with West online, East standby.

Parameters
voterMulti-site voter state
configConfiguration
Returns
0 if OK, -1 on error

Definition at line 138 of file redundancy_multi_site.c.

◆ multi_site_vote_cycle()

int multi_site_vote_cycle ( multi_site_voter_t * voter,
site_id_t site,
const train_command_t * cmd_a,
const train_command_t * cmd_b )

Process voting cycle on one site.

Each site independently:

  1. Receives/computes commands from channels A, B
  2. Votes (2oo2 comparison)
  3. Outputs result via service channel C
Parameters
voterMulti-site state
siteWhich site (WEST or EAST)
cmd_aChannel A command
cmd_bChannel B command
Returns
0 if voting OK, -1 on fatal error

Definition at line 173 of file redundancy_multi_site.c.

◆ multi_site_heartbeat()

site_id_t multi_site_heartbeat ( multi_site_voter_t * voter)

Check heartbeat between sites and trigger failover if needed.

Called periodically to:

  • Check if standby site is still responsive
  • Detect if active site has failed
  • Transition standby to ONLINE if active is down
Parameters
voterMulti-site state
Returns
SITE_WEST or SITE_EAST (current active site)

Definition at line 195 of file redundancy_multi_site.c.

◆ multi_site_failover_request()

int multi_site_failover_request ( multi_site_voter_t * voter,
site_id_t new_active )

Trigger manual failover (for maintenance).

Parameters
voterMulti-site state
new_activeNew active site
Returns
0 if OK

Allows graceful switchover without waiting for timeout. Example: "Switch to East for maintenance on West"

Definition at line 254 of file redundancy_multi_site.c.

◆ multi_site_get_active_command()

int multi_site_get_active_command ( multi_site_voter_t * voter,
train_command_t * cmd_out )

Get voted command from currently active site.

Parameters
voterMulti-site state
cmd_outReceives voted command
Returns
0 if OK

Definition at line 285 of file redundancy_multi_site.c.

◆ multi_site_get_service_output()

int multi_site_get_service_output ( multi_site_voter_t * voter,
char * output_buf,
uint32_t buf_size )

Get service output from active site (for printf, logging).

Parameters
voterMulti-site state
output_bufBuffer to receive output
buf_sizeSize of buffer
Returns
Number of bytes written

Definition at line 303 of file redundancy_multi_site.c.

◆ multi_site_print_stats()

void multi_site_print_stats ( const multi_site_voter_t * voter)

Print multi-site statistics for diagnostics.

Parameters
voterMulti-site state

Definition at line 324 of file redundancy_multi_site.c.

◆ multi_site_voter_shutdown()

int multi_site_voter_shutdown ( multi_site_voter_t * voter)

Shutdown multi-site voter.

Parameters
voterMulti-site state
Returns
0 if OK

Definition at line 364 of file redundancy_multi_site.c.