#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "System.h"
#include "MonitorSystem.h"
#include "../Utils/Constants.h"
#include "../Utils/Updateable.h"
#include "../Scheduler/Task.h"
Go to the source code of this file.
◆ ControllerSystem
◆ ControllerState
◆ ControllerType
◆ c_defaultAddMonitor()
Adds a monitor to the controller.
- Parameters
-
- Returns
- _SUCCESS if the monitor was added, _FAILURE otherwise.
Definition at line 24 of file ControllerSystem.c.
24 {
26 printf("Cannot add more monitors to the controller\n");
28 }
31}
MonitorSystem * monitors[MAX_MONITORS]
◆ c_defaultRemoveMonitor()
Removes a monitor from the controller.
- Parameters
-
- Returns
- _SUCCESS if the monitor was removed, _FAILURE otherwise.
Definition at line 33 of file ControllerSystem.c.
33 {
35 if (controller->
monitors[i] == monitor) {
38 }
41 }
42 }
43 printf("Monitor not found in the controller\n");
45}
◆ c_defaultSafety()
Default safety function for ControllerSystem objects.
- Parameters
-
- Returns
- int Status of the ControllerSystem object.
Definition at line 69 of file ControllerSystem.c.
69 {
70
72 printf("Controller not computed new value\n");
74 }
75
77 printf("No monitors set for Controller\n");
79 }
80
84 }
85 }
88}
int(* runMonitor)(void *self)
◆ c_defaultUpdate()
Default update function for ControllerSystem objects.
- Parameters
-
- Returns
- int _SUCCESS or _FAILURE.
Definition at line 47 of file ControllerSystem.c.
47 {
48
51
52
53 if (controller->updateController(controller) ==
_FAILURE) {
55 }
56
57
59
60
61 if (controller->safety(controller) ==
_FAILURE) {
63 }
64
65
67}
◆ initControllerSystem()
Initializes the Controller System with initial settings.
- Parameters
-
controller | A pointer to the ControllerSystem structure. |
name | The name of the controller. |
hz | Rate at which the controller is called (in hz). |
type | The type of controller (per ControllerType). |
updateController | The function to update the controller. |
Definition at line 6 of file ControllerSystem.c.
8 {
10 controller->
type = type;
17
18
20 controller->
child = child;
21
22}
int c_defaultRemoveMonitor(ControllerSystem *controller, MonitorSystem *monitor)
Removes a monitor from the controller.
int c_defaultAddMonitor(ControllerSystem *controller, MonitorSystem *monitor)
Adds a monitor to the controller.
int c_defaultUpdate(Updateable *updateable)
Default update function for ControllerSystem objects.
int c_defaultSafety(ControllerSystem *controller)
Default safety function for ControllerSystem objects.
void initSystem(System *system, const char *name, int hz, SystemType type, void *child)
Initializes a System object.
int(* addMonitor)(struct ControllerSystem *controller, MonitorSystem *monitor)
int(* safety)(struct ControllerSystem *controller)
int(* updateController)(struct ControllerSystem *controller)
int(* removeMonitor)(struct ControllerSystem *controller, MonitorSystem *monitor)
int(* update)(struct Updateable *self)