7#include "TeensyTimerTool.h"
8using namespace TeensyTimerTool;
20 PeriodicTimer emergency_timer_;
21 volatile bool timer_has_started =
false;
27 inline static ASState *instance =
nullptr;
71 if (!timer_has_started) {
72 emergency_timer_.begin(
76 instance->_output_coordinator_->enter_emergency_state();
77 instance->_checkup_manager_._ebs_sound_timestamp_.reset();
78 instance->state_ = State::AS_EMERGENCY;
118 DEBUG_PRINT(
"Entering EMERGENCY state from FINISHED");
The ASState class manages and transitions between different states of the vehicle system.
void calculate_state()
Calculates the state of the vehicle.
CheckupManager _checkup_manager_
CheckupManager object for handling various checkup operations.
State state_
Current state of the vehicle system, initialized to OFF.
ASState(SystemData *system_data, Communicator *communicator, OutputCoordinator *output_coordinator)
Constructor for the ASState class.
The CheckupManager class handles various checkup operations.
bool should_stay_manual_driving() const
Performs a manual driving checkup.
bool should_enter_emergency(State current_state) const
Performs an emergency checkup.
Metro _ebs_sound_timestamp_
Timer for the EBS buzzer sound check.
bool emergency_sequence_complete() const
Checks if the emergency sequence is complete and the vehicle can transition to AS_OFF.
bool should_stay_ready() const
Performs a ready to drive checkup.
bool should_go_ready_from_off() const
Performs a last re-check for off to ready transition.
void reset_checkup_state()
Resets the checkup state to the initial state.
bool should_stay_off()
Performs an off checkup.
bool should_stay_mission_finished() const
Performs a mission finished checkup.
bool res_triggered() const
Checks if the RES has been triggered.
bool should_stay_driving() const
Class that contains definitions of typical messages to send via CAN It serves only as an example of t...
void reset()
Resets the timer to the current time.
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.
Communicator communicator
OutputCoordinator output_coordinator
The whole model of the system: holds all the data necessary.