3#include "TeensyTimerTool.h"
24 uint8_t previous_master_state_;
25 uint8_t previous_checkup_state_;
26 uint8_t previous_mission_;
36 previous_master_state_(static_cast<uint8_t>(15)),
37 previous_checkup_state_(static_cast<uint8_t>(15)),
38 previous_mission_(static_cast<uint8_t>(15)) {}
41 mission_timer_.
reset();
46 void process(uint8_t current_master_state, uint8_t current_checkup_state) {
47 if (process_timer_.
check()) {
50 send_debug_on_state_change(current_master_state, current_checkup_state);
51 send_mission_update();
52 send_state_update(current_master_state);
53 dash_ats_update(current_master_state);
54 update_physical_outputs();
56 process_timer_.
reset();
61 if (blink_timer_.
check()) {
67 if (blink_timer_.
check()) {
117 blink_timer_.
reset();
134 void send_debug_on_state_change(uint8_t current_master_state, uint8_t current_checkup_state) {
136 current_checkup_state);
143 void send_mission_update() {
144 if (mission_timer_.
check()) {
146 mission_timer_.
reset();
150 void send_state_update(uint8_t current_master_state) {
151 if (state_timer_.
check()) {
153 state_timer_.
reset();
157 void update_physical_outputs() {
158 brake_light_update();
164 void brake_light_update() {
179 void bsdp_sdc_update() {
186 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_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 blink_emergency_led()
void enter_ready_state()
ASSI yellow LED on, ebs valves activated, sdc closed.
void process(uint8_t current_master_state, uint8_t current_checkup_state)
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 ASSI_BLUE_PIN
constexpr int ASSI_YELLOW_PIN
Communicator communicator
DigitalSender digital_sender
int _hydraulic_line_pressure
The whole model of the system: holds all the data necessary.
HardwareData hardware_data_
constexpr auto MISSION_PUBLISH_INTERVAL
constexpr auto STATE_PUBLISH_INTERVAL