blob: 5b1ffd79056ad37d489cabc7deb8dc24f0dcb642 [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::"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050013 elif serviceInterface == "xyz.openbmc_project.Inventory.Manager":
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050014 updateFunc = "notify::"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050015 else:
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050016 assert "Un-supported interface: " + serviceInterface
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050017 endif
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050018 if serviceInterface not in interfaceDict:
19 interfaceDict[serviceInterface] = {}
20 interfaceDict[serviceInterface]["updateFunc"] = updateFunc
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050021%>\
22% endfor
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050023
Ratan Gupta00659052017-02-23 17:29:08 +053024#include "types.hpp"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050025#include "sensordatahandler.hpp"
Ratan Gupta00659052017-02-23 17:29:08 +053026
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050027using namespace ipmi::sensor;
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050028
29%for key in sensorDict.iterkeys():
30<%
31 sensor = sensorDict[key]
32 readingType = sensor["readingType"]
33 interfaces = sensor["interfaces"]
34 for interface, properties in interfaces.items():
35 for property, values in properties.items():
36 for offset, attributes in values.items():
37 type = attributes["type"]
38%>\
39%if "readingAssertion" == readingType:
40namespace sensor_${key}
41{
42
43inline ipmi_ret_t readingAssertion(const SetSensorReadingReq& cmdData,
44 const Info& sensorInfo)
45{
46 return set::readingAssertion<${type}>(cmdData, sensorInfo);
47}
48
49} // namespace sensor_${key}
50
Emily Shaffercc941e12017-06-14 13:06:26 -070051%elif "readingData" == readingType:
52
53namespace sensor_${key}
54{
55
56inline ipmi_ret_t readingData(const SetSensorReadingReq& cmdData,
57 const Info& sensorInfo)
58{
59 return set::readingData<${type}>(cmdData, sensorInfo);
60}
61
62} // namespace sensor_${key}
63
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050064%endif
65% endfor
66
Ratan Gupta00659052017-02-23 17:29:08 +053067extern const IdInfoMap sensors = {
68% for key in sensorDict.iterkeys():
69 % if key:
70{${key},{
71<%
72 sensor = sensorDict[key]
73 interfaces = sensor["interfaces"]
74 path = sensor["path"]
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050075 serviceInterface = sensor["serviceInterface"]
Ratan Gupta00659052017-02-23 17:29:08 +053076 sensorType = sensor["sensorType"]
77 readingType = sensor["sensorReadingType"]
Emily Shaffer10f49592017-05-10 12:01:10 -070078 multiplier = sensor.get("multiplierM", 1)
79 offset = sensor.get("offsetB", 0)
80 exp = sensor.get("bExp", 0)
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050081 valueReadingType = sensor["readingType"]
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050082 updateFunc = interfaceDict[serviceInterface]["updateFunc"]
83 updateFunc += sensor["readingType"]
84 if "readingAssertion" == valueReadingType:
85 updateFunc = "sensor_" + str(key) + "::" + valueReadingType
Emily Shaffercc941e12017-06-14 13:06:26 -070086 elif "readingData" == valueReadingType:
87 updateFunc = "sensor_" + str(key) + "::" + valueReadingType
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050088 sensorInterface = serviceInterface
89 if serviceInterface == "org.freedesktop.DBus.Properties":
90 sensorInterface = next(iter(interfaces))
Emily Shaffercc941e12017-06-14 13:06:26 -070091 mutability = sensor.get("mutability", "Mutability::Read")
Ratan Gupta00659052017-02-23 17:29:08 +053092%>
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050093 ${sensorType},"${path}","${sensorInterface}",${readingType},${multiplier},
Emily Shaffercc941e12017-06-14 13:06:26 -070094 ${offset},${exp},${offset * pow(10,exp)},${updateFunc},Mutability(${mutability}),{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050095 % for interface,properties in interfaces.items():
Ratan Gupta00659052017-02-23 17:29:08 +053096 {"${interface}",{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050097 % for dbus_property,property_value in properties.items():
Ratan Gupta00659052017-02-23 17:29:08 +053098 {"${dbus_property}",{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050099 % for offset,values in property_value.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"] %>\
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500106 % for name,value in values.items():
Ratan Gupta00659052017-02-23 17:29:08 +0530107 % if name == "type":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500108<% continue %>\
Ratan Gupta00659052017-02-23 17:29:08 +0530109 % endif
110 % if valueType == "string":
111 std::string("${value}"),
Ratan Guptaca4c4462017-03-16 00:00:06 +0530112 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500113<% value = str(value).lower() %>\
Ratan Guptaca4c4462017-03-16 00:00:06 +0530114 ${value},
Ratan Gupta00659052017-02-23 17:29:08 +0530115 % else:
116 ${value},
117 % endif
118 % endfor
119 }
120 },
121 % endfor
122 }},
123 % endfor
124 }},
125 % endfor
Emily Shaffercc941e12017-06-14 13:06:26 -0700126 },
Ratan Gupta00659052017-02-23 17:29:08 +0530127}},
128 % endif
129% endfor
130};
131