xref: /openbmc/phosphor-pid-control/sensors/pluggable.cpp (revision 46a755fce8dc0bdd9c0c5ea09d55d3e5494f335f)
1 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: Copyright 2017 Google Inc
3 
4 #include "pluggable.hpp"
5 
6 #include "hoststatemonitor.hpp"
7 #include "interfaces.hpp"
8 
9 #include <cstdint>
10 #include <string>
11 
12 namespace pid_control
13 {
14 
read(void)15 ReadReturn PluggableSensor::read(void)
16 {
17     return _reader->read();
18 }
19 
write(double value)20 void PluggableSensor::write(double value)
21 {
22     _writer->write(value);
23 }
24 
write(double value,bool force,int64_t * written)25 void PluggableSensor::write(double value, bool force, int64_t* written)
26 {
27     _writer->write(value, force, written);
28 }
29 
getFailed(void)30 bool PluggableSensor::getFailed(void)
31 {
32     bool isFailed = _reader->getFailed();
33 
34     if (isFailed && getIgnoreFailIfHostOff())
35     {
36         auto& hostState = HostStateMonitor::getInstance();
37         if (!hostState.isPowerOn())
38         {
39             return false;
40         }
41     }
42 
43     return isFailed;
44 }
45 
getFailReason(void)46 std::string PluggableSensor::getFailReason(void)
47 {
48     return _reader->getFailReason();
49 }
50 
51 } // namespace pid_control
52