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