1702c4a55SMatthew Barth <%include file="defs.mako"/>\ 2702c4a55SMatthew Barth <%namespace file="defs.mako" import="*"/>\ 3702c4a55SMatthew Barth <%! 4702c4a55SMatthew Barth def indent(str, depth): 5702c4a55SMatthew Barth return ''.join(4*' '*depth+line for line in str.splitlines(True)) 6702c4a55SMatthew Barth %>\ 7702c4a55SMatthew Barth /* This is a generated file. */ 8702c4a55SMatthew Barth #include "manager.hpp" 9702c4a55SMatthew Barth #include "functor.hpp" 10702c4a55SMatthew Barth #include "actions.hpp" 11702c4a55SMatthew Barth #include "handlers.hpp" 12702c4a55SMatthew Barth #include "preconditions.hpp" 13702c4a55SMatthew Barth #include "matches.hpp" 141b4de26aSMatthew Barth #include "triggers.hpp" 15702c4a55SMatthew Barth 16702c4a55SMatthew Barth using namespace phosphor::fan::control; 17702c4a55SMatthew Barth 18702c4a55SMatthew Barth const unsigned int Manager::_powerOnDelay{${mgr_data['power_on_delay']}}; 19702c4a55SMatthew Barth 20702c4a55SMatthew Barth const std::vector<ZoneGroup> Manager::_zoneLayouts 21702c4a55SMatthew Barth { 22702c4a55SMatthew Barth %for zone_group in zones: 23702c4a55SMatthew Barth ZoneGroup{ 24702c4a55SMatthew Barth std::vector<Condition>{ 25702c4a55SMatthew Barth %for condition in zone_group['conditions']: 26702c4a55SMatthew Barth Condition{ 27702c4a55SMatthew Barth "${condition['type']}", 28702c4a55SMatthew Barth std::vector<ConditionProperty>{ 29702c4a55SMatthew Barth %for property in condition['properties']: 30702c4a55SMatthew Barth ConditionProperty{ 31702c4a55SMatthew Barth "${property['property']}", 32702c4a55SMatthew Barth "${property['interface']}", 33702c4a55SMatthew Barth "${property['path']}", 34702c4a55SMatthew Barth static_cast<${property['type']}>(${property['value']}), 35702c4a55SMatthew Barth }, 36702c4a55SMatthew Barth %endfor 37702c4a55SMatthew Barth }, 38702c4a55SMatthew Barth }, 39702c4a55SMatthew Barth %endfor 40702c4a55SMatthew Barth }, 41702c4a55SMatthew Barth std::vector<ZoneDefinition>{ 42702c4a55SMatthew Barth %for zone in zone_group['zones']: 43702c4a55SMatthew Barth ZoneDefinition{ 44702c4a55SMatthew Barth ${zone['num']}, 45702c4a55SMatthew Barth ${zone['full_speed']}, 46702c4a55SMatthew Barth ${zone['default_floor']}, 47702c4a55SMatthew Barth ${zone['increase_delay']}, 48702c4a55SMatthew Barth ${zone['decrease_interval']}, 497883f58aSMatthew Barth std::vector<ZoneHandler>{ 507883f58aSMatthew Barth %if ('ifaces' in zone) and \ 517883f58aSMatthew Barth (zone['ifaces'] is not None): 527883f58aSMatthew Barth %for i in zone['ifaces']: 537883f58aSMatthew Barth %if ('props' in i) and \ 547883f58aSMatthew Barth (i['props'] is not None): 557883f58aSMatthew Barth %for p in i['props']: 567883f58aSMatthew Barth ZoneHandler{ 577883f58aSMatthew Barth make_zoneHandler(handler::setZoneProperty( 5859096e50SMatthew Barth "${i['name']}", 5959096e50SMatthew Barth "${p['name']}", 6059096e50SMatthew Barth &Zone::${p['func']}, 617883f58aSMatthew Barth static_cast<${p['type']}>( 627883f58aSMatthew Barth %if "vector" in p['type'] or "map" in p['type']: 637883f58aSMatthew Barth ${p['type']}{ 647883f58aSMatthew Barth %endif 6559096e50SMatthew Barth %for j, v in enumerate(p['values']): 6659096e50SMatthew Barth %if (j+1) != len(p['values']): 677883f58aSMatthew Barth ${v}, 687883f58aSMatthew Barth %else: 697883f58aSMatthew Barth ${v} 707883f58aSMatthew Barth %endif 717883f58aSMatthew Barth %endfor 727883f58aSMatthew Barth %if "vector" in p['type'] or "map" in p['type']: 737883f58aSMatthew Barth } 747883f58aSMatthew Barth %endif 7559096e50SMatthew Barth ), 7659096e50SMatthew Barth ${p['persist']} 777883f58aSMatthew Barth )) 787883f58aSMatthew Barth }, 797883f58aSMatthew Barth %endfor 807883f58aSMatthew Barth %endif 817883f58aSMatthew Barth %endfor 827883f58aSMatthew Barth %endif 837883f58aSMatthew Barth }, 84702c4a55SMatthew Barth std::vector<FanDefinition>{ 85702c4a55SMatthew Barth %for fan in zone['fans']: 86702c4a55SMatthew Barth FanDefinition{ 87702c4a55SMatthew Barth "${fan['name']}", 88702c4a55SMatthew Barth std::vector<std::string>{ 89702c4a55SMatthew Barth %for sensor in fan['sensors']: 90702c4a55SMatthew Barth "${sensor}", 91702c4a55SMatthew Barth %endfor 92702c4a55SMatthew Barth }, 93702c4a55SMatthew Barth "${fan['target_interface']}" 94702c4a55SMatthew Barth }, 95702c4a55SMatthew Barth %endfor 96702c4a55SMatthew Barth }, 97702c4a55SMatthew Barth std::vector<SetSpeedEvent>{ 98702c4a55SMatthew Barth %for event in zone['events']: 99702c4a55SMatthew Barth %if ('pc' in event) and \ 100702c4a55SMatthew Barth (event['pc'] is not None): 101702c4a55SMatthew Barth SetSpeedEvent{ 102*621a5778SMatthew Barth "${event['pc']['pcname']}", 103702c4a55SMatthew Barth Group{ 104702c4a55SMatthew Barth %for group in event['pc']['pcgrps']: 105702c4a55SMatthew Barth %for member in group['members']: 106702c4a55SMatthew Barth { 107702c4a55SMatthew Barth "${member['object']}", 108146b7390SMatthew Barth "${member['interface']}", 109146b7390SMatthew Barth "${member['property']}" 110702c4a55SMatthew Barth }, 111702c4a55SMatthew Barth %endfor 112702c4a55SMatthew Barth %endfor 113702c4a55SMatthew Barth }, 114702c4a55SMatthew Barth std::vector<Action>{ 115702c4a55SMatthew Barth %for i, a in enumerate(event['pc']['pcact']): 116702c4a55SMatthew Barth %if len(a['params']) != 0: 117702c4a55SMatthew Barth make_action( 118702c4a55SMatthew Barth precondition::${a['name']}( 119702c4a55SMatthew Barth %else: 120702c4a55SMatthew Barth make_action( 121702c4a55SMatthew Barth precondition::${a['name']} 122702c4a55SMatthew Barth %endif 123702c4a55SMatthew Barth %for p in a['params']: 124702c4a55SMatthew Barth ${p['type']}${p['open']} 125702c4a55SMatthew Barth %for j, v in enumerate(p['values']): 126702c4a55SMatthew Barth %if (j+1) != len(p['values']): 127702c4a55SMatthew Barth ${v['value']}, 128702c4a55SMatthew Barth %else: 129702c4a55SMatthew Barth ${v['value']} 130702c4a55SMatthew Barth %endif 131702c4a55SMatthew Barth %endfor 132702c4a55SMatthew Barth ${p['close']}, 133702c4a55SMatthew Barth %endfor 134702c4a55SMatthew Barth %if (i+1) != len(event['pc']['pcact']): 135702c4a55SMatthew Barth %if len(a['params']) != 0: 136702c4a55SMatthew Barth )), 137702c4a55SMatthew Barth %else: 138702c4a55SMatthew Barth ), 139702c4a55SMatthew Barth %endif 140702c4a55SMatthew Barth %endif 141702c4a55SMatthew Barth %endfor 142702c4a55SMatthew Barth std::vector<SetSpeedEvent>{ 143702c4a55SMatthew Barth %for pcevt in event['pc']['pcevts']: 144*621a5778SMatthew Barth SetSpeedEvent{ 145*621a5778SMatthew Barth "${pcevt['name']}",\ 146702c4a55SMatthew Barth ${indent(genSSE(event=pcevt), 6)}\ 147702c4a55SMatthew Barth }, 148702c4a55SMatthew Barth %endfor 149702c4a55SMatthew Barth %else: 150*621a5778SMatthew Barth SetSpeedEvent{ 151*621a5778SMatthew Barth "${event['name']}",\ 152702c4a55SMatthew Barth ${indent(genSSE(event=event), 6)} 153702c4a55SMatthew Barth %endif 154702c4a55SMatthew Barth %if ('pc' in event) and (event['pc'] is not None): 155702c4a55SMatthew Barth } 156702c4a55SMatthew Barth %if len(event['pc']['pcact'][-1]['params']) != 0: 157702c4a55SMatthew Barth )), 158702c4a55SMatthew Barth %else: 159702c4a55SMatthew Barth ), 160702c4a55SMatthew Barth %endif 161702c4a55SMatthew Barth }, 1621b4de26aSMatthew Barth std::vector<Trigger>{ 163d0b90fc6SMatthew Barth %if ('timer' in event['pc']['triggers']) and \ 164d0b90fc6SMatthew Barth (event['pc']['triggers']['timer'] is not None): 1651b4de26aSMatthew Barth make_trigger(trigger::timer(TimerConf{ 166d0b90fc6SMatthew Barth ${event['pc']['triggers']['pctime']['interval']}, 167d0b90fc6SMatthew Barth ${event['pc']['triggers']['pctime']['type']} 168016bd24cSMatthew Barth })), 169d0b90fc6SMatthew Barth %endif 170016bd24cSMatthew Barth %if ('pcsigs' in event['pc']['triggers']) and \ 171016bd24cSMatthew Barth (event['pc']['triggers']['pcsigs'] is not None): 172f20c321dSMatthew Barth %for s in event['pc']['triggers']['pcsigs']: 173016bd24cSMatthew Barth make_trigger(trigger::signal( 17418c91030SMatthew Barth %if ('match' in s) and \ 17518c91030SMatthew Barth (s['match'] is not None): 176702c4a55SMatthew Barth match::${s['match']}( 177926df663SMatthew Barth %for i, mp in enumerate(s['mparams']['params']): 178926df663SMatthew Barth %if (i+1) != len(s['mparams']['params']): 179926df663SMatthew Barth ${indent(s['mparams'][mp], 1)}, 180702c4a55SMatthew Barth %else: 181926df663SMatthew Barth ${indent(s['mparams'][mp], 1)} 182702c4a55SMatthew Barth %endif 183702c4a55SMatthew Barth %endfor 184702c4a55SMatthew Barth ), 18518c91030SMatthew Barth %else: 18618c91030SMatthew Barth "", 18718c91030SMatthew Barth %endif 188926df663SMatthew Barth make_handler<SignalHandler>(\ 189926df663SMatthew Barth ${indent(genSignal(sig=s), 9)}\ 190702c4a55SMatthew Barth ) 191016bd24cSMatthew Barth )), 192702c4a55SMatthew Barth %endfor 193016bd24cSMatthew Barth %endif 194cd3bfbc1SMatthew Barth %if ('init' in event['pc']['triggers']): 195cd3bfbc1SMatthew Barth %for i in event['pc']['triggers']['init']: 196cd3bfbc1SMatthew Barth make_trigger(trigger::init( 197926df663SMatthew Barth %if ('method' in i): 198926df663SMatthew Barth make_handler<MethodHandler>(\ 199926df663SMatthew Barth ${indent(genMethod(meth=i), 3)}\ 200cd3bfbc1SMatthew Barth ) 201cd3bfbc1SMatthew Barth %endif 202cd3bfbc1SMatthew Barth )), 203cd3bfbc1SMatthew Barth %endfor 204cd3bfbc1SMatthew Barth %endif 205016bd24cSMatthew Barth }, 206702c4a55SMatthew Barth %endif 207702c4a55SMatthew Barth }, 208702c4a55SMatthew Barth %endfor 209702c4a55SMatthew Barth } 210702c4a55SMatthew Barth }, 211702c4a55SMatthew Barth %endfor 212702c4a55SMatthew Barth } 213702c4a55SMatthew Barth }, 214702c4a55SMatthew Barth %endfor 215702c4a55SMatthew Barth }; 216