blob: e08147446af8f967bc7bce00d93cd11a08b1621f [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
Ratan Gupta00659052017-02-23 17:29:08 +053032extern const IdInfoMap sensors = {
33% for key in sensorDict.iterkeys():
34 % if key:
35{${key},{
36<%
37 sensor = sensorDict[key]
38 interfaces = sensor["interfaces"]
39 path = sensor["path"]
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050040 serviceInterface = sensor["serviceInterface"]
Ratan Gupta00659052017-02-23 17:29:08 +053041 sensorType = sensor["sensorType"]
42 readingType = sensor["sensorReadingType"]
Emily Shaffer10f49592017-05-10 12:01:10 -070043 multiplier = sensor.get("multiplierM", 1)
Tom Josephb673ff62017-09-07 15:28:32 +053044 offsetB = sensor.get("offsetB", 0)
Emily Shaffer10f49592017-05-10 12:01:10 -070045 exp = sensor.get("bExp", 0)
Emily Shaffer62235612017-06-14 13:06:26 -070046 unit = sensor.get("unit", "")
47 scale = sensor.get("scale", 0)
48 hasScale = "true" if "scale" in sensor.keys() else "false"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050049 valueReadingType = sensor["readingType"]
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050050 updateFunc = interfaceDict[serviceInterface]["updateFunc"]
51 updateFunc += sensor["readingType"]
Tom Joseph9f9a9a42017-09-07 01:17:28 +053052 getFunc = interfaceDict[serviceInterface]["getFunc"]
53 getFunc += sensor["readingType"]
Tom Joseph580af362017-09-07 15:38:40 +053054 if "readingAssertion" == valueReadingType or "readingData" == valueReadingType:
55 for interface,properties in interfaces.items():
56 for dbus_property,property_value in properties.items():
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050057 for offset,values in property_value["Offsets"].items():
Tom Joseph580af362017-09-07 15:38:40 +053058 valueType = values["type"]
59 updateFunc = "set::" + valueReadingType + "<" + valueType + ">"
60 getFunc = "get::" + valueReadingType + "<" + valueType + ">"
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050061 sensorInterface = serviceInterface
62 if serviceInterface == "org.freedesktop.DBus.Properties":
63 sensorInterface = next(iter(interfaces))
Emily Shaffercc941e12017-06-14 13:06:26 -070064 mutability = sensor.get("mutability", "Mutability::Read")
Ratan Gupta00659052017-02-23 17:29:08 +053065%>
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050066 ${sensorType},"${path}","${sensorInterface}",${readingType},${multiplier},
Emily Shaffer62235612017-06-14 13:06:26 -070067 ${offsetB},${exp},${offsetB * pow(10,exp)},
68 ${hasScale},${scale},"${unit}",
69 ${updateFunc},${getFunc},Mutability(${mutability}),{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050070 % for interface,properties in interfaces.items():
Ratan Gupta00659052017-02-23 17:29:08 +053071 {"${interface}",{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050072 % for dbus_property,property_value in properties.items():
Ratan Gupta00659052017-02-23 17:29:08 +053073 {"${dbus_property}",{
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050074<%
75try:
76 preReq = property_value["Prereqs"]
77except KeyError, e:
78 preReq = dict()
79%>\
80 {
81 % for preOffset,preValues in preReq.items():
82 { ${preOffset},{
83 % for name,value in preValues.items():
84 % if name == "type":
85<% continue %>\
86 % endif
87<% value = str(value).lower() %>\
88 ${value},
89 % endfor
90 }
91 },
92 % endfor
93 },
94 {
95 % for offset,values in property_value["Offsets"].items():
Ratan Gupta00659052017-02-23 17:29:08 +053096 { ${offset},{
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050097 % if offset == 0xFF:
98 }},
99<% continue %>\
100 % endif
101<% valueType = values["type"] %>\
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500102<%
103try:
104 skip = values["skipOn"]
105 if skip == "assert":
106 skipVal = "SkipAssertion::ASSERT"
107 elif skip == "deassert":
108 skipVal = "SkipAssertion::DEASSERT"
109 else:
110 assert "Unknown skip value " + str(skip)
111except KeyError, e:
112 skipVal = "SkipAssertion::NONE"
113%>\
114 ${skipVal},
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500115 % for name,value in values.items():
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500116 % if name == "type" or name == "skipOn":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500117<% continue %>\
Ratan Gupta00659052017-02-23 17:29:08 +0530118 % endif
119 % if valueType == "string":
120 std::string("${value}"),
Ratan Guptaca4c4462017-03-16 00:00:06 +0530121 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500122<% value = str(value).lower() %>\
Ratan Guptaca4c4462017-03-16 00:00:06 +0530123 ${value},
Ratan Gupta00659052017-02-23 17:29:08 +0530124 % else:
125 ${value},
126 % endif
127 % endfor
128 }
129 },
130 % endfor
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500131 }}},
Ratan Gupta00659052017-02-23 17:29:08 +0530132 % endfor
133 }},
134 % endfor
Emily Shaffer62235612017-06-14 13:06:26 -0700135 },
Ratan Gupta00659052017-02-23 17:29:08 +0530136}},
137 % endif
138% endfor
139};
140