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. |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 3 | // !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!! |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 4 | <% |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 5 | interfaceDict = {} |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 6 | %>\ |
| 7 | %for key in sensorDict.iterkeys(): |
| 8 | <% |
| 9 | sensor = sensorDict[key] |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 10 | serviceInterface = sensor["serviceInterface"] |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 11 | if serviceInterface == "org.freedesktop.DBus.Properties": |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 12 | updateFunc = "set::" |
Tom Joseph | 9f9a9a4 | 2017-09-07 01:17:28 +0530 | [diff] [blame] | 13 | getFunc = "get::" |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 14 | elif serviceInterface == "xyz.openbmc_project.Inventory.Manager": |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 15 | updateFunc = "notify::" |
Tom Joseph | 9f9a9a4 | 2017-09-07 01:17:28 +0530 | [diff] [blame] | 16 | getFunc = "inventory::get::" |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 17 | else: |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 18 | assert "Un-supported interface: " + serviceInterface |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 19 | endif |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 20 | if serviceInterface not in interfaceDict: |
| 21 | interfaceDict[serviceInterface] = {} |
| 22 | interfaceDict[serviceInterface]["updateFunc"] = updateFunc |
Tom Joseph | 9f9a9a4 | 2017-09-07 01:17:28 +0530 | [diff] [blame] | 23 | interfaceDict[serviceInterface]["getFunc"] = getFunc |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 24 | %>\ |
| 25 | % endfor |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 26 | |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 27 | #include "types.hpp" |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 28 | #include "sensordatahandler.hpp" |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 29 | |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 30 | using namespace ipmi::sensor; |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 31 | |
| 32 | %for key in sensorDict.iterkeys(): |
| 33 | <% |
| 34 | sensor = sensorDict[key] |
| 35 | readingType = sensor["readingType"] |
| 36 | interfaces = sensor["interfaces"] |
| 37 | for interface, properties in interfaces.items(): |
| 38 | for property, values in properties.items(): |
| 39 | for offset, attributes in values.items(): |
| 40 | type = attributes["type"] |
| 41 | %>\ |
| 42 | %if "readingAssertion" == readingType: |
| 43 | namespace sensor_${key} |
| 44 | { |
| 45 | |
| 46 | inline ipmi_ret_t readingAssertion(const SetSensorReadingReq& cmdData, |
| 47 | const Info& sensorInfo) |
| 48 | { |
| 49 | return set::readingAssertion<${type}>(cmdData, sensorInfo); |
| 50 | } |
| 51 | |
Tom Joseph | 9f9a9a4 | 2017-09-07 01:17:28 +0530 | [diff] [blame] | 52 | namespace get |
| 53 | { |
| 54 | |
| 55 | inline GetSensorResponse readingAssertion(const Info& sensorInfo) |
| 56 | { |
| 57 | return ipmi::sensor::get::readingAssertion<${type}>(sensorInfo); |
| 58 | } |
| 59 | |
| 60 | } //namespace get |
| 61 | |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 62 | } // namespace sensor_${key} |
| 63 | |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 64 | %elif "readingData" == readingType: |
| 65 | |
| 66 | namespace sensor_${key} |
| 67 | { |
| 68 | |
| 69 | inline ipmi_ret_t readingData(const SetSensorReadingReq& cmdData, |
| 70 | const Info& sensorInfo) |
| 71 | { |
| 72 | return set::readingData<${type}>(cmdData, sensorInfo); |
| 73 | } |
| 74 | |
Tom Joseph | 9f9a9a4 | 2017-09-07 01:17:28 +0530 | [diff] [blame] | 75 | namespace get |
| 76 | { |
| 77 | |
| 78 | inline GetSensorResponse readingData(const Info& sensorInfo) |
| 79 | { |
| 80 | return ipmi::sensor::get::readingData<${type}>(sensorInfo); |
| 81 | } |
| 82 | |
| 83 | } //namespace get |
| 84 | |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 85 | } // namespace sensor_${key} |
| 86 | |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 87 | %endif |
| 88 | % endfor |
| 89 | |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 90 | extern const IdInfoMap sensors = { |
| 91 | % for key in sensorDict.iterkeys(): |
| 92 | % if key: |
| 93 | {${key},{ |
| 94 | <% |
| 95 | sensor = sensorDict[key] |
| 96 | interfaces = sensor["interfaces"] |
| 97 | path = sensor["path"] |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 98 | serviceInterface = sensor["serviceInterface"] |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 99 | sensorType = sensor["sensorType"] |
| 100 | readingType = sensor["sensorReadingType"] |
Emily Shaffer | 10f4959 | 2017-05-10 12:01:10 -0700 | [diff] [blame] | 101 | multiplier = sensor.get("multiplierM", 1) |
| 102 | offset = sensor.get("offsetB", 0) |
| 103 | exp = sensor.get("bExp", 0) |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 104 | valueReadingType = sensor["readingType"] |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 105 | updateFunc = interfaceDict[serviceInterface]["updateFunc"] |
| 106 | updateFunc += sensor["readingType"] |
Tom Joseph | 9f9a9a4 | 2017-09-07 01:17:28 +0530 | [diff] [blame] | 107 | getFunc = interfaceDict[serviceInterface]["getFunc"] |
| 108 | getFunc += sensor["readingType"] |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 109 | if "readingAssertion" == valueReadingType: |
| 110 | updateFunc = "sensor_" + str(key) + "::" + valueReadingType |
Tom Joseph | 9f9a9a4 | 2017-09-07 01:17:28 +0530 | [diff] [blame] | 111 | getFunc = "sensor_" + str(key) + "::get::" + valueReadingType |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 112 | elif "readingData" == valueReadingType: |
| 113 | updateFunc = "sensor_" + str(key) + "::" + valueReadingType |
Tom Joseph | 9f9a9a4 | 2017-09-07 01:17:28 +0530 | [diff] [blame] | 114 | getFunc = "sensor_" + str(key) + "::get::" + valueReadingType |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 115 | sensorInterface = serviceInterface |
| 116 | if serviceInterface == "org.freedesktop.DBus.Properties": |
| 117 | sensorInterface = next(iter(interfaces)) |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 118 | mutability = sensor.get("mutability", "Mutability::Read") |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 119 | %> |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 120 | ${sensorType},"${path}","${sensorInterface}",${readingType},${multiplier}, |
Tom Joseph | 9f9a9a4 | 2017-09-07 01:17:28 +0530 | [diff] [blame] | 121 | ${offset},${exp},${offset * pow(10,exp)},${updateFunc},${getFunc},Mutability(${mutability}),{ |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 122 | % for interface,properties in interfaces.items(): |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 123 | {"${interface}",{ |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 124 | % for dbus_property,property_value in properties.items(): |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 125 | {"${dbus_property}",{ |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 126 | % for offset,values in property_value.items(): |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 127 | { ${offset},{ |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 128 | % if offset == 0xFF: |
| 129 | }}, |
| 130 | <% continue %>\ |
| 131 | % endif |
| 132 | <% valueType = values["type"] %>\ |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 133 | % for name,value in values.items(): |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 134 | % if name == "type": |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 135 | <% continue %>\ |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 136 | % endif |
| 137 | % if valueType == "string": |
| 138 | std::string("${value}"), |
Ratan Gupta | ca4c446 | 2017-03-16 00:00:06 +0530 | [diff] [blame] | 139 | % elif valueType == "bool": |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 140 | <% value = str(value).lower() %>\ |
Ratan Gupta | ca4c446 | 2017-03-16 00:00:06 +0530 | [diff] [blame] | 141 | ${value}, |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 142 | % else: |
| 143 | ${value}, |
| 144 | % endif |
| 145 | % endfor |
| 146 | } |
| 147 | }, |
| 148 | % endfor |
| 149 | }}, |
| 150 | % endfor |
| 151 | }}, |
| 152 | % endfor |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 153 | }, |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 154 | }}, |
| 155 | % endif |
| 156 | % endfor |
| 157 | }; |
| 158 | |