James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2018 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | |
Andrew Jeffery | e73bd0a | 2023-01-25 10:39:57 +1030 | [diff] [blame] | 17 | #include "ExitAirTempSensor.hpp" |
| 18 | |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame^] | 19 | #include "SensorPaths.hpp" |
| 20 | #include "Thresholds.hpp" |
Andrew Jeffery | e73bd0a | 2023-01-25 10:39:57 +1030 | [diff] [blame] | 21 | #include "Utils.hpp" |
| 22 | #include "VariantVisitors.hpp" |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame^] | 23 | #include "sensor.hpp" |
Andrew Jeffery | e73bd0a | 2023-01-25 10:39:57 +1030 | [diff] [blame] | 24 | |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 25 | #include <boost/algorithm/string/replace.hpp> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame^] | 26 | #include <boost/asio/error.hpp> |
| 27 | #include <boost/asio/io_context.hpp> |
| 28 | #include <boost/asio/post.hpp> |
| 29 | #include <boost/asio/steady_timer.hpp> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 30 | #include <boost/container/flat_map.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 31 | #include <sdbusplus/asio/connection.hpp> |
| 32 | #include <sdbusplus/asio/object_server.hpp> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame^] | 33 | #include <sdbusplus/bus.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 34 | #include <sdbusplus/bus/match.hpp> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame^] | 35 | #include <sdbusplus/message.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 36 | |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame^] | 37 | #include <algorithm> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 38 | #include <array> |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 39 | #include <chrono> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 40 | #include <cmath> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame^] | 41 | #include <cstddef> |
| 42 | #include <cstdint> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 43 | #include <functional> |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 44 | #include <iostream> |
| 45 | #include <limits> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 46 | #include <memory> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 47 | #include <stdexcept> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame^] | 48 | #include <string> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 49 | #include <utility> |
| 50 | #include <variant> |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 51 | #include <vector> |
| 52 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 53 | constexpr const double altitudeFactor = 1.14; |
Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 54 | constexpr const char* exitAirType = "ExitAirTempSensor"; |
| 55 | constexpr const char* cfmType = "CFMSensor"; |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 56 | |
| 57 | // todo: this *might* need to be configurable |
| 58 | constexpr const char* inletTemperatureSensor = "temperature/Front_Panel_Temp"; |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 59 | constexpr const char* pidConfigurationType = |
| 60 | "xyz.openbmc_project.Configuration.Pid"; |
| 61 | constexpr const char* settingsDaemon = "xyz.openbmc_project.Settings"; |
| 62 | constexpr const char* cfmSettingPath = "/xyz/openbmc_project/control/cfm_limit"; |
| 63 | constexpr const char* cfmSettingIface = "xyz.openbmc_project.Control.CFMLimit"; |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 64 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 65 | static constexpr bool debug = false; |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 66 | |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 67 | static constexpr double cfmMaxReading = 255; |
| 68 | static constexpr double cfmMinReading = 0; |
| 69 | |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 70 | static constexpr size_t minSystemCfm = 50; |
| 71 | |
Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 72 | constexpr const auto monitorTypes{ |
| 73 | std::to_array<const char*>({exitAirType, cfmType})}; |
James Feist | 655f376 | 2020-10-05 15:28:15 -0700 | [diff] [blame] | 74 | |
James Feist | 9a25ed4 | 2019-10-15 15:43:44 -0700 | [diff] [blame] | 75 | static std::vector<std::shared_ptr<CFMSensor>> cfmSensors; |
| 76 | |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 77 | static void setupSensorMatch( |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 78 | std::vector<sdbusplus::bus::match_t>& matches, sdbusplus::bus_t& connection, |
| 79 | const std::string& type, |
| 80 | std::function<void(const double&, sdbusplus::message_t&)>&& callback) |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 81 | { |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 82 | std::function<void(sdbusplus::message_t & message)> eventHandler = |
| 83 | [callback{std::move(callback)}](sdbusplus::message_t& message) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 84 | std::string objectName; |
| 85 | boost::container::flat_map<std::string, std::variant<double, int64_t>> |
| 86 | values; |
| 87 | message.read(objectName, values); |
| 88 | auto findValue = values.find("Value"); |
| 89 | if (findValue == values.end()) |
| 90 | { |
| 91 | return; |
| 92 | } |
| 93 | double value = std::visit(VariantToDoubleVisitor(), findValue->second); |
| 94 | if (std::isnan(value)) |
| 95 | { |
| 96 | return; |
| 97 | } |
James Feist | 9566bfa | 2019-01-29 15:31:23 -0800 | [diff] [blame] | 98 | |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 99 | callback(value, message); |
| 100 | }; |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 101 | matches.emplace_back(connection, |
| 102 | "type='signal'," |
| 103 | "member='PropertiesChanged',interface='org." |
| 104 | "freedesktop.DBus.Properties',path_" |
| 105 | "namespace='/xyz/openbmc_project/sensors/" + |
| 106 | std::string(type) + |
| 107 | "',arg0='xyz.openbmc_project.Sensor.Value'", |
| 108 | std::move(eventHandler)); |
| 109 | } |
| 110 | |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 111 | static void setMaxPWM(const std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 112 | double value) |
| 113 | { |
| 114 | using GetSubTreeType = std::vector<std::pair< |
| 115 | std::string, |
| 116 | std::vector<std::pair<std::string, std::vector<std::string>>>>>; |
| 117 | |
| 118 | conn->async_method_call( |
| 119 | [conn, value](const boost::system::error_code ec, |
| 120 | const GetSubTreeType& ret) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 121 | if (ec) |
| 122 | { |
| 123 | std::cerr << "Error calling mapper\n"; |
| 124 | return; |
| 125 | } |
| 126 | for (const auto& [path, objDict] : ret) |
| 127 | { |
| 128 | if (objDict.empty()) |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 129 | { |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 130 | return; |
| 131 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 132 | const std::string& owner = objDict.begin()->first; |
| 133 | |
| 134 | conn->async_method_call( |
| 135 | [conn, value, owner, |
| 136 | path{path}](const boost::system::error_code ec, |
| 137 | const std::variant<std::string>& classType) { |
| 138 | if (ec) |
| 139 | { |
| 140 | std::cerr << "Error getting pid class\n"; |
| 141 | return; |
| 142 | } |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 143 | const auto* classStr = std::get_if<std::string>(&classType); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 144 | if (classStr == nullptr || *classStr != "fan") |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 145 | { |
| 146 | return; |
| 147 | } |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 148 | conn->async_method_call( |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 149 | [](boost::system::error_code& ec) { |
| 150 | if (ec) |
| 151 | { |
| 152 | std::cerr << "Error setting pid class\n"; |
| 153 | return; |
| 154 | } |
Patrick Williams | 597e842 | 2023-10-20 11:19:01 -0500 | [diff] [blame] | 155 | }, |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 156 | owner, path, "org.freedesktop.DBus.Properties", "Set", |
| 157 | pidConfigurationType, "OutLimitMax", |
| 158 | std::variant<double>(value)); |
Patrick Williams | 597e842 | 2023-10-20 11:19:01 -0500 | [diff] [blame] | 159 | }, |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 160 | owner, path, "org.freedesktop.DBus.Properties", "Get", |
| 161 | pidConfigurationType, "Class"); |
| 162 | } |
Patrick Williams | 597e842 | 2023-10-20 11:19:01 -0500 | [diff] [blame] | 163 | }, |
James Feist | a5e5872 | 2019-04-22 14:43:11 -0700 | [diff] [blame] | 164 | mapper::busName, mapper::path, mapper::interface, mapper::subtree, "/", |
| 165 | 0, std::array<std::string, 1>{pidConfigurationType}); |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 166 | } |
| 167 | |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 168 | CFMSensor::CFMSensor(std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 169 | const std::string& sensorName, |
| 170 | const std::string& sensorConfiguration, |
| 171 | sdbusplus::asio::object_server& objectServer, |
James Feist | b839c05 | 2019-05-15 10:25:24 -0700 | [diff] [blame] | 172 | std::vector<thresholds::Threshold>&& thresholdData, |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 173 | std::shared_ptr<ExitAirTempSensor>& parent) : |
Zhikui Ren | da98f09 | 2021-11-01 09:41:08 -0700 | [diff] [blame] | 174 | Sensor(escapeName(sensorName), std::move(thresholdData), |
Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 175 | sensorConfiguration, "CFMSensor", false, false, cfmMaxReading, |
| 176 | cfmMinReading, conn, PowerState::on), |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 177 | parent(parent), objServer(objectServer) |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 178 | { |
Basheer Ahmed Muddebihal | e5b867b | 2021-07-26 08:32:19 -0700 | [diff] [blame] | 179 | sensorInterface = objectServer.add_interface( |
| 180 | "/xyz/openbmc_project/sensors/airflow/" + name, |
| 181 | "xyz.openbmc_project.Sensor.Value"); |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 182 | |
Jayashree Dhanapal | 5667808 | 2022-01-04 17:27:20 +0530 | [diff] [blame] | 183 | for (const auto& threshold : thresholds) |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 184 | { |
Jayashree Dhanapal | 5667808 | 2022-01-04 17:27:20 +0530 | [diff] [blame] | 185 | std::string interface = thresholds::getInterface(threshold.level); |
| 186 | thresholdInterfaces[static_cast<size_t>(threshold.level)] = |
| 187 | objectServer.add_interface( |
| 188 | "/xyz/openbmc_project/sensors/airflow/" + name, interface); |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 189 | } |
James Feist | 078f232 | 2019-03-08 11:09:05 -0800 | [diff] [blame] | 190 | |
| 191 | association = objectServer.add_interface( |
Basheer Ahmed Muddebihal | e5b867b | 2021-07-26 08:32:19 -0700 | [diff] [blame] | 192 | "/xyz/openbmc_project/sensors/airflow/" + name, association::interface); |
James Feist | 078f232 | 2019-03-08 11:09:05 -0800 | [diff] [blame] | 193 | |
Andrei Kartashev | 3928741 | 2022-02-04 16:04:47 +0300 | [diff] [blame] | 194 | setInitialProperties(sensor_paths::unitCFM); |
James Feist | 9a25ed4 | 2019-10-15 15:43:44 -0700 | [diff] [blame] | 195 | |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 196 | pwmLimitIface = |
| 197 | objectServer.add_interface("/xyz/openbmc_project/control/pwm_limit", |
| 198 | "xyz.openbmc_project.Control.PWMLimit"); |
| 199 | cfmLimitIface = |
| 200 | objectServer.add_interface("/xyz/openbmc_project/control/MaxCFM", |
| 201 | "xyz.openbmc_project.Control.CFMLimit"); |
James Feist | 9a25ed4 | 2019-10-15 15:43:44 -0700 | [diff] [blame] | 202 | } |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 203 | |
James Feist | 9a25ed4 | 2019-10-15 15:43:44 -0700 | [diff] [blame] | 204 | void CFMSensor::setupMatches() |
| 205 | { |
Zhikui Ren | dbb73aa | 2021-04-02 13:39:04 -0700 | [diff] [blame] | 206 | std::weak_ptr<CFMSensor> weakRef = weak_from_this(); |
Ed Tanous | 8a17c30 | 2021-09-02 15:07:11 -0700 | [diff] [blame] | 207 | setupSensorMatch( |
| 208 | matches, *dbusConnection, "fan_tach", |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 209 | [weakRef](const double& value, sdbusplus::message_t& message) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 210 | auto self = weakRef.lock(); |
| 211 | if (!self) |
| 212 | { |
| 213 | return; |
| 214 | } |
| 215 | self->tachReadings[message.get_path()] = value; |
| 216 | if (self->tachRanges.find(message.get_path()) == self->tachRanges.end()) |
| 217 | { |
| 218 | // calls update reading after updating ranges |
| 219 | self->addTachRanges(message.get_sender(), message.get_path()); |
| 220 | } |
| 221 | else |
| 222 | { |
| 223 | self->updateReading(); |
| 224 | } |
Patrick Williams | 597e842 | 2023-10-20 11:19:01 -0500 | [diff] [blame] | 225 | }); |
James Feist | 9a25ed4 | 2019-10-15 15:43:44 -0700 | [diff] [blame] | 226 | |
| 227 | dbusConnection->async_method_call( |
Zhikui Ren | dbb73aa | 2021-04-02 13:39:04 -0700 | [diff] [blame] | 228 | [weakRef](const boost::system::error_code ec, |
| 229 | const std::variant<double> cfmVariant) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 230 | auto self = weakRef.lock(); |
| 231 | if (!self) |
| 232 | { |
| 233 | return; |
| 234 | } |
Zhikui Ren | dbb73aa | 2021-04-02 13:39:04 -0700 | [diff] [blame] | 235 | |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 236 | uint64_t maxRpm = 100; |
| 237 | if (!ec) |
| 238 | { |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 239 | const auto* cfm = std::get_if<double>(&cfmVariant); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 240 | if (cfm != nullptr && *cfm >= minSystemCfm) |
| 241 | { |
| 242 | maxRpm = self->getMaxRpm(*cfm); |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 243 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 244 | } |
| 245 | self->pwmLimitIface->register_property("Limit", maxRpm); |
| 246 | self->pwmLimitIface->initialize(); |
| 247 | setMaxPWM(self->dbusConnection, maxRpm); |
Patrick Williams | 597e842 | 2023-10-20 11:19:01 -0500 | [diff] [blame] | 248 | }, |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 249 | settingsDaemon, cfmSettingPath, "org.freedesktop.DBus.Properties", |
| 250 | "Get", cfmSettingIface, "Limit"); |
| 251 | |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 252 | matches.emplace_back(*dbusConnection, |
| 253 | "type='signal'," |
| 254 | "member='PropertiesChanged',interface='org." |
| 255 | "freedesktop.DBus.Properties',path='" + |
| 256 | std::string(cfmSettingPath) + "',arg0='" + |
| 257 | std::string(cfmSettingIface) + "'", |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 258 | [weakRef](sdbusplus::message_t& message) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 259 | auto self = weakRef.lock(); |
| 260 | if (!self) |
| 261 | { |
| 262 | return; |
| 263 | } |
| 264 | boost::container::flat_map<std::string, std::variant<double>> values; |
| 265 | std::string objectName; |
| 266 | message.read(objectName, values); |
| 267 | const auto findValue = values.find("Limit"); |
| 268 | if (findValue == values.end()) |
| 269 | { |
| 270 | return; |
| 271 | } |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 272 | auto* const reading = std::get_if<double>(&(findValue->second)); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 273 | if (reading == nullptr) |
| 274 | { |
| 275 | std::cerr << "Got CFM Limit of wrong type\n"; |
| 276 | return; |
| 277 | } |
| 278 | if (*reading < minSystemCfm && *reading != 0) |
| 279 | { |
| 280 | std::cerr << "Illegal CFM setting detected\n"; |
| 281 | return; |
| 282 | } |
| 283 | uint64_t maxRpm = self->getMaxRpm(*reading); |
| 284 | self->pwmLimitIface->set_property("Limit", maxRpm); |
| 285 | setMaxPWM(self->dbusConnection, maxRpm); |
| 286 | }); |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 287 | } |
| 288 | |
James Feist | 9566bfa | 2019-01-29 15:31:23 -0800 | [diff] [blame] | 289 | CFMSensor::~CFMSensor() |
| 290 | { |
Jayashree Dhanapal | 5667808 | 2022-01-04 17:27:20 +0530 | [diff] [blame] | 291 | for (const auto& iface : thresholdInterfaces) |
| 292 | { |
| 293 | objServer.remove_interface(iface); |
| 294 | } |
James Feist | 9566bfa | 2019-01-29 15:31:23 -0800 | [diff] [blame] | 295 | objServer.remove_interface(sensorInterface); |
James Feist | 078f232 | 2019-03-08 11:09:05 -0800 | [diff] [blame] | 296 | objServer.remove_interface(association); |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 297 | objServer.remove_interface(cfmLimitIface); |
| 298 | objServer.remove_interface(pwmLimitIface); |
| 299 | } |
| 300 | |
Ed Tanous | 201a101 | 2024-04-03 18:07:28 -0700 | [diff] [blame] | 301 | void CFMSensor::createMaxCFMIface() |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 302 | { |
James Feist | b6c0b91 | 2019-07-09 12:21:44 -0700 | [diff] [blame] | 303 | cfmLimitIface->register_property("Limit", c2 * maxCFM * tachs.size()); |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 304 | cfmLimitIface->initialize(); |
James Feist | 9566bfa | 2019-01-29 15:31:23 -0800 | [diff] [blame] | 305 | } |
| 306 | |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 307 | void CFMSensor::addTachRanges(const std::string& serviceName, |
| 308 | const std::string& path) |
| 309 | { |
Zhikui Ren | dbb73aa | 2021-04-02 13:39:04 -0700 | [diff] [blame] | 310 | std::weak_ptr<CFMSensor> weakRef = weak_from_this(); |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 311 | dbusConnection->async_method_call( |
Zev Weiss | afd1504 | 2022-07-18 12:28:40 -0700 | [diff] [blame] | 312 | [weakRef, path](const boost::system::error_code ec, |
| 313 | const SensorBaseConfigMap& data) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 314 | if (ec) |
| 315 | { |
| 316 | std::cerr << "Error getting properties from " << path << "\n"; |
| 317 | return; |
| 318 | } |
| 319 | auto self = weakRef.lock(); |
| 320 | if (!self) |
| 321 | { |
| 322 | return; |
| 323 | } |
| 324 | double max = loadVariant<double>(data, "MaxValue"); |
| 325 | double min = loadVariant<double>(data, "MinValue"); |
| 326 | self->tachRanges[path] = std::make_pair(min, max); |
| 327 | self->updateReading(); |
Patrick Williams | 597e842 | 2023-10-20 11:19:01 -0500 | [diff] [blame] | 328 | }, |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 329 | serviceName, path, "org.freedesktop.DBus.Properties", "GetAll", |
| 330 | "xyz.openbmc_project.Sensor.Value"); |
| 331 | } |
| 332 | |
Ed Tanous | 201a101 | 2024-04-03 18:07:28 -0700 | [diff] [blame] | 333 | void CFMSensor::checkThresholds() |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 334 | { |
| 335 | thresholds::checkThresholds(this); |
| 336 | } |
| 337 | |
Ed Tanous | 201a101 | 2024-04-03 18:07:28 -0700 | [diff] [blame] | 338 | void CFMSensor::updateReading() |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 339 | { |
| 340 | double val = 0.0; |
| 341 | if (calculate(val)) |
| 342 | { |
| 343 | if (value != val && parent) |
| 344 | { |
| 345 | parent->updateReading(); |
| 346 | } |
| 347 | updateValue(val); |
| 348 | } |
| 349 | else |
| 350 | { |
| 351 | updateValue(std::numeric_limits<double>::quiet_NaN()); |
| 352 | } |
| 353 | } |
| 354 | |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 355 | uint64_t CFMSensor::getMaxRpm(uint64_t cfmMaxSetting) const |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 356 | { |
| 357 | uint64_t pwmPercent = 100; |
| 358 | double totalCFM = std::numeric_limits<double>::max(); |
| 359 | if (cfmMaxSetting == 0) |
| 360 | { |
| 361 | return pwmPercent; |
| 362 | } |
| 363 | |
James Feist | 5242795 | 2019-04-05 14:23:35 -0700 | [diff] [blame] | 364 | bool firstLoop = true; |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 365 | while (totalCFM > cfmMaxSetting) |
| 366 | { |
James Feist | 5242795 | 2019-04-05 14:23:35 -0700 | [diff] [blame] | 367 | if (firstLoop) |
| 368 | { |
| 369 | firstLoop = false; |
| 370 | } |
| 371 | else |
| 372 | { |
| 373 | pwmPercent--; |
| 374 | } |
| 375 | |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 376 | double ci = 0; |
| 377 | if (pwmPercent == 0) |
| 378 | { |
| 379 | ci = 0; |
| 380 | } |
| 381 | else if (pwmPercent < tachMinPercent) |
| 382 | { |
| 383 | ci = c1; |
| 384 | } |
| 385 | else if (pwmPercent > tachMaxPercent) |
| 386 | { |
| 387 | ci = c2; |
| 388 | } |
| 389 | else |
| 390 | { |
| 391 | ci = c1 + (((c2 - c1) * (pwmPercent - tachMinPercent)) / |
| 392 | (tachMaxPercent - tachMinPercent)); |
| 393 | } |
| 394 | |
| 395 | // Now calculate the CFM for this tach |
| 396 | // CFMi = Ci * Qmaxi * TACHi |
| 397 | totalCFM = ci * maxCFM * pwmPercent; |
| 398 | totalCFM *= tachs.size(); |
| 399 | // divide by 100 since pwm is in percent |
| 400 | totalCFM /= 100; |
| 401 | |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 402 | if (pwmPercent <= 0) |
| 403 | { |
| 404 | break; |
| 405 | } |
| 406 | } |
James Feist | 5242795 | 2019-04-05 14:23:35 -0700 | [diff] [blame] | 407 | |
James Feist | 1345209 | 2019-03-07 16:38:12 -0800 | [diff] [blame] | 408 | return pwmPercent; |
| 409 | } |
| 410 | |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 411 | bool CFMSensor::calculate(double& value) |
| 412 | { |
| 413 | double totalCFM = 0; |
| 414 | for (const std::string& tachName : tachs) |
| 415 | { |
| 416 | auto findReading = std::find_if( |
Zev Weiss | 6c106d6 | 2022-08-17 20:50:00 -0700 | [diff] [blame] | 417 | tachReadings.begin(), tachReadings.end(), |
| 418 | [&](const auto& item) { return item.first.ends_with(tachName); }); |
Patrick Williams | 597e842 | 2023-10-20 11:19:01 -0500 | [diff] [blame] | 419 | auto findRange = std::find_if( |
| 420 | tachRanges.begin(), tachRanges.end(), |
| 421 | [&](const auto& item) { return item.first.ends_with(tachName); }); |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 422 | if (findReading == tachReadings.end()) |
| 423 | { |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 424 | if constexpr (debug) |
James Feist | a96329f | 2019-01-24 10:08:27 -0800 | [diff] [blame] | 425 | { |
| 426 | std::cerr << "Can't find " << tachName << "in readings\n"; |
| 427 | } |
James Feist | 9566bfa | 2019-01-29 15:31:23 -0800 | [diff] [blame] | 428 | continue; // haven't gotten a reading |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | if (findRange == tachRanges.end()) |
| 432 | { |
James Feist | 523828e | 2019-03-04 14:38:37 -0800 | [diff] [blame] | 433 | std::cerr << "Can't find " << tachName << " in ranges\n"; |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 434 | return false; // haven't gotten a max / min |
| 435 | } |
| 436 | |
| 437 | // avoid divide by 0 |
| 438 | if (findRange->second.second == 0) |
| 439 | { |
| 440 | std::cerr << "Tach Max Set to 0 " << tachName << "\n"; |
| 441 | return false; |
| 442 | } |
| 443 | |
| 444 | double rpm = findReading->second; |
| 445 | |
| 446 | // for now assume the min for a fan is always 0, divide by max to get |
| 447 | // percent and mult by 100 |
| 448 | rpm /= findRange->second.second; |
| 449 | rpm *= 100; |
| 450 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 451 | if constexpr (debug) |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 452 | { |
| 453 | std::cout << "Tach " << tachName << "at " << rpm << "\n"; |
| 454 | } |
| 455 | |
| 456 | // Do a linear interpolation to get Ci |
| 457 | // Ci = C1 + (C2 - C1)/(RPM2 - RPM1) * (TACHi - TACH1) |
| 458 | |
| 459 | double ci = 0; |
| 460 | if (rpm == 0) |
| 461 | { |
| 462 | ci = 0; |
| 463 | } |
| 464 | else if (rpm < tachMinPercent) |
| 465 | { |
| 466 | ci = c1; |
| 467 | } |
| 468 | else if (rpm > tachMaxPercent) |
| 469 | { |
| 470 | ci = c2; |
| 471 | } |
| 472 | else |
| 473 | { |
| 474 | ci = c1 + (((c2 - c1) * (rpm - tachMinPercent)) / |
| 475 | (tachMaxPercent - tachMinPercent)); |
| 476 | } |
| 477 | |
| 478 | // Now calculate the CFM for this tach |
| 479 | // CFMi = Ci * Qmaxi * TACHi |
| 480 | totalCFM += ci * maxCFM * rpm; |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 481 | if constexpr (debug) |
James Feist | a5e5872 | 2019-04-22 14:43:11 -0700 | [diff] [blame] | 482 | { |
| 483 | std::cerr << "totalCFM = " << totalCFM << "\n"; |
| 484 | std::cerr << "Ci " << ci << " MaxCFM " << maxCFM << " rpm " << rpm |
| 485 | << "\n"; |
| 486 | std::cerr << "c1 " << c1 << " c2 " << c2 << " max " |
| 487 | << tachMaxPercent << " min " << tachMinPercent << "\n"; |
| 488 | } |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | // divide by 100 since rpm is in percent |
| 492 | value = totalCFM / 100; |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 493 | if constexpr (debug) |
James Feist | a5e5872 | 2019-04-22 14:43:11 -0700 | [diff] [blame] | 494 | { |
| 495 | std::cerr << "cfm value = " << value << "\n"; |
| 496 | } |
James Feist | 9566bfa | 2019-01-29 15:31:23 -0800 | [diff] [blame] | 497 | return true; |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | static constexpr double exitAirMaxReading = 127; |
| 501 | static constexpr double exitAirMinReading = -128; |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 502 | ExitAirTempSensor::ExitAirTempSensor( |
| 503 | std::shared_ptr<sdbusplus::asio::connection>& conn, |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 504 | const std::string& sensorName, const std::string& sensorConfiguration, |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 505 | sdbusplus::asio::object_server& objectServer, |
James Feist | b839c05 | 2019-05-15 10:25:24 -0700 | [diff] [blame] | 506 | std::vector<thresholds::Threshold>&& thresholdData) : |
Zhikui Ren | da98f09 | 2021-11-01 09:41:08 -0700 | [diff] [blame] | 507 | Sensor(escapeName(sensorName), std::move(thresholdData), |
Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 508 | sensorConfiguration, "ExitAirTemp", false, false, exitAirMaxReading, |
| 509 | exitAirMinReading, conn, PowerState::on), |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 510 | objServer(objectServer) |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 511 | { |
| 512 | sensorInterface = objectServer.add_interface( |
| 513 | "/xyz/openbmc_project/sensors/temperature/" + name, |
| 514 | "xyz.openbmc_project.Sensor.Value"); |
| 515 | |
Jayashree Dhanapal | 5667808 | 2022-01-04 17:27:20 +0530 | [diff] [blame] | 516 | for (const auto& threshold : thresholds) |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 517 | { |
Jayashree Dhanapal | 5667808 | 2022-01-04 17:27:20 +0530 | [diff] [blame] | 518 | std::string interface = thresholds::getInterface(threshold.level); |
| 519 | thresholdInterfaces[static_cast<size_t>(threshold.level)] = |
| 520 | objectServer.add_interface( |
| 521 | "/xyz/openbmc_project/sensors/temperature/" + name, interface); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 522 | } |
James Feist | 078f232 | 2019-03-08 11:09:05 -0800 | [diff] [blame] | 523 | association = objectServer.add_interface( |
| 524 | "/xyz/openbmc_project/sensors/temperature/" + name, |
James Feist | 2adc95c | 2019-09-30 14:55:28 -0700 | [diff] [blame] | 525 | association::interface); |
Andrei Kartashev | 3928741 | 2022-02-04 16:04:47 +0300 | [diff] [blame] | 526 | setInitialProperties(sensor_paths::unitDegreesC); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | ExitAirTempSensor::~ExitAirTempSensor() |
| 530 | { |
Jayashree Dhanapal | 5667808 | 2022-01-04 17:27:20 +0530 | [diff] [blame] | 531 | for (const auto& iface : thresholdInterfaces) |
| 532 | { |
| 533 | objServer.remove_interface(iface); |
| 534 | } |
James Feist | 523828e | 2019-03-04 14:38:37 -0800 | [diff] [blame] | 535 | objServer.remove_interface(sensorInterface); |
James Feist | 078f232 | 2019-03-08 11:09:05 -0800 | [diff] [blame] | 536 | objServer.remove_interface(association); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 537 | } |
| 538 | |
Ed Tanous | 201a101 | 2024-04-03 18:07:28 -0700 | [diff] [blame] | 539 | void ExitAirTempSensor::setupMatches() |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 540 | { |
Brandon Kim | 6655823 | 2021-11-09 16:53:08 -0800 | [diff] [blame] | 541 | constexpr const auto matchTypes{ |
| 542 | std::to_array<const char*>({"power", inletTemperatureSensor})}; |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 543 | |
Zhikui Ren | dbb73aa | 2021-04-02 13:39:04 -0700 | [diff] [blame] | 544 | std::weak_ptr<ExitAirTempSensor> weakRef = weak_from_this(); |
Ed Tanous | 13b63f8 | 2021-05-11 16:12:52 -0700 | [diff] [blame] | 545 | for (const std::string type : matchTypes) |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 546 | { |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 547 | setupSensorMatch(matches, *dbusConnection, type, |
Zhikui Ren | dbb73aa | 2021-04-02 13:39:04 -0700 | [diff] [blame] | 548 | [weakRef, type](const double& value, |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 549 | sdbusplus::message_t& message) { |
Zhikui Ren | dbb73aa | 2021-04-02 13:39:04 -0700 | [diff] [blame] | 550 | auto self = weakRef.lock(); |
| 551 | if (!self) |
| 552 | { |
| 553 | return; |
| 554 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 555 | if (type == "power") |
| 556 | { |
| 557 | std::string path = message.get_path(); |
| 558 | if (path.find("PS") != std::string::npos && |
Zev Weiss | 6c106d6 | 2022-08-17 20:50:00 -0700 | [diff] [blame] | 559 | path.ends_with("Input_Power")) |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 560 | { |
| 561 | self->powerReadings[message.get_path()] = value; |
| 562 | } |
| 563 | } |
| 564 | else if (type == inletTemperatureSensor) |
| 565 | { |
| 566 | self->inletTemp = value; |
| 567 | } |
| 568 | self->updateReading(); |
| 569 | }); |
| 570 | } |
| 571 | dbusConnection->async_method_call( |
| 572 | [weakRef](boost::system::error_code ec, |
| 573 | const std::variant<double>& value) { |
| 574 | if (ec) |
| 575 | { |
| 576 | // sensor not ready yet |
| 577 | return; |
| 578 | } |
| 579 | auto self = weakRef.lock(); |
| 580 | if (!self) |
| 581 | { |
| 582 | return; |
| 583 | } |
| 584 | self->inletTemp = std::visit(VariantToDoubleVisitor(), value); |
Patrick Williams | 597e842 | 2023-10-20 11:19:01 -0500 | [diff] [blame] | 585 | }, |
James Feist | 9566bfa | 2019-01-29 15:31:23 -0800 | [diff] [blame] | 586 | "xyz.openbmc_project.HwmonTempSensor", |
| 587 | std::string("/xyz/openbmc_project/sensors/") + inletTemperatureSensor, |
James Feist | a5e5872 | 2019-04-22 14:43:11 -0700 | [diff] [blame] | 588 | properties::interface, properties::get, sensorValueInterface, "Value"); |
| 589 | dbusConnection->async_method_call( |
Zhikui Ren | dbb73aa | 2021-04-02 13:39:04 -0700 | [diff] [blame] | 590 | [weakRef](boost::system::error_code ec, const GetSubTreeType& subtree) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 591 | if (ec) |
| 592 | { |
| 593 | std::cerr << "Error contacting mapper\n"; |
| 594 | return; |
| 595 | } |
| 596 | auto self = weakRef.lock(); |
| 597 | if (!self) |
| 598 | { |
| 599 | return; |
| 600 | } |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 601 | for (const auto& [path, matches] : subtree) |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 602 | { |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 603 | size_t lastSlash = path.rfind('/'); |
| 604 | if (lastSlash == std::string::npos || lastSlash == path.size() || |
| 605 | matches.empty()) |
James Feist | a5e5872 | 2019-04-22 14:43:11 -0700 | [diff] [blame] | 606 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 607 | continue; |
James Feist | a5e5872 | 2019-04-22 14:43:11 -0700 | [diff] [blame] | 608 | } |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 609 | std::string sensorName = path.substr(lastSlash + 1); |
Zev Weiss | 6c106d6 | 2022-08-17 20:50:00 -0700 | [diff] [blame] | 610 | if (sensorName.starts_with("PS") && |
| 611 | sensorName.ends_with("Input_Power")) |
Zhikui Ren | dbb73aa | 2021-04-02 13:39:04 -0700 | [diff] [blame] | 612 | { |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 613 | // lambda capture requires a proper variable (not a structured |
| 614 | // binding) |
| 615 | const std::string& cbPath = path; |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 616 | self->dbusConnection->async_method_call( |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 617 | [weakRef, cbPath](boost::system::error_code ec, |
| 618 | const std::variant<double>& value) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 619 | if (ec) |
| 620 | { |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 621 | std::cerr << "Error getting value from " << cbPath |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 622 | << "\n"; |
| 623 | } |
| 624 | auto self = weakRef.lock(); |
| 625 | if (!self) |
| 626 | { |
| 627 | return; |
| 628 | } |
Patrick Williams | 779c96a | 2023-05-10 07:50:42 -0500 | [diff] [blame] | 629 | double reading = std::visit(VariantToDoubleVisitor(), |
| 630 | value); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 631 | if constexpr (debug) |
| 632 | { |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 633 | std::cerr << cbPath << "Reading " << reading << "\n"; |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 634 | } |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 635 | self->powerReadings[cbPath] = reading; |
Patrick Williams | 597e842 | 2023-10-20 11:19:01 -0500 | [diff] [blame] | 636 | }, |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 637 | matches[0].first, cbPath, properties::interface, |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 638 | properties::get, sensorValueInterface, "Value"); |
Zhikui Ren | dbb73aa | 2021-04-02 13:39:04 -0700 | [diff] [blame] | 639 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 640 | } |
Patrick Williams | 597e842 | 2023-10-20 11:19:01 -0500 | [diff] [blame] | 641 | }, |
James Feist | a5e5872 | 2019-04-22 14:43:11 -0700 | [diff] [blame] | 642 | mapper::busName, mapper::path, mapper::interface, mapper::subtree, |
| 643 | "/xyz/openbmc_project/sensors/power", 0, |
| 644 | std::array<const char*, 1>{sensorValueInterface}); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 645 | } |
| 646 | |
Ed Tanous | 201a101 | 2024-04-03 18:07:28 -0700 | [diff] [blame] | 647 | void ExitAirTempSensor::updateReading() |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 648 | { |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 649 | double val = 0.0; |
| 650 | if (calculate(val)) |
| 651 | { |
James Feist | 18af423 | 2019-03-13 11:14:00 -0700 | [diff] [blame] | 652 | val = std::floor(val + 0.5); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 653 | updateValue(val); |
| 654 | } |
| 655 | else |
| 656 | { |
| 657 | updateValue(std::numeric_limits<double>::quiet_NaN()); |
| 658 | } |
| 659 | } |
| 660 | |
Ed Tanous | 201a101 | 2024-04-03 18:07:28 -0700 | [diff] [blame] | 661 | double ExitAirTempSensor::getTotalCFM() |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 662 | { |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 663 | double sum = 0; |
| 664 | for (auto& sensor : cfmSensors) |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 665 | { |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 666 | double reading = 0; |
| 667 | if (!sensor->calculate(reading)) |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 668 | { |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 669 | return -1; |
| 670 | } |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 671 | sum += reading; |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 672 | } |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 673 | |
| 674 | return sum; |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 675 | } |
| 676 | |
| 677 | bool ExitAirTempSensor::calculate(double& val) |
| 678 | { |
Zhikui Ren | 12e3d67 | 2020-12-03 15:14:49 -0800 | [diff] [blame] | 679 | constexpr size_t maxErrorPrint = 5; |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 680 | static bool firstRead = false; |
James Feist | ae11cfc | 2019-05-07 15:01:20 -0700 | [diff] [blame] | 681 | static size_t errorPrint = maxErrorPrint; |
| 682 | |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 683 | double cfm = getTotalCFM(); |
| 684 | if (cfm <= 0) |
| 685 | { |
| 686 | std::cerr << "Error getting cfm\n"; |
| 687 | return false; |
| 688 | } |
| 689 | |
Zhikui Ren | 12e3d67 | 2020-12-03 15:14:49 -0800 | [diff] [blame] | 690 | // Though cfm is not expected to be less than qMin normally, |
| 691 | // it is not a hard limit for exit air temp calculation. |
| 692 | // 50% qMin is chosen as a generic limit between providing |
| 693 | // a valid derived exit air temp and reporting exit air temp not available. |
| 694 | constexpr const double cfmLimitFactor = 0.5; |
| 695 | if (cfm < (qMin * cfmLimitFactor)) |
| 696 | { |
| 697 | if (errorPrint > 0) |
| 698 | { |
| 699 | errorPrint--; |
| 700 | std::cerr << "cfm " << cfm << " is too low, expected qMin " << qMin |
| 701 | << "\n"; |
| 702 | } |
| 703 | val = 0; |
| 704 | return false; |
| 705 | } |
| 706 | |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 707 | // if there is an error getting inlet temp, return error |
| 708 | if (std::isnan(inletTemp)) |
| 709 | { |
James Feist | ae11cfc | 2019-05-07 15:01:20 -0700 | [diff] [blame] | 710 | if (errorPrint > 0) |
| 711 | { |
| 712 | errorPrint--; |
| 713 | std::cerr << "Cannot get inlet temp\n"; |
| 714 | } |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 715 | val = 0; |
| 716 | return false; |
| 717 | } |
| 718 | |
| 719 | // if fans are off, just make the exit temp equal to inlet |
James Feist | 71d31b2 | 2019-01-02 16:57:54 -0800 | [diff] [blame] | 720 | if (!isPowerOn()) |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 721 | { |
| 722 | val = inletTemp; |
| 723 | return true; |
| 724 | } |
| 725 | |
| 726 | double totalPower = 0; |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 727 | for (const auto& [path, reading] : powerReadings) |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 728 | { |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 729 | if (std::isnan(reading)) |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 730 | { |
| 731 | continue; |
| 732 | } |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 733 | totalPower += reading; |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 734 | } |
| 735 | |
| 736 | // Calculate power correction factor |
| 737 | // Ci = CL + (CH - CL)/(QMax - QMin) * (CFM - QMin) |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 738 | double powerFactor = 0.0; |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 739 | if (cfm <= qMin) |
| 740 | { |
| 741 | powerFactor = powerFactorMin; |
| 742 | } |
| 743 | else if (cfm >= qMax) |
| 744 | { |
| 745 | powerFactor = powerFactorMax; |
| 746 | } |
| 747 | else |
| 748 | { |
| 749 | powerFactor = powerFactorMin + ((powerFactorMax - powerFactorMin) / |
| 750 | (qMax - qMin) * (cfm - qMin)); |
| 751 | } |
| 752 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 753 | totalPower *= powerFactor; |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 754 | totalPower += pOffset; |
| 755 | |
| 756 | if (totalPower == 0) |
| 757 | { |
James Feist | ae11cfc | 2019-05-07 15:01:20 -0700 | [diff] [blame] | 758 | if (errorPrint > 0) |
| 759 | { |
| 760 | errorPrint--; |
| 761 | std::cerr << "total power 0\n"; |
| 762 | } |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 763 | val = 0; |
| 764 | return false; |
| 765 | } |
| 766 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 767 | if constexpr (debug) |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 768 | { |
| 769 | std::cout << "Power Factor " << powerFactor << "\n"; |
| 770 | std::cout << "Inlet Temp " << inletTemp << "\n"; |
| 771 | std::cout << "Total Power" << totalPower << "\n"; |
| 772 | } |
| 773 | |
| 774 | // Calculate the exit air temp |
| 775 | // Texit = Tfp + (1.76 * TotalPower / CFM * Faltitude) |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 776 | double reading = 1.76 * totalPower * altitudeFactor; |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 777 | reading /= cfm; |
| 778 | reading += inletTemp; |
| 779 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 780 | if constexpr (debug) |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 781 | { |
| 782 | std::cout << "Reading 1: " << reading << "\n"; |
| 783 | } |
| 784 | |
| 785 | // Now perform the exponential average |
| 786 | // Calculate alpha based on SDR values and CFM |
| 787 | // Ai = As + (Af - As)/(QMax - QMin) * (CFM - QMin) |
| 788 | |
| 789 | double alpha = 0.0; |
| 790 | if (cfm < qMin) |
| 791 | { |
| 792 | alpha = alphaS; |
| 793 | } |
| 794 | else if (cfm >= qMax) |
| 795 | { |
| 796 | alpha = alphaF; |
| 797 | } |
| 798 | else |
| 799 | { |
| 800 | alpha = alphaS + ((alphaF - alphaS) * (cfm - qMin) / (qMax - qMin)); |
| 801 | } |
| 802 | |
Zhikui Ren | 12e3d67 | 2020-12-03 15:14:49 -0800 | [diff] [blame] | 803 | auto time = std::chrono::steady_clock::now(); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 804 | if (!firstRead) |
| 805 | { |
| 806 | firstRead = true; |
| 807 | lastTime = time; |
| 808 | lastReading = reading; |
| 809 | } |
| 810 | double alphaDT = |
| 811 | std::chrono::duration_cast<std::chrono::seconds>(time - lastTime) |
| 812 | .count() * |
| 813 | alpha; |
| 814 | |
| 815 | // cap at 1.0 or the below fails |
| 816 | if (alphaDT > 1.0) |
| 817 | { |
| 818 | alphaDT = 1.0; |
| 819 | } |
| 820 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 821 | if constexpr (debug) |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 822 | { |
| 823 | std::cout << "AlphaDT: " << alphaDT << "\n"; |
| 824 | } |
| 825 | |
| 826 | reading = ((reading * alphaDT) + (lastReading * (1.0 - alphaDT))); |
| 827 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 828 | if constexpr (debug) |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 829 | { |
| 830 | std::cout << "Reading 2: " << reading << "\n"; |
| 831 | } |
| 832 | |
| 833 | val = reading; |
| 834 | lastReading = reading; |
| 835 | lastTime = time; |
James Feist | ae11cfc | 2019-05-07 15:01:20 -0700 | [diff] [blame] | 836 | errorPrint = maxErrorPrint; |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 837 | return true; |
| 838 | } |
| 839 | |
Ed Tanous | 201a101 | 2024-04-03 18:07:28 -0700 | [diff] [blame] | 840 | void ExitAirTempSensor::checkThresholds() |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 841 | { |
| 842 | thresholds::checkThresholds(this); |
| 843 | } |
| 844 | |
Zev Weiss | afd1504 | 2022-07-18 12:28:40 -0700 | [diff] [blame] | 845 | static void loadVariantPathArray(const SensorBaseConfigMap& data, |
| 846 | const std::string& key, |
| 847 | std::vector<std::string>& resp) |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 848 | { |
| 849 | auto it = data.find(key); |
| 850 | if (it == data.end()) |
| 851 | { |
| 852 | std::cerr << "Configuration missing " << key << "\n"; |
| 853 | throw std::invalid_argument("Key Missing"); |
| 854 | } |
| 855 | BasicVariantType copy = it->second; |
James Feist | 3eb8262 | 2019-02-08 13:10:22 -0800 | [diff] [blame] | 856 | std::vector<std::string> config = std::get<std::vector<std::string>>(copy); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 857 | for (auto& str : config) |
| 858 | { |
| 859 | boost::replace_all(str, " ", "_"); |
| 860 | } |
| 861 | resp = std::move(config); |
| 862 | } |
| 863 | |
| 864 | void createSensor(sdbusplus::asio::object_server& objectServer, |
James Feist | b2eb3f5 | 2018-12-04 16:17:50 -0800 | [diff] [blame] | 865 | std::shared_ptr<ExitAirTempSensor>& exitAirSensor, |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 866 | std::shared_ptr<sdbusplus::asio::connection>& dbusConnection) |
| 867 | { |
| 868 | if (!dbusConnection) |
| 869 | { |
| 870 | std::cerr << "Connection not created\n"; |
| 871 | return; |
| 872 | } |
James Feist | 655f376 | 2020-10-05 15:28:15 -0700 | [diff] [blame] | 873 | auto getter = std::make_shared<GetSensorConfiguration>( |
Patrick Williams | 597e842 | 2023-10-20 11:19:01 -0500 | [diff] [blame] | 874 | dbusConnection, [&objectServer, &dbusConnection, |
| 875 | &exitAirSensor](const ManagedObjectType& resp) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 876 | cfmSensors.clear(); |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 877 | for (const auto& [path, interfaces] : resp) |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 878 | { |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 879 | for (const auto& [intf, cfg] : interfaces) |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 880 | { |
Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 881 | if (intf == configInterfaceName(exitAirType)) |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 882 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 883 | // thresholds should be under the same path |
| 884 | std::vector<thresholds::Threshold> sensorThresholds; |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 885 | parseThresholdsFromConfig(interfaces, sensorThresholds); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 886 | |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 887 | std::string name = loadVariant<std::string>(cfg, "Name"); |
Matt Simmering | bcb062a | 2023-12-13 15:13:03 -0800 | [diff] [blame] | 888 | exitAirSensor = nullptr; |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 889 | exitAirSensor = std::make_shared<ExitAirTempSensor>( |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 890 | dbusConnection, name, path.str, objectServer, |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 891 | std::move(sensorThresholds)); |
| 892 | exitAirSensor->powerFactorMin = |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 893 | loadVariant<double>(cfg, "PowerFactorMin"); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 894 | exitAirSensor->powerFactorMax = |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 895 | loadVariant<double>(cfg, "PowerFactorMax"); |
| 896 | exitAirSensor->qMin = loadVariant<double>(cfg, "QMin"); |
| 897 | exitAirSensor->qMax = loadVariant<double>(cfg, "QMax"); |
| 898 | exitAirSensor->alphaS = loadVariant<double>(cfg, "AlphaS"); |
| 899 | exitAirSensor->alphaF = loadVariant<double>(cfg, "AlphaF"); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 900 | } |
Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 901 | else if (intf == configInterfaceName(cfmType)) |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 902 | { |
| 903 | // thresholds should be under the same path |
| 904 | std::vector<thresholds::Threshold> sensorThresholds; |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 905 | parseThresholdsFromConfig(interfaces, sensorThresholds); |
| 906 | std::string name = loadVariant<std::string>(cfg, "Name"); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 907 | auto sensor = std::make_shared<CFMSensor>( |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 908 | dbusConnection, name, path.str, objectServer, |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 909 | std::move(sensorThresholds), exitAirSensor); |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 910 | loadVariantPathArray(cfg, "Tachs", sensor->tachs); |
| 911 | sensor->maxCFM = loadVariant<double>(cfg, "MaxCFM"); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 912 | |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 913 | // change these into percent upon getting the data |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 914 | sensor->c1 = loadVariant<double>(cfg, "C1") / 100; |
| 915 | sensor->c2 = loadVariant<double>(cfg, "C2") / 100; |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 916 | sensor->tachMinPercent = |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 917 | loadVariant<double>(cfg, "TachMinPercent"); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 918 | sensor->tachMaxPercent = |
Zev Weiss | 72f322f | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 919 | loadVariant<double>(cfg, "TachMaxPercent"); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 920 | sensor->createMaxCFMIface(); |
| 921 | sensor->setupMatches(); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 922 | |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 923 | cfmSensors.emplace_back(std::move(sensor)); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 924 | } |
| 925 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 926 | } |
| 927 | if (exitAirSensor) |
| 928 | { |
| 929 | exitAirSensor->setupMatches(); |
| 930 | exitAirSensor->updateReading(); |
| 931 | } |
Patrick Williams | 597e842 | 2023-10-20 11:19:01 -0500 | [diff] [blame] | 932 | }); |
James Feist | 655f376 | 2020-10-05 15:28:15 -0700 | [diff] [blame] | 933 | getter->getConfiguration( |
Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 934 | std::vector<std::string>(monitorTypes.begin(), monitorTypes.end())); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 935 | } |
| 936 | |
James Feist | b6c0b91 | 2019-07-09 12:21:44 -0700 | [diff] [blame] | 937 | int main() |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 938 | { |
Ed Tanous | 1f97863 | 2023-02-28 18:16:39 -0800 | [diff] [blame] | 939 | boost::asio::io_context io; |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 940 | auto systemBus = std::make_shared<sdbusplus::asio::connection>(io); |
Johnathan Mantey | 661d437 | 2022-10-27 09:00:59 -0700 | [diff] [blame] | 941 | sdbusplus::asio::object_server objectServer(systemBus, true); |
| 942 | objectServer.add_manager("/xyz/openbmc_project/sensors"); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 943 | systemBus->request_name("xyz.openbmc_project.ExitAirTempSensor"); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 944 | std::shared_ptr<ExitAirTempSensor> sensor = |
| 945 | nullptr; // wait until we find the config |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 946 | |
Ed Tanous | 83db50c | 2023-03-01 10:20:24 -0800 | [diff] [blame] | 947 | boost::asio::post(io, |
| 948 | [&]() { createSensor(objectServer, sensor, systemBus); }); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 949 | |
Ed Tanous | 9b4a20e | 2022-09-06 08:47:11 -0700 | [diff] [blame] | 950 | boost::asio::steady_timer configTimer(io); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 951 | |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 952 | std::function<void(sdbusplus::message_t&)> eventHandler = |
| 953 | [&](sdbusplus::message_t&) { |
Ed Tanous | 83db50c | 2023-03-01 10:20:24 -0800 | [diff] [blame] | 954 | configTimer.expires_after(std::chrono::seconds(1)); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 955 | // create a timer because normally multiple properties change |
| 956 | configTimer.async_wait([&](const boost::system::error_code& ec) { |
| 957 | if (ec == boost::asio::error::operation_aborted) |
| 958 | { |
| 959 | return; // we're being canceled |
| 960 | } |
| 961 | createSensor(objectServer, sensor, systemBus); |
| 962 | if (!sensor) |
| 963 | { |
| 964 | std::cout << "Configuration not detected\n"; |
| 965 | } |
| 966 | }); |
| 967 | }; |
Zev Weiss | 214d971 | 2022-08-12 12:54:31 -0700 | [diff] [blame] | 968 | std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches = |
Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 969 | setupPropertiesChangedMatches(*systemBus, monitorTypes, eventHandler); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 970 | |
Bruce Lee | 913d4d0 | 2021-07-22 10:18:42 +0800 | [diff] [blame] | 971 | setupManufacturingModeMatch(*systemBus); |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 972 | io.run(); |
Zhikui Ren | 8685b17 | 2021-06-29 15:16:52 -0700 | [diff] [blame] | 973 | return 0; |
James Feist | bc896df | 2018-11-26 16:28:17 -0800 | [diff] [blame] | 974 | } |