blob: 7123c37f5172505b1d2cd19765d5e869f10edf3a [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
Jian Zhanga23af122022-08-15 15:17:18 +080035extern const IdInfoMap __attribute__((init_priority(101))) 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}",
Willy Tu11d68892022-01-20 10:37:34 -0800102 .sensorNameFunc = nullptr,
Jeremy Kerrbe4ffa82020-08-10 16:17:37 +0800103 % else:
Willy Tu11d68892022-01-20 10:37:34 -0800104 .sensorName = "",
Jeremy Kerr8deea352020-08-10 15:22:59 +0800105 .sensorNameFunc = ${sensorNameFunc},
Jeremy Kerrbe4ffa82020-08-10 16:17:37 +0800106 % endif
Jeremy Kerr8deea352020-08-10 15:22:59 +0800107 .propertyInterfaces = {
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500108 % for interface,properties in interfaces.items():
Ratan Gupta00659052017-02-23 17:29:08 +0530109 {"${interface}",{
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530110 % if properties:
111 % for dbus_property,property_value in properties.items():
112 {"${dbus_property}",{
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500113<%
114try:
115 preReq = property_value["Prereqs"]
Tom Joseph31eed5c2020-03-23 20:56:47 +0530116except KeyError:
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500117 preReq = dict()
118%>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530119 {
120 % for preOffset,preValues in preReq.items():
121 { ${preOffset},{
122 % for name,value in preValues.items():
123 % if name == "type":
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500124<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530125 % endif
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500126<% value = str(value).lower() %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530127 ${value},
128 % endfor
129 }
130 },
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500131 % endfor
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500132 },
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530133 {
134 % for offset,values in property_value["Offsets"].items():
135 { ${offset},{
136 % if offset == 0xFF:
137 }},
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500138<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530139 % endif
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500140<% valueType = values["type"] %>\
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500141<%
142try:
143 skip = values["skipOn"]
144 if skip == "assert":
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530145 skipVal = "SkipAssertion::ASSERT"
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500146 elif skip == "deassert":
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530147 skipVal = "SkipAssertion::DEASSERT"
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500148 else:
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530149 assert "Unknown skip value " + str(skip)
Tom Joseph31eed5c2020-03-23 20:56:47 +0530150except KeyError:
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500151 skipVal = "SkipAssertion::NONE"
152%>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530153 ${skipVal},
154 % for name,value in values.items():
155 % if name == "type" or name == "skipOn":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500156<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530157 % endif
158 % if valueType == "string":
159 std::string("${value}"),
160 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500161<% value = str(value).lower() %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530162 ${value},
163 % else:
164 ${value},
165 % endif
166 % endfor
167 }
168 },
169 % endfor
170 }}},
Ratan Gupta00659052017-02-23 17:29:08 +0530171 % endfor
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530172 % endif
Ratan Gupta00659052017-02-23 17:29:08 +0530173 }},
174 % endfor
Emily Shaffer62235612017-06-14 13:06:26 -0700175 },
Ratan Gupta00659052017-02-23 17:29:08 +0530176}},
177 % endif
178% endfor
179};
180
Patrick Venturedb0cbe62019-09-09 14:47:22 -0700181} // namespace sensor
182} // namespace ipmi