1#ifndef STATE_MACHINE_TEST
2#define STATE_MACHINE_TEST
3#include <gtest/gtest.h>
4#include <gmock/gmock.h>
40 auto sys_time2 = sys_time;
51 AnalogConversion_s pedals1_data;
53 pedals1_data.conversion = 0;
54 pedals1_data.status = AnalogSensorStatus_e::ANALOG_SENSOR_GOOD;
55 auto pedals2_data = pedals1_data;
57 AnalogConversion_s pedals3_data;
58 pedals3_data.raw = 3000;
59 pedals3_data.conversion = 1.0;
60 pedals3_data.status = pedals1_data.status;
61 auto pedals4_data = pedals3_data;
62 pedals.
tick(SysTick_s{}, pedals1_data, pedals2_data, pedals3_data, pedals4_data);
67TEST(MCUStateMachineTesting, test_state_machine_init_tick)
79 unsigned long sys_time = 1000;
85TEST(MCUStateMachineTesting, test_state_machine_tractive_system_activation)
98 unsigned long sys_time = 1000;
121TEST(MCUStateMachineTesting, test_state_machine_tractive_system_enabling)
123 unsigned long sys_time = 1000;
152 dash_interface.start_button_status_ =
true;
154 AnalogConversion_s pedals1_data;
155 pedals1_data.raw = 0;
156 pedals1_data.conversion = 0;
157 pedals1_data.status = AnalogSensorStatus_e::ANALOG_SENSOR_GOOD;
158 auto pedals2_data = pedals1_data;
160 AnalogConversion_s pedals3_data;
161 pedals3_data.raw = 3000;
162 pedals3_data.conversion = 1.0;
163 pedals3_data.status = pedals1_data.status;
164 auto pedals4_data = pedals3_data;
165 pedals.tick(SysTick_s{}, pedals1_data, pedals2_data, pedals3_data, pedals4_data);
171TEST(MCUStateMachineTesting, test_state_machine_ready_to_drive_alert)
184 unsigned long sys_time = 1000;
194 dash_interface.buzzer =
true;
200 dash_interface.buzzer =
false;
206TEST(MCUStateMachineTesting, test_state_machine_ready_to_drive_alert_leaving)
220 unsigned long sys_time = 1000;
240TEST(MCUStateMachineTesting, test_state_machine_rtd_state_transitions_to_ts_active)
256 unsigned long sys_time = 1000;
269 dash_interface.buzzer =
true;
271 dash_interface.buzzer =
false;
287TEST(MCUStateMachineTesting, test_state_machine_rtd_state_transitions_to_ts_not_active)
304 unsigned long sys_time = 1000;
317 dash_interface.buzzer =
true;
319 dash_interface.buzzer =
false;
@ WAITING_READY_TO_DRIVE_SOUND
@ TRACTIVE_SYSTEM_NOT_ACTIVE
this class is for interfacing with the AMS (accumulator management system)
void activate_buzzer(unsigned long act_time)
Base class for all controllers, which define drivetrain command containing different variations of
bool start_button_status_
bool hv_over_threshold_on_drivetrain()
void command_drivetrain_no_torque()
void command_drivetrain(const DrivetrainCommand_s &data)
bool handle_inverter_startup(unsigned long cm)
bool drivetrain_error_occured()
bool inverter_init_timeout(unsigned long curr_time)
TorqueControllerOutput_s evaluate(const SharedCarState_s &state)
This mehod must be implemented by every controller in the Tc Muxer. This is called in the Muxer whene...
void tick_state_machine(unsigned long cm, const SharedCarState_s ¤t_car_state)
function to tick the state machine.
void tick(const SysTick_s &tick, const AnalogConversion_s &accel1, const AnalogConversion_s &accel2, const AnalogConversion_s &brake)
overloaded tick function that runs the evaluation of the pedals system. evaluates brake using only mi...
BuzzerController buzzer(BUZZER_ON_INTERVAL)
TEST(MCUStateMachineTesting, test_state_machine_init_tick)
void handle_startup(MCUStateMachine< DrivetrainMock > &state_machine, unsigned long sys_time, DrivetrainMock &drivetrain, PedalsSystem &pedals, DashboardInterface &dash_interface)
SharedCarState_s dummy_state({}, {}, {}, {}, {}, {}, {}, {})
Stores setpoints for a command to the Drivetrain, containing speed and torque setpoints for each moto...
car state struct that contains state of everything about the car including
Packages drivetrain command with ready boolean to give feedback on controller successfully evaluating...