blob: bbc80e3732461ed38107308df3a1f29b1769a7e2 [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"]
Tom Joseph31ff6e62018-01-24 16:10:09 +053042 entityID = sensor.get("entityID", 0)
43 instance = sensor.get("entityInstance", 0)
Ratan Gupta00659052017-02-23 17:29:08 +053044 readingType = sensor["sensorReadingType"]
Emily Shaffer10f49592017-05-10 12:01:10 -070045 multiplier = sensor.get("multiplierM", 1)
Tom Josephb673ff62017-09-07 15:28:32 +053046 offsetB = sensor.get("offsetB", 0)
Kirill Pakhomov4d1a5dd2018-10-10 17:06:41 +030047 bExp = sensor.get("bExp", 0)
Tom Joseph0a1301c2018-02-16 08:27:00 +053048 rExp = sensor.get("rExp", 0)
Emily Shaffer62235612017-06-14 13:06:26 -070049 unit = sensor.get("unit", "")
50 scale = sensor.get("scale", 0)
51 hasScale = "true" if "scale" in sensor.keys() else "false"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050052 valueReadingType = sensor["readingType"]
Tom Joseph31ff6e62018-01-24 16:10:09 +053053 sensorNamePattern = sensor.get("sensorNamePattern", "nameLeaf")
54 sensorNameFunc = "get::" + sensorNamePattern
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050055 updateFunc = interfaceDict[serviceInterface]["updateFunc"]
56 updateFunc += sensor["readingType"]
Tom Joseph9f9a9a42017-09-07 01:17:28 +053057 getFunc = interfaceDict[serviceInterface]["getFunc"]
58 getFunc += sensor["readingType"]
Tom Joseph580af362017-09-07 15:38:40 +053059 if "readingAssertion" == valueReadingType or "readingData" == valueReadingType:
60 for interface,properties in interfaces.items():
61 for dbus_property,property_value in properties.items():
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050062 for offset,values in property_value["Offsets"].items():
Tom Joseph580af362017-09-07 15:38:40 +053063 valueType = values["type"]
64 updateFunc = "set::" + valueReadingType + "<" + valueType + ">"
65 getFunc = "get::" + valueReadingType + "<" + valueType + ">"
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050066 sensorInterface = serviceInterface
67 if serviceInterface == "org.freedesktop.DBus.Properties":
68 sensorInterface = next(iter(interfaces))
Emily Shaffercc941e12017-06-14 13:06:26 -070069 mutability = sensor.get("mutability", "Mutability::Read")
Ratan Gupta00659052017-02-23 17:29:08 +053070%>
Tom Joseph31ff6e62018-01-24 16:10:09 +053071 ${entityID},${instance},${sensorType},"${path}","${sensorInterface}",
Kirill Pakhomov4d1a5dd2018-10-10 17:06:41 +030072 ${readingType},${multiplier},${offsetB},${bExp},
73 ${offsetB * pow(10,bExp)}, ${rExp}, ${hasScale},${scale},"${unit}",
Tom Joseph31ff6e62018-01-24 16:10:09 +053074 ${updateFunc},${getFunc},Mutability(${mutability}),${sensorNameFunc},{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050075 % for interface,properties in interfaces.items():
Ratan Gupta00659052017-02-23 17:29:08 +053076 {"${interface}",{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050077 % for dbus_property,property_value in properties.items():
Ratan Gupta00659052017-02-23 17:29:08 +053078 {"${dbus_property}",{
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050079<%
80try:
81 preReq = property_value["Prereqs"]
82except KeyError, e:
83 preReq = dict()
84%>\
85 {
86 % for preOffset,preValues in preReq.items():
87 { ${preOffset},{
88 % for name,value in preValues.items():
89 % if name == "type":
90<% continue %>\
91 % endif
92<% value = str(value).lower() %>\
93 ${value},
94 % endfor
95 }
96 },
97 % endfor
98 },
99 {
100 % for offset,values in property_value["Offsets"].items():
Ratan Gupta00659052017-02-23 17:29:08 +0530101 { ${offset},{
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500102 % if offset == 0xFF:
103 }},
104<% continue %>\
105 % endif
106<% valueType = values["type"] %>\
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500107<%
108try:
109 skip = values["skipOn"]
110 if skip == "assert":
111 skipVal = "SkipAssertion::ASSERT"
112 elif skip == "deassert":
113 skipVal = "SkipAssertion::DEASSERT"
114 else:
115 assert "Unknown skip value " + str(skip)
116except KeyError, e:
117 skipVal = "SkipAssertion::NONE"
118%>\
119 ${skipVal},
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500120 % for name,value in values.items():
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500121 % if name == "type" or name == "skipOn":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500122<% continue %>\
Ratan Gupta00659052017-02-23 17:29:08 +0530123 % endif
124 % if valueType == "string":
125 std::string("${value}"),
Ratan Guptaca4c4462017-03-16 00:00:06 +0530126 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500127<% value = str(value).lower() %>\
Ratan Guptaca4c4462017-03-16 00:00:06 +0530128 ${value},
Ratan Gupta00659052017-02-23 17:29:08 +0530129 % else:
130 ${value},
131 % endif
132 % endfor
133 }
134 },
135 % endfor
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500136 }}},
Ratan Gupta00659052017-02-23 17:29:08 +0530137 % endfor
138 }},
139 % endfor
Emily Shaffer62235612017-06-14 13:06:26 -0700140 },
Ratan Gupta00659052017-02-23 17:29:08 +0530141}},
142 % endif
143% endfor
144};
145