blob: 4644ff75e768598e5febd710e43d5b8e86fcf1e9 [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
Ratan Gupta00659052017-02-23 17:29:08 +053027#include "types.hpp"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050028#include "sensordatahandler.hpp"
Ratan Gupta00659052017-02-23 17:29:08 +053029
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050030using namespace ipmi::sensor;
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050031
Ratan Gupta00659052017-02-23 17:29:08 +053032extern const IdInfoMap sensors = {
33% for key in sensorDict.iterkeys():
34 % if key:
35{${key},{
36<%
37 sensor = sensorDict[key]
38 interfaces = sensor["interfaces"]
39 path = sensor["path"]
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050040 serviceInterface = sensor["serviceInterface"]
Ratan Gupta00659052017-02-23 17:29:08 +053041 sensorType = sensor["sensorType"]
Tom Joseph31ff6e62018-01-24 16:10:09 +053042 entityID = sensor.get("entityID", 0)
43 instance = sensor.get("entityInstance", 0)
Ratan Gupta00659052017-02-23 17:29:08 +053044 readingType = sensor["sensorReadingType"]
Emily Shaffer10f49592017-05-10 12:01:10 -070045 multiplier = sensor.get("multiplierM", 1)
Tom Josephb673ff62017-09-07 15:28:32 +053046 offsetB = sensor.get("offsetB", 0)
Emily Shaffer10f49592017-05-10 12:01:10 -070047 exp = sensor.get("bExp", 0)
Emily Shaffer62235612017-06-14 13:06:26 -070048 unit = sensor.get("unit", "")
49 scale = sensor.get("scale", 0)
50 hasScale = "true" if "scale" in sensor.keys() else "false"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050051 valueReadingType = sensor["readingType"]
Tom Joseph31ff6e62018-01-24 16:10:09 +053052 sensorNamePattern = sensor.get("sensorNamePattern", "nameLeaf")
53 sensorNameFunc = "get::" + sensorNamePattern
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050054 updateFunc = interfaceDict[serviceInterface]["updateFunc"]
55 updateFunc += sensor["readingType"]
Tom Joseph9f9a9a42017-09-07 01:17:28 +053056 getFunc = interfaceDict[serviceInterface]["getFunc"]
57 getFunc += sensor["readingType"]
Tom Joseph580af362017-09-07 15:38:40 +053058 if "readingAssertion" == valueReadingType or "readingData" == valueReadingType:
59 for interface,properties in interfaces.items():
60 for dbus_property,property_value in properties.items():
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050061 for offset,values in property_value["Offsets"].items():
Tom Joseph580af362017-09-07 15:38:40 +053062 valueType = values["type"]
63 updateFunc = "set::" + valueReadingType + "<" + valueType + ">"
64 getFunc = "get::" + valueReadingType + "<" + valueType + ">"
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050065 sensorInterface = serviceInterface
66 if serviceInterface == "org.freedesktop.DBus.Properties":
67 sensorInterface = next(iter(interfaces))
Emily Shaffercc941e12017-06-14 13:06:26 -070068 mutability = sensor.get("mutability", "Mutability::Read")
Ratan Gupta00659052017-02-23 17:29:08 +053069%>
Tom Joseph31ff6e62018-01-24 16:10:09 +053070 ${entityID},${instance},${sensorType},"${path}","${sensorInterface}",
71 ${readingType},${multiplier}, ${offsetB},${exp},
72 ${offsetB * pow(10,exp)}, ${hasScale},${scale},"${unit}",
73 ${updateFunc},${getFunc},Mutability(${mutability}),${sensorNameFunc},{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050074 % for interface,properties in interfaces.items():
Ratan Gupta00659052017-02-23 17:29:08 +053075 {"${interface}",{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050076 % for dbus_property,property_value in properties.items():
Ratan Gupta00659052017-02-23 17:29:08 +053077 {"${dbus_property}",{
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050078<%
79try:
80 preReq = property_value["Prereqs"]
81except KeyError, e:
82 preReq = dict()
83%>\
84 {
85 % for preOffset,preValues in preReq.items():
86 { ${preOffset},{
87 % for name,value in preValues.items():
88 % if name == "type":
89<% continue %>\
90 % endif
91<% value = str(value).lower() %>\
92 ${value},
93 % endfor
94 }
95 },
96 % endfor
97 },
98 {
99 % for offset,values in property_value["Offsets"].items():
Ratan Gupta00659052017-02-23 17:29:08 +0530100 { ${offset},{
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500101 % if offset == 0xFF:
102 }},
103<% continue %>\
104 % endif
105<% valueType = values["type"] %>\
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500106<%
107try:
108 skip = values["skipOn"]
109 if skip == "assert":
110 skipVal = "SkipAssertion::ASSERT"
111 elif skip == "deassert":
112 skipVal = "SkipAssertion::DEASSERT"
113 else:
114 assert "Unknown skip value " + str(skip)
115except KeyError, e:
116 skipVal = "SkipAssertion::NONE"
117%>\
118 ${skipVal},
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500119 % for name,value in values.items():
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500120 % if name == "type" or name == "skipOn":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500121<% continue %>\
Ratan Gupta00659052017-02-23 17:29:08 +0530122 % endif
123 % if valueType == "string":
124 std::string("${value}"),
Ratan Guptaca4c4462017-03-16 00:00:06 +0530125 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500126<% value = str(value).lower() %>\
Ratan Guptaca4c4462017-03-16 00:00:06 +0530127 ${value},
Ratan Gupta00659052017-02-23 17:29:08 +0530128 % else:
129 ${value},
130 % endif
131 % endfor
132 }
133 },
134 % endfor
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500135 }}},
Ratan Gupta00659052017-02-23 17:29:08 +0530136 % endfor
137 }},
138 % endfor
Emily Shaffer62235612017-06-14 13:06:26 -0700139 },
Ratan Gupta00659052017-02-23 17:29:08 +0530140}},
141 % endif
142% endfor
143};
144