-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtempstate.cpp
More file actions
45 lines (40 loc) · 981 Bytes
/
Copy pathtempstate.cpp
File metadata and controls
45 lines (40 loc) · 981 Bytes
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
#include "tempstate.h"
#include <cstdlib>
#ifdef DEBUG
# include <iostream>
#endif
TempState::TempState() {
#ifdef DEBUG
std::cout << "[DBG] TempState init\n" << std::endl;
#endif
}
TempState::~TempState() {
#ifdef DEBUG
std::cout << "[DBG] TempState term\n" << std::endl;
#endif
}
float TempState::update() {
int value = rand() % (((int) this->max - (int) this->min) * 10);
#ifdef DEBUG
std::cout << "[TempState.update][DBG] value: " << value << std::endl;
#endif
return this->temp = this->min + (float) value * 0.1f;
}
float TempState::get() {
return this->temp;
}
void TempState::updateMin(float newvalue) {
this->min = newvalue;
}
void TempState::updateMax(float newvalue) {
this->max = newvalue;
}
void TempState::updateThreshold(float newvalue) {
this->threshold = newvalue;
}
bool TempState::moreThreshold() {
return this->temp >= this->threshold;
}
bool TempState::lessThreshold() {
return this->temp < this->threshold;
}