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 | |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 27 | #include "sensordatahandler.hpp" |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 28 | |
Vernon Mauery | 3325024 | 2019-03-12 16:49:26 -0700 | [diff] [blame] | 29 | #include <ipmid/types.hpp> |
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 | |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 32 | extern const IdInfoMap sensors = { |
| 33 | % for key in sensorDict.iterkeys(): |
| 34 | % if key: |
| 35 | {${key},{ |
| 36 | <% |
| 37 | sensor = sensorDict[key] |
| 38 | interfaces = sensor["interfaces"] |
| 39 | path = sensor["path"] |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 40 | serviceInterface = sensor["serviceInterface"] |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 41 | sensorType = sensor["sensorType"] |
Tom Joseph | 31ff6e6 | 2018-01-24 16:10:09 +0530 | [diff] [blame] | 42 | entityID = sensor.get("entityID", 0) |
| 43 | instance = sensor.get("entityInstance", 0) |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 44 | readingType = sensor["sensorReadingType"] |
Emily Shaffer | 10f4959 | 2017-05-10 12:01:10 -0700 | [diff] [blame] | 45 | multiplier = sensor.get("multiplierM", 1) |
Tom Joseph | b673ff6 | 2017-09-07 15:28:32 +0530 | [diff] [blame] | 46 | offsetB = sensor.get("offsetB", 0) |
Kirill Pakhomov | 4d1a5dd | 2018-10-10 17:06:41 +0300 | [diff] [blame] | 47 | bExp = sensor.get("bExp", 0) |
Tom Joseph | 0a1301c | 2018-02-16 08:27:00 +0530 | [diff] [blame] | 48 | rExp = sensor.get("rExp", 0) |
Emily Shaffer | 6223561 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 49 | unit = sensor.get("unit", "") |
| 50 | scale = sensor.get("scale", 0) |
| 51 | hasScale = "true" if "scale" in sensor.keys() else "false" |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 52 | valueReadingType = sensor["readingType"] |
Tom Joseph | 31ff6e6 | 2018-01-24 16:10:09 +0530 | [diff] [blame] | 53 | sensorNamePattern = sensor.get("sensorNamePattern", "nameLeaf") |
| 54 | sensorNameFunc = "get::" + sensorNamePattern |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 55 | updateFunc = interfaceDict[serviceInterface]["updateFunc"] |
| 56 | updateFunc += sensor["readingType"] |
Tom Joseph | 9f9a9a4 | 2017-09-07 01:17:28 +0530 | [diff] [blame] | 57 | getFunc = interfaceDict[serviceInterface]["getFunc"] |
| 58 | getFunc += sensor["readingType"] |
Tom Joseph | 580af36 | 2017-09-07 15:38:40 +0530 | [diff] [blame] | 59 | if "readingAssertion" == valueReadingType or "readingData" == valueReadingType: |
| 60 | for interface,properties in interfaces.items(): |
| 61 | for dbus_property,property_value in properties.items(): |
Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 62 | for offset,values in property_value["Offsets"].items(): |
Tom Joseph | 580af36 | 2017-09-07 15:38:40 +0530 | [diff] [blame] | 63 | valueType = values["type"] |
| 64 | updateFunc = "set::" + valueReadingType + "<" + valueType + ">" |
| 65 | getFunc = "get::" + valueReadingType + "<" + valueType + ">" |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 66 | sensorInterface = serviceInterface |
| 67 | if serviceInterface == "org.freedesktop.DBus.Properties": |
| 68 | sensorInterface = next(iter(interfaces)) |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 69 | mutability = sensor.get("mutability", "Mutability::Read") |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 70 | %> |
Tom Joseph | 31ff6e6 | 2018-01-24 16:10:09 +0530 | [diff] [blame] | 71 | ${entityID},${instance},${sensorType},"${path}","${sensorInterface}", |
Kirill Pakhomov | 4d1a5dd | 2018-10-10 17:06:41 +0300 | [diff] [blame] | 72 | ${readingType},${multiplier},${offsetB},${bExp}, |
| 73 | ${offsetB * pow(10,bExp)}, ${rExp}, ${hasScale},${scale},"${unit}", |
Tom Joseph | 31ff6e6 | 2018-01-24 16:10:09 +0530 | [diff] [blame] | 74 | ${updateFunc},${getFunc},Mutability(${mutability}),${sensorNameFunc},{ |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 75 | % for interface,properties in interfaces.items(): |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 76 | {"${interface}",{ |
Santosh Puranik | bbf8bd6 | 2019-05-01 19:02:52 +0530 | [diff] [blame] | 77 | % if properties: |
| 78 | % for dbus_property,property_value in properties.items(): |
| 79 | {"${dbus_property}",{ |
Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 80 | <% |
| 81 | try: |
| 82 | preReq = property_value["Prereqs"] |
| 83 | except KeyError, e: |
| 84 | preReq = dict() |
| 85 | %>\ |
Santosh Puranik | bbf8bd6 | 2019-05-01 19:02:52 +0530 | [diff] [blame] | 86 | { |
| 87 | % for preOffset,preValues in preReq.items(): |
| 88 | { ${preOffset},{ |
| 89 | % for name,value in preValues.items(): |
| 90 | % if name == "type": |
Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 91 | <% continue %>\ |
Santosh Puranik | bbf8bd6 | 2019-05-01 19:02:52 +0530 | [diff] [blame] | 92 | % endif |
Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 93 | <% value = str(value).lower() %>\ |
Santosh Puranik | bbf8bd6 | 2019-05-01 19:02:52 +0530 | [diff] [blame] | 94 | ${value}, |
| 95 | % endfor |
| 96 | } |
| 97 | }, |
Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 98 | % endfor |
Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 99 | }, |
Santosh Puranik | bbf8bd6 | 2019-05-01 19:02:52 +0530 | [diff] [blame] | 100 | { |
| 101 | % for offset,values in property_value["Offsets"].items(): |
| 102 | { ${offset},{ |
| 103 | % if offset == 0xFF: |
| 104 | }}, |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 105 | <% continue %>\ |
Santosh Puranik | bbf8bd6 | 2019-05-01 19:02:52 +0530 | [diff] [blame] | 106 | % endif |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 107 | <% valueType = values["type"] %>\ |
Dhruvaraj Subhashchandran | e84841c | 2017-08-22 07:40:27 -0500 | [diff] [blame] | 108 | <% |
| 109 | try: |
| 110 | skip = values["skipOn"] |
| 111 | if skip == "assert": |
Santosh Puranik | bbf8bd6 | 2019-05-01 19:02:52 +0530 | [diff] [blame] | 112 | skipVal = "SkipAssertion::ASSERT" |
Dhruvaraj Subhashchandran | e84841c | 2017-08-22 07:40:27 -0500 | [diff] [blame] | 113 | elif skip == "deassert": |
Santosh Puranik | bbf8bd6 | 2019-05-01 19:02:52 +0530 | [diff] [blame] | 114 | skipVal = "SkipAssertion::DEASSERT" |
Dhruvaraj Subhashchandran | e84841c | 2017-08-22 07:40:27 -0500 | [diff] [blame] | 115 | else: |
Santosh Puranik | bbf8bd6 | 2019-05-01 19:02:52 +0530 | [diff] [blame] | 116 | assert "Unknown skip value " + str(skip) |
Dhruvaraj Subhashchandran | e84841c | 2017-08-22 07:40:27 -0500 | [diff] [blame] | 117 | except KeyError, e: |
| 118 | skipVal = "SkipAssertion::NONE" |
| 119 | %>\ |
Santosh Puranik | bbf8bd6 | 2019-05-01 19:02:52 +0530 | [diff] [blame] | 120 | ${skipVal}, |
| 121 | % for name,value in values.items(): |
| 122 | % if name == "type" or name == "skipOn": |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 123 | <% continue %>\ |
Santosh Puranik | bbf8bd6 | 2019-05-01 19:02:52 +0530 | [diff] [blame] | 124 | % endif |
| 125 | % if valueType == "string": |
| 126 | std::string("${value}"), |
| 127 | % elif valueType == "bool": |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 128 | <% value = str(value).lower() %>\ |
Santosh Puranik | bbf8bd6 | 2019-05-01 19:02:52 +0530 | [diff] [blame] | 129 | ${value}, |
| 130 | % else: |
| 131 | ${value}, |
| 132 | % endif |
| 133 | % endfor |
| 134 | } |
| 135 | }, |
| 136 | % endfor |
| 137 | }}}, |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 138 | % endfor |
Santosh Puranik | bbf8bd6 | 2019-05-01 19:02:52 +0530 | [diff] [blame] | 139 | % endif |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 140 | }}, |
| 141 | % endfor |
Emily Shaffer | 6223561 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 142 | }, |
Ratan Gupta | 0065905 | 2017-02-23 17:29:08 +0530 | [diff] [blame] | 143 | }}, |
| 144 | % endif |
| 145 | % endfor |
| 146 | }; |
| 147 | |