blob: 9cd4e48257c5132d5a1aa0a5f1e194b34f45ce2a [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"] %>\
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -050076<%
77try:
78 skip = values["skipOn"]
79 if skip == "assert":
80 skipVal = "SkipAssertion::ASSERT"
81 elif skip == "deassert":
82 skipVal = "SkipAssertion::DEASSERT"
83 else:
84 assert "Unknown skip value " + str(skip)
85except KeyError, e:
86 skipVal = "SkipAssertion::NONE"
87%>\
88 ${skipVal},
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050089 % for name,value in values.items():
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -050090 % if name == "type" or name == "skipOn":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050091<% continue %>\
Ratan Gupta00659052017-02-23 17:29:08 +053092 % endif
93 % if valueType == "string":
94 std::string("${value}"),
Ratan Guptaca4c4462017-03-16 00:00:06 +053095 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050096<% value = str(value).lower() %>\
Ratan Guptaca4c4462017-03-16 00:00:06 +053097 ${value},
Ratan Gupta00659052017-02-23 17:29:08 +053098 % else:
99 ${value},
100 % endif
101 % endfor
102 }
103 },
104 % endfor
105 }},
106 % endfor
107 }},
108 % endfor
Emily Shaffercc941e12017-06-14 13:06:26 -0700109 },
Ratan Gupta00659052017-02-23 17:29:08 +0530110}},
111 % endif
112% endfor
113};
114