sensors: host: Implement getFailed function to HostSensor
1. Add getFailed function to check the dbus value in HostSensor
is finite or not, if not, pid control will into failsafe mode.
Signed-off-by: Harvey Wu <Harvey.Wu@quantatw.com>
Change-Id: Ib198aecf512a3a107793319014f6c0b531cc6211
diff --git a/sensors/host.cpp b/sensors/host.cpp
index 53f114e..85a37dc 100644
--- a/sensors/host.cpp
+++ b/sensors/host.cpp
@@ -96,4 +96,14 @@
throw std::runtime_error("Not Implemented.");
}
+bool HostSensor::getFailed(void)
+{
+ if (std::isfinite(_value))
+ {
+ return false;
+ }
+
+ return true;
+}
+
} // namespace pid_control
diff --git a/sensors/host.hpp b/sensors/host.hpp
index 35c7f45..5c70526 100644
--- a/sensors/host.hpp
+++ b/sensors/host.hpp
@@ -55,6 +55,7 @@
ReadReturn read(void) override;
void write(double value) override;
+ bool getFailed(void) override;
private:
/*