blob: c740f6f48c9f009574ed6e5a64735a58727c7d41 [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>
Patrick Venturedb0cbe62019-09-09 14:47:22 -070030
31namespace ipmi {
32namespace sensor {
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050033
Ratan Gupta00659052017-02-23 17:29:08 +053034extern const IdInfoMap sensors = {
35% for key in sensorDict.iterkeys():
36 % if key:
37{${key},{
38<%
39 sensor = sensorDict[key]
40 interfaces = sensor["interfaces"]
41 path = sensor["path"]
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050042 serviceInterface = sensor["serviceInterface"]
Ratan Gupta00659052017-02-23 17:29:08 +053043 sensorType = sensor["sensorType"]
Tom Joseph31ff6e62018-01-24 16:10:09 +053044 entityID = sensor.get("entityID", 0)
45 instance = sensor.get("entityInstance", 0)
Ratan Gupta00659052017-02-23 17:29:08 +053046 readingType = sensor["sensorReadingType"]
Emily Shaffer10f49592017-05-10 12:01:10 -070047 multiplier = sensor.get("multiplierM", 1)
Tom Josephb673ff62017-09-07 15:28:32 +053048 offsetB = sensor.get("offsetB", 0)
Kirill Pakhomov4d1a5dd2018-10-10 17:06:41 +030049 bExp = sensor.get("bExp", 0)
Tom Joseph0a1301c2018-02-16 08:27:00 +053050 rExp = sensor.get("rExp", 0)
Emily Shaffer62235612017-06-14 13:06:26 -070051 unit = sensor.get("unit", "")
52 scale = sensor.get("scale", 0)
53 hasScale = "true" if "scale" in sensor.keys() else "false"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050054 valueReadingType = sensor["readingType"]
Tom Joseph31ff6e62018-01-24 16:10:09 +053055 sensorNamePattern = sensor.get("sensorNamePattern", "nameLeaf")
56 sensorNameFunc = "get::" + sensorNamePattern
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050057 updateFunc = interfaceDict[serviceInterface]["updateFunc"]
58 updateFunc += sensor["readingType"]
Tom Joseph9f9a9a42017-09-07 01:17:28 +053059 getFunc = interfaceDict[serviceInterface]["getFunc"]
60 getFunc += sensor["readingType"]
Tom Joseph580af362017-09-07 15:38:40 +053061 if "readingAssertion" == valueReadingType or "readingData" == valueReadingType:
62 for interface,properties in interfaces.items():
63 for dbus_property,property_value in properties.items():
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050064 for offset,values in property_value["Offsets"].items():
Tom Joseph580af362017-09-07 15:38:40 +053065 valueType = values["type"]
66 updateFunc = "set::" + valueReadingType + "<" + valueType + ">"
67 getFunc = "get::" + valueReadingType + "<" + valueType + ">"
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050068 sensorInterface = serviceInterface
69 if serviceInterface == "org.freedesktop.DBus.Properties":
70 sensorInterface = next(iter(interfaces))
Emily Shaffercc941e12017-06-14 13:06:26 -070071 mutability = sensor.get("mutability", "Mutability::Read")
Ratan Gupta00659052017-02-23 17:29:08 +053072%>
Tom Joseph31ff6e62018-01-24 16:10:09 +053073 ${entityID},${instance},${sensorType},"${path}","${sensorInterface}",
Kirill Pakhomov4d1a5dd2018-10-10 17:06:41 +030074 ${readingType},${multiplier},${offsetB},${bExp},
75 ${offsetB * pow(10,bExp)}, ${rExp}, ${hasScale},${scale},"${unit}",
Tom Joseph31ff6e62018-01-24 16:10:09 +053076 ${updateFunc},${getFunc},Mutability(${mutability}),${sensorNameFunc},{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050077 % for interface,properties in interfaces.items():
Ratan Gupta00659052017-02-23 17:29:08 +053078 {"${interface}",{
Santosh Puranikbbf8bd62019-05-01 19:02:52 +053079 % if properties:
80 % for dbus_property,property_value in properties.items():
81 {"${dbus_property}",{
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050082<%
83try:
84 preReq = property_value["Prereqs"]
85except KeyError, e:
86 preReq = dict()
87%>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +053088 {
89 % for preOffset,preValues in preReq.items():
90 { ${preOffset},{
91 % for name,value in preValues.items():
92 % if name == "type":
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050093<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +053094 % endif
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050095<% value = str(value).lower() %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +053096 ${value},
97 % endfor
98 }
99 },
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500100 % endfor
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500101 },
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530102 {
103 % for offset,values in property_value["Offsets"].items():
104 { ${offset},{
105 % if offset == 0xFF:
106 }},
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500107<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530108 % endif
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500109<% valueType = values["type"] %>\
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500110<%
111try:
112 skip = values["skipOn"]
113 if skip == "assert":
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530114 skipVal = "SkipAssertion::ASSERT"
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500115 elif skip == "deassert":
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530116 skipVal = "SkipAssertion::DEASSERT"
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500117 else:
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530118 assert "Unknown skip value " + str(skip)
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500119except KeyError, e:
120 skipVal = "SkipAssertion::NONE"
121%>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530122 ${skipVal},
123 % for name,value in values.items():
124 % if name == "type" or name == "skipOn":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500125<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530126 % endif
127 % if valueType == "string":
128 std::string("${value}"),
129 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500130<% value = str(value).lower() %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530131 ${value},
132 % else:
133 ${value},
134 % endif
135 % endfor
136 }
137 },
138 % endfor
139 }}},
Ratan Gupta00659052017-02-23 17:29:08 +0530140 % endfor
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530141 % endif
Ratan Gupta00659052017-02-23 17:29:08 +0530142 }},
143 % endfor
Emily Shaffer62235612017-06-14 13:06:26 -0700144 },
Ratan Gupta00659052017-02-23 17:29:08 +0530145}},
146 % endif
147% endfor
148};
149
Patrick Venturedb0cbe62019-09-09 14:47:22 -0700150} // namespace sensor
151} // namespace ipmi