blob: 5cc024eae56bef590038d2447a134f418f427645 [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():
54 for offset,values in property_value.items():
55 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}",{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050069 % for offset,values in property_value.items():
Ratan Gupta00659052017-02-23 17:29:08 +053070 { ${offset},{
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050071 % if offset == 0xFF:
72 }},
73<% continue %>\
74 % endif
75<% valueType = values["type"] %>\
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050076 % for name,value in values.items():
Ratan Gupta00659052017-02-23 17:29:08 +053077 % if name == "type":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050078<% continue %>\
Ratan Gupta00659052017-02-23 17:29:08 +053079 % endif
80 % if valueType == "string":
81 std::string("${value}"),
Ratan Guptaca4c4462017-03-16 00:00:06 +053082 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050083<% value = str(value).lower() %>\
Ratan Guptaca4c4462017-03-16 00:00:06 +053084 ${value},
Ratan Gupta00659052017-02-23 17:29:08 +053085 % else:
86 ${value},
87 % endif
88 % endfor
89 }
90 },
91 % endfor
92 }},
93 % endfor
94 }},
95 % endfor
Emily Shaffercc941e12017-06-14 13:06:26 -070096 },
Ratan Gupta00659052017-02-23 17:29:08 +053097}},
98 % endif
99% endfor
100};
101