blob: b2da7cafcc35ec3fcabfc37751d203dbebf31e71 [file] [log] [blame]
Ratan Gupta00659052017-02-23 17:29:08 +05301## This file is a template. The comment below is emitted
2## into the rendered file; feel free to edit this file.
Ratan Gupta00659052017-02-23 17:29:08 +05303// !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!!
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -05004<%
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -05005interfaceDict = {}
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -05006%>\
7%for key in sensorDict.iterkeys():
8<%
9 sensor = sensorDict[key]
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050010 serviceInterface = sensor["serviceInterface"]
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050011 if serviceInterface == "org.freedesktop.DBus.Properties":
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050012 updateFunc = "set::"
Tom Joseph9f9a9a42017-09-07 01:17:28 +053013 getFunc = "get::"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050014 elif serviceInterface == "xyz.openbmc_project.Inventory.Manager":
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050015 updateFunc = "notify::"
Tom Joseph9f9a9a42017-09-07 01:17:28 +053016 getFunc = "inventory::get::"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050017 else:
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050018 assert "Un-supported interface: " + serviceInterface
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050019 endif
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050020 if serviceInterface not in interfaceDict:
21 interfaceDict[serviceInterface] = {}
22 interfaceDict[serviceInterface]["updateFunc"] = updateFunc
Tom Joseph9f9a9a42017-09-07 01:17:28 +053023 interfaceDict[serviceInterface]["getFunc"] = getFunc
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050024%>\
25% endfor
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050026
Ratan Gupta00659052017-02-23 17:29:08 +053027#include "types.hpp"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050028#include "sensordatahandler.hpp"
Ratan Gupta00659052017-02-23 17:29:08 +053029
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050030using namespace ipmi::sensor;
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050031
32%for key in sensorDict.iterkeys():
33<%
34 sensor = sensorDict[key]
35 readingType = sensor["readingType"]
36 interfaces = sensor["interfaces"]
37 for interface, properties in interfaces.items():
38 for property, values in properties.items():
39 for offset, attributes in values.items():
40 type = attributes["type"]
41%>\
42%if "readingAssertion" == readingType:
43namespace sensor_${key}
44{
45
46inline ipmi_ret_t readingAssertion(const SetSensorReadingReq& cmdData,
47 const Info& sensorInfo)
48{
49 return set::readingAssertion<${type}>(cmdData, sensorInfo);
50}
51
Tom Joseph9f9a9a42017-09-07 01:17:28 +053052namespace get
53{
54
55inline GetSensorResponse readingAssertion(const Info& sensorInfo)
56{
57 return ipmi::sensor::get::readingAssertion<${type}>(sensorInfo);
58}
59
60} //namespace get
61
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050062} // namespace sensor_${key}
63
Emily Shaffercc941e12017-06-14 13:06:26 -070064%elif "readingData" == readingType:
65
66namespace sensor_${key}
67{
68
69inline ipmi_ret_t readingData(const SetSensorReadingReq& cmdData,
70 const Info& sensorInfo)
71{
72 return set::readingData<${type}>(cmdData, sensorInfo);
73}
74
Tom Joseph9f9a9a42017-09-07 01:17:28 +053075namespace get
76{
77
78inline GetSensorResponse readingData(const Info& sensorInfo)
79{
80 return ipmi::sensor::get::readingData<${type}>(sensorInfo);
81}
82
83} //namespace get
84
Emily Shaffercc941e12017-06-14 13:06:26 -070085} // namespace sensor_${key}
86
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050087%endif
88% endfor
89
Ratan Gupta00659052017-02-23 17:29:08 +053090extern const IdInfoMap sensors = {
91% for key in sensorDict.iterkeys():
92 % if key:
93{${key},{
94<%
95 sensor = sensorDict[key]
96 interfaces = sensor["interfaces"]
97 path = sensor["path"]
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050098 serviceInterface = sensor["serviceInterface"]
Ratan Gupta00659052017-02-23 17:29:08 +053099 sensorType = sensor["sensorType"]
100 readingType = sensor["sensorReadingType"]
Emily Shaffer10f49592017-05-10 12:01:10 -0700101 multiplier = sensor.get("multiplierM", 1)
102 offset = sensor.get("offsetB", 0)
103 exp = sensor.get("bExp", 0)
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500104 valueReadingType = sensor["readingType"]
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500105 updateFunc = interfaceDict[serviceInterface]["updateFunc"]
106 updateFunc += sensor["readingType"]
Tom Joseph9f9a9a42017-09-07 01:17:28 +0530107 getFunc = interfaceDict[serviceInterface]["getFunc"]
108 getFunc += sensor["readingType"]
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500109 if "readingAssertion" == valueReadingType:
110 updateFunc = "sensor_" + str(key) + "::" + valueReadingType
Tom Joseph9f9a9a42017-09-07 01:17:28 +0530111 getFunc = "sensor_" + str(key) + "::get::" + valueReadingType
Emily Shaffercc941e12017-06-14 13:06:26 -0700112 elif "readingData" == valueReadingType:
113 updateFunc = "sensor_" + str(key) + "::" + valueReadingType
Tom Joseph9f9a9a42017-09-07 01:17:28 +0530114 getFunc = "sensor_" + str(key) + "::get::" + valueReadingType
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500115 sensorInterface = serviceInterface
116 if serviceInterface == "org.freedesktop.DBus.Properties":
117 sensorInterface = next(iter(interfaces))
Emily Shaffercc941e12017-06-14 13:06:26 -0700118 mutability = sensor.get("mutability", "Mutability::Read")
Ratan Gupta00659052017-02-23 17:29:08 +0530119%>
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500120 ${sensorType},"${path}","${sensorInterface}",${readingType},${multiplier},
Tom Joseph9f9a9a42017-09-07 01:17:28 +0530121 ${offset},${exp},${offset * pow(10,exp)},${updateFunc},${getFunc},Mutability(${mutability}),{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500122 % for interface,properties in interfaces.items():
Ratan Gupta00659052017-02-23 17:29:08 +0530123 {"${interface}",{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500124 % for dbus_property,property_value in properties.items():
Ratan Gupta00659052017-02-23 17:29:08 +0530125 {"${dbus_property}",{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500126 % for offset,values in property_value.items():
Ratan Gupta00659052017-02-23 17:29:08 +0530127 { ${offset},{
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500128 % if offset == 0xFF:
129 }},
130<% continue %>\
131 % endif
132<% valueType = values["type"] %>\
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500133 % for name,value in values.items():
Ratan Gupta00659052017-02-23 17:29:08 +0530134 % if name == "type":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500135<% continue %>\
Ratan Gupta00659052017-02-23 17:29:08 +0530136 % endif
137 % if valueType == "string":
138 std::string("${value}"),
Ratan Guptaca4c4462017-03-16 00:00:06 +0530139 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500140<% value = str(value).lower() %>\
Ratan Guptaca4c4462017-03-16 00:00:06 +0530141 ${value},
Ratan Gupta00659052017-02-23 17:29:08 +0530142 % else:
143 ${value},
144 % endif
145 % endfor
146 }
147 },
148 % endfor
149 }},
150 % endfor
151 }},
152 % endfor
Emily Shaffercc941e12017-06-14 13:06:26 -0700153 },
Ratan Gupta00659052017-02-23 17:29:08 +0530154}},
155 % endif
156% endfor
157};
158