blob: e4609ab92df2fec94f424b2a0a8d5b894ab7c908 [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
51%endif
52% endfor
53
Ratan Gupta00659052017-02-23 17:29:08 +053054extern const IdInfoMap sensors = {
55% for key in sensorDict.iterkeys():
56 % if key:
57{${key},{
58<%
59 sensor = sensorDict[key]
60 interfaces = sensor["interfaces"]
61 path = sensor["path"]
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050062 serviceInterface = sensor["serviceInterface"]
Ratan Gupta00659052017-02-23 17:29:08 +053063 sensorType = sensor["sensorType"]
64 readingType = sensor["sensorReadingType"]
Emily Shaffer10f49592017-05-10 12:01:10 -070065 multiplier = sensor.get("multiplierM", 1)
66 offset = sensor.get("offsetB", 0)
67 exp = sensor.get("bExp", 0)
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050068 valueReadingType = sensor["readingType"]
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050069 updateFunc = interfaceDict[serviceInterface]["updateFunc"]
70 updateFunc += sensor["readingType"]
71 if "readingAssertion" == valueReadingType:
72 updateFunc = "sensor_" + str(key) + "::" + valueReadingType
73 sensorInterface = serviceInterface
74 if serviceInterface == "org.freedesktop.DBus.Properties":
75 sensorInterface = next(iter(interfaces))
Ratan Gupta00659052017-02-23 17:29:08 +053076%>
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050077 ${sensorType},"${path}","${sensorInterface}",${readingType},${multiplier},
78 ${offset},${exp},${offset * pow(10,exp)},${updateFunc},{
79 % for interface,properties in interfaces.items():
Ratan Gupta00659052017-02-23 17:29:08 +053080 {"${interface}",{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050081 % for dbus_property,property_value in properties.items():
Ratan Gupta00659052017-02-23 17:29:08 +053082 {"${dbus_property}",{
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050083 % for offset,values in property_value.items():
Ratan Gupta00659052017-02-23 17:29:08 +053084 { ${offset},{
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050085 % if offset == 0xFF:
86 }},
87<% continue %>\
88 % endif
89<% valueType = values["type"] %>\
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050090 % for name,value in values.items():
Ratan Gupta00659052017-02-23 17:29:08 +053091 % if name == "type":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050092<% continue %>\
Ratan Gupta00659052017-02-23 17:29:08 +053093 % endif
94 % if valueType == "string":
95 std::string("${value}"),
Ratan Guptaca4c4462017-03-16 00:00:06 +053096 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050097<% value = str(value).lower() %>\
Ratan Guptaca4c4462017-03-16 00:00:06 +053098 ${value},
Ratan Gupta00659052017-02-23 17:29:08 +053099 % else:
100 ${value},
101 % endif
102 % endfor
103 }
104 },
105 % endfor
106 }},
107 % endfor
108 }},
109 % endfor
110 }
111}},
112 % endif
113% endfor
114};
115