blob: c5db13a0f47a3bb198ead3ee565d66bc9b1667ce [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"]
42 readingType = sensor["sensorReadingType"]
Emily Shaffer10f49592017-05-10 12:01:10 -070043 multiplier = sensor.get("multiplierM", 1)
Tom Josephb673ff62017-09-07 15:28:32 +053044 offsetB = sensor.get("offsetB", 0)
Emily Shaffer10f49592017-05-10 12:01:10 -070045 exp = sensor.get("bExp", 0)
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050046 valueReadingType = sensor["readingType"]
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050047 updateFunc = interfaceDict[serviceInterface]["updateFunc"]
48 updateFunc += sensor["readingType"]
Tom Joseph9f9a9a42017-09-07 01:17:28 +053049 getFunc = interfaceDict[serviceInterface]["getFunc"]
50 getFunc += sensor["readingType"]
Tom Joseph580af362017-09-07 15:38:40 +053051 if "readingAssertion" == valueReadingType or "readingData" == valueReadingType:
52 for interface,properties in interfaces.items():
53 for dbus_property,property_value in properties.items():
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050054 for offset,values in property_value["Offsets"].items():
Tom Joseph580af362017-09-07 15:38:40 +053055 valueType = values["type"]
56 updateFunc = "set::" + valueReadingType + "<" + valueType + ">"
57 getFunc = "get::" + valueReadingType + "<" + valueType + ">"
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050058 sensorInterface = serviceInterface
59 if serviceInterface == "org.freedesktop.DBus.Properties":
60 sensorInterface = next(iter(interfaces))
Emily Shaffercc941e12017-06-14 13:06:26 -070061 mutability = sensor.get("mutability", "Mutability::Read")
Ratan Gupta00659052017-02-23 17:29:08 +053062%>
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050063 ${sensorType},"${path}","${sensorInterface}",${readingType},${multiplier},
Tom Josephb673ff62017-09-07 15:28:32 +053064 ${offsetB},${exp},${offsetB * pow(10,exp)},${updateFunc},${getFunc},Mutability(${mutability}),{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050065 % for interface,properties in interfaces.items():
Ratan Gupta00659052017-02-23 17:29:08 +053066 {"${interface}",{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050067 % for dbus_property,property_value in properties.items():
Ratan Gupta00659052017-02-23 17:29:08 +053068 {"${dbus_property}",{
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -050069<%
70try:
71 preReq = property_value["Prereqs"]
72except KeyError, e:
73 preReq = dict()
74%>\
75 {
76 % for preOffset,preValues in preReq.items():
77 { ${preOffset},{
78 % for name,value in preValues.items():
79 % if name == "type":
80<% continue %>\
81 % endif
82<% value = str(value).lower() %>\
83 ${value},
84 % endfor
85 }
86 },
87 % endfor
88 },
89 {
90 % for offset,values in property_value["Offsets"].items():
Ratan Gupta00659052017-02-23 17:29:08 +053091 { ${offset},{
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050092 % if offset == 0xFF:
93 }},
94<% continue %>\
95 % endif
96<% valueType = values["type"] %>\
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -050097<%
98try:
99 skip = values["skipOn"]
100 if skip == "assert":
101 skipVal = "SkipAssertion::ASSERT"
102 elif skip == "deassert":
103 skipVal = "SkipAssertion::DEASSERT"
104 else:
105 assert "Unknown skip value " + str(skip)
106except KeyError, e:
107 skipVal = "SkipAssertion::NONE"
108%>\
109 ${skipVal},
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500110 % for name,value in values.items():
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500111 % if name == "type" or name == "skipOn":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500112<% continue %>\
Ratan Gupta00659052017-02-23 17:29:08 +0530113 % endif
114 % if valueType == "string":
115 std::string("${value}"),
Ratan Guptaca4c4462017-03-16 00:00:06 +0530116 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500117<% value = str(value).lower() %>\
Ratan Guptaca4c4462017-03-16 00:00:06 +0530118 ${value},
Ratan Gupta00659052017-02-23 17:29:08 +0530119 % else:
120 ${value},
121 % endif
122 % endfor
123 }
124 },
125 % endfor
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500126 }}},
Ratan Gupta00659052017-02-23 17:29:08 +0530127 % endfor
128 }},
129 % endfor
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500130 }
Ratan Gupta00659052017-02-23 17:29:08 +0530131}},
132 % endif
133% endfor
134};
135