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