blob: 62eec6263fa26915521231e01fbcbe440c92b0b6 [file] [log] [blame]
James Feistaf79dd32018-09-12 12:54:15 -07001#pragma once
2
3#include <Thresholds.hpp>
4#include <sdbusplus/asio/object_server.hpp>
5
James Feist3452f0e2018-10-31 10:08:47 -07006constexpr size_t sensorFailedPollTimeMs = 5000;
James Feistaf79dd32018-09-12 12:54:15 -07007struct Sensor
8{
James Feist39132a62018-10-31 12:53:20 -07009 Sensor(const std::string& name, const std::string& path,
10 std::vector<thresholds::Threshold>&& thresholdData) :
11 name(name),
12 path(path), thresholds(std::move(thresholdData))
13 {
14 }
James Feistaf79dd32018-09-12 12:54:15 -070015 virtual ~Sensor() = default;
James Feist39132a62018-10-31 12:53:20 -070016 std::string name;
17 std::string path;
James Feistaf79dd32018-09-12 12:54:15 -070018 std::vector<thresholds::Threshold> thresholds;
19 std::shared_ptr<sdbusplus::asio::dbus_interface> sensorInterface;
20 std::shared_ptr<sdbusplus::asio::dbus_interface> thresholdInterfaceWarning;
21 std::shared_ptr<sdbusplus::asio::dbus_interface> thresholdInterfaceCritical;
22 double value = std::numeric_limits<double>::quiet_NaN();
Richard Marian Thomaiyarb7bd2a82018-11-06 20:25:38 +053023 double overriddenValue = std::numeric_limits<double>::quiet_NaN();
24 bool internalSet = false;
25 int setSensorValue(const double& newValue, double& oldValue)
26 {
27 if (internalSet)
28 {
29 internalSet = false;
30 oldValue = newValue;
31 return 1;
32 }
33 overriddenValue = newValue;
34 return 1;
35 }
James Feistaf79dd32018-09-12 12:54:15 -070036};