Repository navigation
Expand file tree
/
Copy pathtemp_monitor.h
More file actions
92 lines (82 loc) · 3.01 KB
/
Copy pathtemp_monitor.h
File metadata and controls
92 lines (82 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef TEMP_MONITOR
#define TEMP_MONITOR
#include <iostream>
#include <vector>
#include <string>
#include <memory>
using namespace std;
class Sensor {
string _sensor;
int _highTempThresh;
int _lowTempThresh;
vector<string> _highTempThreshCmds;
vector<string> _lowTempThreshCmds;
public:
Sensor(string sensor, int highTempThresh, int lowTempThresh,
vector<string> highTempThreshCmds = vector<string>{},
vector<string> lowTempThreshCmds = vector<string>{}) :
_sensor(sensor), _highTempThresh(highTempThresh), _lowTempThresh(lowTempThresh),
_highTempThreshCmds(highTempThreshCmds),
_lowTempThreshCmds(lowTempThreshCmds) {};
/**
* \brief Getter for the _sensor variable.
* \return _sensor - Sensor Linux path.
*/
string get_sensor();
/**
* \brief Getter for the _highTempThreshCmds variable.
* \return _highTempThreshCmds - Vector list of commands to run when the upper threshold is exceeded.
*/
vector<string> get_high_temp_thresh_cmd();
/**
* \brief Getter for the _lowTempThreshCmds variable.
* \return _lowTempThreshCmds - Vector list of commands to run when the lower threshold is surpassed.
*/
vector<string> get_low_temp_thresh_cmd();
/**
* \brief Setter for the _highTempThresh variable.
* \param threshold - Upper temperature threshold for the sensor.
*/
void set_high_temp_thresh(int threshold);
/**
* \brief Getter for the _highTempThresh variable.
* \return _highTempThresh - Upper temperature threshold for the sensor.
*/
int get_high_temp_thresh();
/**
* \brief Setter for the _lowTempThresh variable.
* \param threshold - Lower temperature threshold for the sensor.
*/
void set_low_temp_thresh(int threshold);
/**
* \brief Getter for the _lowTempThresh variable.
* \return _lowTempThresh - Lower temperature threshold for the sensor.
*/
int get_low_temp_thresh();
};
class System {
vector<shared_ptr<Sensor>> _sensorsConfig; // List of Sensors
int _loggingPeriod; // In miliseconds
public:
System (vector<shared_ptr<Sensor>> sensorsConfig, int loggingPeriod = 5) :
_sensorsConfig(sensorsConfig),
_loggingPeriod(loggingPeriod) {};
/**
* \brief Getter for the _loggingPeriod variable.
* \return _loggingPeriod - Logging Period for the application.
*/
int get_logging_period();
/**
* \brief Getter for the _sensorsConfig variable.
* \return _sensorsConfig - Vector list of shared pointers to the System's sensors.
*/
vector<shared_ptr<Sensor>> get_sensors_config();
};
class TempMonitor
{
public:
shared_ptr<System> mySystem;
void execute_cmd(string cmd);
void monitor();
};
#endif