Vijay Khemka | 7452a86 | 2020-08-11 16:01:23 -0700 | [diff] [blame] | 1 | #include "dbusSensor.hpp" |
Vijay Khemka | 92d648b | 2020-08-21 18:55:07 -0700 | [diff] [blame] | 2 | #include "exprtkTools.hpp" |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 3 | #include "thresholds.hpp" |
| 4 | |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 5 | #include <nlohmann/json.hpp> |
Patrick Williams | 82b39c6 | 2021-07-28 16:22:27 -0500 | [diff] [blame] | 6 | #include <phosphor-logging/lg2.hpp> |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 7 | #include <sdbusplus/bus.hpp> |
Lei YU | 0fcf0e1 | 2021-06-04 11:14:17 +0800 | [diff] [blame] | 8 | #include <xyz/openbmc_project/Association/Definitions/server.hpp> |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 9 | #include <xyz/openbmc_project/Sensor/Value/server.hpp> |
| 10 | |
| 11 | #include <map> |
| 12 | #include <string> |
| 13 | |
| 14 | namespace phosphor |
| 15 | { |
| 16 | namespace virtualSensor |
| 17 | { |
| 18 | |
Patrick Williams | 82b39c6 | 2021-07-28 16:22:27 -0500 | [diff] [blame] | 19 | PHOSPHOR_LOG2_USING_WITH_FLAGS; |
| 20 | |
Rashmica Gupta | e7efe13 | 2021-07-27 19:42:11 +1000 | [diff] [blame] | 21 | using BasicVariantType = |
| 22 | std::variant<std::string, int64_t, uint64_t, double, int32_t, uint32_t, |
| 23 | int16_t, uint16_t, uint8_t, bool, std::vector<std::string>>; |
| 24 | |
| 25 | using PropertyMap = std::map<std::string, BasicVariantType>; |
| 26 | |
| 27 | using InterfaceMap = std::map<std::string, PropertyMap>; |
| 28 | |
| 29 | using ManagedObjectType = |
| 30 | std::map<sdbusplus::message::object_path, InterfaceMap>; |
| 31 | |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 32 | using Json = nlohmann::json; |
Matt Spinler | ce67522 | 2021-01-14 16:38:09 -0600 | [diff] [blame] | 33 | |
| 34 | template <typename... T> |
Patrick Williams | 8e11ccc | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 35 | using ServerObject = typename sdbusplus::server::object_t<T...>; |
Matt Spinler | ce67522 | 2021-01-14 16:38:09 -0600 | [diff] [blame] | 36 | |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 37 | using ValueIface = sdbusplus::xyz::openbmc_project::Sensor::server::Value; |
Matt Spinler | ce67522 | 2021-01-14 16:38:09 -0600 | [diff] [blame] | 38 | using ValueObject = ServerObject<ValueIface>; |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 39 | |
Lei YU | 0fcf0e1 | 2021-06-04 11:14:17 +0800 | [diff] [blame] | 40 | using AssociationIface = |
| 41 | sdbusplus::xyz::openbmc_project::Association::server::Definitions; |
| 42 | using AssociationObject = ServerObject<AssociationIface>; |
| 43 | |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 44 | class SensorParam |
| 45 | { |
| 46 | public: |
| 47 | SensorParam() = delete; |
| 48 | virtual ~SensorParam() = default; |
| 49 | |
| 50 | enum ParamType |
| 51 | { |
| 52 | constParam, |
| 53 | dbusParam |
| 54 | }; |
| 55 | |
| 56 | /** @brief Constructs SensorParam (type = constParam) |
| 57 | * |
| 58 | * @param[in] value - Value of constant parameter |
| 59 | */ |
Patrick Williams | 1226f20 | 2023-05-10 07:51:16 -0500 | [diff] [blame] | 60 | explicit SensorParam(double value) : value(value), paramType(constParam) {} |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 61 | |
Vijay Khemka | 7452a86 | 2020-08-11 16:01:23 -0700 | [diff] [blame] | 62 | /** @brief Constructs SensorParam (type = dbusParam) |
| 63 | * |
| 64 | * @param[in] bus - Handle to system dbus |
| 65 | * @param[in] path - The Dbus path of sensor |
Vijay Khemka | 51f898e | 2020-09-09 22:24:18 -0700 | [diff] [blame] | 66 | * @param[in] ctx - sensor context for update |
Vijay Khemka | 7452a86 | 2020-08-11 16:01:23 -0700 | [diff] [blame] | 67 | */ |
Patrick Williams | 8e11ccc | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 68 | SensorParam(sdbusplus::bus_t& bus, const std::string& path, void* ctx) : |
Vijay Khemka | 51f898e | 2020-09-09 22:24:18 -0700 | [diff] [blame] | 69 | dbusSensor(std::make_unique<DbusSensor>(bus, path, ctx)), |
Vijay Khemka | 7452a86 | 2020-08-11 16:01:23 -0700 | [diff] [blame] | 70 | paramType(dbusParam) |
| 71 | {} |
| 72 | |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 73 | /** @brief Get sensor value property from D-bus interface */ |
| 74 | double getParamValue(); |
| 75 | |
| 76 | private: |
Vijay Khemka | 7452a86 | 2020-08-11 16:01:23 -0700 | [diff] [blame] | 77 | std::unique_ptr<DbusSensor> dbusSensor = nullptr; |
| 78 | double value = 0; |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 79 | ParamType paramType; |
| 80 | }; |
| 81 | |
Matt Spinler | ce67522 | 2021-01-14 16:38:09 -0600 | [diff] [blame] | 82 | class VirtualSensor : public ValueObject |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 83 | { |
| 84 | public: |
| 85 | VirtualSensor() = delete; |
| 86 | virtual ~VirtualSensor() = default; |
| 87 | |
| 88 | /** @brief Constructs VirtualSensor |
| 89 | * |
| 90 | * @param[in] bus - Handle to system dbus |
| 91 | * @param[in] objPath - The Dbus path of sensor |
| 92 | * @param[in] sensorConfig - Json object for sensor config |
| 93 | */ |
Patrick Williams | 8e11ccc | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 94 | VirtualSensor(sdbusplus::bus_t& bus, const char* objPath, |
Vijay Khemka | 32a7156 | 2020-09-10 15:29:18 -0700 | [diff] [blame] | 95 | const Json& sensorConfig, const std::string& name) : |
Rashmica Gupta | a2fa63a | 2021-08-06 12:21:13 +1000 | [diff] [blame] | 96 | ValueObject(bus, objPath, action::defer_emit), |
Vijay Khemka | 32a7156 | 2020-09-10 15:29:18 -0700 | [diff] [blame] | 97 | bus(bus), name(name) |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 98 | { |
Matt Spinler | ce67522 | 2021-01-14 16:38:09 -0600 | [diff] [blame] | 99 | initVirtualSensor(sensorConfig, objPath); |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Rashmica Gupta | e7efe13 | 2021-07-27 19:42:11 +1000 | [diff] [blame] | 102 | /** @brief Constructs VirtualSensor |
| 103 | * |
| 104 | * @param[in] bus - Handle to system dbus |
| 105 | * @param[in] objPath - The Dbus path of sensor |
| 106 | * @param[in] ifacemap - All the sensor information |
| 107 | * @param[in] name - Virtual sensor name |
| 108 | * @param[in] type - Virtual sensor type/unit |
| 109 | * @param[in] calcType - Calculation used to calculate sensor value |
Tao Lin | dc77701 | 2022-07-27 20:41:46 +0800 | [diff] [blame] | 110 | * @param[in] entityPath - Virtual sensor path in entityManager Dbus |
Rashmica Gupta | e7efe13 | 2021-07-27 19:42:11 +1000 | [diff] [blame] | 111 | * |
| 112 | */ |
Patrick Williams | 8e11ccc | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 113 | VirtualSensor(sdbusplus::bus_t& bus, const char* objPath, |
Rashmica Gupta | e7efe13 | 2021-07-27 19:42:11 +1000 | [diff] [blame] | 114 | const InterfaceMap& ifacemap, const std::string& name, |
Tao Lin | dc77701 | 2022-07-27 20:41:46 +0800 | [diff] [blame] | 115 | const std::string& type, const std::string& calculationType, |
| 116 | const std::string& entityPath) : |
Rashmica Gupta | e7efe13 | 2021-07-27 19:42:11 +1000 | [diff] [blame] | 117 | ValueObject(bus, objPath, action::defer_emit), |
Tao Lin | dc77701 | 2022-07-27 20:41:46 +0800 | [diff] [blame] | 118 | bus(bus), name(name), entityPath(entityPath) |
Rashmica Gupta | e7efe13 | 2021-07-27 19:42:11 +1000 | [diff] [blame] | 119 | { |
| 120 | initVirtualSensor(ifacemap, objPath, type, calculationType); |
| 121 | } |
| 122 | |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 123 | /** @brief Set sensor value */ |
| 124 | void setSensorValue(double value); |
Vijay Khemka | 3ed9a51 | 2020-08-21 16:13:05 -0700 | [diff] [blame] | 125 | /** @brief Update sensor at regular intrval */ |
| 126 | void updateVirtualSensor(); |
Rashmica Gupta | 304fd0e | 2021-08-10 16:50:44 +1000 | [diff] [blame] | 127 | /** @brief Check if sensor value is in valid range */ |
| 128 | bool sensorInRange(double value); |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 129 | |
| 130 | /** @brief Map of list of parameters */ |
| 131 | using ParamMap = |
| 132 | std::unordered_map<std::string, std::unique_ptr<SensorParam>>; |
| 133 | ParamMap paramMap; |
| 134 | |
| 135 | private: |
| 136 | /** @brief sdbusplus bus client connection. */ |
Patrick Williams | 8e11ccc | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 137 | sdbusplus::bus_t& bus; |
Vijay Khemka | 32a7156 | 2020-09-10 15:29:18 -0700 | [diff] [blame] | 138 | /** @brief name of sensor */ |
| 139 | std::string name; |
Tao Lin | dc77701 | 2022-07-27 20:41:46 +0800 | [diff] [blame] | 140 | |
| 141 | /** @brief Virtual sensor path in entityManager Dbus. |
| 142 | * This value is used to set thresholds/create association |
| 143 | */ |
| 144 | std::string entityPath; |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 145 | /** @brief Expression string for virtual sensor value calculations */ |
| 146 | std::string exprStr; |
Vijay Khemka | 3ed9a51 | 2020-08-21 16:13:05 -0700 | [diff] [blame] | 147 | /** @brief symbol table from exprtk */ |
| 148 | exprtk::symbol_table<double> symbols{}; |
| 149 | /** @brief expression from exprtk to calculate sensor value */ |
| 150 | exprtk::expression<double> expression{}; |
Matt Spinler | 9f1ef4f | 2020-11-09 15:59:11 -0600 | [diff] [blame] | 151 | /** @brief The vecops package so the expression can use vectors */ |
| 152 | exprtk::rtl::vecops::package<double> vecopsPackage; |
Rashmica Gupta | e7efe13 | 2021-07-27 19:42:11 +1000 | [diff] [blame] | 153 | /** @brief The maximum valid value for an input sensor **/ |
| 154 | double maxValidInput = std::numeric_limits<double>::infinity(); |
| 155 | /** @brief The minimum valid value for an input sensor **/ |
| 156 | double minValidInput = -std::numeric_limits<double>::infinity(); |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 157 | |
Matt Spinler | ce67522 | 2021-01-14 16:38:09 -0600 | [diff] [blame] | 158 | /** @brief The critical threshold interface object */ |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 159 | std::unique_ptr<Threshold<CriticalObject>> criticalIface; |
Matt Spinler | ce67522 | 2021-01-14 16:38:09 -0600 | [diff] [blame] | 160 | /** @brief The warning threshold interface object */ |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 161 | std::unique_ptr<Threshold<WarningObject>> warningIface; |
Matt Spinler | ce67522 | 2021-01-14 16:38:09 -0600 | [diff] [blame] | 162 | /** @brief The soft shutdown threshold interface object */ |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 163 | std::unique_ptr<Threshold<SoftShutdownObject>> softShutdownIface; |
Matt Spinler | ce67522 | 2021-01-14 16:38:09 -0600 | [diff] [blame] | 164 | /** @brief The hard shutdown threshold interface object */ |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 165 | std::unique_ptr<Threshold<HardShutdownObject>> hardShutdownIface; |
Matt Spinler | b306b03 | 2021-02-01 10:05:46 -0600 | [diff] [blame] | 166 | /** @brief The performance loss threshold interface object */ |
| 167 | std::unique_ptr<Threshold<PerformanceLossObject>> perfLossIface; |
Matt Spinler | ce67522 | 2021-01-14 16:38:09 -0600 | [diff] [blame] | 168 | |
Lei YU | 0fcf0e1 | 2021-06-04 11:14:17 +0800 | [diff] [blame] | 169 | /** @brief The association interface object */ |
| 170 | std::unique_ptr<AssociationObject> associationIface; |
| 171 | |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 172 | /** @brief Read config from json object and initialize sensor data |
| 173 | * for each virtual sensor |
| 174 | */ |
Matt Spinler | ce67522 | 2021-01-14 16:38:09 -0600 | [diff] [blame] | 175 | void initVirtualSensor(const Json& sensorConfig, |
| 176 | const std::string& objPath); |
| 177 | |
Rashmica Gupta | e7efe13 | 2021-07-27 19:42:11 +1000 | [diff] [blame] | 178 | /** @brief Read config from interface map and initialize sensor data |
| 179 | * for each virtual sensor |
| 180 | */ |
| 181 | void initVirtualSensor(const InterfaceMap& interfaceMap, |
| 182 | const std::string& objPath, |
| 183 | const std::string& sensorType, |
| 184 | const std::string& calculationType); |
| 185 | |
| 186 | /** @brief Returns which calculation function or expression to use */ |
Rashmica Gupta | 304fd0e | 2021-08-10 16:50:44 +1000 | [diff] [blame] | 187 | double calculateValue(const std::string& sensortype, |
| 188 | const VirtualSensor::ParamMap& paramMap); |
| 189 | /** @brief Calculate median value from sensors */ |
| 190 | double |
| 191 | calculateModifiedMedianValue(const VirtualSensor::ParamMap& paramMap); |
Tao Lin | f6b7e0a | 2022-10-09 09:35:44 +0800 | [diff] [blame] | 192 | /** @brief Calculate maximum value from sensors */ |
| 193 | double calculateMaximumValue(const VirtualSensor::ParamMap& paramMap); |
Rashmica Gupta | 3e99919 | 2021-06-09 16:17:04 +1000 | [diff] [blame] | 194 | /** @brief create threshold objects from json config */ |
| 195 | void createThresholds(const Json& threshold, const std::string& objPath); |
Rashmica Gupta | e7efe13 | 2021-07-27 19:42:11 +1000 | [diff] [blame] | 196 | /** @brief parse config from entity manager **/ |
| 197 | void parseConfigInterface(const PropertyMap& propertyMap, |
| 198 | const std::string& sensorType, |
| 199 | const std::string& interface); |
Rashmica Gupta | 3e99919 | 2021-06-09 16:17:04 +1000 | [diff] [blame] | 200 | |
Vijay Khemka | 32a7156 | 2020-09-10 15:29:18 -0700 | [diff] [blame] | 201 | /** @brief Check Sensor threshold and update alarm and log */ |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 202 | template <typename V, typename T> |
| 203 | void checkThresholds(V value, T& threshold) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 204 | { |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 205 | if (!threshold) |
| 206 | return; |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 207 | |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 208 | static constexpr auto tname = T::element_type::name; |
| 209 | |
| 210 | auto alarmHigh = threshold->alarmHigh(); |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 211 | auto highHysteresis = threshold->getHighHysteresis(); |
Matt Spinler | a4fe665 | 2021-01-28 14:02:59 -0600 | [diff] [blame] | 212 | if ((!alarmHigh && value >= threshold->high()) || |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 213 | (alarmHigh && value < (threshold->high() - highHysteresis))) |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 214 | { |
| 215 | if (!alarmHigh) |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 216 | { |
Patrick Williams | 82b39c6 | 2021-07-28 16:22:27 -0500 | [diff] [blame] | 217 | error("ASSERT: sensor {SENSOR} is above the upper threshold " |
| 218 | "{THRESHOLD}.", |
| 219 | "SENSOR", name, "THRESHOLD", tname); |
George Hung | 4294e6d | 2021-04-14 20:58:21 +0800 | [diff] [blame] | 220 | threshold->alarmHighSignalAsserted(value); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 221 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 222 | else |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 223 | { |
Patrick Williams | 82b39c6 | 2021-07-28 16:22:27 -0500 | [diff] [blame] | 224 | info("DEASSERT: sensor {SENSOR} is under the upper threshold " |
| 225 | "{THRESHOLD}.", |
| 226 | "SENSOR", name, "THRESHOLD", tname); |
George Hung | 4294e6d | 2021-04-14 20:58:21 +0800 | [diff] [blame] | 227 | threshold->alarmHighSignalDeasserted(value); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 228 | } |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 229 | threshold->alarmHigh(!alarmHigh); |
| 230 | } |
| 231 | |
| 232 | auto alarmLow = threshold->alarmLow(); |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 233 | auto lowHysteresis = threshold->getLowHysteresis(); |
Matt Spinler | a4fe665 | 2021-01-28 14:02:59 -0600 | [diff] [blame] | 234 | if ((!alarmLow && value <= threshold->low()) || |
Rashmica Gupta | 1dff7dc | 2021-07-27 19:43:31 +1000 | [diff] [blame] | 235 | (alarmLow && value > (threshold->low() + lowHysteresis))) |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 236 | { |
| 237 | if (!alarmLow) |
| 238 | { |
Patrick Williams | 82b39c6 | 2021-07-28 16:22:27 -0500 | [diff] [blame] | 239 | error("ASSERT: sensor {SENSOR} is below the lower threshold " |
| 240 | "{THRESHOLD}.", |
| 241 | "SENSOR", name, "THRESHOLD", tname); |
George Hung | 4294e6d | 2021-04-14 20:58:21 +0800 | [diff] [blame] | 242 | threshold->alarmLowSignalAsserted(value); |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 243 | } |
| 244 | else |
| 245 | { |
Patrick Williams | 82b39c6 | 2021-07-28 16:22:27 -0500 | [diff] [blame] | 246 | info("DEASSERT: sensor {SENSOR} is above the lower threshold " |
| 247 | "{THRESHOLD}.", |
| 248 | "SENSOR", name, "THRESHOLD", tname); |
George Hung | 4294e6d | 2021-04-14 20:58:21 +0800 | [diff] [blame] | 249 | threshold->alarmLowSignalDeasserted(value); |
Patrick Williams | fdb826d | 2021-01-20 14:37:53 -0600 | [diff] [blame] | 250 | } |
| 251 | threshold->alarmLow(!alarmLow); |
Matt Spinler | 8f5e611 | 2021-01-15 10:44:32 -0600 | [diff] [blame] | 252 | } |
| 253 | } |
Tao Lin | dc77701 | 2022-07-27 20:41:46 +0800 | [diff] [blame] | 254 | |
| 255 | /** @brief Create Association from entityPath*/ |
| 256 | void createAssociation(const std::string& objPath, |
| 257 | const std::string& entityPath); |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 258 | }; |
| 259 | |
| 260 | class VirtualSensors |
| 261 | { |
| 262 | public: |
| 263 | VirtualSensors() = delete; |
| 264 | virtual ~VirtualSensors() = default; |
| 265 | |
| 266 | /** @brief Constructs VirtualSensors |
| 267 | * |
| 268 | * @param[in] bus - Handle to system dbus |
| 269 | */ |
Patrick Williams | 8e11ccc | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 270 | explicit VirtualSensors(sdbusplus::bus_t& bus) : bus(bus) |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 271 | { |
| 272 | createVirtualSensors(); |
| 273 | } |
Rashmica Gupta | e7efe13 | 2021-07-27 19:42:11 +1000 | [diff] [blame] | 274 | /** @brief Calls createVirtualSensor when interface added */ |
Patrick Williams | 8e11ccc | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 275 | void propertiesChanged(sdbusplus::message_t& msg); |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 276 | |
| 277 | private: |
| 278 | /** @brief sdbusplus bus client connection. */ |
Patrick Williams | 8e11ccc | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 279 | sdbusplus::bus_t& bus; |
Rashmica Gupta | e7efe13 | 2021-07-27 19:42:11 +1000 | [diff] [blame] | 280 | /** @brief Get virual sensor config from DBus**/ |
| 281 | ManagedObjectType getObjectsFromDBus(); |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 282 | /** @brief Parsing virtual sensor config JSON file */ |
Patrick Williams | 32dff21 | 2023-02-09 13:54:18 -0600 | [diff] [blame] | 283 | Json parseConfigFile(); |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 284 | |
Rashmica Gupta | e7efe13 | 2021-07-27 19:42:11 +1000 | [diff] [blame] | 285 | /** @brief Matches for virtual sensors */ |
Patrick Williams | 8e11ccc | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 286 | std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches; |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 287 | /** @brief Map of the object VirtualSensor */ |
| 288 | std::unordered_map<std::string, std::unique_ptr<VirtualSensor>> |
| 289 | virtualSensorsMap; |
| 290 | |
Rashmica Gupta | e7efe13 | 2021-07-27 19:42:11 +1000 | [diff] [blame] | 291 | /** @brief Create list of virtual sensors from JSON config*/ |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 292 | void createVirtualSensors(); |
Rashmica Gupta | e7efe13 | 2021-07-27 19:42:11 +1000 | [diff] [blame] | 293 | /** @brief Create list of virtual sensors from DBus config */ |
| 294 | void createVirtualSensorsFromDBus(const std::string& calculationType); |
| 295 | /** @brief Setup matches for virtual sensors */ |
| 296 | void setupMatches(); |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 297 | }; |
| 298 | |
| 299 | } // namespace virtualSensor |
| 300 | } // namespace phosphor |