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                         },
93*44872b07SChau Ly                         "${fan['target_interface']}",
94*44872b07SChau Ly                         "${fan['target_path']}"
95702c4a55SMatthew Barth                     },
96702c4a55SMatthew Barth                 %endfor
97702c4a55SMatthew Barth                 },
98702c4a55SMatthew Barth                 std::vector<SetSpeedEvent>{
99702c4a55SMatthew Barth                 %for event in zone['events']:
100702c4a55SMatthew Barth                     %if ('pc' in event) and \
101702c4a55SMatthew Barth                         (event['pc'] is not None):
102702c4a55SMatthew Barth                     SetSpeedEvent{
103621a5778SMatthew Barth                         "${event['pc']['pcname']}",
10406fa7817SMatthew Barth                         Group
10506fa7817SMatthew Barth                         {
106702c4a55SMatthew Barth                         %for group in event['pc']['pcgrps']:
107702c4a55SMatthew Barth                         %for member in group['members']:
10806fa7817SMatthew Barth                             {"${member['object']}",
109146b7390SMatthew Barth                             "${member['interface']}",
11006fa7817SMatthew Barth                             "${member['property']}"},
111702c4a55SMatthew Barth                         %endfor
112702c4a55SMatthew Barth                         %endfor
113702c4a55SMatthew Barth                         },
11406fa7817SMatthew Barth                         ActionData{
11575d97350SMatthew Barth                         {Group{},
116702c4a55SMatthew Barth                         std::vector<Action>{
117702c4a55SMatthew Barth                         %for i, a in enumerate(event['pc']['pcact']):
118702c4a55SMatthew Barth                         make_action(
119702c4a55SMatthew Barth                             precondition::${a['name']}(
120702c4a55SMatthew Barth                         %for p in a['params']:
121702c4a55SMatthew Barth                         ${p['type']}${p['open']}
122702c4a55SMatthew Barth                         %for j, v in enumerate(p['values']):
123702c4a55SMatthew Barth                         %if (j+1) != len(p['values']):
124702c4a55SMatthew Barth                             ${v['value']},
125702c4a55SMatthew Barth                         %else:
126702c4a55SMatthew Barth                             ${v['value']}
127702c4a55SMatthew Barth                         %endif
128702c4a55SMatthew Barth                         %endfor
129702c4a55SMatthew Barth                         ${p['close']},
130702c4a55SMatthew Barth                         %endfor
131702c4a55SMatthew Barth                         %endfor
132702c4a55SMatthew Barth                     std::vector<SetSpeedEvent>{
133702c4a55SMatthew Barth                     %for pcevt in event['pc']['pcevts']:
134621a5778SMatthew Barth                     SetSpeedEvent{
135621a5778SMatthew Barth                         "${pcevt['name']}",\
136702c4a55SMatthew Barth                     ${indent(genSSE(event=pcevt), 6)}\
137702c4a55SMatthew Barth                     },
138702c4a55SMatthew Barth                     %endfor
139702c4a55SMatthew Barth                     %else:
140621a5778SMatthew Barth                     SetSpeedEvent{
141621a5778SMatthew Barth                         "${event['name']}",\
142702c4a55SMatthew Barth                     ${indent(genSSE(event=event), 6)}
143702c4a55SMatthew Barth                     %endif
144702c4a55SMatthew Barth                     %if ('pc' in event) and (event['pc'] is not None):
145702c4a55SMatthew Barth                     }
146702c4a55SMatthew Barth                         )),
14775d97350SMatthew Barth                         }},
14806fa7817SMatthew Barth                         },
1491b4de26aSMatthew Barth                         std::vector<Trigger>{
150d0b90fc6SMatthew Barth                             %if ('timer' in event['pc']['triggers']) and \
151d0b90fc6SMatthew Barth                                 (event['pc']['triggers']['timer'] is not None):
1521b4de26aSMatthew Barth                             make_trigger(trigger::timer(TimerConf{
153d0b90fc6SMatthew Barth                             ${event['pc']['triggers']['pctime']['interval']},
154d0b90fc6SMatthew Barth                             ${event['pc']['triggers']['pctime']['type']}
155016bd24cSMatthew Barth                             })),
156d0b90fc6SMatthew Barth                             %endif
157016bd24cSMatthew Barth                             %if ('pcsigs' in event['pc']['triggers']) and \
158016bd24cSMatthew Barth                                 (event['pc']['triggers']['pcsigs'] is not None):
159f20c321dSMatthew Barth                             %for s in event['pc']['triggers']['pcsigs']:
160016bd24cSMatthew Barth                             make_trigger(trigger::signal(
16118c91030SMatthew Barth                                 %if ('match' in s) and \
16218c91030SMatthew Barth                                     (s['match'] is not None):
163702c4a55SMatthew Barth                                 match::${s['match']}(
164926df663SMatthew Barth                                 %for i, mp in enumerate(s['mparams']['params']):
165926df663SMatthew Barth                                 %if (i+1) != len(s['mparams']['params']):
166926df663SMatthew Barth                                 ${indent(s['mparams'][mp], 1)},
167702c4a55SMatthew Barth                                 %else:
168926df663SMatthew Barth                                 ${indent(s['mparams'][mp], 1)}
169702c4a55SMatthew Barth                                 %endif
170702c4a55SMatthew Barth                                 %endfor
171702c4a55SMatthew Barth                                 ),
17218c91030SMatthew Barth                                 %else:
17318c91030SMatthew Barth                                 "",
17418c91030SMatthew Barth                                 %endif
175926df663SMatthew Barth                                 make_handler<SignalHandler>(\
176926df663SMatthew Barth                                 ${indent(genSignal(sig=s), 9)}\
177702c4a55SMatthew Barth                                 )
178016bd24cSMatthew Barth                             )),
179702c4a55SMatthew Barth                             %endfor
180016bd24cSMatthew Barth                             %endif
181cd3bfbc1SMatthew Barth                             %if ('init' in event['pc']['triggers']):
182cd3bfbc1SMatthew Barth                             %for i in event['pc']['triggers']['init']:
183cd3bfbc1SMatthew Barth                             make_trigger(trigger::init(
184926df663SMatthew Barth                                 %if ('method' in i):
185926df663SMatthew Barth                                 make_handler<MethodHandler>(\
186926df663SMatthew Barth                                 ${indent(genMethod(meth=i), 3)}\
187cd3bfbc1SMatthew Barth                                 )
188cd3bfbc1SMatthew Barth                                 %endif
189cd3bfbc1SMatthew Barth                             )),
190cd3bfbc1SMatthew Barth                             %endfor
191cd3bfbc1SMatthew Barth                             %endif
192016bd24cSMatthew Barth                         },
193702c4a55SMatthew Barth                     %endif
194702c4a55SMatthew Barth                     },
195702c4a55SMatthew Barth                 %endfor
196702c4a55SMatthew Barth                 }
197702c4a55SMatthew Barth             },
198702c4a55SMatthew Barth         %endfor
199702c4a55SMatthew Barth         }
200702c4a55SMatthew Barth     },
201702c4a55SMatthew Barth %endfor
202702c4a55SMatthew Barth };
203