From 2b36d30243707cff2c9969b19ab5b8dfb91df4e6 Mon Sep 17 00:00:00 2001 From: Stefan Andritoiu Date: Wed, 20 Jun 2018 18:25:24 +0300 Subject: [PATCH] Added iOrp interface Signed-off-by: Stefan Andritoiu Signed-off-by: Mihai Tudor Panu --- include/interfaces/iOrp.hpp | 45 +++++++++++++++++++++++++++++++++++++ src/dfrorp/dfrorp.cxx | 6 +++++ src/dfrorp/dfrorp.hpp | 11 ++++++++- 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 include/interfaces/iOrp.hpp diff --git a/include/interfaces/iOrp.hpp b/include/interfaces/iOrp.hpp new file mode 100644 index 00000000..a27f7e40 --- /dev/null +++ b/include/interfaces/iOrp.hpp @@ -0,0 +1,45 @@ +/* + * Author: Mihai Stefanescu + * Copyright (c) 2018 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#pragma once + +namespace upm +{ +/** + * @brief Interface for Oxidation/Reduction/Potential (ORP) Sensors +*/ + class iOrp + { + public: + virtual ~iOrp() {} + + /** + * Get computed ORP (in millivolts) value from the + * sensor. + * + * @return ORP value in millivolts + */ + virtual float getORPValue() = 0; + }; +} diff --git a/src/dfrorp/dfrorp.cxx b/src/dfrorp/dfrorp.cxx index 1eeaf381..ece3c65f 100644 --- a/src/dfrorp/dfrorp.cxx +++ b/src/dfrorp/dfrorp.cxx @@ -75,6 +75,12 @@ float DFRORP::getORP() return dfrorp_get_orp(m_dfrorp); } +float DFRORP::getORPValue() +{ + DFRORP::update(); + return DFRORP::getORP(); +} + float DFRORP::getVolts() { return dfrorp_get_volts(m_dfrorp); diff --git a/src/dfrorp/dfrorp.hpp b/src/dfrorp/dfrorp.hpp index d56ddba3..7fd7d58d 100644 --- a/src/dfrorp/dfrorp.hpp +++ b/src/dfrorp/dfrorp.hpp @@ -31,6 +31,7 @@ #include #include "dfrorp.h" +#include namespace upm { /** @@ -70,7 +71,7 @@ namespace upm { * @snippet dfrorp.cxx Interesting */ - class DFRORP { + class DFRORP : virtual public iOrp { public: /** @@ -118,6 +119,14 @@ namespace upm { */ float getORP(); + /** + * Get computed ORP (in millivolts) value from the + * sensor. + * + * @return ORP value in millivolts + */ + virtual float getORPValue(); + /** * Set the calibration offset for the device. This is * determined by disconnecting the sensor probe (but leaving the