Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2019 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 | */ |
Josh Lehan | 0830c7b | 2019-10-08 16:35:09 -0700 | [diff] [blame] | 16 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 17 | #include <PSUEvent.hpp> |
| 18 | #include <PSUSensor.hpp> |
| 19 | #include <Utils.hpp> |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 20 | #include <boost/algorithm/string/predicate.hpp> |
| 21 | #include <boost/algorithm/string/replace.hpp> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 22 | #include <boost/container/flat_map.hpp> |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 23 | #include <boost/container/flat_set.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 24 | #include <sdbusplus/asio/connection.hpp> |
| 25 | #include <sdbusplus/asio/object_server.hpp> |
| 26 | #include <sdbusplus/bus/match.hpp> |
| 27 | |
| 28 | #include <array> |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 29 | #include <cmath> |
James Feist | 24f02f2 | 2019-04-15 11:05:39 -0700 | [diff] [blame] | 30 | #include <filesystem> |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 31 | #include <fstream> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 32 | #include <functional> |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 33 | #include <iostream> |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 34 | #include <regex> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 35 | #include <string> |
Lei YU | a2c7cea | 2020-12-23 14:07:28 +0800 | [diff] [blame] | 36 | #include <string_view> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 37 | #include <utility> |
| 38 | #include <variant> |
| 39 | #include <vector> |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 40 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 41 | static constexpr bool debug = false; |
Josh Lehan | 49cfba9 | 2019-10-08 16:50:42 -0700 | [diff] [blame] | 42 | |
Paul Fertser | 678f53b | 2021-04-06 07:06:28 +0000 | [diff] [blame] | 43 | static constexpr std::array<const char*, 23> sensorTypes = { |
Josh Lehan | 62084c8 | 2020-06-22 15:27:12 -0700 | [diff] [blame] | 44 | "xyz.openbmc_project.Configuration.ADM1272", |
Paul Fertser | 678f53b | 2021-04-06 07:06:28 +0000 | [diff] [blame] | 45 | "xyz.openbmc_project.Configuration.ADM1275", |
Josh Lehan | 62084c8 | 2020-06-22 15:27:12 -0700 | [diff] [blame] | 46 | "xyz.openbmc_project.Configuration.ADM1278", |
Jeff Lin | a0683a8 | 2021-02-22 13:56:55 +0800 | [diff] [blame] | 47 | "xyz.openbmc_project.Configuration.DPS800", |
Josh Lehan | 62084c8 | 2020-06-22 15:27:12 -0700 | [diff] [blame] | 48 | "xyz.openbmc_project.Configuration.INA219", |
Devjit Gopalpur | de65ef7 | 2019-10-30 04:47:35 -0700 | [diff] [blame] | 49 | "xyz.openbmc_project.Configuration.INA230", |
Alex Qiu | 6690d8f | 2020-01-22 17:56:33 -0800 | [diff] [blame] | 50 | "xyz.openbmc_project.Configuration.ISL68137", |
Jason Ling | dfad1ff | 2020-07-29 15:43:11 -0700 | [diff] [blame] | 51 | "xyz.openbmc_project.Configuration.ISL68220", |
Gaurav Gandhi | 4958558 | 2020-12-22 01:01:24 +0000 | [diff] [blame] | 52 | "xyz.openbmc_project.Configuration.ISL68223", |
| 53 | "xyz.openbmc_project.Configuration.ISL69243", |
Jeff Lin | a0683a8 | 2021-02-22 13:56:55 +0800 | [diff] [blame] | 54 | "xyz.openbmc_project.Configuration.ISL69260", |
Alex Qiu | f5709b4 | 2020-01-29 13:29:50 -0800 | [diff] [blame] | 55 | "xyz.openbmc_project.Configuration.MAX16601", |
Gaurav Gandhi | 4958558 | 2020-12-22 01:01:24 +0000 | [diff] [blame] | 56 | "xyz.openbmc_project.Configuration.MAX20710", |
Alex Qiu | 6690d8f | 2020-01-22 17:56:33 -0800 | [diff] [blame] | 57 | "xyz.openbmc_project.Configuration.MAX20730", |
| 58 | "xyz.openbmc_project.Configuration.MAX20734", |
| 59 | "xyz.openbmc_project.Configuration.MAX20796", |
| 60 | "xyz.openbmc_project.Configuration.MAX34451", |
Josh Lehan | 62084c8 | 2020-06-22 15:27:12 -0700 | [diff] [blame] | 61 | "xyz.openbmc_project.Configuration.pmbus", |
| 62 | "xyz.openbmc_project.Configuration.PXE1610", |
Jeff Lin | a0683a8 | 2021-02-22 13:56:55 +0800 | [diff] [blame] | 63 | "xyz.openbmc_project.Configuration.RAA228000", |
| 64 | "xyz.openbmc_project.Configuration.RAA228228", |
| 65 | "xyz.openbmc_project.Configuration.RAA229004", |
| 66 | "xyz.openbmc_project.Configuration.TPS546D24"}; |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 67 | |
Alex Qiu | 6690d8f | 2020-01-22 17:56:33 -0800 | [diff] [blame] | 68 | static std::vector<std::string> pmbusNames = { |
Paul Fertser | 678f53b | 2021-04-06 07:06:28 +0000 | [diff] [blame] | 69 | "adm1272", "adm1275", "adm1278", "dps800", "ina219", "ina230", |
| 70 | "isl68137", "isl68220", "isl68223", "isl69243", "isl69260", "max16601", |
| 71 | "max20710", "max20730", "max20734", "max20796", "max34451", "pmbus", |
| 72 | "pxe1610", "raa228000", "raa228228", "raa229004", "tps546d24"}; |
Josh Lehan | 0830c7b | 2019-10-08 16:35:09 -0700 | [diff] [blame] | 73 | |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 74 | namespace fs = std::filesystem; |
| 75 | |
Yong Li | bf8b1da | 2020-04-15 16:32:50 +0800 | [diff] [blame] | 76 | static boost::container::flat_map<std::string, std::shared_ptr<PSUSensor>> |
Cheng C Yang | 916360b | 2019-05-07 18:47:16 +0800 | [diff] [blame] | 77 | sensors; |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 78 | static boost::container::flat_map<std::string, std::unique_ptr<PSUCombineEvent>> |
| 79 | combineEvents; |
Cheng C Yang | 916360b | 2019-05-07 18:47:16 +0800 | [diff] [blame] | 80 | static boost::container::flat_map<std::string, std::unique_ptr<PwmSensor>> |
| 81 | pwmSensors; |
| 82 | static boost::container::flat_map<std::string, std::string> sensorTable; |
| 83 | static boost::container::flat_map<std::string, PSUProperty> labelMatch; |
| 84 | static boost::container::flat_map<std::string, std::string> pwmTable; |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 85 | static boost::container::flat_map<std::string, std::vector<std::string>> |
| 86 | eventMatch; |
Cheng C Yang | 202a1ff | 2020-01-09 09:34:22 +0800 | [diff] [blame] | 87 | static boost::container::flat_map< |
| 88 | std::string, |
| 89 | boost::container::flat_map<std::string, std::vector<std::string>>> |
| 90 | groupEventMatch; |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 91 | static boost::container::flat_map<std::string, std::vector<std::string>> |
| 92 | limitEventMatch; |
| 93 | |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 94 | static std::vector<PSUProperty> psuProperties; |
| 95 | |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 96 | // Function CheckEvent will check each attribute from eventMatch table in the |
| 97 | // sysfs. If the attributes exists in sysfs, then store the complete path |
| 98 | // of the attribute into eventPathList. |
| 99 | void checkEvent( |
| 100 | const std::string& directory, |
| 101 | const boost::container::flat_map<std::string, std::vector<std::string>>& |
| 102 | eventMatch, |
| 103 | boost::container::flat_map<std::string, std::vector<std::string>>& |
| 104 | eventPathList) |
| 105 | { |
| 106 | for (const auto& match : eventMatch) |
| 107 | { |
| 108 | const std::vector<std::string>& eventAttrs = match.second; |
| 109 | const std::string& eventName = match.first; |
| 110 | for (const auto& eventAttr : eventAttrs) |
| 111 | { |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 112 | std::string eventPath = directory; |
| 113 | eventPath += "/"; |
| 114 | eventPath += eventAttr; |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 115 | |
| 116 | std::ifstream eventFile(eventPath); |
| 117 | if (!eventFile.good()) |
| 118 | { |
| 119 | continue; |
| 120 | } |
| 121 | |
| 122 | eventPathList[eventName].push_back(eventPath); |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | |
Cheng C Yang | 202a1ff | 2020-01-09 09:34:22 +0800 | [diff] [blame] | 127 | // Check Group Events which contains more than one targets in each combine |
| 128 | // events. |
| 129 | void checkGroupEvent( |
| 130 | const std::string& directory, |
| 131 | const boost::container::flat_map< |
| 132 | std::string, |
| 133 | boost::container::flat_map<std::string, std::vector<std::string>>>& |
| 134 | groupEventMatch, |
| 135 | boost::container::flat_map< |
| 136 | std::string, |
| 137 | boost::container::flat_map<std::string, std::vector<std::string>>>& |
| 138 | groupEventPathList) |
| 139 | { |
| 140 | for (const auto& match : groupEventMatch) |
| 141 | { |
| 142 | const std::string& groupEventName = match.first; |
| 143 | const boost::container::flat_map<std::string, std::vector<std::string>> |
| 144 | events = match.second; |
| 145 | boost::container::flat_map<std::string, std::vector<std::string>> |
| 146 | pathList; |
| 147 | for (const auto& match : events) |
| 148 | { |
| 149 | const std::string& eventName = match.first; |
| 150 | const std::vector<std::string>& eventAttrs = match.second; |
| 151 | for (const auto& eventAttr : eventAttrs) |
| 152 | { |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 153 | std::string eventPath = directory; |
| 154 | eventPath += "/"; |
| 155 | eventPath += eventAttr; |
Cheng C Yang | 202a1ff | 2020-01-09 09:34:22 +0800 | [diff] [blame] | 156 | std::ifstream eventFile(eventPath); |
| 157 | if (!eventFile.good()) |
| 158 | { |
| 159 | continue; |
| 160 | } |
| 161 | |
| 162 | pathList[eventName].push_back(eventPath); |
| 163 | } |
| 164 | } |
| 165 | groupEventPathList[groupEventName] = pathList; |
| 166 | } |
| 167 | } |
| 168 | |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 169 | // Function checkEventLimits will check all the psu related xxx_input attributes |
| 170 | // in sysfs to see if xxx_crit_alarm xxx_lcrit_alarm xxx_max_alarm |
| 171 | // xxx_min_alarm exist, then store the existing paths of the alarm attributes |
| 172 | // to eventPathList. |
| 173 | void checkEventLimits( |
| 174 | const std::string& sensorPathStr, |
| 175 | const boost::container::flat_map<std::string, std::vector<std::string>>& |
| 176 | limitEventMatch, |
| 177 | boost::container::flat_map<std::string, std::vector<std::string>>& |
| 178 | eventPathList) |
| 179 | { |
Lei YU | a2c7cea | 2020-12-23 14:07:28 +0800 | [diff] [blame] | 180 | auto attributePartPos = sensorPathStr.find_last_of('_'); |
| 181 | if (attributePartPos == std::string::npos) |
| 182 | { |
| 183 | // There is no '_' in the string, skip it |
| 184 | return; |
| 185 | } |
| 186 | auto attributePart = |
| 187 | std::string_view(sensorPathStr).substr(attributePartPos + 1); |
| 188 | if (attributePart != "input") |
| 189 | { |
| 190 | // If the sensor is not xxx_input, skip it |
| 191 | return; |
| 192 | } |
| 193 | |
| 194 | auto prefixPart = sensorPathStr.substr(0, attributePartPos + 1); |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 195 | for (const auto& limitMatch : limitEventMatch) |
| 196 | { |
| 197 | const std::vector<std::string>& limitEventAttrs = limitMatch.second; |
| 198 | const std::string& eventName = limitMatch.first; |
| 199 | for (const auto& limitEventAttr : limitEventAttrs) |
| 200 | { |
Lei YU | a2c7cea | 2020-12-23 14:07:28 +0800 | [diff] [blame] | 201 | auto limitEventPath = prefixPart + limitEventAttr; |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 202 | std::ifstream eventFile(limitEventPath); |
| 203 | if (!eventFile.good()) |
| 204 | { |
| 205 | continue; |
| 206 | } |
| 207 | eventPathList[eventName].push_back(limitEventPath); |
| 208 | } |
| 209 | } |
| 210 | } |
Cheng C Yang | 916360b | 2019-05-07 18:47:16 +0800 | [diff] [blame] | 211 | |
AppaRao Puli | d9d8caf | 2020-02-27 20:56:59 +0530 | [diff] [blame] | 212 | static void |
| 213 | checkPWMSensor(const fs::path& sensorPath, std::string& labelHead, |
| 214 | const std::string& interfacePath, |
| 215 | std::shared_ptr<sdbusplus::asio::connection>& dbusConnection, |
| 216 | sdbusplus::asio::object_server& objectServer, |
| 217 | const std::string& psuName) |
Cheng C Yang | 916360b | 2019-05-07 18:47:16 +0800 | [diff] [blame] | 218 | { |
| 219 | for (const auto& pwmName : pwmTable) |
| 220 | { |
| 221 | if (pwmName.first != labelHead) |
| 222 | { |
| 223 | continue; |
| 224 | } |
| 225 | |
| 226 | const std::string& sensorPathStr = sensorPath.string(); |
| 227 | const std::string& pwmPathStr = |
| 228 | boost::replace_all_copy(sensorPathStr, "input", "target"); |
| 229 | std::ifstream pwmFile(pwmPathStr); |
| 230 | if (!pwmFile.good()) |
| 231 | { |
| 232 | continue; |
| 233 | } |
| 234 | |
| 235 | auto findPWMSensor = pwmSensors.find(psuName + labelHead); |
| 236 | if (findPWMSensor != pwmSensors.end()) |
| 237 | { |
| 238 | continue; |
| 239 | } |
| 240 | |
| 241 | pwmSensors[psuName + labelHead] = std::make_unique<PwmSensor>( |
AppaRao Puli | d9d8caf | 2020-02-27 20:56:59 +0530 | [diff] [blame] | 242 | "Pwm_" + psuName + "_" + pwmName.second, pwmPathStr, dbusConnection, |
| 243 | objectServer, interfacePath + "_" + pwmName.second, "PSU"); |
Cheng C Yang | 916360b | 2019-05-07 18:47:16 +0800 | [diff] [blame] | 244 | } |
| 245 | } |
| 246 | |
Zhikui Ren | 23c96e7 | 2020-11-05 22:32:28 -0800 | [diff] [blame] | 247 | static void createSensorsCallback( |
| 248 | boost::asio::io_service& io, sdbusplus::asio::object_server& objectServer, |
| 249 | std::shared_ptr<sdbusplus::asio::connection>& dbusConnection, |
| 250 | const ManagedObjectType& sensorConfigs, |
| 251 | const std::shared_ptr<boost::container::flat_set<std::string>>& |
| 252 | sensorsChanged) |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 253 | { |
Josh Lehan | 49cfba9 | 2019-10-08 16:50:42 -0700 | [diff] [blame] | 254 | int numCreated = 0; |
Zhikui Ren | 23c96e7 | 2020-11-05 22:32:28 -0800 | [diff] [blame] | 255 | bool firstScan = sensorsChanged == nullptr; |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 256 | |
| 257 | std::vector<fs::path> pmbusPaths; |
| 258 | if (!findFiles(fs::path("/sys/class/hwmon"), "name", pmbusPaths)) |
| 259 | { |
| 260 | std::cerr << "No PSU sensors in system\n"; |
| 261 | return; |
| 262 | } |
| 263 | |
| 264 | boost::container::flat_set<std::string> directories; |
| 265 | for (const auto& pmbusPath : pmbusPaths) |
| 266 | { |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 267 | boost::container::flat_map<std::string, std::vector<std::string>> |
| 268 | eventPathList; |
Cheng C Yang | 202a1ff | 2020-01-09 09:34:22 +0800 | [diff] [blame] | 269 | boost::container::flat_map< |
| 270 | std::string, |
| 271 | boost::container::flat_map<std::string, std::vector<std::string>>> |
| 272 | groupEventPathList; |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 273 | |
| 274 | std::ifstream nameFile(pmbusPath); |
| 275 | if (!nameFile.good()) |
| 276 | { |
Josh Lehan | 49cfba9 | 2019-10-08 16:50:42 -0700 | [diff] [blame] | 277 | std::cerr << "Failure finding pmbus path " << pmbusPath << "\n"; |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 278 | continue; |
| 279 | } |
| 280 | |
| 281 | std::string pmbusName; |
| 282 | std::getline(nameFile, pmbusName); |
| 283 | nameFile.close(); |
Vijay Khemka | 996bad1 | 2019-05-28 15:15:16 -0700 | [diff] [blame] | 284 | |
| 285 | if (std::find(pmbusNames.begin(), pmbusNames.end(), pmbusName) == |
| 286 | pmbusNames.end()) |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 287 | { |
Josh Lehan | 49cfba9 | 2019-10-08 16:50:42 -0700 | [diff] [blame] | 288 | // To avoid this error message, add your driver name to |
| 289 | // the pmbusNames vector at the top of this file. |
| 290 | std::cerr << "Driver name " << pmbusName |
| 291 | << " not found in sensor whitelist\n"; |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 292 | continue; |
| 293 | } |
| 294 | |
| 295 | const std::string* psuName; |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 296 | auto directory = pmbusPath.parent_path(); |
| 297 | |
| 298 | auto ret = directories.insert(directory.string()); |
| 299 | if (!ret.second) |
| 300 | { |
Josh Lehan | 49cfba9 | 2019-10-08 16:50:42 -0700 | [diff] [blame] | 301 | std::cerr << "Duplicate path " << directory.string() << "\n"; |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 302 | continue; // check if path has already been searched |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 303 | } |
| 304 | |
James Feist | b6c0b91 | 2019-07-09 12:21:44 -0700 | [diff] [blame] | 305 | fs::path device = directory / "device"; |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 306 | std::string deviceName = fs::canonical(device).stem(); |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 307 | auto findHyphen = deviceName.find('-'); |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 308 | if (findHyphen == std::string::npos) |
| 309 | { |
| 310 | std::cerr << "found bad device" << deviceName << "\n"; |
| 311 | continue; |
| 312 | } |
| 313 | std::string busStr = deviceName.substr(0, findHyphen); |
| 314 | std::string addrStr = deviceName.substr(findHyphen + 1); |
| 315 | |
| 316 | size_t bus = 0; |
| 317 | size_t addr = 0; |
| 318 | |
| 319 | try |
| 320 | { |
| 321 | bus = std::stoi(busStr); |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 322 | addr = std::stoi(addrStr, nullptr, 16); |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 323 | } |
James Feist | b6c0b91 | 2019-07-09 12:21:44 -0700 | [diff] [blame] | 324 | catch (std::invalid_argument&) |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 325 | { |
Josh Lehan | 49cfba9 | 2019-10-08 16:50:42 -0700 | [diff] [blame] | 326 | std::cerr << "Error parsing bus " << busStr << " addr " << addrStr |
| 327 | << "\n"; |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 328 | continue; |
| 329 | } |
| 330 | |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 331 | const std::pair<std::string, boost::container::flat_map< |
| 332 | std::string, BasicVariantType>>* |
| 333 | baseConfig = nullptr; |
| 334 | const SensorData* sensorData = nullptr; |
| 335 | const std::string* interfacePath = nullptr; |
| 336 | const char* sensorType = nullptr; |
Cheng C Yang | 6b1247a | 2020-03-09 23:48:39 +0800 | [diff] [blame] | 337 | size_t thresholdConfSize = 0; |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 338 | |
| 339 | for (const std::pair<sdbusplus::message::object_path, SensorData>& |
| 340 | sensor : sensorConfigs) |
| 341 | { |
| 342 | sensorData = &(sensor.second); |
| 343 | for (const char* type : sensorTypes) |
| 344 | { |
| 345 | auto sensorBase = sensorData->find(type); |
| 346 | if (sensorBase != sensorData->end()) |
| 347 | { |
| 348 | baseConfig = &(*sensorBase); |
| 349 | sensorType = type; |
| 350 | break; |
| 351 | } |
| 352 | } |
| 353 | if (baseConfig == nullptr) |
| 354 | { |
| 355 | std::cerr << "error finding base configuration for " |
| 356 | << deviceName << "\n"; |
| 357 | continue; |
| 358 | } |
| 359 | |
| 360 | auto configBus = baseConfig->second.find("Bus"); |
| 361 | auto configAddress = baseConfig->second.find("Address"); |
| 362 | |
| 363 | if (configBus == baseConfig->second.end() || |
| 364 | configAddress == baseConfig->second.end()) |
| 365 | { |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 366 | std::cerr << "error finding necessary entry in configuration\n"; |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 367 | continue; |
| 368 | } |
| 369 | |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 370 | const uint64_t* confBus; |
| 371 | const uint64_t* confAddr; |
| 372 | if (!(confBus = std::get_if<uint64_t>(&(configBus->second))) || |
| 373 | !(confAddr = std::get_if<uint64_t>(&(configAddress->second)))) |
| 374 | { |
| 375 | std::cerr |
Josh Lehan | 49cfba9 | 2019-10-08 16:50:42 -0700 | [diff] [blame] | 376 | << "Cannot get bus or address, invalid configuration\n"; |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 377 | continue; |
| 378 | } |
| 379 | |
| 380 | if ((*confBus != bus) || (*confAddr != addr)) |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 381 | { |
Josh Lehan | 432d1ed | 2019-10-16 12:23:31 -0700 | [diff] [blame] | 382 | std::cerr << "Configuration skipping " << *confBus << "-" |
| 383 | << *confAddr << " because not " << bus << "-" << addr |
| 384 | << "\n"; |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 385 | continue; |
| 386 | } |
| 387 | |
Cheng C Yang | 6b1247a | 2020-03-09 23:48:39 +0800 | [diff] [blame] | 388 | std::vector<thresholds::Threshold> confThresholds; |
| 389 | if (!parseThresholdsFromConfig(*sensorData, confThresholds)) |
| 390 | { |
| 391 | std::cerr << "error populating totoal thresholds\n"; |
| 392 | } |
| 393 | thresholdConfSize = confThresholds.size(); |
| 394 | |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 395 | interfacePath = &(sensor.first.str); |
| 396 | break; |
| 397 | } |
| 398 | if (interfacePath == nullptr) |
| 399 | { |
Josh Lehan | 49cfba9 | 2019-10-08 16:50:42 -0700 | [diff] [blame] | 400 | // To avoid this error message, add your export map entry, |
| 401 | // from Entity Manager, to sensorTypes at the top of this file. |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 402 | std::cerr << "failed to find match for " << deviceName << "\n"; |
| 403 | continue; |
| 404 | } |
| 405 | |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 406 | auto findPSUName = baseConfig->second.find("Name"); |
| 407 | if (findPSUName == baseConfig->second.end()) |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 408 | { |
| 409 | std::cerr << "could not determine configuration name for " |
| 410 | << deviceName << "\n"; |
| 411 | continue; |
| 412 | } |
| 413 | |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 414 | if (!(psuName = std::get_if<std::string>(&(findPSUName->second)))) |
| 415 | { |
| 416 | std::cerr << "Cannot find psu name, invalid configuration\n"; |
| 417 | continue; |
| 418 | } |
Zhikui Ren | 23c96e7 | 2020-11-05 22:32:28 -0800 | [diff] [blame] | 419 | |
| 420 | // on rescans, only update sensors we were signaled by |
| 421 | if (!firstScan) |
| 422 | { |
| 423 | std::string psuNameStr = "/" + *psuName; |
| 424 | auto it = |
| 425 | std::find_if(sensorsChanged->begin(), sensorsChanged->end(), |
| 426 | [psuNameStr](std::string& s) { |
| 427 | return boost::ends_with(s, psuNameStr); |
| 428 | }); |
| 429 | |
| 430 | if (it == sensorsChanged->end()) |
| 431 | { |
| 432 | continue; |
| 433 | } |
| 434 | sensorsChanged->erase(it); |
| 435 | } |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 436 | checkEvent(directory.string(), eventMatch, eventPathList); |
Cheng C Yang | 202a1ff | 2020-01-09 09:34:22 +0800 | [diff] [blame] | 437 | checkGroupEvent(directory.string(), groupEventMatch, |
| 438 | groupEventPathList); |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 439 | |
Vijay Khemka | 996bad1 | 2019-05-28 15:15:16 -0700 | [diff] [blame] | 440 | /* Check if there are more sensors in the same interface */ |
| 441 | int i = 1; |
| 442 | std::vector<std::string> psuNames; |
| 443 | do |
| 444 | { |
Josh Lehan | 49cfba9 | 2019-10-08 16:50:42 -0700 | [diff] [blame] | 445 | // Individual string fields: Name, Name1, Name2, Name3, ... |
Vijay Khemka | 996bad1 | 2019-05-28 15:15:16 -0700 | [diff] [blame] | 446 | psuNames.push_back(std::get<std::string>(findPSUName->second)); |
| 447 | findPSUName = baseConfig->second.find("Name" + std::to_string(i++)); |
| 448 | } while (findPSUName != baseConfig->second.end()); |
| 449 | |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 450 | std::vector<fs::path> sensorPaths; |
James Feist | b6c0b91 | 2019-07-09 12:21:44 -0700 | [diff] [blame] | 451 | if (!findFiles(directory, R"(\w\d+_input$)", sensorPaths, 0)) |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 452 | { |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 453 | std::cerr << "No PSU non-label sensor in PSU\n"; |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 454 | continue; |
| 455 | } |
| 456 | |
Manikandan Elumalai | c7e9562 | 2020-06-03 20:22:01 +0530 | [diff] [blame] | 457 | /* read max value in sysfs for in, curr, power, temp, ... */ |
| 458 | if (!findFiles(directory, R"(\w\d+_max$)", sensorPaths, 0)) |
| 459 | { |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 460 | if constexpr (debug) |
Manikandan Elumalai | c7e9562 | 2020-06-03 20:22:01 +0530 | [diff] [blame] | 461 | { |
| 462 | std::cerr << "No max name in PSU \n"; |
| 463 | } |
| 464 | } |
| 465 | |
Vijay Khemka | 996bad1 | 2019-05-28 15:15:16 -0700 | [diff] [blame] | 466 | /* Find array of labels to be exposed if it is defined in config */ |
| 467 | std::vector<std::string> findLabels; |
| 468 | auto findLabelObj = baseConfig->second.find("Labels"); |
| 469 | if (findLabelObj != baseConfig->second.end()) |
| 470 | { |
| 471 | findLabels = |
| 472 | std::get<std::vector<std::string>>(findLabelObj->second); |
| 473 | } |
| 474 | |
Jason Ling | 5747fab | 2019-10-02 16:46:23 -0700 | [diff] [blame] | 475 | std::regex sensorNameRegEx("([A-Za-z]+)[0-9]*_"); |
| 476 | std::smatch matches; |
| 477 | |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 478 | for (const auto& sensorPath : sensorPaths) |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 479 | { |
Manikandan Elumalai | c7e9562 | 2020-06-03 20:22:01 +0530 | [diff] [blame] | 480 | bool maxLabel = false; |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 481 | std::string labelHead; |
| 482 | std::string sensorPathStr = sensorPath.string(); |
| 483 | std::string sensorNameStr = sensorPath.filename(); |
Jason Ling | 5747fab | 2019-10-02 16:46:23 -0700 | [diff] [blame] | 484 | std::string sensorNameSubStr{""}; |
| 485 | if (std::regex_search(sensorNameStr, matches, sensorNameRegEx)) |
| 486 | { |
Josh Lehan | 0649445 | 2019-10-31 09:49:16 -0700 | [diff] [blame] | 487 | // hwmon *_input filename without number: |
| 488 | // in, curr, power, temp, ... |
Jason Ling | 5747fab | 2019-10-02 16:46:23 -0700 | [diff] [blame] | 489 | sensorNameSubStr = matches[1]; |
| 490 | } |
| 491 | else |
| 492 | { |
Josh Lehan | 0649445 | 2019-10-31 09:49:16 -0700 | [diff] [blame] | 493 | std::cerr << "Could not extract the alpha prefix from " |
Jason Ling | 5747fab | 2019-10-02 16:46:23 -0700 | [diff] [blame] | 494 | << sensorNameStr; |
| 495 | continue; |
| 496 | } |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 497 | |
Manikandan Elumalai | c7e9562 | 2020-06-03 20:22:01 +0530 | [diff] [blame] | 498 | std::string labelPath; |
| 499 | |
| 500 | /* find and differentiate _max and _input to replace "label" */ |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 501 | size_t pos = sensorPathStr.find('_'); |
Manikandan Elumalai | c7e9562 | 2020-06-03 20:22:01 +0530 | [diff] [blame] | 502 | if (pos != std::string::npos) |
| 503 | { |
| 504 | |
| 505 | std::string sensorPathStrMax = sensorPathStr.substr(pos); |
| 506 | if (sensorPathStrMax.compare("_max") == 0) |
| 507 | { |
| 508 | labelPath = |
| 509 | boost::replace_all_copy(sensorPathStr, "max", "label"); |
| 510 | maxLabel = true; |
| 511 | } |
| 512 | else |
| 513 | { |
| 514 | labelPath = boost::replace_all_copy(sensorPathStr, "input", |
| 515 | "label"); |
| 516 | maxLabel = false; |
| 517 | } |
| 518 | } |
| 519 | else |
| 520 | { |
| 521 | continue; |
| 522 | } |
| 523 | |
Cheng C Yang | ecba9de | 2019-09-12 23:41:50 +0800 | [diff] [blame] | 524 | std::ifstream labelFile(labelPath); |
| 525 | if (!labelFile.good()) |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 526 | { |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 527 | if constexpr (debug) |
Cheng C Yang | 6b1247a | 2020-03-09 23:48:39 +0800 | [diff] [blame] | 528 | { |
| 529 | std::cerr << "Input file " << sensorPath |
| 530 | << " has no corresponding label file\n"; |
| 531 | } |
Josh Lehan | 0649445 | 2019-10-31 09:49:16 -0700 | [diff] [blame] | 532 | // hwmon *_input filename with number: |
| 533 | // temp1, temp2, temp3, ... |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 534 | labelHead = sensorNameStr.substr(0, sensorNameStr.find('_')); |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 535 | } |
| 536 | else |
| 537 | { |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 538 | std::string label; |
| 539 | std::getline(labelFile, label); |
| 540 | labelFile.close(); |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 541 | auto findSensor = sensors.find(label); |
| 542 | if (findSensor != sensors.end()) |
| 543 | { |
| 544 | continue; |
| 545 | } |
| 546 | |
Josh Lehan | 0649445 | 2019-10-31 09:49:16 -0700 | [diff] [blame] | 547 | // hwmon corresponding *_label file contents: |
| 548 | // vin1, vout1, ... |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 549 | labelHead = label.substr(0, label.find(' ')); |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 550 | } |
| 551 | |
Manikandan Elumalai | c7e9562 | 2020-06-03 20:22:01 +0530 | [diff] [blame] | 552 | /* append "max" for labelMatch */ |
| 553 | if (maxLabel) |
| 554 | { |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 555 | labelHead.insert(0, "max"); |
Manikandan Elumalai | c7e9562 | 2020-06-03 20:22:01 +0530 | [diff] [blame] | 556 | } |
| 557 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 558 | if constexpr (debug) |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 559 | { |
| 560 | std::cerr << "Sensor type=\"" << sensorNameSubStr |
| 561 | << "\" label=\"" << labelHead << "\"\n"; |
| 562 | } |
| 563 | |
AppaRao Puli | d9d8caf | 2020-02-27 20:56:59 +0530 | [diff] [blame] | 564 | checkPWMSensor(sensorPath, labelHead, *interfacePath, |
| 565 | dbusConnection, objectServer, psuNames[0]); |
Cheng C Yang | 916360b | 2019-05-07 18:47:16 +0800 | [diff] [blame] | 566 | |
Vijay Khemka | 996bad1 | 2019-05-28 15:15:16 -0700 | [diff] [blame] | 567 | if (!findLabels.empty()) |
| 568 | { |
| 569 | /* Check if this labelHead is enabled in config file */ |
| 570 | if (std::find(findLabels.begin(), findLabels.end(), |
| 571 | labelHead) == findLabels.end()) |
| 572 | { |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 573 | if constexpr (debug) |
Cheng C Yang | 6b1247a | 2020-03-09 23:48:39 +0800 | [diff] [blame] | 574 | { |
| 575 | std::cerr << "could not find " << labelHead |
| 576 | << " in the Labels list\n"; |
| 577 | } |
Vijay Khemka | 996bad1 | 2019-05-28 15:15:16 -0700 | [diff] [blame] | 578 | continue; |
| 579 | } |
| 580 | } |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 581 | |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 582 | auto findProperty = labelMatch.find(labelHead); |
| 583 | if (findProperty == labelMatch.end()) |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 584 | { |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 585 | if constexpr (debug) |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 586 | { |
| 587 | std::cerr << "Could not find matching default property for " |
| 588 | << labelHead << "\n"; |
| 589 | } |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 590 | continue; |
| 591 | } |
| 592 | |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 593 | // Protect the hardcoded labelMatch list from changes, |
| 594 | // by making a copy and modifying that instead. |
| 595 | // Avoid bleedthrough of one device's customizations to |
| 596 | // the next device, as each should be independently customizable. |
| 597 | psuProperties.push_back(findProperty->second); |
| 598 | auto psuProperty = psuProperties.rbegin(); |
| 599 | |
| 600 | // Use label head as prefix for reading from config file, |
| 601 | // example if temp1: temp1_Name, temp1_Scale, temp1_Min, ... |
| 602 | std::string keyName = labelHead + "_Name"; |
| 603 | std::string keyScale = labelHead + "_Scale"; |
| 604 | std::string keyMin = labelHead + "_Min"; |
| 605 | std::string keyMax = labelHead + "_Max"; |
| 606 | |
| 607 | bool customizedName = false; |
| 608 | auto findCustomName = baseConfig->second.find(keyName); |
| 609 | if (findCustomName != baseConfig->second.end()) |
Josh Lehan | 432d1ed | 2019-10-16 12:23:31 -0700 | [diff] [blame] | 610 | { |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 611 | try |
| 612 | { |
| 613 | psuProperty->labelTypeName = std::visit( |
| 614 | VariantToStringVisitor(), findCustomName->second); |
| 615 | } |
| 616 | catch (std::invalid_argument&) |
| 617 | { |
| 618 | std::cerr << "Unable to parse " << keyName << "\n"; |
| 619 | continue; |
| 620 | } |
| 621 | |
| 622 | // All strings are valid, including empty string |
| 623 | customizedName = true; |
| 624 | } |
| 625 | |
| 626 | bool customizedScale = false; |
| 627 | auto findCustomScale = baseConfig->second.find(keyScale); |
| 628 | if (findCustomScale != baseConfig->second.end()) |
| 629 | { |
| 630 | try |
| 631 | { |
| 632 | psuProperty->sensorScaleFactor = std::visit( |
| 633 | VariantToUnsignedIntVisitor(), findCustomScale->second); |
| 634 | } |
| 635 | catch (std::invalid_argument&) |
| 636 | { |
| 637 | std::cerr << "Unable to parse " << keyScale << "\n"; |
| 638 | continue; |
| 639 | } |
| 640 | |
| 641 | // Avoid later division by zero |
| 642 | if (psuProperty->sensorScaleFactor > 0) |
| 643 | { |
| 644 | customizedScale = true; |
| 645 | } |
| 646 | else |
| 647 | { |
| 648 | std::cerr << "Unable to accept " << keyScale << "\n"; |
| 649 | continue; |
| 650 | } |
| 651 | } |
| 652 | |
| 653 | auto findCustomMin = baseConfig->second.find(keyMin); |
| 654 | if (findCustomMin != baseConfig->second.end()) |
| 655 | { |
| 656 | try |
| 657 | { |
| 658 | psuProperty->minReading = std::visit( |
| 659 | VariantToDoubleVisitor(), findCustomMin->second); |
| 660 | } |
| 661 | catch (std::invalid_argument&) |
| 662 | { |
| 663 | std::cerr << "Unable to parse " << keyMin << "\n"; |
| 664 | continue; |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | auto findCustomMax = baseConfig->second.find(keyMax); |
| 669 | if (findCustomMax != baseConfig->second.end()) |
| 670 | { |
| 671 | try |
| 672 | { |
| 673 | psuProperty->maxReading = std::visit( |
| 674 | VariantToDoubleVisitor(), findCustomMax->second); |
| 675 | } |
| 676 | catch (std::invalid_argument&) |
| 677 | { |
| 678 | std::cerr << "Unable to parse " << keyMax << "\n"; |
| 679 | continue; |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | if (!(psuProperty->minReading < psuProperty->maxReading)) |
| 684 | { |
| 685 | std::cerr << "Min must be less than Max\n"; |
| 686 | continue; |
| 687 | } |
| 688 | |
| 689 | // If the sensor name is being customized by config file, |
| 690 | // then prefix/suffix composition becomes not necessary, |
| 691 | // and in fact not wanted, because it gets in the way. |
| 692 | std::string psuNameFromIndex; |
| 693 | if (!customizedName) |
| 694 | { |
| 695 | /* Find out sensor name index for this label */ |
| 696 | std::regex rgx("[A-Za-z]+([0-9]+)"); |
Brad Bishop | fbb44ad | 2019-11-08 09:42:37 -0500 | [diff] [blame] | 697 | size_t nameIndex{0}; |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 698 | if (std::regex_search(labelHead, matches, rgx)) |
| 699 | { |
| 700 | nameIndex = std::stoi(matches[1]); |
| 701 | |
| 702 | // Decrement to preserve alignment, because hwmon |
| 703 | // human-readable filenames and labels use 1-based |
| 704 | // numbering, but the "Name", "Name1", "Name2", etc. naming |
| 705 | // convention (the psuNames vector) uses 0-based numbering. |
| 706 | if (nameIndex > 0) |
| 707 | { |
| 708 | --nameIndex; |
| 709 | } |
| 710 | } |
| 711 | else |
| 712 | { |
| 713 | nameIndex = 0; |
| 714 | } |
| 715 | |
| 716 | if (psuNames.size() <= nameIndex) |
| 717 | { |
| 718 | std::cerr << "Could not pair " << labelHead |
| 719 | << " with a Name field\n"; |
| 720 | continue; |
| 721 | } |
| 722 | |
| 723 | psuNameFromIndex = psuNames[nameIndex]; |
| 724 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 725 | if constexpr (debug) |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 726 | { |
| 727 | std::cerr << "Sensor label head " << labelHead |
| 728 | << " paired with " << psuNameFromIndex |
| 729 | << " at index " << nameIndex << "\n"; |
| 730 | } |
Josh Lehan | 432d1ed | 2019-10-16 12:23:31 -0700 | [diff] [blame] | 731 | } |
| 732 | |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 733 | checkEventLimits(sensorPathStr, limitEventMatch, eventPathList); |
| 734 | |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 735 | // Similarly, if sensor scaling factor is being customized, |
| 736 | // then the below power-of-10 constraint becomes unnecessary, |
| 737 | // as config should be able to specify an arbitrary divisor. |
| 738 | unsigned int factor = psuProperty->sensorScaleFactor; |
| 739 | if (!customizedScale) |
Vijay Khemka | 53ca444 | 2019-07-23 11:03:55 -0700 | [diff] [blame] | 740 | { |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 741 | // Preserve existing usage of hardcoded labelMatch table below |
| 742 | factor = std::pow(10.0, factor); |
Vijay Khemka | 53ca444 | 2019-07-23 11:03:55 -0700 | [diff] [blame] | 743 | |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 744 | /* Change first char of substring to uppercase */ |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 745 | char firstChar = |
| 746 | static_cast<char>(std::toupper(sensorNameSubStr[0])); |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 747 | std::string strScaleFactor = |
| 748 | firstChar + sensorNameSubStr.substr(1) + "ScaleFactor"; |
| 749 | |
| 750 | // Preserve existing configs by accepting earlier syntax, |
| 751 | // example CurrScaleFactor, PowerScaleFactor, ... |
| 752 | auto findScaleFactor = baseConfig->second.find(strScaleFactor); |
| 753 | if (findScaleFactor != baseConfig->second.end()) |
| 754 | { |
| 755 | factor = std::visit(VariantToIntVisitor(), |
| 756 | findScaleFactor->second); |
| 757 | } |
| 758 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 759 | if constexpr (debug) |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 760 | { |
| 761 | std::cerr << "Sensor scaling factor " << factor |
| 762 | << " string " << strScaleFactor << "\n"; |
| 763 | } |
Josh Lehan | 49cfba9 | 2019-10-08 16:50:42 -0700 | [diff] [blame] | 764 | } |
| 765 | |
Vijay Khemka | 996bad1 | 2019-05-28 15:15:16 -0700 | [diff] [blame] | 766 | std::vector<thresholds::Threshold> sensorThresholds; |
Joshi, Mansi | 14f0ad8 | 2019-11-21 10:52:30 +0530 | [diff] [blame] | 767 | if (!parseThresholdsFromConfig(*sensorData, sensorThresholds, |
| 768 | &labelHead)) |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 769 | { |
James Feist | 17ab6e0 | 2019-06-25 12:28:13 -0700 | [diff] [blame] | 770 | std::cerr << "error populating thresholds for " |
| 771 | << sensorNameSubStr << "\n"; |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | auto findSensorType = sensorTable.find(sensorNameSubStr); |
| 775 | if (findSensorType == sensorTable.end()) |
| 776 | { |
Jason Ling | 5747fab | 2019-10-02 16:46:23 -0700 | [diff] [blame] | 777 | std::cerr << sensorNameSubStr |
Josh Lehan | 0649445 | 2019-10-31 09:49:16 -0700 | [diff] [blame] | 778 | << " is not a recognized sensor type\n"; |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 779 | continue; |
| 780 | } |
| 781 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 782 | if constexpr (debug) |
Josh Lehan | 49cfba9 | 2019-10-08 16:50:42 -0700 | [diff] [blame] | 783 | { |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 784 | std::cerr << "Sensor properties: Name \"" |
| 785 | << psuProperty->labelTypeName << "\" Scale " |
| 786 | << psuProperty->sensorScaleFactor << " Min " |
| 787 | << psuProperty->minReading << " Max " |
| 788 | << psuProperty->maxReading << "\n"; |
| 789 | } |
| 790 | |
| 791 | std::string sensorName = psuProperty->labelTypeName; |
| 792 | if (customizedName) |
| 793 | { |
| 794 | if (sensorName.empty()) |
| 795 | { |
| 796 | // Allow selective disabling of an individual sensor, |
| 797 | // by customizing its name to an empty string. |
| 798 | std::cerr << "Sensor disabled, empty string\n"; |
| 799 | continue; |
| 800 | } |
| 801 | } |
| 802 | else |
| 803 | { |
| 804 | // Sensor name not customized, do prefix/suffix composition, |
| 805 | // preserving default behavior by using psuNameFromIndex. |
| 806 | sensorName = |
| 807 | psuNameFromIndex + " " + psuProperty->labelTypeName; |
| 808 | } |
| 809 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 810 | if constexpr (debug) |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 811 | { |
| 812 | std::cerr << "Sensor name \"" << sensorName << "\" path \"" |
| 813 | << sensorPathStr << "\" type \"" << sensorType |
| 814 | << "\"\n"; |
Josh Lehan | 49cfba9 | 2019-10-08 16:50:42 -0700 | [diff] [blame] | 815 | } |
Zhikui Ren | 23c96e7 | 2020-11-05 22:32:28 -0800 | [diff] [blame] | 816 | // destruct existing one first if already created |
| 817 | sensors[sensorName] = nullptr; |
Yong Li | bf8b1da | 2020-04-15 16:32:50 +0800 | [diff] [blame] | 818 | sensors[sensorName] = std::make_shared<PSUSensor>( |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 819 | sensorPathStr, sensorType, objectServer, dbusConnection, io, |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 820 | sensorName, std::move(sensorThresholds), *interfacePath, |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 821 | findSensorType->second, factor, psuProperty->maxReading, |
Cheng C Yang | 6b1247a | 2020-03-09 23:48:39 +0800 | [diff] [blame] | 822 | psuProperty->minReading, labelHead, thresholdConfSize); |
Yong Li | bf8b1da | 2020-04-15 16:32:50 +0800 | [diff] [blame] | 823 | sensors[sensorName]->setupRead(); |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 824 | ++numCreated; |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 825 | if constexpr (debug) |
Josh Lehan | 74d9bd9 | 2019-10-31 08:51:58 -0700 | [diff] [blame] | 826 | { |
| 827 | std::cerr << "Created " << numCreated << " sensors so far\n"; |
| 828 | } |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 829 | } |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 830 | |
| 831 | // OperationalStatus event |
Cheng C Yang | 92498eb | 2019-09-26 21:59:25 +0800 | [diff] [blame] | 832 | combineEvents[*psuName + "OperationalStatus"] = nullptr; |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 833 | combineEvents[*psuName + "OperationalStatus"] = |
Yong Li | 3046a02 | 2020-04-03 13:01:02 +0800 | [diff] [blame] | 834 | std::make_unique<PSUCombineEvent>( |
| 835 | objectServer, dbusConnection, io, *psuName, eventPathList, |
| 836 | groupEventPathList, "OperationalStatus"); |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 837 | } |
Josh Lehan | 49cfba9 | 2019-10-08 16:50:42 -0700 | [diff] [blame] | 838 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 839 | if constexpr (debug) |
Josh Lehan | 49cfba9 | 2019-10-08 16:50:42 -0700 | [diff] [blame] | 840 | { |
| 841 | std::cerr << "Created total of " << numCreated << " sensors\n"; |
| 842 | } |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 843 | return; |
| 844 | } |
| 845 | |
Zhikui Ren | 23c96e7 | 2020-11-05 22:32:28 -0800 | [diff] [blame] | 846 | void createSensors( |
| 847 | boost::asio::io_service& io, sdbusplus::asio::object_server& objectServer, |
| 848 | std::shared_ptr<sdbusplus::asio::connection>& dbusConnection, |
| 849 | const std::shared_ptr<boost::container::flat_set<std::string>>& |
| 850 | sensorsChanged) |
| 851 | { |
| 852 | auto getter = std::make_shared<GetSensorConfiguration>( |
| 853 | dbusConnection, [&io, &objectServer, &dbusConnection, sensorsChanged]( |
| 854 | const ManagedObjectType& sensorConfigs) { |
| 855 | createSensorsCallback(io, objectServer, dbusConnection, |
| 856 | sensorConfigs, sensorsChanged); |
| 857 | }); |
| 858 | getter->getConfiguration( |
| 859 | std::vector<std::string>(sensorTypes.begin(), sensorTypes.end())); |
| 860 | } |
| 861 | |
Cheng C Yang | 916360b | 2019-05-07 18:47:16 +0800 | [diff] [blame] | 862 | void propertyInitialize(void) |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 863 | { |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 864 | sensorTable = {{"power", "power/"}, |
| 865 | {"curr", "current/"}, |
| 866 | {"temp", "temperature/"}, |
| 867 | {"in", "voltage/"}, |
| 868 | {"fan", "fan_tach/"}}; |
| 869 | |
| 870 | labelMatch = {{"pin", PSUProperty("Input Power", 3000, 0, 6)}, |
| 871 | {"pout1", PSUProperty("Output Power", 3000, 0, 6)}, |
Vijay Khemka | 996bad1 | 2019-05-28 15:15:16 -0700 | [diff] [blame] | 872 | {"pout2", PSUProperty("Output Power", 3000, 0, 6)}, |
| 873 | {"pout3", PSUProperty("Output Power", 3000, 0, 6)}, |
Vijay Khemka | be66441 | 2019-06-28 12:10:04 -0700 | [diff] [blame] | 874 | {"power1", PSUProperty("Output Power", 3000, 0, 6)}, |
Manikandan Elumalai | c7e9562 | 2020-06-03 20:22:01 +0530 | [diff] [blame] | 875 | {"maxpin", PSUProperty("Max Input Power", 3000, 0, 6)}, |
Cheng C Yang | bdbde96 | 2019-04-26 22:50:34 +0800 | [diff] [blame] | 876 | {"vin", PSUProperty("Input Voltage", 300, 0, 3)}, |
Manikandan Elumalai | c7e9562 | 2020-06-03 20:22:01 +0530 | [diff] [blame] | 877 | {"maxvin", PSUProperty("Max Input Voltage", 300, 0, 3)}, |
Vijay Khemka | 996bad1 | 2019-05-28 15:15:16 -0700 | [diff] [blame] | 878 | {"vout1", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 879 | {"vout2", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 880 | {"vout3", PSUProperty("Output Voltage", 255, 0, 3)}, |
Jason Ling | 5747fab | 2019-10-02 16:46:23 -0700 | [diff] [blame] | 881 | {"vout4", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 882 | {"vout5", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 883 | {"vout6", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 884 | {"vout7", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 885 | {"vout8", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 886 | {"vout9", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 887 | {"vout10", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 888 | {"vout11", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 889 | {"vout12", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 890 | {"vout13", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 891 | {"vout14", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 892 | {"vout15", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 893 | {"vout16", PSUProperty("Output Voltage", 255, 0, 3)}, |
Jason Ling | 32047ef | 2020-09-30 15:43:32 -0700 | [diff] [blame] | 894 | {"vout17", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 895 | {"vout18", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 896 | {"vout19", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 897 | {"vout20", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 898 | {"vout21", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 899 | {"vout22", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 900 | {"vout23", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 901 | {"vout24", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 902 | {"vout25", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 903 | {"vout26", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 904 | {"vout27", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 905 | {"vout28", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 906 | {"vout29", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 907 | {"vout30", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 908 | {"vout31", PSUProperty("Output Voltage", 255, 0, 3)}, |
| 909 | {"vout32", PSUProperty("Output Voltage", 255, 0, 3)}, |
Vijay Khemka | be66441 | 2019-06-28 12:10:04 -0700 | [diff] [blame] | 910 | {"in1", PSUProperty("Output Voltage", 255, 0, 3)}, |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 911 | {"iin", PSUProperty("Input Current", 20, 0, 3)}, |
| 912 | {"iout1", PSUProperty("Output Current", 255, 0, 3)}, |
Vijay Khemka | 996bad1 | 2019-05-28 15:15:16 -0700 | [diff] [blame] | 913 | {"iout2", PSUProperty("Output Current", 255, 0, 3)}, |
| 914 | {"iout3", PSUProperty("Output Current", 255, 0, 3)}, |
Peter Lundgren | 48b4423 | 2020-01-30 16:02:11 -0800 | [diff] [blame] | 915 | {"iout4", PSUProperty("Output Current", 255, 0, 3)}, |
| 916 | {"iout5", PSUProperty("Output Current", 255, 0, 3)}, |
| 917 | {"iout6", PSUProperty("Output Current", 255, 0, 3)}, |
| 918 | {"iout7", PSUProperty("Output Current", 255, 0, 3)}, |
| 919 | {"iout8", PSUProperty("Output Current", 255, 0, 3)}, |
| 920 | {"iout9", PSUProperty("Output Current", 255, 0, 3)}, |
| 921 | {"iout10", PSUProperty("Output Current", 255, 0, 3)}, |
| 922 | {"iout11", PSUProperty("Output Current", 255, 0, 3)}, |
| 923 | {"iout12", PSUProperty("Output Current", 255, 0, 3)}, |
| 924 | {"iout13", PSUProperty("Output Current", 255, 0, 3)}, |
| 925 | {"iout14", PSUProperty("Output Current", 255, 0, 3)}, |
Vijay Khemka | be66441 | 2019-06-28 12:10:04 -0700 | [diff] [blame] | 926 | {"curr1", PSUProperty("Output Current", 255, 0, 3)}, |
Manikandan Elumalai | c7e9562 | 2020-06-03 20:22:01 +0530 | [diff] [blame] | 927 | {"maxiout1", PSUProperty("Max Output Current", 255, 0, 3)}, |
Cheng C Yang | e50345b | 2019-04-02 17:26:15 +0800 | [diff] [blame] | 928 | {"temp1", PSUProperty("Temperature", 127, -128, 3)}, |
Vijay Khemka | 996bad1 | 2019-05-28 15:15:16 -0700 | [diff] [blame] | 929 | {"temp2", PSUProperty("Temperature", 127, -128, 3)}, |
| 930 | {"temp3", PSUProperty("Temperature", 127, -128, 3)}, |
Jason Ling | 5747fab | 2019-10-02 16:46:23 -0700 | [diff] [blame] | 931 | {"temp4", PSUProperty("Temperature", 127, -128, 3)}, |
| 932 | {"temp5", PSUProperty("Temperature", 127, -128, 3)}, |
Alex Qiu | f5709b4 | 2020-01-29 13:29:50 -0800 | [diff] [blame] | 933 | {"temp6", PSUProperty("Temperature", 127, -128, 3)}, |
Manikandan Elumalai | c7e9562 | 2020-06-03 20:22:01 +0530 | [diff] [blame] | 934 | {"maxtemp1", PSUProperty("Max Temperature", 127, -128, 3)}, |
Cheng C Yang | 8dbb395 | 2019-05-23 00:03:12 +0800 | [diff] [blame] | 935 | {"fan1", PSUProperty("Fan Speed 1", 30000, 0, 0)}, |
| 936 | {"fan2", PSUProperty("Fan Speed 2", 30000, 0, 0)}}; |
Cheng C Yang | 916360b | 2019-05-07 18:47:16 +0800 | [diff] [blame] | 937 | |
| 938 | pwmTable = {{"fan1", "Fan_1"}, {"fan2", "Fan_2"}}; |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 939 | |
| 940 | limitEventMatch = {{"PredictiveFailure", {"max_alarm", "min_alarm"}}, |
| 941 | {"Failure", {"crit_alarm", "lcrit_alarm"}}}; |
| 942 | |
Cheng C Yang | 202a1ff | 2020-01-09 09:34:22 +0800 | [diff] [blame] | 943 | eventMatch = {{"PredictiveFailure", {"power1_alarm"}}, |
| 944 | {"Failure", {"in2_alarm"}}, |
| 945 | {"ACLost", {"in1_beep"}}, |
| 946 | {"ConfigureError", {"in1_fault"}}}; |
| 947 | |
| 948 | groupEventMatch = {{"FanFault", |
| 949 | {{"fan1", {"fan1_alarm", "fan1_fault"}}, |
| 950 | {"fan2", {"fan2_alarm", "fan2_fault"}}}}}; |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 951 | } |
| 952 | |
James Feist | b6c0b91 | 2019-07-09 12:21:44 -0700 | [diff] [blame] | 953 | int main() |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 954 | { |
| 955 | boost::asio::io_service io; |
| 956 | auto systemBus = std::make_shared<sdbusplus::asio::connection>(io); |
| 957 | |
| 958 | systemBus->request_name("xyz.openbmc_project.PSUSensor"); |
| 959 | sdbusplus::asio::object_server objectServer(systemBus); |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 960 | std::vector<std::unique_ptr<sdbusplus::bus::match::match>> matches; |
Zhikui Ren | 23c96e7 | 2020-11-05 22:32:28 -0800 | [diff] [blame] | 961 | auto sensorsChanged = |
| 962 | std::make_shared<boost::container::flat_set<std::string>>(); |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 963 | |
Cheng C Yang | 916360b | 2019-05-07 18:47:16 +0800 | [diff] [blame] | 964 | propertyInitialize(); |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 965 | |
Zhikui Ren | 23c96e7 | 2020-11-05 22:32:28 -0800 | [diff] [blame] | 966 | io.post([&]() { createSensors(io, objectServer, systemBus, nullptr); }); |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 967 | boost::asio::deadline_timer filterTimer(io); |
| 968 | std::function<void(sdbusplus::message::message&)> eventHandler = |
| 969 | [&](sdbusplus::message::message& message) { |
| 970 | if (message.is_method_error()) |
| 971 | { |
| 972 | std::cerr << "callback method error\n"; |
| 973 | return; |
| 974 | } |
Zhikui Ren | 23c96e7 | 2020-11-05 22:32:28 -0800 | [diff] [blame] | 975 | sensorsChanged->insert(message.get_path()); |
Cheng C Yang | a97f134 | 2020-02-11 15:10:41 +0800 | [diff] [blame] | 976 | filterTimer.expires_from_now(boost::posix_time::seconds(3)); |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 977 | filterTimer.async_wait([&](const boost::system::error_code& ec) { |
| 978 | if (ec == boost::asio::error::operation_aborted) |
| 979 | { |
| 980 | return; |
| 981 | } |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 982 | if (ec) |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 983 | { |
| 984 | std::cerr << "timer error\n"; |
| 985 | } |
Zhikui Ren | 23c96e7 | 2020-11-05 22:32:28 -0800 | [diff] [blame] | 986 | createSensors(io, objectServer, systemBus, sensorsChanged); |
Cheng C Yang | 209ec56 | 2019-03-12 16:37:44 +0800 | [diff] [blame] | 987 | }); |
| 988 | }; |
| 989 | |
| 990 | for (const char* type : sensorTypes) |
| 991 | { |
| 992 | auto match = std::make_unique<sdbusplus::bus::match::match>( |
| 993 | static_cast<sdbusplus::bus::bus&>(*systemBus), |
| 994 | "type='signal',member='PropertiesChanged',path_namespace='" + |
| 995 | std::string(inventoryPath) + "',arg0namespace='" + type + "'", |
| 996 | eventHandler); |
| 997 | matches.emplace_back(std::move(match)); |
| 998 | } |
| 999 | io.run(); |
| 1000 | } |