Cheng C Yang | e83604b | 2020-01-09 09:41:47 +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 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | #include <boost/container/flat_map.hpp> |
| 19 | #include <chrono> |
| 20 | #include <cstdint> |
| 21 | #include <iostream> |
| 22 | #include <sdbusplus/asio/connection.hpp> |
| 23 | |
| 24 | namespace CR |
| 25 | { |
| 26 | |
| 27 | using BasicVariantType = |
| 28 | std::variant<std::vector<std::string>, std::vector<uint64_t>, |
| 29 | std::vector<uint8_t>, std::string, int64_t, uint64_t, double, |
| 30 | int32_t, uint32_t, int16_t, uint16_t, uint8_t, bool>; |
| 31 | |
| 32 | using PropertyMapType = |
| 33 | boost::container::flat_map<std::string, BasicVariantType>; |
| 34 | |
| 35 | using GetSubTreeType = std::vector< |
| 36 | std::pair<std::string, |
| 37 | std::vector<std::pair<std::string, std::vector<std::string>>>>>; |
| 38 | |
| 39 | constexpr std::chrono::microseconds dbusTimeout(5000); |
| 40 | static std::string psuEventPath = "/xyz/openbmc_project/State/Decorator/"; |
| 41 | |
| 42 | enum class PSUState |
| 43 | { |
| 44 | normal, |
| 45 | acLost |
| 46 | }; |
| 47 | |
| 48 | /** |
| 49 | * Getting PSU Event from PSU D-Bus interfaces |
| 50 | * |
| 51 | * @param[in] dbusConnection - D-Bus connection |
| 52 | * @param[in] psuName - PSU name such as "PSU1" |
| 53 | * @param[out] state - PSU state, normal or acLost |
| 54 | */ |
| 55 | void getPSUEvent( |
| 56 | const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection, |
| 57 | const std::string& psuName, PSUState& state); |
| 58 | |
| 59 | } // namespace CR |