# Status Controller
###### tags: `firmware_hardware` `electrical_system` `NTURT`
## Introduction
Status controller checks if the states of the vehicle fufills **safe** condition and controls the RTD feature required by FSAE rule.
## Status
- Init: Initial state, checking RTD condition.
- Ready: Ready state, waiting RTD command to run.
- RTD: Transition state, playing RTD sound.
- Running: Running state, motor torque enabled.
- Error: Error state, motor torque disabled, error handling.
:::warning
There is currtnely no BMS CAN signal, so following requirements for BMS is ingored for now.
:::
## Safe condition
- APPS signal normal. (Checked by no APPS error handler being called.)
- BSE signal normal. (Checked by no BSE error handler being called.)
- Pedal plausibility ckeck passes.
- Able to send CAN signal. (Checked by no CAN TX timeout error handler being called.)
- Receiving CAN signals from: (Checked by no CAN RX timeout error handler being called.)
- Inverter
- BMS
- Rear box
- Inverter, BMS, rear box status safe.
- Inverter DC bus voltage higher than minium battery voltage.
## RTD
If **Safe Condition** is fufilled, and the vehicle has not yet RTDed:
Check if brake is engaged:
- Yes: Able to RTD, turn on RTD light, when pressed, transition to RTD status.
- No: Blink RTD light.
## Status Flow Chart
```graphviz
digraph status_controller_status_flow {
graph [fontname="Times"];
node [shape=ellipse style=filled fontname="Times"];
edge[fontname=Times];
StatusInit;
StatusReady;
StatusRTD[shape=rectangle];
StatusRunning;
StatusError;
StatusInit->StatusReady[label="Safe"];
StatusReady->StatusRTD[label="RTD Button"];
StatusReady->StatusError[label="Unsafe"];
StatusRTD->StatusReady[label="Reset"];
StatusRTD->StatusRunning[label="Finished RTD"];
StatusRunning->StatusReady[label="Reset"];
StatusRunning->StatusError[label="Unsafe"];
StatusError->StatusReady[label="Safe"];
}
```