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