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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
## This file is a template. The comment below is emitted
## into the rendered file; feel free to edit this file.
// !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!!
<%
interfaceDict = {}
%>\
%for key in sensorDict.iterkeys():
<%
sensor = sensorDict[key]
serviceInterface = sensor["serviceInterface"]
if serviceInterface == "org.freedesktop.DBus.Properties":
updateFunc = "set::"
elif serviceInterface == "xyz.openbmc_project.Inventory.Manager":
updateFunc = "notify::"
else:
assert "Un-supported interface: " + serviceInterface
endif
if serviceInterface not in interfaceDict:
interfaceDict[serviceInterface] = {}
interfaceDict[serviceInterface]["updateFunc"] = updateFunc
%>\
% endfor
#include "types.hpp"
#include "sensordatahandler.hpp"
using namespace ipmi::sensor;
%for key in sensorDict.iterkeys():
<%
sensor = sensorDict[key]
readingType = sensor["readingType"]
interfaces = sensor["interfaces"]
for interface, properties in interfaces.items():
for property, values in properties.items():
for offset, attributes in values.items():
type = attributes["type"]
%>\
%if "readingAssertion" == readingType:
namespace sensor_${key}
{
inline ipmi_ret_t readingAssertion(const SetSensorReadingReq& cmdData,
const Info& sensorInfo)
{
return set::readingAssertion<${type}>(cmdData, sensorInfo);
}
} // namespace sensor_${key}
%endif
% endfor
extern const IdInfoMap sensors = {
% for key in sensorDict.iterkeys():
% if key:
{${key},{
<%
sensor = sensorDict[key]
interfaces = sensor["interfaces"]
path = sensor["path"]
serviceInterface = sensor["serviceInterface"]
sensorType = sensor["sensorType"]
readingType = sensor["sensorReadingType"]
multiplier = sensor.get("multiplierM", 1)
offset = sensor.get("offsetB", 0)
exp = sensor.get("bExp", 0)
valueReadingType = sensor["readingType"]
updateFunc = interfaceDict[serviceInterface]["updateFunc"]
updateFunc += sensor["readingType"]
if "readingAssertion" == valueReadingType:
updateFunc = "sensor_" + str(key) + "::" + valueReadingType
sensorInterface = serviceInterface
if serviceInterface == "org.freedesktop.DBus.Properties":
sensorInterface = next(iter(interfaces))
%>
${sensorType},"${path}","${sensorInterface}",${readingType},${multiplier},
${offset},${exp},${offset * pow(10,exp)},${updateFunc},{
% for interface,properties in interfaces.items():
{"${interface}",{
% for dbus_property,property_value in properties.items():
{"${dbus_property}",{
% for offset,values in property_value.items():
{ ${offset},{
% if offset == 0xFF:
}},
<% continue %>\
% endif
<% valueType = values["type"] %>\
% for name,value in values.items():
% if name == "type":
<% continue %>\
% endif
% if valueType == "string":
std::string("${value}"),
% elif valueType == "bool":
<% value = str(value).lower() %>\
${value},
% else:
${value},
% endif
% endfor
}
},
% endfor
}},
% endfor
}},
% endfor
}
}},
% endif
% endfor
};
|