-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsingleoutdoorsensor.h
85 lines (69 loc) · 1.98 KB
/
singleoutdoorsensor.h
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
#ifndef SINGLEOUTDOORSENSOR_H
#define SINGLEOUTDOORSENSOR_H
#include <QCheckBox>
#include <QSlider>
#include <QLabel>
/**
* Handles all elements for one groupbox of an outdoor sensor
* with temperature, humidity and manual control checkbox.
*/
class SingleOutdoorSensor : public QWidget
{
Q_OBJECT
int id;
int currentTemp;
int currentHumidity;
bool manualControl;
QCheckBox *checkManual;
QSlider *sliderTemp;
QSlider *sliderHum;
QLabel *labelTemp;
QLabel *labelHum;
QLabel *labelId;
public:
SingleOutdoorSensor(QWidget *parent, QCheckBox *checkBox, QSlider *sliderTemp, QSlider *sliderHum,
QLabel *labelTemp, QLabel *labelHum, QLabel *labelId);
/**
* @brief Initial connect the object and set ID and initial sensor values
*/
void connectSensor(int id, int temp, int humidity) {
this->id = id;
this->currentTemp = temp;
this->currentHumidity = humidity;
}
/**
* Getter for currentTemp
*/
int getCurrentTemp() const {
return currentTemp;
}
/**
* Getter for currentHumidity
*/
int getCurrentHumidity() const {
return currentHumidity;
}
/**
* @brief return true if manual control via slider is active.
*/
bool isManualControl() const {
return manualControl;
}
signals:
void newValues(int temp, int hum);
public slots:
// new sensor values for channel (updates id + temp + hum)
void updateAll();
void updateSensors(int temp, int hum);
// slider moves for temperature and humidity
void tempSliderMoved(int value);
void humSliderMoved(int value);
// slider changed
void tempActionTriggered(int action);
void humActionTriggered(int action);
// slider touched, activate manual control
void activateManualControl();
// change state of manual control for the sliders
void toggleManualControl(int v);
};
#endif // SINGLEOUTDOORSENSOR_H