93 GasData(
const EGasType& gasType,
const double& gasSlope,
const double& gasYIntercept,
const double& startX,
const double& startY,
const double& middleX,
const double& middleY,
const double& lastX,
const double& lastY,
const double& dangerLevel,
const bool& isUsingDataCache);
115 GasData(
const EGasType& gasType,
const double& startX,
const double& startY,
const double& middleX,
const double& middleY,
const double& lastX,
const double& lastY,
const double& dangerLevel,
const bool& isUsingDataCache);
133 GasData(
const EGasType& gasType,
const double& gasSlope,
const double& gasYIntercept,
const double& dangerLevel,
const bool& isUsingDataCache);
Gas data (its response curve and danger level) used by the MQ gas sensors.
Definition: GasData.h:40
static const int MAX_ANALOG_VALUE
The maximum 10-bit raw analog reading.
Definition: GasData.h:42
double GetLastY() const
Gets the y of the last graph point.
Definition: GasData.cpp:463
void SetFirstX(const double &firstX)
Sets the x of the first graph point.
Definition: GasData.cpp:576
void SetMiddleY(const double &middleY)
Sets the y of the middle graph point.
Definition: GasData.cpp:627
std::string ToString() const
Serializes the gas name, slope, and y-intercept to a string.
Definition: GasData.cpp:733
double GetFirstY() const
Gets the y of the first graph point.
Definition: GasData.cpp:395
double GetLastX() const
Gets the x of the last graph point.
Definition: GasData.cpp:446
double myDangerLevel
The amount considered dangerous for this gas in ppm.
Definition: GasData.h:54
double myMiddleY
The y in-between the start and last.
Definition: GasData.h:51
void SetLastY(const double &lastY)
Sets the y of the last graph point.
Definition: GasData.cpp:661
double myGasSlope
The m in "y = mx + b".
Definition: GasData.h:46
GasData()
Builds an empty GasData with all curve values sentinel-initialized to INT_MIN.
Definition: GasData.cpp:15
double myDataCache[MAX_ANALOG_VALUE+1]
Cache of expensive calculations (e.g. BAC in the MQ-3). Zero-initialized; filled by cache-using senso...
Definition: GasData.h:55
double myLastY
The y for the last point on the graph.
Definition: GasData.h:53
double GetGasYIntercept() const
Gets the response curve's y-intercept (b).
Definition: GasData.cpp:361
double myMiddleX
The x in-between the start and last.
Definition: GasData.h:50
double myFirstY
The y in the first point on the graph.
Definition: GasData.h:49
void SetDataCacheValueAtIndex(const int &index, const double &value)
Sets a cached value at the given raw-analog index, ignoring out-of-range indices.
Definition: GasData.cpp:696
double GetDataCacheValueAtIndex(const int &index) const
Gets a cached value at the given raw-analog index, or 0 if the index is out of range.
Definition: GasData.cpp:499
void SetGasYIntercept(const double &yIntercept)
Sets the response curve's y-intercept (b).
Definition: GasData.cpp:559
double GetFirstX() const
Gets the x of the first graph point.
Definition: GasData.cpp:378
EGasType GetGasType() const
Gets the gas type this data describes.
Definition: GasData.cpp:322
double GetGasSlope()
Gets the response curve's slope (m), calculating it first if it has not been computed yet.
Definition: GasData.cpp:339
double GetMiddleX() const
Gets the x of the middle graph point.
Definition: GasData.cpp:412
void SetIsUsingDataCache(const bool &isUsingDataCache)
Sets whether this gas sensor uses the data cache for its calculations.
Definition: GasData.cpp:716
void SetLastX(const double &lastX)
Sets the x of the last graph point.
Definition: GasData.cpp:644
double GetMiddleY() const
Gets the y of the middle graph point.
Definition: GasData.cpp:429
double GetDangerLevel() const
Gets the concentration (ppm) considered dangerous for this gas.
Definition: GasData.cpp:480
void SetDangerLevel(const double &dangerLevel)
Sets the concentration (ppm) considered dangerous for this gas.
Definition: GasData.cpp:678
double CalculateSlope()
Computes the response curve's slope (m) from the first and last graph points, using base-10 logs.
Definition: GasData.cpp:164
const char * GetGasName() const
Gets the human-readable name of this data's gas type.
Definition: GasData.cpp:216
double myGasYIntercept
The b in "y = mx + b".
Definition: GasData.h:47
void SetFirstY(const double &firstY)
Sets the y of the first graph point.
Definition: GasData.cpp:593
double myLastX
The x for the last point on the graph.
Definition: GasData.h:52
double CalculateYIntercept()
Computes the response curve's y-intercept (b) from the middle graph point, calculating the slope firs...
Definition: GasData.cpp:187
double myFirstX
The x in the first point on the graph.
Definition: GasData.h:48
virtual ~GasData()
Destroys the GasData.
Definition: GasData.cpp:147
bool GetIsUsingDataCache() const
Gets whether this gas sensor uses the data cache for its calculations.
Definition: GasData.cpp:525
void SetGasSlope(const double &slope)
Sets the response curve's slope (m).
Definition: GasData.cpp:542
EGasType myGasType
The type of gas this data corresponds to.
Definition: GasData.h:45
void SetMiddleX(const double &middleX)
Sets the x of the middle graph point.
Definition: GasData.cpp:610
bool myIsUsingDataCache
True if this gas sensor uses the data cache for calculations instead of slope and intercept.
Definition: GasData.h:56
RumPi is the library's top-level facade.
Definition: AlertManager.h:6
EGasType
The types of gas the MQ sensor family can detect.
Definition: GasData.h:13
@ E_Benzene
Definition: GasData.h:17
@ E_CarbonMonoxide
Definition: GasData.h:21
@ E_Ammonium
Definition: GasData.h:16
@ E_Hydrogen
Definition: GasData.h:24
@ E_Hexane
Definition: GasData.h:23
@ E_Acetone
Definition: GasData.h:14
@ E_Benzine
Definition: GasData.h:18
@ E_Methane
Definition: GasData.h:26
@ E_Butane
Definition: GasData.h:19
@ E_NaturalGas
Definition: GasData.h:27
@ E_LPG
Definition: GasData.h:25
@ E_Alcohol
Definition: GasData.h:15
@ E_Toluene
Definition: GasData.h:30
@ E_Propane
Definition: GasData.h:28
@ E_CarbonDioxide
Definition: GasData.h:20
@ E_Smoke
Definition: GasData.h:29
@ E_CNG
Definition: GasData.h:22