blob: 192b858a12de264188051a39e661f77673c586e2 [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
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050027#include "sensordatahandler.hpp"
Ratan Gupta00659052017-02-23 17:29:08 +053028
Vernon Mauery33250242019-03-12 16:49:26 -070029#include <ipmid/types.hpp>
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}",{
Santosh Puranikbbf8bd62019-05-01 19:02:52 +053077 % if properties:
78 % for dbus_property,property_value in properties.items():
79 {"${dbus_property}",{
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050080<%
81try:
82 preReq = property_value["Prereqs"]
83except KeyError, e:
84 preReq = dict()
85%>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +053086 {
87 % for preOffset,preValues in preReq.items():
88 { ${preOffset},{
89 % for name,value in preValues.items():
90 % if name == "type":
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050091<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +053092 % endif
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050093<% value = str(value).lower() %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +053094 ${value},
95 % endfor
96 }
97 },
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050098 % endfor
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050099 },
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530100 {
101 % for offset,values in property_value["Offsets"].items():
102 { ${offset},{
103 % if offset == 0xFF:
104 }},
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500105<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530106 % endif
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500107<% valueType = values["type"] %>\
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500108<%
109try:
110 skip = values["skipOn"]
111 if skip == "assert":
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530112 skipVal = "SkipAssertion::ASSERT"
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500113 elif skip == "deassert":
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530114 skipVal = "SkipAssertion::DEASSERT"
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500115 else:
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530116 assert "Unknown skip value " + str(skip)
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500117except KeyError, e:
118 skipVal = "SkipAssertion::NONE"
119%>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530120 ${skipVal},
121 % for name,value in values.items():
122 % if name == "type" or name == "skipOn":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500123<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530124 % endif
125 % if valueType == "string":
126 std::string("${value}"),
127 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500128<% value = str(value).lower() %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530129 ${value},
130 % else:
131 ${value},
132 % endif
133 % endfor
134 }
135 },
136 % endfor
137 }}},
Ratan Gupta00659052017-02-23 17:29:08 +0530138 % endfor
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530139 % endif
Ratan Gupta00659052017-02-23 17:29:08 +0530140 }},
141 % endfor
Emily Shaffer62235612017-06-14 13:06:26 -0700142 },
Ratan Gupta00659052017-02-23 17:29:08 +0530143}},
144 % endif
145% endfor
146};
147