1 <%include file="defs.mako"/>\ 2 <%namespace file="defs.mako" import="*"/>\ 3 <%! 4 def indent(str, depth): 5 return ''.join(4*' '*depth+line for line in str.splitlines(True)) 6 %>\ 7 /* This is a generated file. */ 8 #include "manager.hpp" 9 #include "functor.hpp" 10 #include "actions.hpp" 11 #include "handlers.hpp" 12 #include "preconditions.hpp" 13 #include "matches.hpp" 14 #include "triggers.hpp" 15 16 using namespace phosphor::fan::control; 17 18 const unsigned int Manager::_powerOnDelay{${mgr_data['power_on_delay']}}; 19 20 const std::vector<ZoneGroup> Manager::_zoneLayouts 21 { 22 %for zone_group in zones: 23 ZoneGroup{ 24 std::vector<Condition>{ 25 %for condition in zone_group['conditions']: 26 Condition{ 27 "${condition['type']}", 28 std::vector<ConditionProperty>{ 29 %for property in condition['properties']: 30 ConditionProperty{ 31 "${property['property']}", 32 "${property['interface']}", 33 "${property['path']}", 34 static_cast<${property['type']}>(${property['value']}), 35 }, 36 %endfor 37 }, 38 }, 39 %endfor 40 }, 41 std::vector<ZoneDefinition>{ 42 %for zone in zone_group['zones']: 43 ZoneDefinition{ 44 ${zone['num']}, 45 ${zone['full_speed']}, 46 ${zone['default_floor']}, 47 ${zone['increase_delay']}, 48 ${zone['decrease_interval']}, 49 std::vector<ZoneHandler>{ 50 %if ('ifaces' in zone) and \ 51 (zone['ifaces'] is not None): 52 %for i in zone['ifaces']: 53 %if ('props' in i) and \ 54 (i['props'] is not None): 55 %for p in i['props']: 56 ZoneHandler{ 57 make_zoneHandler(handler::setZoneProperty( 58 "${i['name']}", 59 "${p['name']}", 60 &Zone::${p['func']}, 61 static_cast<${p['type']}>( 62 %if "vector" in p['type'] or "map" in p['type']: 63 ${p['type']}{ 64 %endif 65 %for j, v in enumerate(p['values']): 66 %if (j+1) != len(p['values']): 67 ${v}, 68 %else: 69 ${v} 70 %endif 71 %endfor 72 %if "vector" in p['type'] or "map" in p['type']: 73 } 74 %endif 75 ), 76 ${p['persist']} 77 )) 78 }, 79 %endfor 80 %endif 81 %endfor 82 %endif 83 }, 84 std::vector<FanDefinition>{ 85 %for fan in zone['fans']: 86 FanDefinition{ 87 "${fan['name']}", 88 std::vector<std::string>{ 89 %for sensor in fan['sensors']: 90 "${sensor}", 91 %endfor 92 }, 93 "${fan['target_interface']}", 94 "${fan['target_path']}" 95 }, 96 %endfor 97 }, 98 std::vector<SetSpeedEvent>{ 99 %for event in zone['events']: 100 %if ('pc' in event) and \ 101 (event['pc'] is not None): 102 SetSpeedEvent{ 103 "${event['pc']['pcname']}", 104 Group 105 { 106 %for group in event['pc']['pcgrps']: 107 %for member in group['members']: 108 {"${member['object']}", 109 "${member['interface']}", 110 "${member['property']}"}, 111 %endfor 112 %endfor 113 }, 114 ActionData{ 115 {Group{}, 116 std::vector<Action>{ 117 %for i, a in enumerate(event['pc']['pcact']): 118 make_action( 119 precondition::${a['name']}( 120 %for p in a['params']: 121 ${p['type']}${p['open']} 122 %for j, v in enumerate(p['values']): 123 %if (j+1) != len(p['values']): 124 ${v['value']}, 125 %else: 126 ${v['value']} 127 %endif 128 %endfor 129 ${p['close']}, 130 %endfor 131 %endfor 132 std::vector<SetSpeedEvent>{ 133 %for pcevt in event['pc']['pcevts']: 134 SetSpeedEvent{ 135 "${pcevt['name']}",\ 136 ${indent(genSSE(event=pcevt), 6)}\ 137 }, 138 %endfor 139 %else: 140 SetSpeedEvent{ 141 "${event['name']}",\ 142 ${indent(genSSE(event=event), 6)} 143 %endif 144 %if ('pc' in event) and (event['pc'] is not None): 145 } 146 )), 147 }}, 148 }, 149 std::vector<Trigger>{ 150 %if ('timer' in event['pc']['triggers']) and \ 151 (event['pc']['triggers']['timer'] is not None): 152 make_trigger(trigger::timer(TimerConf{ 153 ${event['pc']['triggers']['pctime']['interval']}, 154 ${event['pc']['triggers']['pctime']['type']} 155 })), 156 %endif 157 %if ('pcsigs' in event['pc']['triggers']) and \ 158 (event['pc']['triggers']['pcsigs'] is not None): 159 %for s in event['pc']['triggers']['pcsigs']: 160 make_trigger(trigger::signal( 161 %if ('match' in s) and \ 162 (s['match'] is not None): 163 match::${s['match']}( 164 %for i, mp in enumerate(s['mparams']['params']): 165 %if (i+1) != len(s['mparams']['params']): 166 ${indent(s['mparams'][mp], 1)}, 167 %else: 168 ${indent(s['mparams'][mp], 1)} 169 %endif 170 %endfor 171 ), 172 %else: 173 "", 174 %endif 175 make_handler<SignalHandler>(\ 176 ${indent(genSignal(sig=s), 9)}\ 177 ) 178 )), 179 %endfor 180 %endif 181 %if ('init' in event['pc']['triggers']): 182 %for i in event['pc']['triggers']['init']: 183 make_trigger(trigger::init( 184 %if ('method' in i): 185 make_handler<MethodHandler>(\ 186 ${indent(genMethod(meth=i), 3)}\ 187 ) 188 %endif 189 )), 190 %endfor 191 %endif 192 }, 193 %endif 194 }, 195 %endfor 196 } 197 }, 198 %endfor 199 } 200 }, 201 %endfor 202 }; 203