Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 1 | ## 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 Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 5 | <% |
| 6 | from collections import defaultdict |
| 7 | readingTypes = { 'reading': 'cmdData.reading', |
Dhruvaraj Subhashchandran | 18e9999 | 2017-08-09 09:10:47 -0500 | [diff] [blame] | 8 | 'assertion': '((cmdData.assertOffset8_14 << 8)|cmdData.assertOffset0_7)', |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 9 | 'eventdata1': 'cmdData.eventData1', |
| 10 | 'eventdata2': 'cmdData.eventData2', |
| 11 | 'eventdata3': 'cmdData.eventData3'} |
| 12 | funcProps = {} |
| 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 Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 44 | #include "types.hpp" |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 45 | #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 Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 50 | |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 51 | namespace ipmi |
| 52 | { |
| 53 | namespace sensor |
| 54 | { |
| 55 | |
| 56 | |
| 57 | namespace sensor_set |
| 58 | { |
| 59 | % for sensorType, funcProp in funcProps.iteritems(): |
| 60 | namespace sensor_type_${sensorType} |
| 61 | { |
| 62 | |
| 63 | ipmi_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 | |
| 105 | using namespace ipmi::sensor; |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 106 | extern 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 Shaffer | 10f4959 | 2017-05-10 12:01:10 -0700 | [diff] [blame] | 116 | multiplier = sensor.get("multiplierM", 1) |
| 117 | offset = sensor.get("offsetB", 0) |
| 118 | exp = sensor.get("bExp", 0) |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 119 | valueReadingType = sensor["readingType"] |
| 120 | updateFunc = funcProps[sensorType]["updateFunc"] |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 121 | %> |
Emily Shaffer | 10f4959 | 2017-05-10 12:01:10 -0700 | [diff] [blame] | 122 | ${sensorType},"${path}",${readingType},${multiplier},${offset},${exp}, |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 123 | ${offset * pow(10,exp)},${updateFunc},{ |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 124 | % 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 Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 130 | % if offset == 0xFF: |
| 131 | }}, |
| 132 | <% continue %>\ |
| 133 | % endif |
| 134 | <% valueType = values["type"] %>\ |
| 135 | % for name,value in values.iteritems(): |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 136 | % if name == "type": |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 137 | <% continue %>\ |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 138 | % endif |
| 139 | % if valueType == "string": |
| 140 | std::string("${value}"), |
Ratan Gupta | ca4c446 | 2017-03-16 00:00:06 +0530 | [diff] [blame] | 141 | % elif valueType == "bool": |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 142 | <% value = str(value).lower() %>\ |
Ratan Gupta | ca4c446 | 2017-03-16 00:00:06 +0530 | [diff] [blame] | 143 | ${value}, |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 144 | % 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 | |