blob: 8b26805224dd82244fe6eb9f54393f6e0a172ef4 [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 = {}
Jeremy Kerrbe4ffa82020-08-10 16:17:37 +08006sensorNameMaxLength = 16
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -05007%>\
Tom Joseph31eed5c2020-03-23 20:56:47 +05308%for key in sensorDict.keys():
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -05009<%
10 sensor = sensorDict[key]
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050011 serviceInterface = sensor["serviceInterface"]
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050012 if serviceInterface == "org.freedesktop.DBus.Properties":
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050013 updateFunc = "set::"
Tom Joseph9f9a9a42017-09-07 01:17:28 +053014 getFunc = "get::"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050015 elif serviceInterface == "xyz.openbmc_project.Inventory.Manager":
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050016 updateFunc = "notify::"
Tom Joseph9f9a9a42017-09-07 01:17:28 +053017 getFunc = "inventory::get::"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050018 else:
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050019 assert "Un-supported interface: " + serviceInterface
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050020 endif
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050021 if serviceInterface not in interfaceDict:
22 interfaceDict[serviceInterface] = {}
23 interfaceDict[serviceInterface]["updateFunc"] = updateFunc
Tom Joseph9f9a9a42017-09-07 01:17:28 +053024 interfaceDict[serviceInterface]["getFunc"] = getFunc
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050025%>\
26% endfor
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050027
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050028#include "sensordatahandler.hpp"
Ratan Gupta00659052017-02-23 17:29:08 +053029
Vernon Mauery33250242019-03-12 16:49:26 -070030#include <ipmid/types.hpp>
Patrick Venturedb0cbe62019-09-09 14:47:22 -070031
32namespace ipmi {
33namespace sensor {
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050034
Ratan Gupta00659052017-02-23 17:29:08 +053035extern const IdInfoMap sensors = {
Tom Joseph31eed5c2020-03-23 20:56:47 +053036% for key in sensorDict.keys():
Ratan Gupta00659052017-02-23 17:29:08 +053037 % if key:
38{${key},{
39<%
40 sensor = sensorDict[key]
41 interfaces = sensor["interfaces"]
42 path = sensor["path"]
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050043 serviceInterface = sensor["serviceInterface"]
Ratan Gupta00659052017-02-23 17:29:08 +053044 sensorType = sensor["sensorType"]
Tom Joseph31ff6e62018-01-24 16:10:09 +053045 entityID = sensor.get("entityID", 0)
46 instance = sensor.get("entityInstance", 0)
Ratan Gupta00659052017-02-23 17:29:08 +053047 readingType = sensor["sensorReadingType"]
Emily Shaffer10f49592017-05-10 12:01:10 -070048 multiplier = sensor.get("multiplierM", 1)
Tom Josephb673ff62017-09-07 15:28:32 +053049 offsetB = sensor.get("offsetB", 0)
Kirill Pakhomov4d1a5dd2018-10-10 17:06:41 +030050 bExp = sensor.get("bExp", 0)
Tom Joseph0a1301c2018-02-16 08:27:00 +053051 rExp = sensor.get("rExp", 0)
Emily Shaffer62235612017-06-14 13:06:26 -070052 unit = sensor.get("unit", "")
53 scale = sensor.get("scale", 0)
54 hasScale = "true" if "scale" in sensor.keys() else "false"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050055 valueReadingType = sensor["readingType"]
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050056 updateFunc = interfaceDict[serviceInterface]["updateFunc"]
57 updateFunc += sensor["readingType"]
Tom Joseph9f9a9a42017-09-07 01:17:28 +053058 getFunc = interfaceDict[serviceInterface]["getFunc"]
59 getFunc += sensor["readingType"]
Jeremy Kerrbe4ffa82020-08-10 16:17:37 +080060 sensorName = sensor.get("sensorName", None)
61 if sensorName:
62 assert len(sensorName) <= sensorNameMaxLength, \
63 "sensor name '%s' is too long (%d bytes max)" % \
64 (sensorName, sensorNameMaxLength)
65 else:
66 sensorNameFunc = "get::" + sensor.get("sensorNamePattern",
67 "nameLeaf")
68
Tom Joseph580af362017-09-07 15:38:40 +053069 if "readingAssertion" == valueReadingType or "readingData" == valueReadingType:
70 for interface,properties in interfaces.items():
71 for dbus_property,property_value in properties.items():
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050072 for offset,values in property_value["Offsets"].items():
Tom Joseph580af362017-09-07 15:38:40 +053073 valueType = values["type"]
74 updateFunc = "set::" + valueReadingType + "<" + valueType + ">"
75 getFunc = "get::" + valueReadingType + "<" + valueType + ">"
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050076 sensorInterface = serviceInterface
77 if serviceInterface == "org.freedesktop.DBus.Properties":
78 sensorInterface = next(iter(interfaces))
Emily Shaffercc941e12017-06-14 13:06:26 -070079 mutability = sensor.get("mutability", "Mutability::Read")
Ratan Gupta00659052017-02-23 17:29:08 +053080%>
Jeremy Kerr8deea352020-08-10 15:22:59 +080081 .entityType = ${entityID},
82 .instance = ${instance},
83 .sensorType = ${sensorType},
84 .sensorPath = "${path}",
85 .sensorInterface = "${sensorInterface}",
86 .sensorReadingType = ${readingType},
87 .coefficientM = ${multiplier},
88 .coefficientB = ${offsetB},
89 .exponentB = ${bExp},
90 .scaledOffset = ${offsetB * pow(10,bExp)},
91 .exponentR = ${rExp},
92 .hasScale = ${hasScale},
93 .scale = ${scale},
94 .unit = "${unit}",
95 .updateFunc = ${updateFunc},
96 .getFunc = ${getFunc},
97 .mutability = Mutability(${mutability}),
Jeremy Kerrbe4ffa82020-08-10 16:17:37 +080098 % if sensorName:
99 .sensorName = "${sensorName}",
100 % else:
Jeremy Kerr8deea352020-08-10 15:22:59 +0800101 .sensorNameFunc = ${sensorNameFunc},
Jeremy Kerrbe4ffa82020-08-10 16:17:37 +0800102 % endif
Jeremy Kerr8deea352020-08-10 15:22:59 +0800103 .propertyInterfaces = {
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500104 % for interface,properties in interfaces.items():
Ratan Gupta00659052017-02-23 17:29:08 +0530105 {"${interface}",{
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530106 % if properties:
107 % for dbus_property,property_value in properties.items():
108 {"${dbus_property}",{
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500109<%
110try:
111 preReq = property_value["Prereqs"]
Tom Joseph31eed5c2020-03-23 20:56:47 +0530112except KeyError:
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500113 preReq = dict()
114%>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530115 {
116 % for preOffset,preValues in preReq.items():
117 { ${preOffset},{
118 % for name,value in preValues.items():
119 % if name == "type":
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500120<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530121 % endif
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500122<% value = str(value).lower() %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530123 ${value},
124 % endfor
125 }
126 },
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500127 % endfor
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500128 },
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530129 {
130 % for offset,values in property_value["Offsets"].items():
131 { ${offset},{
132 % if offset == 0xFF:
133 }},
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500134<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530135 % endif
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500136<% valueType = values["type"] %>\
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500137<%
138try:
139 skip = values["skipOn"]
140 if skip == "assert":
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530141 skipVal = "SkipAssertion::ASSERT"
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500142 elif skip == "deassert":
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530143 skipVal = "SkipAssertion::DEASSERT"
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500144 else:
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530145 assert "Unknown skip value " + str(skip)
Tom Joseph31eed5c2020-03-23 20:56:47 +0530146except KeyError:
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500147 skipVal = "SkipAssertion::NONE"
148%>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530149 ${skipVal},
150 % for name,value in values.items():
151 % if name == "type" or name == "skipOn":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500152<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530153 % endif
154 % if valueType == "string":
155 std::string("${value}"),
156 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500157<% value = str(value).lower() %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530158 ${value},
159 % else:
160 ${value},
161 % endif
162 % endfor
163 }
164 },
165 % endfor
166 }}},
Ratan Gupta00659052017-02-23 17:29:08 +0530167 % endfor
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530168 % endif
Ratan Gupta00659052017-02-23 17:29:08 +0530169 }},
170 % endfor
Emily Shaffer62235612017-06-14 13:06:26 -0700171 },
Ratan Gupta00659052017-02-23 17:29:08 +0530172}},
173 % endif
174% endfor
175};
176
Patrick Venturedb0cbe62019-09-09 14:47:22 -0700177} // namespace sensor
178} // namespace ipmi