Mario Simaremare
/
g3_waterplay
Salinity and temperature sensors are implemented in classes.
Diff: TemperatureSensor.cpp
- Revision:
- 15:e112bab9aa2f
- Parent:
- 13:142a142a7ac5
--- a/TemperatureSensor.cpp Fri Jun 24 13:46:52 2016 +0000 +++ b/TemperatureSensor.cpp Tue Jun 28 12:30:40 2016 +0000 @@ -16,7 +16,8 @@ _voltage(0.0), _temperature(0.0), _status(0.0), - _strStatus("OK") + _strStatus("OK"), + _in_boundary(false) { this->reload(); } @@ -45,6 +46,11 @@ this->_temperature += 0.21*this->_temperature - 6.09; } + this->_in_boundary = false; + if(this->_temperature > 0.0 && this->_temperature < 100.0){ + this->_in_boundary = true; + } + this->_status = 0.0; this->_strStatus = "OK"; if(this->_temperature < LOWER_BOUNDARY){ @@ -89,4 +95,12 @@ bool TemperatureSensor::inBoundary(){ return(this->_in_boundary); +} + +bool TemperatureSensor::inDanger(){ + bool in_danger = false; + if(this->_in_boundary && this->_status != 0.0){ + in_danger = true; + } + return(in_danger); } \ No newline at end of file