blob: bd1e94c288723b0b887cf46d448371543a2f1861 [file] [log] [blame]
Alexander Hansen46a755f2025-10-27 16:31:08 +01001// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright 2017 Google Inc
Patrick Venture863b9242018-03-08 08:29:23 -08003
4#include "pluggable.hpp"
5
Potin Laie1fa8592025-08-29 15:27:08 +08006#include "hoststatemonitor.hpp"
Ed Tanousf8b6e552025-06-27 13:27:50 -07007#include "interfaces.hpp"
8
9#include <cstdint>
10#include <string>
11
Patrick Venturea0764872020-08-08 07:48:43 -070012namespace pid_control
13{
Patrick Venture863b9242018-03-08 08:29:23 -080014
Patrick Venture863b9242018-03-08 08:29:23 -080015ReadReturn PluggableSensor::read(void)
16{
17 return _reader->read();
18}
19
20void PluggableSensor::write(double value)
21{
22 _writer->write(value);
23}
James Feist36b7d8e2018-10-05 15:39:01 -070024
Josh Lehan2400ce42020-10-01 01:50:39 -070025void PluggableSensor::write(double value, bool force, int64_t* written)
26{
27 _writer->write(value, force, written);
28}
29
James Feist36b7d8e2018-10-05 15:39:01 -070030bool PluggableSensor::getFailed(void)
31{
Potin Laie1fa8592025-08-29 15:27:08 +080032 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;
Patrick Venturea0764872020-08-08 07:48:43 -070044}
45
Harvey Wua4270072024-05-29 16:11:13 +080046std::string PluggableSensor::getFailReason(void)
47{
48 return _reader->getFailReason();
49}
50
Patrick Venturea0764872020-08-08 07:48:43 -070051} // namespace pid_control