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