Lines Matching +full:boost +full:- +full:max +full:- +full:current
8 // http://www.apache.org/licenses/LICENSE-2.0
26 #include <boost/algorithm/string/case_conv.hpp>
27 #include <boost/algorithm/string/replace.hpp>
28 #include <boost/asio/error.hpp>
29 #include <boost/asio/io_context.hpp>
30 #include <boost/asio/post.hpp>
31 #include <boost/asio/steady_timer.hpp>
32 #include <boost/container/flat_map.hpp>
33 #include <boost/container/flat_set.hpp>
34 #include <phosphor-logging/lg2.hpp>
64 static std::regex i2cDevRegex(R"((\/i2c\-\d+\/\d+-[a-fA-F0-9]{4,4})(\/|$))");
168 static boost::container::flat_map<std::string, std::shared_ptr<PSUSensor>>
170 static boost::container::flat_map<std::string, std::unique_ptr<PSUCombineEvent>>
172 static boost::container::flat_map<std::string, std::unique_ptr<PwmSensor>>
174 static boost::container::flat_map<std::string, std::string> sensorTable;
175 static boost::container::flat_map<std::string, PSUProperty> labelMatch;
179 static boost::container::flat_map<size_t, bool> cpuPresence;
180 static boost::container::flat_map<DevTypes, DevParams> devParamMap;
284 boost::replace_all_copy(sensorPathStr, "input", "target"); in checkPWMSensor()
311 boost::asio::io_context& io, sdbusplus::asio::object_server& objectServer, in createSensorsCallback()
314 const std::shared_ptr<boost::container::flat_set<std::string>>& in createSensorsCallback()
333 boost::container::flat_set<std::string> directories; in createSensorsCallback()
375 // Find /i2c-<bus>/<bus>-<address> match in device path in createSensorsCallback()
383 // Extract <bus>-<address> in createSensorsCallback()
412 auto sensorBase = sensorData->find(configInterfaceName(type)); in createSensorsCallback()
413 if (sensorBase != sensorData->end()) in createSensorsCallback()
415 baseConfig = &sensorBase->second; in createSensorsCallback()
427 auto configBus = baseConfig->find("Bus"); in createSensorsCallback()
428 auto configAddress = baseConfig->find("Address"); in createSensorsCallback()
430 if (configBus == baseConfig->end() || in createSensorsCallback()
431 configAddress == baseConfig->end()) in createSensorsCallback()
438 std::get_if<uint64_t>(&(configBus->second)); in createSensorsCallback()
440 std::get_if<uint64_t>(&(configAddress->second)); in createSensorsCallback()
450 "Configuration skipping '{CONFBUS}'-'{CONFADDR}' because not {BUS}-{ADDR}", in createSensorsCallback()
479 if (activateOnly && !findI2CDev->second.second) in createSensorsCallback()
483 i2cDev = findI2CDev->second.first; in createSensorsCallback()
486 auto findPSUName = baseConfig->find("Name"); in createSensorsCallback()
487 if (findPSUName == baseConfig->end()) in createSensorsCallback()
494 std::get_if<std::string>(&(findPSUName->second)); in createSensorsCallback()
501 auto findCPU = baseConfig->find("CPURequired"); in createSensorsCallback()
502 if (findCPU != baseConfig->end()) in createSensorsCallback()
504 size_t index = std::visit(VariantToIntVisitor(), findCPU->second); in createSensorsCallback()
506 if (presenceFind == cpuPresence.end() || !presenceFind->second) in createSensorsCallback()
517 std::find_if(sensorsChanged->begin(), sensorsChanged->end(), in createSensorsCallback()
522 if (it == sensorsChanged->end()) in createSensorsCallback()
526 sensorsChanged->erase(it); in createSensorsCallback()
540 escapeName(std::get<std::string>(findPSUName->second))); in createSensorsCallback()
541 findPSUName = baseConfig->find("Name" + std::to_string(i++)); in createSensorsCallback()
542 } while (findPSUName != baseConfig->end()); in createSensorsCallback()
548 lg2::error("No PSU non-label sensor in PSU"); in createSensorsCallback()
552 /* read max value in sysfs for in, curr, power, temp, ... */ in createSensorsCallback()
555 lg2::debug("No max name in PSU"); in createSensorsCallback()
562 auto findLabelObj = baseConfig->find("Labels"); in createSensorsCallback()
563 if (findLabelObj != baseConfig->end()) in createSensorsCallback()
566 std::get<std::vector<std::string>>(findLabelObj->second); in createSensorsCallback()
605 labelPath = boost::replace_all_copy(sensorPathStr, in createSensorsCallback()
606 "max", "label"); in createSensorsCallback()
611 labelPath = boost::replace_all_copy(sensorPathStr, in createSensorsCallback()
648 /* append "max" for labelMatch */ in createSensorsCallback()
651 labelHead.insert(0, "max"); in createSensorsCallback()
707 PSUProperty psuProperty = findProperty->second; in createSensorsCallback()
719 auto findCustomName = baseConfig->find(keyName); in createSensorsCallback()
720 if (findCustomName != baseConfig->end()) in createSensorsCallback()
725 VariantToStringVisitor(), findCustomName->second); in createSensorsCallback()
738 auto findCustomScale = baseConfig->find(keyScale); in createSensorsCallback()
739 if (findCustomScale != baseConfig->end()) in createSensorsCallback()
744 VariantToUnsignedIntVisitor(), findCustomScale->second); in createSensorsCallback()
764 auto findCustomMin = baseConfig->find(keyMin); in createSensorsCallback()
765 if (findCustomMin != baseConfig->end()) in createSensorsCallback()
770 VariantToDoubleVisitor(), findCustomMin->second); in createSensorsCallback()
779 auto findCustomMax = baseConfig->find(keyMax); in createSensorsCallback()
780 if (findCustomMax != baseConfig->end()) in createSensorsCallback()
785 VariantToDoubleVisitor(), findCustomMax->second); in createSensorsCallback()
789 lg2::error("Unable to parse '{MAX}'", "MAX", keyMax); in createSensorsCallback()
794 auto findCustomOffset = baseConfig->find(keyOffset); in createSensorsCallback()
795 if (findCustomOffset != baseConfig->end()) in createSensorsCallback()
800 VariantToDoubleVisitor(), findCustomOffset->second); in createSensorsCallback()
811 auto findPowerState = baseConfig->find(keyPowerState); in createSensorsCallback()
812 if (findPowerState != baseConfig->end()) in createSensorsCallback()
815 findPowerState->second); in createSensorsCallback()
820 lg2::error("Min must be less than Max"); in createSensorsCallback()
832 std::regex rgx("[A-Za-z]+([0-9]+)"); in createSensorsCallback()
840 // human-readable filenames and labels use 1-based in createSensorsCallback()
842 // convention (the psuNames vector) uses 0-based numbering. in createSensorsCallback()
845 --nameIndex; in createSensorsCallback()
873 // then the below power-of-10 constraint becomes unnecessary, in createSensorsCallback()
889 auto findScaleFactor = baseConfig->find(strScaleFactor); in createSensorsCallback()
890 if (findScaleFactor != baseConfig->end()) in createSensorsCallback()
893 findScaleFactor->second); in createSensorsCallback()
917 lg2::debug("Sensor properties - Name: {NAME}, Scale: {SCALE}, " in createSensorsCallback()
918 "Min: {MIN}, Max: {MAX}, Offset: {OFFSET}", in createSensorsCallback()
921 psuProperty.minReading, "MAX", psuProperty.maxReading, in createSensorsCallback()
962 sensor->activate(sensorPathStr, i2cDev); in createSensorsCallback()
969 readState, findSensorUnit->second, factor, in createSensorsCallback()
973 sensors[sensorName]->setupRead(); in createSensorsCallback()
1003 auto getItems = dbusConnection->new_method_call( in getPresentCpus()
1008 auto getItemsResp = dbusConnection->call(getItems); in getPresentCpus()
1020 boost::to_lower(obj); in getPresentCpus()
1026 const std::string& owner = objDict.begin()->first; in getPresentCpus()
1031 auto getPresence = dbusConnection->new_method_call( in getPresentCpus()
1035 auto resp = dbusConnection->call(getPresence); in getPresentCpus()
1050 cpuIndex = std::stoi(obj.substr(obj.size() - 1)); in getPresentCpus()
1063 boost::asio::io_context& io, sdbusplus::asio::object_server& objectServer, in createSensors()
1065 const std::shared_ptr<boost::container::flat_set<std::string>>& in createSensors()
1081 getter->getConfiguration(types); in createSensors()
1097 {"maxpin", PSUProperty("Max Input Power", 3000, 0, 6, 0)}, in propertyInitialize()
1099 {"maxvin", PSUProperty("Max Input Voltage", 300, 0, 3, 0)}, in propertyInitialize()
1105 {"iin", PSUProperty("Input Current", 20, 0, 3, 0)}, in propertyInitialize()
1106 {"iout", PSUProperty("Output Current", 255, 0, 3, 0)}, in propertyInitialize()
1107 {"curr", PSUProperty("Output Current", 255, 0, 3, 0)}, in propertyInitialize()
1108 {"maxiout", PSUProperty("Max Output Current", 255, 0, 3, 0)}, in propertyInitialize()
1109 {"temp", PSUProperty("Temperature", 127, -128, 3, 0)}, in propertyInitialize()
1110 {"maxtemp", PSUProperty("Max Temperature", 127, -128, 3, 0)}, in propertyInitialize()
1122 {DevTypes::HWMON, {1, R"(\w\d+_input$)", "([A-Za-z]+)[0-9]*_"}}, in propertyInitialize()
1124 {2, R"(\w+_(raw|input)$)", "^(in|out)_([A-Za-z]+)[0-9]*_"}}}; in propertyInitialize()
1129 boost::container::flat_map<std::string, std::shared_ptr<PSUSensor>>& in powerStateChanged()
1131 boost::asio::io_context& io, sdbusplus::asio::object_server& objectServer, in powerStateChanged()
1142 if (sensor != nullptr && sensor->readState == type) in powerStateChanged()
1144 sensor->deactivate(); in powerStateChanged()
1152 boost::asio::io_context io; in main()
1158 systemBus->request_name("xyz.openbmc_project.PSUSensor"); in main()
1160 std::make_shared<boost::container::flat_set<std::string>>(); in main()
1171 boost::asio::post(io, [&]() { in main()
1174 boost::asio::steady_timer filterTimer(io); in main()
1177 sensorsChanged->insert(message.get_path()); in main()
1179 filterTimer.async_wait([&](const boost::system::error_code& ec) { in main()
1180 if (ec == boost::asio::error::operation_aborted) in main()
1193 boost::asio::steady_timer cpuFilterTimer(io); in main()
1197 boost::to_lower(path); in main()
1208 index = std::stoi(path.substr(path.size() - 1)); in main()
1217 boost::container::flat_map<std::string, std::variant<bool>> values; in main()
1226 cpuPresence[index] = std::get<bool>(findPresence->second); in main()
1238 cpuFilterTimer.async_wait([&](const boost::system::error_code& ec) { in main()
1239 if (ec == boost::asio::error::operation_aborted) in main()