blob: 1c36dafa7db6f9b47361e8b22ae043b458f36694 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#include <unistd.h>
#include <fcntl.h>
#include <sdbusplus/bus.hpp>
#include <phosphor-logging/log.hpp>
#include "utility.hpp"
#include "cooling_type.hpp"
namespace phosphor
{
namespace cooling
{
namespace type
{
void CoolingType::setAirCooled()
{
airCooled = true;
}
void CoolingType::setWaterCooled()
{
waterCooled = true;
}
void CoolingType::setupGpio(const std::string& gpioPath)
{
using namespace phosphor::logging;
gpioFd = open(gpioPath.c_str(), O_RDONLY);
if (gpioFd.is_open())
{
auto rc = 0;//libevdev_new_from_fd(gpiofd, &gpioDev);//FIXME
if (rc < 0)
{
throw std::runtime_error("Failed to get libevdev from " +
gpioPath + " rc = " +
std::to_string(rc));
}
//TODO - more to go here?
}
else
{
throw std::runtime_error("Failed to open GPIO file device");
}
}
CoolingType::ObjectMap CoolingType::getObjectMap(const std::string& objpath)
{
ObjectMap invObj;
InterfaceMap invIntf;
PropertyMap invProp;
invProp.emplace("AirCooled", airCooled);
invProp.emplace("WaterCooled", waterCooled);
invIntf.emplace("xyz.openbmc_project.Inventory.Decorator.CoolingType",
std::move(invProp));
invObj.emplace(objpath, std::move(invIntf));
return invObj;
}
void CoolingType::updateInventory(const std::string& objpath)
{
using namespace phosphor::logging;
ObjectMap invObj = getObjectMap(objpath);
std::string invService;
invService = phosphor::fan::util::getInvService(bus);
// Update inventory
auto invMsg = bus.new_method_call(invService.c_str(),
INVENTORY_PATH,
INVENTORY_INTF,
"Notify");
invMsg.append(std::move(invObj));
auto invMgrResponseMsg = bus.call(invMsg);
if (invMgrResponseMsg.is_method_error())
{
throw std::runtime_error(
"Error in inventory manager call to update inventory");
}
}
}
}
}
// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|