Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
BrakePolice.c
Go to the documentation of this file.
1#include "../../../Inc/Systems/Monitor/BrakePolice.h"
2#include "../../../Inc/Utils/Common.h"
3
4// Make new BrakePolice MonitorSystem
5void initBrakePolice(BrakePolice* bp, BrakeSystemControl *bsc, int hz, int maxTemp) {
7 bp->bsc = bsc;
8 bp->maxTemperatureAllowed = maxTemp;
9 bp->status = BRAKES_OK;
10}
11
12// Start the BrakePolice MonitorSystem
14 if (bp->base.runMonitor == NULL) {
15 printf("Monitor function not set for BrakePolice\n");
16 return _FAILURE;
17 }
18 ENABLE(bp->base.system);
19 return _SUCCESS;
20}
21
22// Check the BrakePolice MonitorSystem
23int checkBrakePolice(void* bp) {
24 BrakePolice* bpPtr = (BrakePolice*)bp;
25 BrakeSystemControl* bsc = bpPtr->bsc;
26 bsc->status = checkSensorLimits(bsc);
27 if (bsc->status != BRAKES_OK) {
28 return _FAILURE;
29 }
30
31 return _SUCCESS;
32}
int startBrakePolice(BrakePolice *bp)
Definition: BrakePolice.c:13
void initBrakePolice(BrakePolice *bp, BrakeSystemControl *bsc, int hz, int maxTemp)
Definition: BrakePolice.c:5
int checkBrakePolice(void *bp)
Definition: BrakePolice.c:23
@ BRAKES_OK
BrakeSystemStatus checkSensorLimits(BrakeSystemControl *bsc)
Checks if the brake system is within the defined limits and desired ranges.
#define _FAILURE
Definition: Common.h:6
#define _SUCCESS
Definition: Common.h:5
void initMonitorSystem(MonitorSystem *monitor, const char *name, int hz, MonitorType type, FaultType fault, int(*runMonitor)(void *self))
Initializes the Monitor System with initial settings.
Definition: MonitorSystem.c:3
@ m_BRAKES
Definition: MonitorSystem.h:13
@ VEHICLE_SHUTDOWN
Definition: MonitorSystem.h:23
#define ENABLE(item_)
Definition: Updateable.h:10
BrakeSystemStatus status
Definition: BrakePolice.h:10
MonitorSystem base
Definition: BrakePolice.h:8
BrakeSystemControl * bsc
Definition: BrakePolice.h:11
int maxTemperatureAllowed
Definition: BrakePolice.h:9
BrakeSystemStatus status
int(* runMonitor)(void *self)
Definition: MonitorSystem.h:30