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