1 ## This file is a template. The comment below is emitted 2 ## into the rendered file; feel free to edit this file. 3 // !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!! 4 <% 5 interfaceDict = {} 6 %>\ 7 %for key in sensorDict.iterkeys(): 8 <% 9 sensor = sensorDict[key] 10 serviceInterface = sensor["serviceInterface"] 11 if serviceInterface == "org.freedesktop.DBus.Properties": 12 updateFunc = "set::" 13 getFunc = "get::" 14 elif serviceInterface == "xyz.openbmc_project.Inventory.Manager": 15 updateFunc = "notify::" 16 getFunc = "inventory::get::" 17 else: 18 assert "Un-supported interface: " + serviceInterface 19 endif 20 if serviceInterface not in interfaceDict: 21 interfaceDict[serviceInterface] = {} 22 interfaceDict[serviceInterface]["updateFunc"] = updateFunc 23 interfaceDict[serviceInterface]["getFunc"] = getFunc 24 %>\ 25 % endfor 26 27 #include "sensordatahandler.hpp" 28 29 #include <ipmid/types.hpp> 30 using namespace ipmi::sensor; 31 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"] 40 serviceInterface = sensor["serviceInterface"] 41 sensorType = sensor["sensorType"] 42 entityID = sensor.get("entityID", 0) 43 instance = sensor.get("entityInstance", 0) 44 readingType = sensor["sensorReadingType"] 45 multiplier = sensor.get("multiplierM", 1) 46 offsetB = sensor.get("offsetB", 0) 47 bExp = sensor.get("bExp", 0) 48 rExp = sensor.get("rExp", 0) 49 unit = sensor.get("unit", "") 50 scale = sensor.get("scale", 0) 51 hasScale = "true" if "scale" in sensor.keys() else "false" 52 valueReadingType = sensor["readingType"] 53 sensorNamePattern = sensor.get("sensorNamePattern", "nameLeaf") 54 sensorNameFunc = "get::" + sensorNamePattern 55 updateFunc = interfaceDict[serviceInterface]["updateFunc"] 56 updateFunc += sensor["readingType"] 57 getFunc = interfaceDict[serviceInterface]["getFunc"] 58 getFunc += sensor["readingType"] 59 if "readingAssertion" == valueReadingType or "readingData" == valueReadingType: 60 for interface,properties in interfaces.items(): 61 for dbus_property,property_value in properties.items(): 62 for offset,values in property_value["Offsets"].items(): 63 valueType = values["type"] 64 updateFunc = "set::" + valueReadingType + "<" + valueType + ">" 65 getFunc = "get::" + valueReadingType + "<" + valueType + ">" 66 sensorInterface = serviceInterface 67 if serviceInterface == "org.freedesktop.DBus.Properties": 68 sensorInterface = next(iter(interfaces)) 69 mutability = sensor.get("mutability", "Mutability::Read") 70 %> 71 ${entityID},${instance},${sensorType},"${path}","${sensorInterface}", 72 ${readingType},${multiplier},${offsetB},${bExp}, 73 ${offsetB * pow(10,bExp)}, ${rExp}, ${hasScale},${scale},"${unit}", 74 ${updateFunc},${getFunc},Mutability(${mutability}),${sensorNameFunc},{ 75 % for interface,properties in interfaces.items(): 76 {"${interface}",{ 77 % for dbus_property,property_value in properties.items(): 78 {"${dbus_property}",{ 79 <% 80 try: 81 preReq = property_value["Prereqs"] 82 except KeyError, e: 83 preReq = dict() 84 %>\ 85 { 86 % for preOffset,preValues in preReq.items(): 87 { ${preOffset},{ 88 % for name,value in preValues.items(): 89 % if name == "type": 90 <% continue %>\ 91 % endif 92 <% value = str(value).lower() %>\ 93 ${value}, 94 % endfor 95 } 96 }, 97 % endfor 98 }, 99 { 100 % for offset,values in property_value["Offsets"].items(): 101 { ${offset},{ 102 % if offset == 0xFF: 103 }}, 104 <% continue %>\ 105 % endif 106 <% valueType = values["type"] %>\ 107 <% 108 try: 109 skip = values["skipOn"] 110 if skip == "assert": 111 skipVal = "SkipAssertion::ASSERT" 112 elif skip == "deassert": 113 skipVal = "SkipAssertion::DEASSERT" 114 else: 115 assert "Unknown skip value " + str(skip) 116 except KeyError, e: 117 skipVal = "SkipAssertion::NONE" 118 %>\ 119 ${skipVal}, 120 % for name,value in values.items(): 121 % if name == "type" or name == "skipOn": 122 <% continue %>\ 123 % endif 124 % if valueType == "string": 125 std::string("${value}"), 126 % elif valueType == "bool": 127 <% value = str(value).lower() %>\ 128 ${value}, 129 % else: 130 ${value}, 131 % endif 132 % endfor 133 } 134 }, 135 % endfor 136 }}}, 137 % endfor 138 }}, 139 % endfor 140 }, 141 }}, 142 % endif 143 % endfor 144 }; 145 146