blob: 435580106f4447ed131101636b6274e76e9d6508 [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.
3
4// !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!!
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -05005<%
6from collections import defaultdict
7readingTypes = { 'reading': 'cmdData.reading',
Dhruvaraj Subhashchandran18e99992017-08-09 09:10:47 -05008 'assertion': '((cmdData.assertOffset8_14 << 8)|cmdData.assertOffset0_7)',
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -05009 'eventdata1': 'cmdData.eventData1',
10 'eventdata2': 'cmdData.eventData2',
11 'eventdata3': 'cmdData.eventData3'}
12funcProps = {}
13%>\
14%for key in sensorDict.iterkeys():
15<%
16 sensor = sensorDict[key]
17 sensorType = sensor["sensorType"]
18 serviceInterface = sensor["serviceInterface"]
19 readingType = sensor["readingType"]
20 if serviceInterface == "org.freedesktop.DBus.Properties":
21 command = "Set"
22 elif serviceInterface == "xyz.openbmc_project.Inventory.Manager":
23 command = "Notify"
24 else:
25 assert "Un-supported interface: serviceInterface"
26 endif
27 sensorInterface = serviceInterface
28 updateFunc = "sensor_set::sensor_type_" + str(sensorType) + "::update"
29 funcProps[sensorType] = {}
30 funcProps[sensorType].update({"command" : command})
31 funcProps[sensorType].update({"path" : sensor["path"]})
32 funcProps[sensorType].update({"serviceInterface" : serviceInterface})
33 funcProps[sensorType].update({"updateFunc" : updateFunc})
34 funcProps[sensorType].update({"readingType" : readingType})
35 funcProps[sensorType].update({"source" : readingTypes[readingType]})
36 funcProps[sensorType].update({"interfaces" : sensor["interfaces"]})
37 if command == "Set":
38 for interface, props in funcProps[sensorType]["interfaces"].items():
39 sensorInterface = interface
40 funcProps[sensorType].update({"sensorInterface" : sensorInterface})
41%>\
42% endfor
43#include <bitset>
Ratan Gupta00659052017-02-23 17:29:08 +053044#include "types.hpp"
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050045#include "host-ipmid/ipmid-api.h"
46#include <phosphor-logging/elog-errors.hpp>
47#include "xyz/openbmc_project/Common/error.hpp"
48#include <phosphor-logging/log.hpp>
49#include "sensordatahandler.hpp"
Ratan Gupta00659052017-02-23 17:29:08 +053050
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050051namespace ipmi
52{
53namespace sensor
54{
55
56
57namespace sensor_set
58{
59% for sensorType, funcProp in funcProps.iteritems():
60namespace sensor_type_${sensorType}
61{
62
63ipmi_ret_t update(const SetSensorReadingReq& cmdData,
64 const Info& sensorInfo)
65{
66 auto msg = ${(funcProp["command"]).lower()}::makeDbusMsg(
67 "${funcProp['serviceInterface']}",
68 sensorInfo.sensorPath,
69 "${funcProp['command']}",
70 "${funcProp['sensorInterface']}");
71
72 auto interfaceList = sensorInfo.sensorInterfaces;
73% for interface, properties in funcProp["interfaces"].iteritems():
74 % for dbus_property, property_value in properties.iteritems():
75 % for offset, values in property_value.iteritems():
76 % if offset == 0xFF:
77<% funcName = "appendReadingData"%>\
78<% param = "static_cast<"+values["type"]+">("+funcProp["source"]+")"%>\
79 % elif funcProp["readingType"] == "assertion":
80<% funcName = "appendAssertion"%>\
81<% param = "sensorInfo.sensorPath, cmdData"%>\
82 % else:
83<% funcName = "appendDiscreteSignalData"%>\
84<% param = funcProp["source"]%>\
85 % endif
86 % endfor
87 % endfor
88% endfor
89 auto result = ${(funcProp["command"]).lower()}::${funcName}(msg,
90 interfaceList,
91 ${param});
92 if (result != IPMI_CC_OK)
93 {
94 return result;
95 }
96 return updateToDbus(msg);
97}
98}//namespace sensor_type_${sensorType}
99
100% endfor
101}//namespace sensor_get
102}//namespace sensor
103}//namespace ipmi
104
105using namespace ipmi::sensor;
Ratan Gupta00659052017-02-23 17:29:08 +0530106extern const IdInfoMap sensors = {
107% for key in sensorDict.iterkeys():
108 % if key:
109{${key},{
110<%
111 sensor = sensorDict[key]
112 interfaces = sensor["interfaces"]
113 path = sensor["path"]
114 sensorType = sensor["sensorType"]
115 readingType = sensor["sensorReadingType"]
Emily Shaffer10f49592017-05-10 12:01:10 -0700116 multiplier = sensor.get("multiplierM", 1)
117 offset = sensor.get("offsetB", 0)
118 exp = sensor.get("bExp", 0)
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500119 valueReadingType = sensor["readingType"]
120 updateFunc = funcProps[sensorType]["updateFunc"]
Ratan Gupta00659052017-02-23 17:29:08 +0530121%>
Emily Shaffer10f49592017-05-10 12:01:10 -0700122 ${sensorType},"${path}",${readingType},${multiplier},${offset},${exp},
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500123 ${offset * pow(10,exp)},${updateFunc},{
Ratan Gupta00659052017-02-23 17:29:08 +0530124 % for interface,properties in interfaces.iteritems():
125 {"${interface}",{
126 % for dbus_property,property_value in properties.iteritems():
127 {"${dbus_property}",{
128 % for offset,values in property_value.iteritems():
129 { ${offset},{
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500130 % if offset == 0xFF:
131 }},
132<% continue %>\
133 % endif
134<% valueType = values["type"] %>\
135 % for name,value in values.iteritems():
Ratan Gupta00659052017-02-23 17:29:08 +0530136 % if name == "type":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500137<% continue %>\
Ratan Gupta00659052017-02-23 17:29:08 +0530138 % endif
139 % if valueType == "string":
140 std::string("${value}"),
Ratan Guptaca4c4462017-03-16 00:00:06 +0530141 % elif valueType == "bool":
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500142<% value = str(value).lower() %>\
Ratan Guptaca4c4462017-03-16 00:00:06 +0530143 ${value},
Ratan Gupta00659052017-02-23 17:29:08 +0530144 % else:
145 ${value},
146 % endif
147 % endfor
148 }
149 },
150 % endfor
151 }},
152 % endfor
153 }},
154 % endfor
155 }
156}},
157 % endif
158% endfor
159};
160