blob: 813f9404b5e8cb403f33d686bc75233faecdc937 [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)
Tony Leec5324252019-10-31 17:24:16 +080052 sensorUnits1 = sensor.get("sensorUnits1", 0)
Emily Shaffer62235612017-06-14 13:06:26 -070053 unit = sensor.get("unit", "")
54 scale = sensor.get("scale", 0)
55 hasScale = "true" if "scale" in sensor.keys() else "false"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050056 valueReadingType = sensor["readingType"]
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"]
Jeremy Kerrbe4ffa82020-08-10 16:17:37 +080061 sensorName = sensor.get("sensorName", None)
62 if sensorName:
63 assert len(sensorName) <= sensorNameMaxLength, \
64 "sensor name '%s' is too long (%d bytes max)" % \
65 (sensorName, sensorNameMaxLength)
66 else:
67 sensorNameFunc = "get::" + sensor.get("sensorNamePattern",
68 "nameLeaf")
69
Tom Joseph580af362017-09-07 15:38:40 +053070 if "readingAssertion" == valueReadingType or "readingData" == valueReadingType:
71 for interface,properties in interfaces.items():
72 for dbus_property,property_value in properties.items():
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050073 for offset,values in property_value["Offsets"].items():
Tom Joseph580af362017-09-07 15:38:40 +053074 valueType = values["type"]
75 updateFunc = "set::" + valueReadingType + "<" + valueType + ">"
76 getFunc = "get::" + valueReadingType + "<" + valueType + ">"
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050077 sensorInterface = serviceInterface
78 if serviceInterface == "org.freedesktop.DBus.Properties":
79 sensorInterface = next(iter(interfaces))
Emily Shaffercc941e12017-06-14 13:06:26 -070080 mutability = sensor.get("mutability", "Mutability::Read")
Ratan Gupta00659052017-02-23 17:29:08 +053081%>
Jeremy Kerr8deea352020-08-10 15:22:59 +080082 .entityType = ${entityID},
83 .instance = ${instance},
84 .sensorType = ${sensorType},
85 .sensorPath = "${path}",
86 .sensorInterface = "${sensorInterface}",
87 .sensorReadingType = ${readingType},
88 .coefficientM = ${multiplier},
89 .coefficientB = ${offsetB},
90 .exponentB = ${bExp},
91 .scaledOffset = ${offsetB * pow(10,bExp)},
92 .exponentR = ${rExp},
93 .hasScale = ${hasScale},
94 .scale = ${scale},
Tony Leec5324252019-10-31 17:24:16 +080095 .sensorUnits1 = ${sensorUnits1},
Jeremy Kerr8deea352020-08-10 15:22:59 +080096 .unit = "${unit}",
97 .updateFunc = ${updateFunc},
98 .getFunc = ${getFunc},
99 .mutability = Mutability(${mutability}),
Jeremy Kerrbe4ffa82020-08-10 16:17:37 +0800100 % if sensorName:
101 .sensorName = "${sensorName}",
102 % else:
Jeremy Kerr8deea352020-08-10 15:22:59 +0800103 .sensorNameFunc = ${sensorNameFunc},
Jeremy Kerrbe4ffa82020-08-10 16:17:37 +0800104 % endif
Jeremy Kerr8deea352020-08-10 15:22:59 +0800105 .propertyInterfaces = {
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500106 % for interface,properties in interfaces.items():
Ratan Gupta00659052017-02-23 17:29:08 +0530107 {"${interface}",{
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530108 % if properties:
109 % for dbus_property,property_value in properties.items():
110 {"${dbus_property}",{
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500111<%
112try:
113 preReq = property_value["Prereqs"]
Tom Joseph31eed5c2020-03-23 20:56:47 +0530114except KeyError:
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500115 preReq = dict()
116%>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530117 {
118 % for preOffset,preValues in preReq.items():
119 { ${preOffset},{
120 % for name,value in preValues.items():
121 % if name == "type":
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500122<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530123 % endif
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500124<% value = str(value).lower() %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530125 ${value},
126 % endfor
127 }
128 },
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500129 % endfor
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500130 },
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530131 {
132 % for offset,values in property_value["Offsets"].items():
133 { ${offset},{
134 % if offset == 0xFF:
135 }},
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500136<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530137 % endif
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500138<% valueType = values["type"] %>\
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500139<%
140try:
141 skip = values["skipOn"]
142 if skip == "assert":
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530143 skipVal = "SkipAssertion::ASSERT"
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500144 elif skip == "deassert":
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530145 skipVal = "SkipAssertion::DEASSERT"
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500146 else:
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530147 assert "Unknown skip value " + str(skip)
Tom Joseph31eed5c2020-03-23 20:56:47 +0530148except KeyError:
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500149 skipVal = "SkipAssertion::NONE"
150%>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530151 ${skipVal},
152 % for name,value in values.items():
153 % if name == "type" or name == "skipOn":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500154<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530155 % endif
156 % if valueType == "string":
157 std::string("${value}"),
158 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500159<% value = str(value).lower() %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530160 ${value},
161 % else:
162 ${value},
163 % endif
164 % endfor
165 }
166 },
167 % endfor
168 }}},
Ratan Gupta00659052017-02-23 17:29:08 +0530169 % endfor
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530170 % endif
Ratan Gupta00659052017-02-23 17:29:08 +0530171 }},
172 % endfor
Emily Shaffer62235612017-06-14 13:06:26 -0700173 },
Ratan Gupta00659052017-02-23 17:29:08 +0530174}},
175 % endif
176% endfor
177};
178
Patrick Venturedb0cbe62019-09-09 14:47:22 -0700179} // namespace sensor
180} // namespace ipmi