James Feist | 8fd8a58 | 2018-11-16 11:10:46 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <Thresholds.hpp> |
| 4 | #include <sdbusplus/asio/object_server.hpp> |
| 5 | |
James Feist | 1169eb4 | 2018-10-31 10:08:47 -0700 | [diff] [blame] | 6 | constexpr size_t sensorFailedPollTimeMs = 5000; |
James Feist | 8fd8a58 | 2018-11-16 11:10:46 -0800 | [diff] [blame] | 7 | struct Sensor |
| 8 | { |
James Feist | dc6c55f | 2018-10-31 12:53:20 -0700 | [diff] [blame] | 9 | 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 Feist | 8fd8a58 | 2018-11-16 11:10:46 -0800 | [diff] [blame] | 15 | virtual ~Sensor() = default; |
James Feist | dc6c55f | 2018-10-31 12:53:20 -0700 | [diff] [blame] | 16 | std::string name; |
| 17 | std::string path; |
James Feist | 8fd8a58 | 2018-11-16 11:10:46 -0800 | [diff] [blame] | 18 | 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 Thomaiyar | 8721922 | 2018-11-06 20:25:38 +0530 | [diff] [blame^] | 23 | 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 Feist | 8fd8a58 | 2018-11-16 11:10:46 -0800 | [diff] [blame] | 36 | }; |