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