blob: d30d642b0830f951119796c187e02288cd0801bf [file] [log] [blame]
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +05301#pragma once
2
3#include <sdbusplus/bus.hpp>
4#include <sdbusplus/server/object.hpp>
5#include <org/open_power/OCC/Status/server.hpp>
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +05306#include "occ_events.hpp"
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +05307#include "occ_device.hpp"
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +05308namespace open_power
9{
10namespace occ
11{
12
13namespace Base = sdbusplus::org::open_power::OCC::server;
14using Interface = sdbusplus::server::object::object<Base::Status>;
15
Vishwanatha Subbanna6add0b82017-07-21 19:02:37 +053016// OCC status instance. Ex. for "occ0", the instance is 0
17using instanceID = int;
18
19// IPMI sensor ID for a given OCC instance
20using sensorID = uint8_t;
21
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053022/** @class Status
23 * @brief Implementation of OCC Active Status
24 */
25class Status : public Interface
26{
27 public:
28 Status() = delete;
29 ~Status() = default;
30 Status(const Status&) = delete;
31 Status& operator=(const Status&) = delete;
32 Status(Status&&) = default;
33 Status& operator=(Status&&) = default;
34
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053035 /** @brief Constructs the Status object and
36 * the underlying device object
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053037 *
38 * @param[in] bus - DBus bus to attach to
39 * @param[in] path - DBus object path
40 */
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053041 Status(sdbusplus::bus::bus& bus, EventPtr& event, const char* path)
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053042 : Interface(bus, path),
43 path(path),
Vishwanatha Subbanna6add0b82017-07-21 19:02:37 +053044 instance(((this->path.back() - '0'))),
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053045 device(event,
Vishwanatha Subbanna6add0b82017-07-21 19:02:37 +053046 name + std::to_string(instance + 1),
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053047 std::bind(&Status::deviceErrorHandler, this))
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053048 {
49 // Nothing to do here
50 }
51
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053052 /** @brief Since we are overriding the setter-occActive but not the
53 * getter-occActive, we need to have this using in order to
54 * allow passthrough usage of the getter-occActive
55 */
56 using Base::Status::occActive;
57
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053058 /** @brief SET OccActive to True or False
59 *
60 * @param[in] value - Intended value
61 *
62 * @return - Updated value of the property
63 */
64 bool occActive(bool value) override;
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053065
66 private:
67 /** @brief OCC dbus object path */
68 std::string path;
69
70 /** @brief occ name prefix */
71 std::string name = OCC_NAME;
72
Vishwanatha Subbanna6add0b82017-07-21 19:02:37 +053073 /** @brief OCC instance number. Ex, 0,1, etc */
74 int instance;
75
76 /** @brief OCC instance to Sensor ID mapping */
77 static const std::map<instanceID, sensorID> sensorMap;
78
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053079 /** @brief OCC device object to do bind and unbind */
80 Device device;
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053081
82 /** @brief Callback handler when device errors are detected */
83 void deviceErrorHandler();
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053084};
85
86} // namespace occ
87} // namespace open_power