Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
Functions
ExternalSystem.c File Reference
#include "../../Inc/Systems/ExternalSystem.h"
#include "../../Inc/Utils/Common.h"
#include "../../Inc/Utils/Updateable.h"
#include "../../Inc/Scheduler/Task.h"
Include dependency graph for ExternalSystem.c:

Go to the source code of this file.

Functions

void initExternalSystem (ExternalSystem *external, const char *name, int hz, ExternalType type, int(*updateExternal)(ExternalSystem *external), int(*check_heartbeat)(void *self), void *child)
 
int e_defaultUpdate (Updateable *updateable)
 

Function Documentation

◆ e_defaultUpdate()

int e_defaultUpdate ( Updateable updateable)

Default update function for ExternalSystem objects.

Parameters
taskPointer to the task to update.
Returns
int _SUCCESS or _FAILURE.

Definition at line 20 of file ExternalSystem.c.

20 {
21 // Cast the child pointer to a external system
22 System* system = (System*)updateable->child;
23 ExternalSystem* external = (ExternalSystem*)system->child;
24
25 // Perform the heartbeat check
26 if (external->check_heartbeat(external) == _FAILURE) {
27 return _FAILURE;
28 }
29
30 // Perform the external system update
31 if (external->updateExternal(external) == _FAILURE) {
32 return _FAILURE;
33 }
34
35 return _SUCCESS;
36}
#define _FAILURE
Definition: Common.h:6
#define _SUCCESS
Definition: Common.h:5
Definition: System.h:17
void * child
Definition: System.h:20
void * child
Definition: Updateable.h:32
Here is the caller graph for this function:

◆ initExternalSystem()

void initExternalSystem ( ExternalSystem external,
const char *  name,
int  hz,
ExternalType  type,
int(*)(ExternalSystem *external)  updateExternal,
int(*)(void *self)  check_heartbeat,
void *  child 
)

Initializes the External System with initial settings.

Parameters
externalA pointer to the ExternalSystem structure.
nameThe name of the external system.
hzRate at which the external system is called (in hz).
typeThe type of external system (per ExternalType).
updateExternalThe function to update the external system.
check_heartbeatThe function to check the heartbeat of the external system.
childPointer to the child struct.

Definition at line 6 of file ExternalSystem.c.

8 {
9 initSystem(&external->system, name, hz, EXTERNAL, external);
10 external->type = type;
11 external->comms = NULL;
12 external->check_heartbeat = check_heartbeat;
13 external->updateExternal = updateExternal;
14 external->child = child;
15
16 // Set the updateable function to generic external system update
18}
int e_defaultUpdate(Updateable *updateable)
@ EXTERNAL
Definition: System.h:12
void initSystem(System *system, const char *name, int hz, SystemType type, void *child)
Initializes a System object.
Definition: System.c:3
ExternalType type
int(* updateExternal)(struct ExternalSystem *external)
CommsSystem * comms
int(* check_heartbeat)(void *self)
Updateable updateable
Definition: System.h:18
int(* update)(struct Updateable *self)
Definition: Updateable.h:27
Here is the call graph for this function:
Here is the caller graph for this function: