3#include "TeensyTimerTool.h"
25 uint8_t previous_master_state_;
26 uint8_t previous_checkup_state_;
27 uint8_t previous_mission_;
29 unsigned long tsms_open_time_ = 0;
30 unsigned long counter = 0;
32 bool tsms_was_closed_ =
false;
42 previous_master_state_(static_cast<uint8_t>(15)),
43 previous_checkup_state_(static_cast<uint8_t>(15)),
44 previous_mission_(static_cast<uint8_t>(15)) {}
47 mission_timer_.
reset();
52 void process(uint8_t current_master_state, uint8_t current_checkup_state, uint8_t ebs_state) {
53 dash_ats_update(current_master_state);
54 update_physical_outputs();
55 if (process_timer_.
check()) {
58 send_mission_update();
59 send_state_update(current_master_state);
60 send_ebs_state(current_checkup_state, ebs_state);
62 if (slower_process_timer_.
check()) {
63 send_data_logging_data(current_master_state, current_checkup_state);
68 if (blink_timer_.
check()) {
74 if (blink_timer_.
check()) {
127 blink_timer_.
reset();
155 void send_data_logging_data(uint8_t current_master_state, uint8_t current_checkup_state) {
157 current_checkup_state);
164 void send_mission_update() {
165 if (mission_timer_.
check()) {
167 mission_timer_.
reset();
170 void send_ebs_state(uint8_t current_checkup_state, uint8_t ebs_state) {
171 static constexpr uint8_t ASB_EBS_STATE_OFF = 1;
172 static constexpr uint8_t ASB_EBS_STATE_INITIAL_CHECKUP_PASSED = 2;
173 static constexpr uint8_t ASB_EBS_STATE_ACTIVATED = 3;
175 static constexpr uint8_t ASB_REDUNDANCY_STATE_DEACTIVATED = 1;
176 static constexpr uint8_t ASB_REDUNDANCY_STATE_ENGAGED = 2;
177 static constexpr uint8_t ASB_REDUNDANCY_STATE_INITIAL_CHECKUP_PASSED = 3;
220 void send_state_update(uint8_t current_master_state) {
221 if (state_timer_.
check()) {
223 state_timer_.
reset();
227 void update_physical_outputs() {
228 brake_light_update();
234 void brake_light_update() {
250 void bsdp_sdc_update() {
258 void dash_ats_update(uint8_t current_master_state) {
Class that contains definitions of typical messages to send via CAN It serves only as an example of t...
static int publish_mission(int mission_id)
Publish AS Mission to CAN.
static int publish_rpm()
Publish rl wheel rpm to CAN.
static int publish_debug_morning_log(const SystemData &system_data, uint8_t sate, uint8_t state_checkup)
Publish AS Mission to CAN.
static int publish_soc(uint8_t soc)
Publish SOC to CAN.
static int publish_asms_on(bool asms_on)
Publish ASMS state to CAN.
static int publish_ebs_states(uint8_t ebs_state, bool is_redundancy=false)
Publish EBS States to CAN.
static int publish_state(int state_id)
Publish AS State to CAN.
Class responsible for controlling digital outputs in the Master Teensy.
void bspd_error()
Turns on the BSPD error signal.
static void turn_off_assi()
Turns off both ASSI LEDs (yellow and blue).
void blink_led(int pin)
Blinks the LED at the given pin.
void turn_on_brake_light()
Turns on the brake light.
void no_bspd_error()
Turns off the BSPD error signal.
void turn_on_blue()
Turns on the blue ASSI LED.
void turn_off_brake_light()
Turns off the brake light.
static void activate_ebs()
Activates the solenoid EBS valves.
static void deactivate_ebs()
Deactivates the solenoid EBS valves.
static void open_sdc()
Opens the SDC in Master and SDC Logic.
static void close_sdc()
Closes the SDC in Master and SDC Logic.
void turn_on_yellow()
Turns on the yellow ASSI LED.
Our own implementation of Metro class.
void reset()
Resets the timer to the current time.
bool check()
Checks if the interval has passed and resets the timer if true.
OutputCoordinator(SystemData *system_data, Communicator *communicator, DigitalSender *digital_sender)
void enter_finish_state()
ASSI blue LED on, ebs valves activated, sdc open.
void enter_manual_state()
Everything off, sdc closed.
void enter_off_state()
Everything off, sdc open.
void enter_driving_state()
ASSI LEDs yellow flashing, ebs valves deactivated, sdc closed.
void enter_emergency_state()
ASSI LEDs blue flashing, sdc open and buzzer ringing.
void process(uint8_t current_master_state, uint8_t current_checkup_state, uint8_t ebs_state)
void blink_emergency_led()
void enter_ready_state()
ASSI yellow LED on, ebs valves activated, sdc closed.
void refresh_emergency_vars()
constexpr auto to_underlying(Enum e) noexcept
constexpr int PROCESS_INTERVAL
constexpr int LED_BLINK_INTERVAL
constexpr int BRAKE_PRESSURE_UPPER_THRESHOLD
constexpr int BRAKE_PRESSURE_LOWER_THRESHOLD
constexpr int SLOWER_PROCESS_INTERVAL
constexpr int ASSI_BLUE_PIN
constexpr int ASSI_YELLOW_PIN
Communicator communicator
DigitalSender digital_sender
volatile bool emergency_signal_
int _hydraulic_line_pressure
void refresh_r2d_vars()
resets timestamps for ready
The whole model of the system: holds all the data necessary.
FailureDetection failure_detection_
HardwareData hardware_data_
constexpr auto MISSION_PUBLISH_INTERVAL
constexpr auto STATE_PUBLISH_INTERVAL