-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSensorReader.h
More file actions
40 lines (30 loc) · 875 Bytes
/
SensorReader.h
File metadata and controls
40 lines (30 loc) · 875 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
#ifndef EVENTLOOPMANAGER_SENSORREADER_H
#define EVENTLOOPMANAGER_SENSORREADER_H
#include <random>
class SensorReader {
public:
virtual float readTemperature() = 0;
virtual float readHumidity() = 0;
virtual float readCO2Concentration() = 0;
~SensorReader() = default;
};
class SimulatedSensorReader : public SensorReader {
public:
float readTemperature() override {
return generateRandom(0.0, 30.0);
}
float readHumidity() override {
return generateRandom(0.0, 90.0);
}
float readCO2Concentration() override {
return generateRandom(400.0, 1000.0);
}
private:
float generateRandom(float min, float max) {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_real_distribution<> dis(min, max);
return dis(gen);
}
};
#endif //EVENTLOOPMANAGER_SENSORREADER_H