Solo Controller Documentation 1.0
Documentation for the Solo Controller
 
Loading...
Searching...
No Matches
Sensor.h
Go to the documentation of this file.
1/*******************************************************************************
2 * @file Sensor.h
3 * @brief Defines a class for managing Sensor data
4 ******************************************************************************/
5
6#ifndef SENSOR_INCLUDED
7#define SENSOR_INCLUDED
8
9#include <Arduino.h>
10
11/******************************************************************************/
12/*** ***/
13/*** Class Definition: Sensor ***/
14/*** ***/
15/******************************************************************************/
23class Sensor
24{
25public:
26 using sensorVal_t = float;
27
28private:
29 // Simulation parameters
30 const sensorVal_t MAXVAL;
31 const sensorVal_t MINVAL;
32 const sensorVal_t SIM_DELTA;
33 sensorVal_t _currentDelta;
34
35protected:
37
46 Sensor(sensorVal_t initialValue, sensorVal_t maxVal, sensorVal_t minVal, sensorVal_t simDelta)
47 : MAXVAL{maxVal}, MINVAL{minVal}, SIM_DELTA{abs(simDelta)},
48 _currentDelta{SIM_DELTA}, _value{initialValue} {};
49
53 ~Sensor(void) = default;
54
55public:
63 virtual void begin(void) = 0;
64
71 virtual void read(void) = 0;
72
76 void simulate(void);
77
84 const sensorVal_t value(void) const { return _value; };
85};
86
87/******************************************************************************/
88/*** ***/
89/*** Class Definition: KettleTempSensor ***/
90/*** ***/
91/******************************************************************************/
98class KettleTempSensor : public Sensor
99{
100 // Instance of the singleton
101 static KettleTempSensor *_instance;
102
103 // Private Constructor
104 KettleTempSensor(void)
105 : Sensor{150.0, 160.0, 145.0, 0.9} {};
106
107 // Private Destructor
108 ~KettleTempSensor(void) = default;
109
110public:
116 static KettleTempSensor &getInstance(void)
117 {
118 if (!_instance)
119 _instance = new KettleTempSensor();
120 return *_instance;
121 };
122
124 KettleTempSensor(const KettleTempSensor &) = delete;
125
127 KettleTempSensor &operator=(const KettleTempSensor &) = delete;
128
136 void begin(void) override;
137
144 void read(void) override;
145};
146
148
149/******************************************************************************/
150/*** ***/
151/*** Class Definition: ChillerTempSensor ***/
152/*** ***/
153/******************************************************************************/
160class ChillerTempSensor : public Sensor
161{
162 // Instance of the singleton
163 static ChillerTempSensor *_instance;
164
165 // Private Constructor
166 ChillerTempSensor(void)
167 : Sensor{40.0, 45.0, 35.0, 0.5} {};
168
169 // Private Destructor
170 ~ChillerTempSensor(void) = default;
171
172public:
178 static ChillerTempSensor &getInstance(void)
179 {
180 if (!_instance)
181 _instance = new ChillerTempSensor();
182 return *_instance;
183 };
184
186 ChillerTempSensor(const ChillerTempSensor &) = delete;
187
189 ChillerTempSensor &operator=(const ChillerTempSensor &) = delete;
190
198 void begin(void) override;
199
206 void read(void) override;
207};
208
210
211/******************************************************************************/
212/*** ***/
213/*** Class Definition: KettleVolSensor ***/
214/*** ***/
215/******************************************************************************/
222class KettleVolSensor : public Sensor
223{
224 // Instance of the singleton
225 static KettleVolSensor *_instance;
226
227 // Private Constructor
228 KettleVolSensor(void)
229 : Sensor{8.0, 9.0, 7.0, 0.2} {};
230
231 // Private Destructor
232 ~KettleVolSensor(void) = default;
233
234public:
240 static KettleVolSensor &getInstance(void)
241 {
242 if (!_instance)
243 _instance = new KettleVolSensor();
244 return *_instance;
245 };
246
248 KettleVolSensor(const KettleVolSensor &) = delete;
249
251 KettleVolSensor &operator=(const KettleVolSensor &) = delete;
252
260 void begin(void) override;
261
268 void read(void) override;
269};
270
272
273#endif
KettleTempSensor * kettleTemp
Pointer to the current, active menu used by the application.
Definition Sensor.cpp:34
ChillerTempSensor * chillerTemp
Pointer to the current, active menu used by the application.
Definition Sensor.cpp:56
KettleVolSensor * kettleVolume
Pointer to the current, active menu used by the application.
Definition Sensor.cpp:77
Manages the Chiller temperature probe.
Definition Sensor.h:161
void begin(void) override
Initializes the sensors used by this object. Not needed if only using simulated sensor values.
Definition Sensor.cpp:58
void read(void) override
Reads the sensor and updates the value stored within this object.
Definition Sensor.cpp:64
static ChillerTempSensor & getInstance(void)
Returns reference to the single instance of the ChillerTempSensor class.
Definition Sensor.h:178
Manages the Kettle temperature probe.
Definition Sensor.h:99
static KettleTempSensor & getInstance(void)
Returns reference to the single instance of the KettleTempSensor class.
Definition Sensor.h:116
void begin(void) override
Initializes the sensors used by this object. Not needed if only using simulated sensor values.
Definition Sensor.cpp:36
void read(void) override
Reads the sensor and updates the value stored within this object.
Definition Sensor.cpp:42
Manages the Kettle Volume sensor.
Definition Sensor.h:223
static KettleVolSensor & getInstance(void)
Returns reference to the single instance of the KettleVolSensor class.
Definition Sensor.h:240
void read(void) override
Reads the sensor and updates the value stored within this object.
Definition Sensor.cpp:85
void begin(void) override
Initializes the sensors used by this object. Not needed if only using simulated sensor values.
Definition Sensor.cpp:79
sensorVal_t _value
Most recent sensor reading.
Definition Sensor.h:36
~Sensor(void)=default
Destroy the Sensor object.
const sensorVal_t value(void) const
Returns the sensor value.
Definition Sensor.h:84
void simulate(void)
Simulates a new sensor value, storing the results in this object.
Definition Sensor.cpp:14
virtual void begin(void)=0
Initializes the sensors used by this object. Not needed if only using simulated sensor values.
virtual void read(void)=0
Reads the sensor and updates the value stored within this object.
Sensor(sensorVal_t initialValue, sensorVal_t maxVal, sensorVal_t minVal, sensorVal_t simDelta)
Protected constructor for Sensor.
Definition Sensor.h:46
float sensorVal_t
Type definition used by Sensor class.
Definition Sensor.h:26