1#include "../../../Inc/Systems/Controller/BrakeSystemControl.h"
2#include "../../../Inc/Utils/Common.h"
3#include "../../../Inc/Sensors/AnalogSensors/BrakePressure.h"
4#include "../../../Inc/Sensors/AnalogSensors/Temperature.h"
8 bsc -> maxTemperatureAllowed = maxTemp;
11 bsc -> minPressure = 0;
12 bsc -> maxPressure = 2000;
14 bsc -> brakeLightActivationPoint = brakeLightActivationPoint;
15 bsc -> brakeLightActive = 0;
16 bsc -> heavyBrakingActivationPoint = heavyBrakingActivationPoint;
17 bsc -> heavyBraking = 0;
30 bsc -> brakeLightActive = 1;
33 bsc -> brakeLightActive = 0;
38 if (
getBrakePressure(bsc -> frontPressure) > bsc -> heavyBrakingActivationPoint ||
getBrakePressure(bsc -> rearPressure) > bsc -> heavyBrakingActivationPoint){
39 bsc -> heavyBraking = 1;
42 bsc -> heavyBraking = 0;
51 if (front > bsc -> maxPressure || rear > bsc -> maxPressure){
54 else if (front > bsc -> minPressure || rear > bsc -> minPressure){
57 else if (temp > bsc -> maxTemperatureAllowed){
68 printf(
"No monitors set for Brake System Control\n");
72 printf(
"Brake System is not in a safe state\n");
81 bsc -> frontPressure -> pressure = pressure;
85 bsc -> rearPressure -> pressure = pressure;
89 bsc -> temperature -> degrees = temperature;
float getBrakePressure(BrakePressure *bp)
Gets the current brake pressure.
void initBrakePressure(BrakePressure *bp, int hz, int channel)
Initializes the BrakePressure sensor with the given frequency and channel.
void updateBrakePressure(void *bp)
Updates the brake pressure data.
void initBrakeSystemControl(BrakeSystemControl *bsc, int hz, int maxTemp, int brakeLightActivationPoint, int heavyBrakingActivationPoint, int fbp_channel, int rbp_channel, int temp_channel)
Initializes the Braking System with initial settings.
void activateBrakeLight(BrakeSystemControl *bsc)
Checks whether the line pressure is higher than the activation point specified by the user.
void setFrontPressure(BrakeSystemControl *bsc, float pressure)
void setSensorReadings(BrakeSystemControl *bsc, float frontPressure, float rearPressure, float temperature)
Updates BrakeSystemStatus with current sensor data.
void setTemperature(BrakeSystemControl *bsc, float temperature)
void setRearPressure(BrakeSystemControl *bsc, float pressure)
int brakeSafteyCheck(void *bsc)
Checks the saftey of the braking system.
void inHeavyBreaking(BrakeSystemControl *bsc)
Checks whether the line pressure is higher than the activation point specified by the user.
BrakeSystemStatus checkSensorLimits(BrakeSystemControl *bsc)
Checks if the brake system is within the defined limits and desired ranges.
@ TEMPERATURE_SENSOR_ERROR
void initControllerSystem(ControllerSystem *controller, const char *name, int hz, ControllerType type)
Initializes the Controller System with initial settings.
double getTemperatureFahrenheit(Temperature *temp)
Gets the current temperature in Fahrenheit.
void initTemperature(Temperature *temp, int hz, int channel)
Initializes the Temperature sensor with the given frequency and channel.
void updateTemperature(void *temp)
Updates the Temperature data.