blob: d55d3a08b8d4d0098dab9751c4d69dac0baa05b8 [file] [log] [blame]
Cheng C Yang209ec562019-03-12 16:37:44 +08001/*
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 Lehan0830c7b2019-10-08 16:35:09 -070016
Patrick Ventureca44b2f2019-10-31 11:02:26 -070017#include "PSUEvent.hpp"
18#include "PSUSensor.hpp"
19#include "Utils.hpp"
20
Cheng C Yang209ec562019-03-12 16:37:44 +080021#include <boost/algorithm/string/predicate.hpp>
22#include <boost/algorithm/string/replace.hpp>
Patrick Venture96e97db2019-10-31 13:44:38 -070023#include <boost/container/flat_map.hpp>
Cheng C Yang209ec562019-03-12 16:37:44 +080024#include <boost/container/flat_set.hpp>
James Feist38fb5982020-05-28 10:09:54 -070025#include <sdbusplus/asio/connection.hpp>
26#include <sdbusplus/asio/object_server.hpp>
27#include <sdbusplus/bus/match.hpp>
28
29#include <array>
Josh Lehan74d9bd92019-10-31 08:51:58 -070030#include <cmath>
James Feist24f02f22019-04-15 11:05:39 -070031#include <filesystem>
Cheng C Yang209ec562019-03-12 16:37:44 +080032#include <fstream>
Patrick Venture96e97db2019-10-31 13:44:38 -070033#include <functional>
Cheng C Yang58b2b532019-05-31 00:19:45 +080034#include <iostream>
Cheng C Yang209ec562019-03-12 16:37:44 +080035#include <regex>
Patrick Venture96e97db2019-10-31 13:44:38 -070036#include <string>
37#include <utility>
38#include <variant>
39#include <vector>
Cheng C Yang209ec562019-03-12 16:37:44 +080040
Josh Lehan49cfba92019-10-08 16:50:42 -070041static constexpr bool DEBUG = false;
42
Jason Lingdfad1ff2020-07-29 15:43:11 -070043static constexpr std::array<const char*, 14> sensorTypes = {
Josh Lehan62084c82020-06-22 15:27:12 -070044 "xyz.openbmc_project.Configuration.ADM1272",
45 "xyz.openbmc_project.Configuration.ADM1278",
46 "xyz.openbmc_project.Configuration.INA219",
Devjit Gopalpurde65ef72019-10-30 04:47:35 -070047 "xyz.openbmc_project.Configuration.INA230",
Alex Qiu6690d8f2020-01-22 17:56:33 -080048 "xyz.openbmc_project.Configuration.ISL68137",
Jason Lingdfad1ff2020-07-29 15:43:11 -070049 "xyz.openbmc_project.Configuration.ISL68220",
Alex Qiuf5709b42020-01-29 13:29:50 -080050 "xyz.openbmc_project.Configuration.MAX16601",
Alex Qiu6690d8f2020-01-22 17:56:33 -080051 "xyz.openbmc_project.Configuration.MAX20730",
52 "xyz.openbmc_project.Configuration.MAX20734",
53 "xyz.openbmc_project.Configuration.MAX20796",
54 "xyz.openbmc_project.Configuration.MAX34451",
Josh Lehan62084c82020-06-22 15:27:12 -070055 "xyz.openbmc_project.Configuration.pmbus",
56 "xyz.openbmc_project.Configuration.PXE1610",
57 "xyz.openbmc_project.Configuration.RAA228228"};
Cheng C Yang209ec562019-03-12 16:37:44 +080058
Alex Qiu6690d8f2020-01-22 17:56:33 -080059static std::vector<std::string> pmbusNames = {
Josh Lehan62084c82020-06-22 15:27:12 -070060 "adm1272", "adm1278", "ina219", "ina230", "isl68137",
Jason Lingdfad1ff2020-07-29 15:43:11 -070061 "isl68220", "max16601", "max20730", "max20734", "max20796",
62 "max34451", "pmbus", "pxe1610", "raa228228"};
Josh Lehan0830c7b2019-10-08 16:35:09 -070063
Cheng C Yang209ec562019-03-12 16:37:44 +080064namespace fs = std::filesystem;
65
Yong Libf8b1da2020-04-15 16:32:50 +080066static boost::container::flat_map<std::string, std::shared_ptr<PSUSensor>>
Cheng C Yang916360b2019-05-07 18:47:16 +080067 sensors;
Cheng C Yang58b2b532019-05-31 00:19:45 +080068static boost::container::flat_map<std::string, std::unique_ptr<PSUCombineEvent>>
69 combineEvents;
Cheng C Yang916360b2019-05-07 18:47:16 +080070static boost::container::flat_map<std::string, std::unique_ptr<PwmSensor>>
71 pwmSensors;
72static boost::container::flat_map<std::string, std::string> sensorTable;
73static boost::container::flat_map<std::string, PSUProperty> labelMatch;
74static boost::container::flat_map<std::string, std::string> pwmTable;
Cheng C Yang58b2b532019-05-31 00:19:45 +080075static boost::container::flat_map<std::string, std::vector<std::string>>
76 eventMatch;
Cheng C Yang202a1ff2020-01-09 09:34:22 +080077static boost::container::flat_map<
78 std::string,
79 boost::container::flat_map<std::string, std::vector<std::string>>>
80 groupEventMatch;
Cheng C Yang58b2b532019-05-31 00:19:45 +080081static boost::container::flat_map<std::string, std::vector<std::string>>
82 limitEventMatch;
83
Josh Lehan74d9bd92019-10-31 08:51:58 -070084static std::vector<PSUProperty> psuProperties;
85
Cheng C Yang58b2b532019-05-31 00:19:45 +080086// Function CheckEvent will check each attribute from eventMatch table in the
87// sysfs. If the attributes exists in sysfs, then store the complete path
88// of the attribute into eventPathList.
89void checkEvent(
90 const std::string& directory,
91 const boost::container::flat_map<std::string, std::vector<std::string>>&
92 eventMatch,
93 boost::container::flat_map<std::string, std::vector<std::string>>&
94 eventPathList)
95{
96 for (const auto& match : eventMatch)
97 {
98 const std::vector<std::string>& eventAttrs = match.second;
99 const std::string& eventName = match.first;
100 for (const auto& eventAttr : eventAttrs)
101 {
102 auto eventPath = directory + "/" + eventAttr;
103
104 std::ifstream eventFile(eventPath);
105 if (!eventFile.good())
106 {
107 continue;
108 }
109
110 eventPathList[eventName].push_back(eventPath);
111 }
112 }
113}
114
Cheng C Yang202a1ff2020-01-09 09:34:22 +0800115// Check Group Events which contains more than one targets in each combine
116// events.
117void checkGroupEvent(
118 const std::string& directory,
119 const boost::container::flat_map<
120 std::string,
121 boost::container::flat_map<std::string, std::vector<std::string>>>&
122 groupEventMatch,
123 boost::container::flat_map<
124 std::string,
125 boost::container::flat_map<std::string, std::vector<std::string>>>&
126 groupEventPathList)
127{
128 for (const auto& match : groupEventMatch)
129 {
130 const std::string& groupEventName = match.first;
131 const boost::container::flat_map<std::string, std::vector<std::string>>
132 events = match.second;
133 boost::container::flat_map<std::string, std::vector<std::string>>
134 pathList;
135 for (const auto& match : events)
136 {
137 const std::string& eventName = match.first;
138 const std::vector<std::string>& eventAttrs = match.second;
139 for (const auto& eventAttr : eventAttrs)
140 {
141 auto eventPath = directory + "/" + eventAttr;
142 std::ifstream eventFile(eventPath);
143 if (!eventFile.good())
144 {
145 continue;
146 }
147
148 pathList[eventName].push_back(eventPath);
149 }
150 }
151 groupEventPathList[groupEventName] = pathList;
152 }
153}
154
Cheng C Yang58b2b532019-05-31 00:19:45 +0800155// Function checkEventLimits will check all the psu related xxx_input attributes
156// in sysfs to see if xxx_crit_alarm xxx_lcrit_alarm xxx_max_alarm
157// xxx_min_alarm exist, then store the existing paths of the alarm attributes
158// to eventPathList.
159void checkEventLimits(
160 const std::string& sensorPathStr,
161 const boost::container::flat_map<std::string, std::vector<std::string>>&
162 limitEventMatch,
163 boost::container::flat_map<std::string, std::vector<std::string>>&
164 eventPathList)
165{
166 for (const auto& limitMatch : limitEventMatch)
167 {
168 const std::vector<std::string>& limitEventAttrs = limitMatch.second;
169 const std::string& eventName = limitMatch.first;
170 for (const auto& limitEventAttr : limitEventAttrs)
171 {
172 auto limitEventPath =
173 boost::replace_all_copy(sensorPathStr, "input", limitEventAttr);
174 std::ifstream eventFile(limitEventPath);
175 if (!eventFile.good())
176 {
177 continue;
178 }
179 eventPathList[eventName].push_back(limitEventPath);
180 }
181 }
182}
Cheng C Yang916360b2019-05-07 18:47:16 +0800183
AppaRao Pulid9d8caf2020-02-27 20:56:59 +0530184static void
185 checkPWMSensor(const fs::path& sensorPath, std::string& labelHead,
186 const std::string& interfacePath,
187 std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
188 sdbusplus::asio::object_server& objectServer,
189 const std::string& psuName)
Cheng C Yang916360b2019-05-07 18:47:16 +0800190{
191 for (const auto& pwmName : pwmTable)
192 {
193 if (pwmName.first != labelHead)
194 {
195 continue;
196 }
197
198 const std::string& sensorPathStr = sensorPath.string();
199 const std::string& pwmPathStr =
200 boost::replace_all_copy(sensorPathStr, "input", "target");
201 std::ifstream pwmFile(pwmPathStr);
202 if (!pwmFile.good())
203 {
204 continue;
205 }
206
207 auto findPWMSensor = pwmSensors.find(psuName + labelHead);
208 if (findPWMSensor != pwmSensors.end())
209 {
210 continue;
211 }
212
213 pwmSensors[psuName + labelHead] = std::make_unique<PwmSensor>(
AppaRao Pulid9d8caf2020-02-27 20:56:59 +0530214 "Pwm_" + psuName + "_" + pwmName.second, pwmPathStr, dbusConnection,
215 objectServer, interfacePath + "_" + pwmName.second, "PSU");
Cheng C Yang916360b2019-05-07 18:47:16 +0800216 }
217}
218
Zhikui Ren23c96e72020-11-05 22:32:28 -0800219static void createSensorsCallback(
220 boost::asio::io_service& io, sdbusplus::asio::object_server& objectServer,
221 std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
222 const ManagedObjectType& sensorConfigs,
223 const std::shared_ptr<boost::container::flat_set<std::string>>&
224 sensorsChanged)
Cheng C Yang209ec562019-03-12 16:37:44 +0800225{
Josh Lehan49cfba92019-10-08 16:50:42 -0700226 int numCreated = 0;
Zhikui Ren23c96e72020-11-05 22:32:28 -0800227 bool firstScan = sensorsChanged == nullptr;
Cheng C Yang209ec562019-03-12 16:37:44 +0800228
229 std::vector<fs::path> pmbusPaths;
230 if (!findFiles(fs::path("/sys/class/hwmon"), "name", pmbusPaths))
231 {
232 std::cerr << "No PSU sensors in system\n";
233 return;
234 }
235
236 boost::container::flat_set<std::string> directories;
237 for (const auto& pmbusPath : pmbusPaths)
238 {
Cheng C Yang58b2b532019-05-31 00:19:45 +0800239 boost::container::flat_map<std::string, std::vector<std::string>>
240 eventPathList;
Cheng C Yang202a1ff2020-01-09 09:34:22 +0800241 boost::container::flat_map<
242 std::string,
243 boost::container::flat_map<std::string, std::vector<std::string>>>
244 groupEventPathList;
Cheng C Yang58b2b532019-05-31 00:19:45 +0800245
246 std::ifstream nameFile(pmbusPath);
247 if (!nameFile.good())
248 {
Josh Lehan49cfba92019-10-08 16:50:42 -0700249 std::cerr << "Failure finding pmbus path " << pmbusPath << "\n";
Cheng C Yang58b2b532019-05-31 00:19:45 +0800250 continue;
251 }
252
253 std::string pmbusName;
254 std::getline(nameFile, pmbusName);
255 nameFile.close();
Vijay Khemka996bad12019-05-28 15:15:16 -0700256
257 if (std::find(pmbusNames.begin(), pmbusNames.end(), pmbusName) ==
258 pmbusNames.end())
Cheng C Yang58b2b532019-05-31 00:19:45 +0800259 {
Josh Lehan49cfba92019-10-08 16:50:42 -0700260 // To avoid this error message, add your driver name to
261 // the pmbusNames vector at the top of this file.
262 std::cerr << "Driver name " << pmbusName
263 << " not found in sensor whitelist\n";
Cheng C Yang58b2b532019-05-31 00:19:45 +0800264 continue;
265 }
266
267 const std::string* psuName;
Cheng C Yang209ec562019-03-12 16:37:44 +0800268 auto directory = pmbusPath.parent_path();
269
270 auto ret = directories.insert(directory.string());
271 if (!ret.second)
272 {
Josh Lehan49cfba92019-10-08 16:50:42 -0700273 std::cerr << "Duplicate path " << directory.string() << "\n";
Cheng C Yang58b2b532019-05-31 00:19:45 +0800274 continue; // check if path has already been searched
Cheng C Yang209ec562019-03-12 16:37:44 +0800275 }
276
James Feistb6c0b912019-07-09 12:21:44 -0700277 fs::path device = directory / "device";
Cheng C Yang209ec562019-03-12 16:37:44 +0800278 std::string deviceName = fs::canonical(device).stem();
279 auto findHyphen = deviceName.find("-");
280 if (findHyphen == std::string::npos)
281 {
282 std::cerr << "found bad device" << deviceName << "\n";
283 continue;
284 }
285 std::string busStr = deviceName.substr(0, findHyphen);
286 std::string addrStr = deviceName.substr(findHyphen + 1);
287
288 size_t bus = 0;
289 size_t addr = 0;
290
291 try
292 {
293 bus = std::stoi(busStr);
294 addr = std::stoi(addrStr, 0, 16);
295 }
James Feistb6c0b912019-07-09 12:21:44 -0700296 catch (std::invalid_argument&)
Cheng C Yang209ec562019-03-12 16:37:44 +0800297 {
Josh Lehan49cfba92019-10-08 16:50:42 -0700298 std::cerr << "Error parsing bus " << busStr << " addr " << addrStr
299 << "\n";
Cheng C Yang209ec562019-03-12 16:37:44 +0800300 continue;
301 }
302
Cheng C Yang209ec562019-03-12 16:37:44 +0800303 const std::pair<std::string, boost::container::flat_map<
304 std::string, BasicVariantType>>*
305 baseConfig = nullptr;
306 const SensorData* sensorData = nullptr;
307 const std::string* interfacePath = nullptr;
308 const char* sensorType = nullptr;
Cheng C Yang6b1247a2020-03-09 23:48:39 +0800309 size_t thresholdConfSize = 0;
Cheng C Yang209ec562019-03-12 16:37:44 +0800310
311 for (const std::pair<sdbusplus::message::object_path, SensorData>&
312 sensor : sensorConfigs)
313 {
314 sensorData = &(sensor.second);
315 for (const char* type : sensorTypes)
316 {
317 auto sensorBase = sensorData->find(type);
318 if (sensorBase != sensorData->end())
319 {
320 baseConfig = &(*sensorBase);
321 sensorType = type;
322 break;
323 }
324 }
325 if (baseConfig == nullptr)
326 {
327 std::cerr << "error finding base configuration for "
328 << deviceName << "\n";
329 continue;
330 }
331
332 auto configBus = baseConfig->second.find("Bus");
333 auto configAddress = baseConfig->second.find("Address");
334
335 if (configBus == baseConfig->second.end() ||
336 configAddress == baseConfig->second.end())
337 {
Cheng C Yang58b2b532019-05-31 00:19:45 +0800338 std::cerr << "error finding necessary entry in configuration\n";
Cheng C Yang209ec562019-03-12 16:37:44 +0800339 continue;
340 }
341
Cheng C Yang58b2b532019-05-31 00:19:45 +0800342 const uint64_t* confBus;
343 const uint64_t* confAddr;
344 if (!(confBus = std::get_if<uint64_t>(&(configBus->second))) ||
345 !(confAddr = std::get_if<uint64_t>(&(configAddress->second))))
346 {
347 std::cerr
Josh Lehan49cfba92019-10-08 16:50:42 -0700348 << "Cannot get bus or address, invalid configuration\n";
Cheng C Yang58b2b532019-05-31 00:19:45 +0800349 continue;
350 }
351
352 if ((*confBus != bus) || (*confAddr != addr))
Cheng C Yang209ec562019-03-12 16:37:44 +0800353 {
Josh Lehan432d1ed2019-10-16 12:23:31 -0700354 std::cerr << "Configuration skipping " << *confBus << "-"
355 << *confAddr << " because not " << bus << "-" << addr
356 << "\n";
Cheng C Yang209ec562019-03-12 16:37:44 +0800357 continue;
358 }
359
Cheng C Yang6b1247a2020-03-09 23:48:39 +0800360 std::vector<thresholds::Threshold> confThresholds;
361 if (!parseThresholdsFromConfig(*sensorData, confThresholds))
362 {
363 std::cerr << "error populating totoal thresholds\n";
364 }
365 thresholdConfSize = confThresholds.size();
366
Cheng C Yang209ec562019-03-12 16:37:44 +0800367 interfacePath = &(sensor.first.str);
368 break;
369 }
370 if (interfacePath == nullptr)
371 {
Josh Lehan49cfba92019-10-08 16:50:42 -0700372 // To avoid this error message, add your export map entry,
373 // from Entity Manager, to sensorTypes at the top of this file.
Cheng C Yang209ec562019-03-12 16:37:44 +0800374 std::cerr << "failed to find match for " << deviceName << "\n";
375 continue;
376 }
377
Cheng C Yange50345b2019-04-02 17:26:15 +0800378 auto findPSUName = baseConfig->second.find("Name");
379 if (findPSUName == baseConfig->second.end())
Cheng C Yang209ec562019-03-12 16:37:44 +0800380 {
381 std::cerr << "could not determine configuration name for "
382 << deviceName << "\n";
383 continue;
384 }
385
Cheng C Yang58b2b532019-05-31 00:19:45 +0800386 if (!(psuName = std::get_if<std::string>(&(findPSUName->second))))
387 {
388 std::cerr << "Cannot find psu name, invalid configuration\n";
389 continue;
390 }
Zhikui Ren23c96e72020-11-05 22:32:28 -0800391
392 // on rescans, only update sensors we were signaled by
393 if (!firstScan)
394 {
395 std::string psuNameStr = "/" + *psuName;
396 auto it =
397 std::find_if(sensorsChanged->begin(), sensorsChanged->end(),
398 [psuNameStr](std::string& s) {
399 return boost::ends_with(s, psuNameStr);
400 });
401
402 if (it == sensorsChanged->end())
403 {
404 continue;
405 }
406 sensorsChanged->erase(it);
407 }
Cheng C Yang58b2b532019-05-31 00:19:45 +0800408 checkEvent(directory.string(), eventMatch, eventPathList);
Cheng C Yang202a1ff2020-01-09 09:34:22 +0800409 checkGroupEvent(directory.string(), groupEventMatch,
410 groupEventPathList);
Cheng C Yang58b2b532019-05-31 00:19:45 +0800411
Vijay Khemka996bad12019-05-28 15:15:16 -0700412 /* Check if there are more sensors in the same interface */
413 int i = 1;
414 std::vector<std::string> psuNames;
415 do
416 {
Josh Lehan49cfba92019-10-08 16:50:42 -0700417 // Individual string fields: Name, Name1, Name2, Name3, ...
Vijay Khemka996bad12019-05-28 15:15:16 -0700418 psuNames.push_back(std::get<std::string>(findPSUName->second));
419 findPSUName = baseConfig->second.find("Name" + std::to_string(i++));
420 } while (findPSUName != baseConfig->second.end());
421
Cheng C Yange50345b2019-04-02 17:26:15 +0800422 std::vector<fs::path> sensorPaths;
James Feistb6c0b912019-07-09 12:21:44 -0700423 if (!findFiles(directory, R"(\w\d+_input$)", sensorPaths, 0))
Cheng C Yang209ec562019-03-12 16:37:44 +0800424 {
Cheng C Yange50345b2019-04-02 17:26:15 +0800425 std::cerr << "No PSU non-label sensor in PSU\n";
Cheng C Yang209ec562019-03-12 16:37:44 +0800426 continue;
427 }
428
Manikandan Elumalaic7e95622020-06-03 20:22:01 +0530429 /* read max value in sysfs for in, curr, power, temp, ... */
430 if (!findFiles(directory, R"(\w\d+_max$)", sensorPaths, 0))
431 {
432 if constexpr (DEBUG)
433 {
434 std::cerr << "No max name in PSU \n";
435 }
436 }
437
Vijay Khemka996bad12019-05-28 15:15:16 -0700438 /* Find array of labels to be exposed if it is defined in config */
439 std::vector<std::string> findLabels;
440 auto findLabelObj = baseConfig->second.find("Labels");
441 if (findLabelObj != baseConfig->second.end())
442 {
443 findLabels =
444 std::get<std::vector<std::string>>(findLabelObj->second);
445 }
446
Jason Ling5747fab2019-10-02 16:46:23 -0700447 std::regex sensorNameRegEx("([A-Za-z]+)[0-9]*_");
448 std::smatch matches;
449
Cheng C Yange50345b2019-04-02 17:26:15 +0800450 for (const auto& sensorPath : sensorPaths)
Cheng C Yang209ec562019-03-12 16:37:44 +0800451 {
Manikandan Elumalaic7e95622020-06-03 20:22:01 +0530452 bool maxLabel = false;
Cheng C Yange50345b2019-04-02 17:26:15 +0800453 std::string labelHead;
454 std::string sensorPathStr = sensorPath.string();
455 std::string sensorNameStr = sensorPath.filename();
Jason Ling5747fab2019-10-02 16:46:23 -0700456 std::string sensorNameSubStr{""};
457 if (std::regex_search(sensorNameStr, matches, sensorNameRegEx))
458 {
Josh Lehan06494452019-10-31 09:49:16 -0700459 // hwmon *_input filename without number:
460 // in, curr, power, temp, ...
Jason Ling5747fab2019-10-02 16:46:23 -0700461 sensorNameSubStr = matches[1];
462 }
463 else
464 {
Josh Lehan06494452019-10-31 09:49:16 -0700465 std::cerr << "Could not extract the alpha prefix from "
Jason Ling5747fab2019-10-02 16:46:23 -0700466 << sensorNameStr;
467 continue;
468 }
Cheng C Yange50345b2019-04-02 17:26:15 +0800469
Manikandan Elumalaic7e95622020-06-03 20:22:01 +0530470 std::string labelPath;
471
472 /* find and differentiate _max and _input to replace "label" */
473 int pos = sensorPathStr.find("_");
474 if (pos != std::string::npos)
475 {
476
477 std::string sensorPathStrMax = sensorPathStr.substr(pos);
478 if (sensorPathStrMax.compare("_max") == 0)
479 {
480 labelPath =
481 boost::replace_all_copy(sensorPathStr, "max", "label");
482 maxLabel = true;
483 }
484 else
485 {
486 labelPath = boost::replace_all_copy(sensorPathStr, "input",
487 "label");
488 maxLabel = false;
489 }
490 }
491 else
492 {
493 continue;
494 }
495
Cheng C Yangecba9de2019-09-12 23:41:50 +0800496 std::ifstream labelFile(labelPath);
497 if (!labelFile.good())
Cheng C Yang209ec562019-03-12 16:37:44 +0800498 {
Cheng C Yang6b1247a2020-03-09 23:48:39 +0800499 if constexpr (DEBUG)
500 {
501 std::cerr << "Input file " << sensorPath
502 << " has no corresponding label file\n";
503 }
Josh Lehan06494452019-10-31 09:49:16 -0700504 // hwmon *_input filename with number:
505 // temp1, temp2, temp3, ...
Cheng C Yange50345b2019-04-02 17:26:15 +0800506 labelHead = sensorNameStr.substr(0, sensorNameStr.find("_"));
Cheng C Yang209ec562019-03-12 16:37:44 +0800507 }
508 else
509 {
Cheng C Yange50345b2019-04-02 17:26:15 +0800510 std::string label;
511 std::getline(labelFile, label);
512 labelFile.close();
Cheng C Yange50345b2019-04-02 17:26:15 +0800513 auto findSensor = sensors.find(label);
514 if (findSensor != sensors.end())
515 {
516 continue;
517 }
518
Josh Lehan06494452019-10-31 09:49:16 -0700519 // hwmon corresponding *_label file contents:
520 // vin1, vout1, ...
Cheng C Yange50345b2019-04-02 17:26:15 +0800521 labelHead = label.substr(0, label.find(" "));
522 }
523
Manikandan Elumalaic7e95622020-06-03 20:22:01 +0530524 /* append "max" for labelMatch */
525 if (maxLabel)
526 {
527 labelHead = "max" + labelHead;
528 }
529
Josh Lehan74d9bd92019-10-31 08:51:58 -0700530 if constexpr (DEBUG)
531 {
532 std::cerr << "Sensor type=\"" << sensorNameSubStr
533 << "\" label=\"" << labelHead << "\"\n";
534 }
535
AppaRao Pulid9d8caf2020-02-27 20:56:59 +0530536 checkPWMSensor(sensorPath, labelHead, *interfacePath,
537 dbusConnection, objectServer, psuNames[0]);
Cheng C Yang916360b2019-05-07 18:47:16 +0800538
Vijay Khemka996bad12019-05-28 15:15:16 -0700539 if (!findLabels.empty())
540 {
541 /* Check if this labelHead is enabled in config file */
542 if (std::find(findLabels.begin(), findLabels.end(),
543 labelHead) == findLabels.end())
544 {
Cheng C Yang6b1247a2020-03-09 23:48:39 +0800545 if constexpr (DEBUG)
546 {
547 std::cerr << "could not find " << labelHead
548 << " in the Labels list\n";
549 }
Vijay Khemka996bad12019-05-28 15:15:16 -0700550 continue;
551 }
552 }
Cheng C Yange50345b2019-04-02 17:26:15 +0800553
Cheng C Yange50345b2019-04-02 17:26:15 +0800554 auto findProperty = labelMatch.find(labelHead);
555 if (findProperty == labelMatch.end())
Cheng C Yang209ec562019-03-12 16:37:44 +0800556 {
Josh Lehan74d9bd92019-10-31 08:51:58 -0700557 if constexpr (DEBUG)
558 {
559 std::cerr << "Could not find matching default property for "
560 << labelHead << "\n";
561 }
Cheng C Yang209ec562019-03-12 16:37:44 +0800562 continue;
563 }
564
Josh Lehan74d9bd92019-10-31 08:51:58 -0700565 // Protect the hardcoded labelMatch list from changes,
566 // by making a copy and modifying that instead.
567 // Avoid bleedthrough of one device's customizations to
568 // the next device, as each should be independently customizable.
569 psuProperties.push_back(findProperty->second);
570 auto psuProperty = psuProperties.rbegin();
571
572 // Use label head as prefix for reading from config file,
573 // example if temp1: temp1_Name, temp1_Scale, temp1_Min, ...
574 std::string keyName = labelHead + "_Name";
575 std::string keyScale = labelHead + "_Scale";
576 std::string keyMin = labelHead + "_Min";
577 std::string keyMax = labelHead + "_Max";
578
579 bool customizedName = false;
580 auto findCustomName = baseConfig->second.find(keyName);
581 if (findCustomName != baseConfig->second.end())
Josh Lehan432d1ed2019-10-16 12:23:31 -0700582 {
Josh Lehan74d9bd92019-10-31 08:51:58 -0700583 try
584 {
585 psuProperty->labelTypeName = std::visit(
586 VariantToStringVisitor(), findCustomName->second);
587 }
588 catch (std::invalid_argument&)
589 {
590 std::cerr << "Unable to parse " << keyName << "\n";
591 continue;
592 }
593
594 // All strings are valid, including empty string
595 customizedName = true;
596 }
597
598 bool customizedScale = false;
599 auto findCustomScale = baseConfig->second.find(keyScale);
600 if (findCustomScale != baseConfig->second.end())
601 {
602 try
603 {
604 psuProperty->sensorScaleFactor = std::visit(
605 VariantToUnsignedIntVisitor(), findCustomScale->second);
606 }
607 catch (std::invalid_argument&)
608 {
609 std::cerr << "Unable to parse " << keyScale << "\n";
610 continue;
611 }
612
613 // Avoid later division by zero
614 if (psuProperty->sensorScaleFactor > 0)
615 {
616 customizedScale = true;
617 }
618 else
619 {
620 std::cerr << "Unable to accept " << keyScale << "\n";
621 continue;
622 }
623 }
624
625 auto findCustomMin = baseConfig->second.find(keyMin);
626 if (findCustomMin != baseConfig->second.end())
627 {
628 try
629 {
630 psuProperty->minReading = std::visit(
631 VariantToDoubleVisitor(), findCustomMin->second);
632 }
633 catch (std::invalid_argument&)
634 {
635 std::cerr << "Unable to parse " << keyMin << "\n";
636 continue;
637 }
638 }
639
640 auto findCustomMax = baseConfig->second.find(keyMax);
641 if (findCustomMax != baseConfig->second.end())
642 {
643 try
644 {
645 psuProperty->maxReading = std::visit(
646 VariantToDoubleVisitor(), findCustomMax->second);
647 }
648 catch (std::invalid_argument&)
649 {
650 std::cerr << "Unable to parse " << keyMax << "\n";
651 continue;
652 }
653 }
654
655 if (!(psuProperty->minReading < psuProperty->maxReading))
656 {
657 std::cerr << "Min must be less than Max\n";
658 continue;
659 }
660
661 // If the sensor name is being customized by config file,
662 // then prefix/suffix composition becomes not necessary,
663 // and in fact not wanted, because it gets in the way.
664 std::string psuNameFromIndex;
665 if (!customizedName)
666 {
667 /* Find out sensor name index for this label */
668 std::regex rgx("[A-Za-z]+([0-9]+)");
Brad Bishopfbb44ad2019-11-08 09:42:37 -0500669 size_t nameIndex{0};
Josh Lehan74d9bd92019-10-31 08:51:58 -0700670 if (std::regex_search(labelHead, matches, rgx))
671 {
672 nameIndex = std::stoi(matches[1]);
673
674 // Decrement to preserve alignment, because hwmon
675 // human-readable filenames and labels use 1-based
676 // numbering, but the "Name", "Name1", "Name2", etc. naming
677 // convention (the psuNames vector) uses 0-based numbering.
678 if (nameIndex > 0)
679 {
680 --nameIndex;
681 }
682 }
683 else
684 {
685 nameIndex = 0;
686 }
687
688 if (psuNames.size() <= nameIndex)
689 {
690 std::cerr << "Could not pair " << labelHead
691 << " with a Name field\n";
692 continue;
693 }
694
695 psuNameFromIndex = psuNames[nameIndex];
696
697 if constexpr (DEBUG)
698 {
699 std::cerr << "Sensor label head " << labelHead
700 << " paired with " << psuNameFromIndex
701 << " at index " << nameIndex << "\n";
702 }
Josh Lehan432d1ed2019-10-16 12:23:31 -0700703 }
704
Cheng C Yang58b2b532019-05-31 00:19:45 +0800705 checkEventLimits(sensorPathStr, limitEventMatch, eventPathList);
706
Josh Lehan74d9bd92019-10-31 08:51:58 -0700707 // Similarly, if sensor scaling factor is being customized,
708 // then the below power-of-10 constraint becomes unnecessary,
709 // as config should be able to specify an arbitrary divisor.
710 unsigned int factor = psuProperty->sensorScaleFactor;
711 if (!customizedScale)
Vijay Khemka53ca4442019-07-23 11:03:55 -0700712 {
Josh Lehan74d9bd92019-10-31 08:51:58 -0700713 // Preserve existing usage of hardcoded labelMatch table below
714 factor = std::pow(10.0, factor);
Vijay Khemka53ca4442019-07-23 11:03:55 -0700715
Josh Lehan74d9bd92019-10-31 08:51:58 -0700716 /* Change first char of substring to uppercase */
717 char firstChar = sensorNameSubStr[0] - 0x20;
718 std::string strScaleFactor =
719 firstChar + sensorNameSubStr.substr(1) + "ScaleFactor";
720
721 // Preserve existing configs by accepting earlier syntax,
722 // example CurrScaleFactor, PowerScaleFactor, ...
723 auto findScaleFactor = baseConfig->second.find(strScaleFactor);
724 if (findScaleFactor != baseConfig->second.end())
725 {
726 factor = std::visit(VariantToIntVisitor(),
727 findScaleFactor->second);
728 }
729
730 if constexpr (DEBUG)
731 {
732 std::cerr << "Sensor scaling factor " << factor
733 << " string " << strScaleFactor << "\n";
734 }
Josh Lehan49cfba92019-10-08 16:50:42 -0700735 }
736
Vijay Khemka996bad12019-05-28 15:15:16 -0700737 std::vector<thresholds::Threshold> sensorThresholds;
Joshi, Mansi14f0ad82019-11-21 10:52:30 +0530738 if (!parseThresholdsFromConfig(*sensorData, sensorThresholds,
739 &labelHead))
Cheng C Yange50345b2019-04-02 17:26:15 +0800740 {
James Feist17ab6e02019-06-25 12:28:13 -0700741 std::cerr << "error populating thresholds for "
742 << sensorNameSubStr << "\n";
Cheng C Yange50345b2019-04-02 17:26:15 +0800743 }
744
745 auto findSensorType = sensorTable.find(sensorNameSubStr);
746 if (findSensorType == sensorTable.end())
747 {
Jason Ling5747fab2019-10-02 16:46:23 -0700748 std::cerr << sensorNameSubStr
Josh Lehan06494452019-10-31 09:49:16 -0700749 << " is not a recognized sensor type\n";
Cheng C Yange50345b2019-04-02 17:26:15 +0800750 continue;
751 }
752
Josh Lehan49cfba92019-10-08 16:50:42 -0700753 if constexpr (DEBUG)
754 {
Josh Lehan74d9bd92019-10-31 08:51:58 -0700755 std::cerr << "Sensor properties: Name \""
756 << psuProperty->labelTypeName << "\" Scale "
757 << psuProperty->sensorScaleFactor << " Min "
758 << psuProperty->minReading << " Max "
759 << psuProperty->maxReading << "\n";
760 }
761
762 std::string sensorName = psuProperty->labelTypeName;
763 if (customizedName)
764 {
765 if (sensorName.empty())
766 {
767 // Allow selective disabling of an individual sensor,
768 // by customizing its name to an empty string.
769 std::cerr << "Sensor disabled, empty string\n";
770 continue;
771 }
772 }
773 else
774 {
775 // Sensor name not customized, do prefix/suffix composition,
776 // preserving default behavior by using psuNameFromIndex.
777 sensorName =
778 psuNameFromIndex + " " + psuProperty->labelTypeName;
779 }
780
781 if constexpr (DEBUG)
782 {
783 std::cerr << "Sensor name \"" << sensorName << "\" path \""
784 << sensorPathStr << "\" type \"" << sensorType
785 << "\"\n";
Josh Lehan49cfba92019-10-08 16:50:42 -0700786 }
Zhikui Ren23c96e72020-11-05 22:32:28 -0800787 // destruct existing one first if already created
788 sensors[sensorName] = nullptr;
Yong Libf8b1da2020-04-15 16:32:50 +0800789 sensors[sensorName] = std::make_shared<PSUSensor>(
Cheng C Yange50345b2019-04-02 17:26:15 +0800790 sensorPathStr, sensorType, objectServer, dbusConnection, io,
Cheng C Yang209ec562019-03-12 16:37:44 +0800791 sensorName, std::move(sensorThresholds), *interfacePath,
Josh Lehan74d9bd92019-10-31 08:51:58 -0700792 findSensorType->second, factor, psuProperty->maxReading,
Cheng C Yang6b1247a2020-03-09 23:48:39 +0800793 psuProperty->minReading, labelHead, thresholdConfSize);
Yong Libf8b1da2020-04-15 16:32:50 +0800794 sensors[sensorName]->setupRead();
Josh Lehan74d9bd92019-10-31 08:51:58 -0700795 ++numCreated;
796 if constexpr (DEBUG)
797 {
798 std::cerr << "Created " << numCreated << " sensors so far\n";
799 }
Cheng C Yang209ec562019-03-12 16:37:44 +0800800 }
Cheng C Yang58b2b532019-05-31 00:19:45 +0800801
802 // OperationalStatus event
Cheng C Yang92498eb2019-09-26 21:59:25 +0800803 combineEvents[*psuName + "OperationalStatus"] = nullptr;
Cheng C Yang58b2b532019-05-31 00:19:45 +0800804 combineEvents[*psuName + "OperationalStatus"] =
Yong Li3046a022020-04-03 13:01:02 +0800805 std::make_unique<PSUCombineEvent>(
806 objectServer, dbusConnection, io, *psuName, eventPathList,
807 groupEventPathList, "OperationalStatus");
Cheng C Yang209ec562019-03-12 16:37:44 +0800808 }
Josh Lehan49cfba92019-10-08 16:50:42 -0700809
810 if constexpr (DEBUG)
811 {
812 std::cerr << "Created total of " << numCreated << " sensors\n";
813 }
Cheng C Yang209ec562019-03-12 16:37:44 +0800814 return;
815}
816
Zhikui Ren23c96e72020-11-05 22:32:28 -0800817void createSensors(
818 boost::asio::io_service& io, sdbusplus::asio::object_server& objectServer,
819 std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
820 const std::shared_ptr<boost::container::flat_set<std::string>>&
821 sensorsChanged)
822{
823 auto getter = std::make_shared<GetSensorConfiguration>(
824 dbusConnection, [&io, &objectServer, &dbusConnection, sensorsChanged](
825 const ManagedObjectType& sensorConfigs) {
826 createSensorsCallback(io, objectServer, dbusConnection,
827 sensorConfigs, sensorsChanged);
828 });
829 getter->getConfiguration(
830 std::vector<std::string>(sensorTypes.begin(), sensorTypes.end()));
831}
832
Cheng C Yang916360b2019-05-07 18:47:16 +0800833void propertyInitialize(void)
Cheng C Yang209ec562019-03-12 16:37:44 +0800834{
Cheng C Yange50345b2019-04-02 17:26:15 +0800835 sensorTable = {{"power", "power/"},
836 {"curr", "current/"},
837 {"temp", "temperature/"},
838 {"in", "voltage/"},
839 {"fan", "fan_tach/"}};
840
841 labelMatch = {{"pin", PSUProperty("Input Power", 3000, 0, 6)},
842 {"pout1", PSUProperty("Output Power", 3000, 0, 6)},
Vijay Khemka996bad12019-05-28 15:15:16 -0700843 {"pout2", PSUProperty("Output Power", 3000, 0, 6)},
844 {"pout3", PSUProperty("Output Power", 3000, 0, 6)},
Vijay Khemkabe664412019-06-28 12:10:04 -0700845 {"power1", PSUProperty("Output Power", 3000, 0, 6)},
Manikandan Elumalaic7e95622020-06-03 20:22:01 +0530846 {"maxpin", PSUProperty("Max Input Power", 3000, 0, 6)},
Cheng C Yangbdbde962019-04-26 22:50:34 +0800847 {"vin", PSUProperty("Input Voltage", 300, 0, 3)},
Manikandan Elumalaic7e95622020-06-03 20:22:01 +0530848 {"maxvin", PSUProperty("Max Input Voltage", 300, 0, 3)},
Vijay Khemka996bad12019-05-28 15:15:16 -0700849 {"vout1", PSUProperty("Output Voltage", 255, 0, 3)},
850 {"vout2", PSUProperty("Output Voltage", 255, 0, 3)},
851 {"vout3", PSUProperty("Output Voltage", 255, 0, 3)},
Jason Ling5747fab2019-10-02 16:46:23 -0700852 {"vout4", PSUProperty("Output Voltage", 255, 0, 3)},
853 {"vout5", PSUProperty("Output Voltage", 255, 0, 3)},
854 {"vout6", PSUProperty("Output Voltage", 255, 0, 3)},
855 {"vout7", PSUProperty("Output Voltage", 255, 0, 3)},
856 {"vout8", PSUProperty("Output Voltage", 255, 0, 3)},
857 {"vout9", PSUProperty("Output Voltage", 255, 0, 3)},
858 {"vout10", PSUProperty("Output Voltage", 255, 0, 3)},
859 {"vout11", PSUProperty("Output Voltage", 255, 0, 3)},
860 {"vout12", PSUProperty("Output Voltage", 255, 0, 3)},
861 {"vout13", PSUProperty("Output Voltage", 255, 0, 3)},
862 {"vout14", PSUProperty("Output Voltage", 255, 0, 3)},
863 {"vout15", PSUProperty("Output Voltage", 255, 0, 3)},
864 {"vout16", PSUProperty("Output Voltage", 255, 0, 3)},
Jason Ling32047ef2020-09-30 15:43:32 -0700865 {"vout17", PSUProperty("Output Voltage", 255, 0, 3)},
866 {"vout18", PSUProperty("Output Voltage", 255, 0, 3)},
867 {"vout19", PSUProperty("Output Voltage", 255, 0, 3)},
868 {"vout20", PSUProperty("Output Voltage", 255, 0, 3)},
869 {"vout21", PSUProperty("Output Voltage", 255, 0, 3)},
870 {"vout22", PSUProperty("Output Voltage", 255, 0, 3)},
871 {"vout23", PSUProperty("Output Voltage", 255, 0, 3)},
872 {"vout24", PSUProperty("Output Voltage", 255, 0, 3)},
873 {"vout25", PSUProperty("Output Voltage", 255, 0, 3)},
874 {"vout26", PSUProperty("Output Voltage", 255, 0, 3)},
875 {"vout27", PSUProperty("Output Voltage", 255, 0, 3)},
876 {"vout28", PSUProperty("Output Voltage", 255, 0, 3)},
877 {"vout29", PSUProperty("Output Voltage", 255, 0, 3)},
878 {"vout30", PSUProperty("Output Voltage", 255, 0, 3)},
879 {"vout31", PSUProperty("Output Voltage", 255, 0, 3)},
880 {"vout32", PSUProperty("Output Voltage", 255, 0, 3)},
Vijay Khemkabe664412019-06-28 12:10:04 -0700881 {"in1", PSUProperty("Output Voltage", 255, 0, 3)},
Cheng C Yange50345b2019-04-02 17:26:15 +0800882 {"iin", PSUProperty("Input Current", 20, 0, 3)},
883 {"iout1", PSUProperty("Output Current", 255, 0, 3)},
Vijay Khemka996bad12019-05-28 15:15:16 -0700884 {"iout2", PSUProperty("Output Current", 255, 0, 3)},
885 {"iout3", PSUProperty("Output Current", 255, 0, 3)},
Peter Lundgren48b44232020-01-30 16:02:11 -0800886 {"iout4", PSUProperty("Output Current", 255, 0, 3)},
887 {"iout5", PSUProperty("Output Current", 255, 0, 3)},
888 {"iout6", PSUProperty("Output Current", 255, 0, 3)},
889 {"iout7", PSUProperty("Output Current", 255, 0, 3)},
890 {"iout8", PSUProperty("Output Current", 255, 0, 3)},
891 {"iout9", PSUProperty("Output Current", 255, 0, 3)},
892 {"iout10", PSUProperty("Output Current", 255, 0, 3)},
893 {"iout11", PSUProperty("Output Current", 255, 0, 3)},
894 {"iout12", PSUProperty("Output Current", 255, 0, 3)},
895 {"iout13", PSUProperty("Output Current", 255, 0, 3)},
896 {"iout14", PSUProperty("Output Current", 255, 0, 3)},
Vijay Khemkabe664412019-06-28 12:10:04 -0700897 {"curr1", PSUProperty("Output Current", 255, 0, 3)},
Manikandan Elumalaic7e95622020-06-03 20:22:01 +0530898 {"maxiout1", PSUProperty("Max Output Current", 255, 0, 3)},
Cheng C Yange50345b2019-04-02 17:26:15 +0800899 {"temp1", PSUProperty("Temperature", 127, -128, 3)},
Vijay Khemka996bad12019-05-28 15:15:16 -0700900 {"temp2", PSUProperty("Temperature", 127, -128, 3)},
901 {"temp3", PSUProperty("Temperature", 127, -128, 3)},
Jason Ling5747fab2019-10-02 16:46:23 -0700902 {"temp4", PSUProperty("Temperature", 127, -128, 3)},
903 {"temp5", PSUProperty("Temperature", 127, -128, 3)},
Alex Qiuf5709b42020-01-29 13:29:50 -0800904 {"temp6", PSUProperty("Temperature", 127, -128, 3)},
Manikandan Elumalaic7e95622020-06-03 20:22:01 +0530905 {"maxtemp1", PSUProperty("Max Temperature", 127, -128, 3)},
Cheng C Yang8dbb3952019-05-23 00:03:12 +0800906 {"fan1", PSUProperty("Fan Speed 1", 30000, 0, 0)},
907 {"fan2", PSUProperty("Fan Speed 2", 30000, 0, 0)}};
Cheng C Yang916360b2019-05-07 18:47:16 +0800908
909 pwmTable = {{"fan1", "Fan_1"}, {"fan2", "Fan_2"}};
Cheng C Yang58b2b532019-05-31 00:19:45 +0800910
911 limitEventMatch = {{"PredictiveFailure", {"max_alarm", "min_alarm"}},
912 {"Failure", {"crit_alarm", "lcrit_alarm"}}};
913
Cheng C Yang202a1ff2020-01-09 09:34:22 +0800914 eventMatch = {{"PredictiveFailure", {"power1_alarm"}},
915 {"Failure", {"in2_alarm"}},
916 {"ACLost", {"in1_beep"}},
917 {"ConfigureError", {"in1_fault"}}};
918
919 groupEventMatch = {{"FanFault",
920 {{"fan1", {"fan1_alarm", "fan1_fault"}},
921 {"fan2", {"fan2_alarm", "fan2_fault"}}}}};
Cheng C Yang209ec562019-03-12 16:37:44 +0800922}
923
James Feistb6c0b912019-07-09 12:21:44 -0700924int main()
Cheng C Yang209ec562019-03-12 16:37:44 +0800925{
926 boost::asio::io_service io;
927 auto systemBus = std::make_shared<sdbusplus::asio::connection>(io);
928
929 systemBus->request_name("xyz.openbmc_project.PSUSensor");
930 sdbusplus::asio::object_server objectServer(systemBus);
Cheng C Yang209ec562019-03-12 16:37:44 +0800931 std::vector<std::unique_ptr<sdbusplus::bus::match::match>> matches;
Zhikui Ren23c96e72020-11-05 22:32:28 -0800932 auto sensorsChanged =
933 std::make_shared<boost::container::flat_set<std::string>>();
Cheng C Yang209ec562019-03-12 16:37:44 +0800934
Cheng C Yang916360b2019-05-07 18:47:16 +0800935 propertyInitialize();
Cheng C Yang209ec562019-03-12 16:37:44 +0800936
Zhikui Ren23c96e72020-11-05 22:32:28 -0800937 io.post([&]() { createSensors(io, objectServer, systemBus, nullptr); });
Cheng C Yang209ec562019-03-12 16:37:44 +0800938 boost::asio::deadline_timer filterTimer(io);
939 std::function<void(sdbusplus::message::message&)> eventHandler =
940 [&](sdbusplus::message::message& message) {
941 if (message.is_method_error())
942 {
943 std::cerr << "callback method error\n";
944 return;
945 }
Zhikui Ren23c96e72020-11-05 22:32:28 -0800946 sensorsChanged->insert(message.get_path());
Cheng C Yanga97f1342020-02-11 15:10:41 +0800947 filterTimer.expires_from_now(boost::posix_time::seconds(3));
Cheng C Yang209ec562019-03-12 16:37:44 +0800948 filterTimer.async_wait([&](const boost::system::error_code& ec) {
949 if (ec == boost::asio::error::operation_aborted)
950 {
951 return;
952 }
953 else if (ec)
954 {
955 std::cerr << "timer error\n";
956 }
Zhikui Ren23c96e72020-11-05 22:32:28 -0800957 createSensors(io, objectServer, systemBus, sensorsChanged);
Cheng C Yang209ec562019-03-12 16:37:44 +0800958 });
959 };
960
961 for (const char* type : sensorTypes)
962 {
963 auto match = std::make_unique<sdbusplus::bus::match::match>(
964 static_cast<sdbusplus::bus::bus&>(*systemBus),
965 "type='signal',member='PropertiesChanged',path_namespace='" +
966 std::string(inventoryPath) + "',arg0namespace='" + type + "'",
967 eventHandler);
968 matches.emplace_back(std::move(match));
969 }
970 io.run();
971}