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