Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
Classes | Functions
AppsMonitor.h File Reference
#include "../MonitorSystem.h"
#include "../Controller/Apps.h"
Include dependency graph for AppsMonitor.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  AppsMonitor
 

Functions

void initAppsMonitor (AppsMonitor *am, Apps *apps, int hz)
 
int startAppsMonitor (AppsMonitor *am)
 
int checkAppsMonitor (void *am)
 
void checkAppsLimit (Apps *apps)
 Checks App limits for faults. More...
 

Function Documentation

◆ checkAppsLimit()

void checkAppsLimit ( Apps apps)

Checks App limits for faults.

Checks if apps are more than 10% out of sync and if the values are reasonable. Position is in % of pedal travel.

Parameters
appsA pointer to the APPs structure.

Definition at line 37 of file AppsMonitor.c.

37 {
38 float pos1 = getAppPosition(apps->app[0]);
39 float pos2 = getAppPosition(apps->app[1]);
40
41 // Resonable Value check upper bound
42 if (pos1 > 100 || pos2 > 100) {
43 apps->status = APPS_FAULT;
44 return;
45 }
46
47 // In sync check
48 float difference = fabs(pos1 - pos2);
49 if (difference > APPS_DIFFERENCE * 100) {
50 apps->status = APPS_FAULT;
51 return;
52 }
53
54 // Resonable Value check lower bound
55 if (pos1 < 0 || pos2 < 0) {
56 apps->status = APPS_LOW;
57 return;
58 }
59
60 apps->status = APPS_OK;
61}
float getAppPosition(App *app)
Gets the current position of the APP.
Definition: App.c:11
@ APPS_LOW
Definition: Apps.h:19
@ APPS_OK
Definition: Apps.h:17
@ APPS_FAULT
Definition: Apps.h:18
#define APPS_DIFFERENCE
Definition: Apps.h:14
App * app[2]
Definition: Apps.h:25
AppsStatus status
Definition: Apps.h:24
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkAppsMonitor()

int checkAppsMonitor ( void *  am)

Definition at line 23 of file AppsMonitor.c.

23 {
24 AppsMonitor* amPtr = (AppsMonitor*)am;
25 Apps* apps = amPtr->apps;
26 checkAppsLimit(apps);
27 if (apps->status != APPS_OK && apps->status != APPS_LOW) {
28 return _FAILURE;
29 }
30 if (apps->status == APPS_LOW) {
31 printf("AppsMonitor: APPS position is too low. Defaulting to 0 to pass\r\n");
32 }
33 return _SUCCESS;
34}
void checkAppsLimit(Apps *apps)
Checks App limits for faults.
Definition: AppsMonitor.c:37
#define _FAILURE
Definition: Common.h:6
#define _SUCCESS
Definition: Common.h:5
Apps * apps
Definition: AppsMonitor.h:9
Definition: Apps.h:22
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initAppsMonitor()

void initAppsMonitor ( AppsMonitor am,
Apps apps,
int  hz 
)

Definition at line 6 of file AppsMonitor.c.

6 {
8 am->apps = apps;
9 am->status = APPS_OK;
10}
int checkAppsMonitor(void *am)
Definition: AppsMonitor.c:23
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_APPS
Definition: MonitorSystem.h:12
@ VEHICLE_SHUTDOWN
Definition: MonitorSystem.h:23
AppsStatus status
Definition: AppsMonitor.h:10
MonitorSystem base
Definition: AppsMonitor.h:8
Here is the call graph for this function:
Here is the caller graph for this function:

◆ startAppsMonitor()

int startAppsMonitor ( AppsMonitor am)

Definition at line 13 of file AppsMonitor.c.

13 {
14 if (am->base.runMonitor == NULL) {
15 printf("Monitor function not set for AppsMonitor\n");
16 return _FAILURE;
17 }
18 ENABLE(am->base.system);
19 return _SUCCESS;
20}
#define ENABLE(item_)
Definition: Updateable.h:10
int(* runMonitor)(void *self)
Definition: MonitorSystem.h:30
Here is the caller graph for this function: