Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Linux: add ThermHygroMeterParsed for temperature+humidity channel. See
README.md file for example usage
- Loading branch information
Showing
6 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
extras/porting/linux/supla/sensor/therm_hygro_meter_parsed.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (C) AC SOFTWARE SP. Z O.O | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
*/ | ||
|
||
#include <supla/log_wrapper.h> | ||
|
||
#include "humidity_parsed.h" | ||
#include "therm_hygro_meter_parsed.h" | ||
|
||
Supla::Sensor::ThermHygroMeterParsed::ThermHygroMeterParsed( | ||
Supla::Parser::Parser *parser) | ||
: SensorParsed(parser) { | ||
} | ||
|
||
double Supla::Sensor::ThermHygroMeterParsed::getTemp() { | ||
double value = TEMPERATURE_NOT_AVAILABLE; | ||
|
||
if (isParameterConfigured(Supla::Parser::Temperature)) { | ||
if (refreshParserSource()) { | ||
value = getParameterValue(Supla::Parser::Temperature); | ||
} | ||
if (!parser->isValid()) { | ||
if (!isDataErrorLogged) { | ||
isDataErrorLogged = true; | ||
SUPLA_LOG_WARNING("ThermHygroMeterParsed: source data error"); | ||
} | ||
return TEMPERATURE_NOT_AVAILABLE; | ||
} | ||
isDataErrorLogged = false; | ||
} | ||
return value; | ||
} | ||
|
||
double Supla::Sensor::ThermHygroMeterParsed::getHumi() { | ||
double value = HUMIDITY_NOT_AVAILABLE; | ||
|
||
if (isParameterConfigured(Supla::Parser::Humidity)) { | ||
if (refreshParserSource()) { | ||
value = getParameterValue(Supla::Parser::Humidity); | ||
} | ||
if (!parser->isValid()) { | ||
if (!isDataErrorLogged) { | ||
isDataErrorLogged = true; | ||
SUPLA_LOG_WARNING("ThermHygroMeterParsed: source data error"); | ||
} | ||
return HUMIDITY_NOT_AVAILABLE; | ||
} | ||
isDataErrorLogged = false; | ||
} | ||
return value; | ||
} | ||
|
47 changes: 47 additions & 0 deletions
47
extras/porting/linux/supla/sensor/therm_hygro_meter_parsed.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (C) AC SOFTWARE SP. Z O.O | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
*/ | ||
|
||
#ifndef EXTRAS_PORTING_LINUX_SUPLA_SENSOR_THERM_HYGRO_METER_PARSED_H_ | ||
#define EXTRAS_PORTING_LINUX_SUPLA_SENSOR_THERM_HYGRO_METER_PARSED_H_ | ||
|
||
#include <supla/parser/parser.h> | ||
#include <supla/sensor/therm_hygro_meter.h> | ||
|
||
#include <string> | ||
|
||
#include "sensor_parsed.h" | ||
#include "thermometer_parsed.h" | ||
#include "humidity_parsed.h" | ||
|
||
namespace Supla { | ||
namespace Sensor { | ||
|
||
class ThermHygroMeterParsed : public ThermHygroMeter, public SensorParsed { | ||
public: | ||
explicit ThermHygroMeterParsed(Supla::Parser::Parser *); | ||
double getTemp() override; | ||
double getHumi() override; | ||
|
||
protected: | ||
bool isDataErrorLogged = false; | ||
}; | ||
}; // namespace Sensor | ||
}; // namespace Supla | ||
|
||
|
||
#endif // EXTRAS_PORTING_LINUX_SUPLA_SENSOR_THERM_HYGRO_METER_PARSED_H_ |