33 uint8_t emergency_stop;
35 uint32_t timestamp_ms;
37 uint32_t sequence_number;
43 uint32_t process_a_seq;
44 uint32_t process_b_seq;
45 volatile uint8_t ready_a;
46 volatile uint8_t ready_b;
47 volatile uint8_t process_a_healthy;
48 volatile uint8_t process_b_healthy;
49 uint32_t timestamp_ms;
52__attribute__((aligned(64)))
62 uint32_t voter_sequence;
63 char log_message[256];
66__attribute__((aligned(64)))
67static voted_result_t voted_result = {0};
74 uint32_t total_results;
78 uint32_t process_a_errors;
79 uint32_t process_b_errors;
88int main(
int argc,
char *argv[])
93 uint32_t cycle_count = 0;
94 uint32_t last_voter_seq = 0;
97 printf(
"╔════════════════════════════════════════════════════════════╗\n");
98 printf(
"║ WEST Site - Process C (Non-Vital Service Channel) ║\n");
99 printf(
"║ Displays voting results and diagnostics ║\n");
100 printf(
"╚════════════════════════════════════════════════════════════╝\n");
107 uint8_t process_a_healthy = shared_mem.process_a_healthy;
108 uint8_t process_b_healthy = shared_mem.process_b_healthy;
110 if (!process_a_healthy) {
111 stats.process_a_errors++;
112 printf(
"[WEST:C] ⚠️ Process A is NOT RESPONDING\n");
115 if (!process_b_healthy) {
116 stats.process_b_errors++;
117 printf(
"[WEST:C] ⚠️ Process B is NOT RESPONDING\n");
121 if (voted_result.voter_sequence != last_voter_seq) {
122 stats.total_results++;
123 last_voter_seq = voted_result.voter_sequence;
126 switch (voted_result.vote_result) {
139 printf(
"[WEST:C] Cycle %u: ", cycle_count);
140 printf(
"%s\n", voted_result.log_message);
141 printf(
" → Signal=%u, Speed=%u km/h, EmergencyStop=%u\n",
142 voted_result.voted_command.signal_state,
143 voted_result.voted_command.speed_limit,
144 voted_result.voted_command.emergency_stop);
148 if ((cycle_count % 20) == 0) {
150 printf(
"┌────── WEST:C Statistics ──────┐\n");
151 printf(
"│ Total results: %u\n", stats.total_results);
152 printf(
"│ Matches: %u (%.0f%%)\n", stats.matches,
153 stats.total_results > 0 ?
154 (100.0 * stats.matches / stats.total_results) : 0.0);
155 printf(
"│ Mismatches: %u\n", stats.mismatches);
156 printf(
"│ Timeouts: %u\n", stats.timeouts);
157 printf(
"│ Process A err: %u\n", stats.process_a_errors);
158 printf(
"│ Process B err: %u\n", stats.process_b_errors);
159 printf(
"│ A healthy: %s, B healthy: %s\n",
160 process_a_healthy ?
"YES" :
"NO ",
161 process_b_healthy ?
"YES" :
"NO ");
162 printf(
"└───────────────────────────────┘\n");