blob: 69a44f47272b91ec4448f9e406ad8eafbd7d2967 [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%>\
Tom Joseph31eed5c2020-03-23 20:56:47 +05307%for key in sensorDict.keys():
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -05008<%
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 = {
Tom Joseph31eed5c2020-03-23 20:56:47 +053035% for key in sensorDict.keys():
Ratan Gupta00659052017-02-23 17:29:08 +053036 % 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%>
Jeremy Kerr8deea352020-08-10 15:22:59 +080073 .entityType = ${entityID},
74 .instance = ${instance},
75 .sensorType = ${sensorType},
76 .sensorPath = "${path}",
77 .sensorInterface = "${sensorInterface}",
78 .sensorReadingType = ${readingType},
79 .coefficientM = ${multiplier},
80 .coefficientB = ${offsetB},
81 .exponentB = ${bExp},
82 .scaledOffset = ${offsetB * pow(10,bExp)},
83 .exponentR = ${rExp},
84 .hasScale = ${hasScale},
85 .scale = ${scale},
86 .unit = "${unit}",
87 .updateFunc = ${updateFunc},
88 .getFunc = ${getFunc},
89 .mutability = Mutability(${mutability}),
90 .sensorNameFunc = ${sensorNameFunc},
91 .propertyInterfaces = {
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050092 % for interface,properties in interfaces.items():
Ratan Gupta00659052017-02-23 17:29:08 +053093 {"${interface}",{
Santosh Puranikbbf8bd62019-05-01 19:02:52 +053094 % if properties:
95 % for dbus_property,property_value in properties.items():
96 {"${dbus_property}",{
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050097<%
98try:
99 preReq = property_value["Prereqs"]
Tom Joseph31eed5c2020-03-23 20:56:47 +0530100except KeyError:
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500101 preReq = dict()
102%>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530103 {
104 % for preOffset,preValues in preReq.items():
105 { ${preOffset},{
106 % for name,value in preValues.items():
107 % if name == "type":
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500108<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530109 % endif
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500110<% value = str(value).lower() %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530111 ${value},
112 % endfor
113 }
114 },
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500115 % endfor
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500116 },
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530117 {
118 % for offset,values in property_value["Offsets"].items():
119 { ${offset},{
120 % if offset == 0xFF:
121 }},
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500122<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530123 % endif
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500124<% valueType = values["type"] %>\
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500125<%
126try:
127 skip = values["skipOn"]
128 if skip == "assert":
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530129 skipVal = "SkipAssertion::ASSERT"
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500130 elif skip == "deassert":
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530131 skipVal = "SkipAssertion::DEASSERT"
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500132 else:
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530133 assert "Unknown skip value " + str(skip)
Tom Joseph31eed5c2020-03-23 20:56:47 +0530134except KeyError:
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500135 skipVal = "SkipAssertion::NONE"
136%>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530137 ${skipVal},
138 % for name,value in values.items():
139 % if name == "type" or name == "skipOn":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500140<% continue %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530141 % endif
142 % if valueType == "string":
143 std::string("${value}"),
144 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500145<% value = str(value).lower() %>\
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530146 ${value},
147 % else:
148 ${value},
149 % endif
150 % endfor
151 }
152 },
153 % endfor
154 }}},
Ratan Gupta00659052017-02-23 17:29:08 +0530155 % endfor
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530156 % endif
Ratan Gupta00659052017-02-23 17:29:08 +0530157 }},
158 % endfor
Emily Shaffer62235612017-06-14 13:06:26 -0700159 },
Ratan Gupta00659052017-02-23 17:29:08 +0530160}},
161 % endif
162% endfor
163};
164
Patrick Venturedb0cbe62019-09-09 14:47:22 -0700165} // namespace sensor
166} // namespace ipmi