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::" |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 13 | elif serviceInterface == "xyz.openbmc_project.Inventory.Manager": |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 14 | updateFunc = "notify::" |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 15 | else: |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 16 | assert "Un-supported interface: " + serviceInterface |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 17 | endif |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 18 | if serviceInterface not in interfaceDict: |
| 19 | interfaceDict[serviceInterface] = {} |
| 20 | interfaceDict[serviceInterface]["updateFunc"] = updateFunc |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 21 | %>\ |
| 22 | % endfor |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 23 | |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 24 | #include "types.hpp" |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 25 | #include "sensordatahandler.hpp" |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 26 | |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 27 | using namespace ipmi::sensor; |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 28 | |
| 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: |
| 40 | namespace sensor_${key} |
| 41 | { |
| 42 | |
| 43 | inline 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 Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 51 | %elif "readingData" == readingType: |
| 52 | |
| 53 | namespace sensor_${key} |
| 54 | { |
| 55 | |
| 56 | inline 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 Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 64 | %endif |
| 65 | % endfor |
| 66 | |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 67 | extern 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 Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 75 | serviceInterface = sensor["serviceInterface"] |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 76 | sensorType = sensor["sensorType"] |
| 77 | readingType = sensor["sensorReadingType"] |
Emily Shaffer | 10f4959 | 2017-05-10 12:01:10 -0700 | [diff] [blame] | 78 | multiplier = sensor.get("multiplierM", 1) |
| 79 | offset = sensor.get("offsetB", 0) |
| 80 | exp = sensor.get("bExp", 0) |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 81 | valueReadingType = sensor["readingType"] |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 82 | updateFunc = interfaceDict[serviceInterface]["updateFunc"] |
| 83 | updateFunc += sensor["readingType"] |
| 84 | if "readingAssertion" == valueReadingType: |
| 85 | updateFunc = "sensor_" + str(key) + "::" + valueReadingType |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 86 | elif "readingData" == valueReadingType: |
| 87 | updateFunc = "sensor_" + str(key) + "::" + valueReadingType |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 88 | sensorInterface = serviceInterface |
| 89 | if serviceInterface == "org.freedesktop.DBus.Properties": |
| 90 | sensorInterface = next(iter(interfaces)) |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 91 | mutability = sensor.get("mutability", "Mutability::Read") |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 92 | %> |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 93 | ${sensorType},"${path}","${sensorInterface}",${readingType},${multiplier}, |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 94 | ${offset},${exp},${offset * pow(10,exp)},${updateFunc},Mutability(${mutability}),{ |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 95 | % for interface,properties in interfaces.items(): |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 96 | {"${interface}",{ |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 97 | % for dbus_property,property_value in properties.items(): |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 98 | {"${dbus_property}",{ |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 99 | % for offset,values in property_value.items(): |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 100 | { ${offset},{ |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 101 | % if offset == 0xFF: |
| 102 | }}, |
| 103 | <% continue %>\ |
| 104 | % endif |
| 105 | <% valueType = values["type"] %>\ |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 106 | % for name,value in values.items(): |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 107 | % if name == "type": |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 108 | <% continue %>\ |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 109 | % endif |
| 110 | % if valueType == "string": |
| 111 | std::string("${value}"), |
Ratan Gupta | ca4c446 | 2017-03-16 00:00:06 +0530 | [diff] [blame] | 112 | % elif valueType == "bool": |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 113 | <% value = str(value).lower() %>\ |
Ratan Gupta | ca4c446 | 2017-03-16 00:00:06 +0530 | [diff] [blame] | 114 | ${value}, |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 115 | % else: |
| 116 | ${value}, |
| 117 | % endif |
| 118 | % endfor |
| 119 | } |
| 120 | }, |
| 121 | % endfor |
| 122 | }}, |
| 123 | % endfor |
| 124 | }}, |
| 125 | % endfor |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 126 | }, |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 127 | }}, |
| 128 | % endif |
| 129 | % endfor |
| 130 | }; |
| 131 | |