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 | |
| 51 | %endif |
| 52 | % endfor |
| 53 | |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 54 | extern 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 Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 62 | serviceInterface = sensor["serviceInterface"] |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 63 | sensorType = sensor["sensorType"] |
| 64 | readingType = sensor["sensorReadingType"] |
Emily Shaffer | 10f4959 | 2017-05-10 12:01:10 -0700 | [diff] [blame] | 65 | multiplier = sensor.get("multiplierM", 1) |
| 66 | offset = sensor.get("offsetB", 0) |
| 67 | exp = sensor.get("bExp", 0) |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 68 | valueReadingType = sensor["readingType"] |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 69 | 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 Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 76 | %> |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 77 | ${sensorType},"${path}","${sensorInterface}",${readingType},${multiplier}, |
| 78 | ${offset},${exp},${offset * pow(10,exp)},${updateFunc},{ |
| 79 | % for interface,properties in interfaces.items(): |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 80 | {"${interface}",{ |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 81 | % for dbus_property,property_value in properties.items(): |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 82 | {"${dbus_property}",{ |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 83 | % for offset,values in property_value.items(): |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 84 | { ${offset},{ |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 85 | % if offset == 0xFF: |
| 86 | }}, |
| 87 | <% continue %>\ |
| 88 | % endif |
| 89 | <% valueType = values["type"] %>\ |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 90 | % for name,value in values.items(): |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 91 | % if name == "type": |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 92 | <% continue %>\ |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 93 | % endif |
| 94 | % if valueType == "string": |
| 95 | std::string("${value}"), |
Ratan Gupta | ca4c446 | 2017-03-16 00:00:06 +0530 | [diff] [blame] | 96 | % elif valueType == "bool": |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 97 | <% value = str(value).lower() %>\ |
Ratan Gupta | ca4c446 | 2017-03-16 00:00:06 +0530 | [diff] [blame] | 98 | ${value}, |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 99 | % 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 | |