Formula Student Electronics & Software
The code for the embedded software
Loading...
Searching...
No Matches
systemDiagnostics.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdlib>
4
5#include "Arduino.h"
6#include "debugUtils.hpp"
8#include "metro.h"
9
10struct R2DLogics {
12
16
20 bool r2d{false};
21
28 r2d = false;
29 }
30
35
44 // if 5 seconds have passed all good, VVVRRRUUUMMMMM
45 if (readyTimestamp.check()) {
46 r2d = true;
47 return;
48 }
49 r2d = false;
50 return;
51 }
52};
53
79
81 bool steer_dead_{false};
82 bool pc_dead_{false};
83 bool inversor_dead_{false};
84 bool res_dead_{false};
85 bool bms_dead_{false};
86
87 volatile bool emergency_signal_{false};
88 volatile bool ts_on_{false};
89 volatile double radio_quality_{0};
90 volatile unsigned dc_voltage_{0};
91
92 // Reference to the timestamp struct
94
95 // init ref
97
98 [[nodiscard]] bool has_any_component_timed_out() {
104
106 DEBUG_PRINT("=== System Component Status Check ===");
107 }
108 if (steer_dead_) {
109 DEBUG_PRINT("Steering System: " + String(steer_dead_ ? "DEAD" : "ALIVE"));
110 }
111 if (pc_dead_) {
112 DEBUG_PRINT("PC Connection: " + String(pc_dead_ ? "DEAD" : "ALIVE"));
113 }
114 if (inversor_dead_) {
115 DEBUG_PRINT("Inverter Status: " + String(inversor_dead_ ? "DEAD" : "ALIVE"));
116 }
117 if (res_dead_) {
118 DEBUG_PRINT("RES Signal: " + String(res_dead_ ? "DEAD" : "ALIVE"));
119 }
120
122 }
123};
Our own implementation of Metro class.
Definition metro.h:13
void reset()
Resets the timer to the current time.
Definition metro.h:124
bool check()
Checks if the interval has passed and resets the timer if true.
Definition metro.h:90
Volatile version of Metro class for interrupt-safe operations.
Definition metro.h:136
bool checkWithoutReset() const volatile
Checks if the interval has passed without resetting the timer.
Definition metro.h:203
#define DEBUG_PRINT(str)
constexpr unsigned long READY_TIMEOUT_MS
constexpr unsigned long RELEASE_EBS_TIMEOUT_MS
constexpr int RES_TIMESTAMP_TIMEOUT
constexpr unsigned long ENGAGE_EBS_TIMEOUT_MS
constexpr int COMPONENT_TIMESTAMP_TIMEOUT
constexpr int DC_VOLTAGE_HOLD
constexpr int DC_VOLTAGE_TIMEOUT
NonUnitaryFailureDetection & timestamps_
volatile bool emergency_signal_
volatile unsigned dc_voltage_
FailureDetection(NonUnitaryFailureDetection &timestamps)
volatile double radio_quality_
NonUnitaryFailureDetection & operator=(const NonUnitaryFailureDetection &other)
void reset_ebs_timestamp()
resets timestamps for driving
Metro releaseEbsTimestamp
void refresh_r2d_vars()
resets timestamps for ready
void process_go_signal()
Processes the go signal.