blob: 214df56f0a1109092b37b41232b97a174f140092 [file] [log] [blame]
Matthew Barth702c4a52018-02-28 16:23:11 -06001<%include file="defs.mako"/>\
2<%namespace file="defs.mako" import="*"/>\
3<%!
4def 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"
Matthew Barth1b4de262018-03-06 13:03:16 -060014#include "triggers.hpp"
Matthew Barth702c4a52018-02-28 16:23:11 -060015
16using namespace phosphor::fan::control;
17
18const unsigned int Manager::_powerOnDelay{${mgr_data['power_on_delay']}};
19
20const 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']},
Matthew Barth7883f582019-02-14 14:24:46 -060049 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(
Matthew Barth59096e52019-02-18 12:23:38 -060058 "${i['name']}",
59 "${p['name']}",
60 &Zone::${p['func']},
Matthew Barth7883f582019-02-14 14:24:46 -060061 static_cast<${p['type']}>(
62 %if "vector" in p['type'] or "map" in p['type']:
63 ${p['type']}{
64 %endif
Matthew Barth59096e52019-02-18 12:23:38 -060065 %for j, v in enumerate(p['values']):
66 %if (j+1) != len(p['values']):
Matthew Barth7883f582019-02-14 14:24:46 -060067 ${v},
68 %else:
69 ${v}
70 %endif
71 %endfor
72 %if "vector" in p['type'] or "map" in p['type']:
73 }
74 %endif
Matthew Barth59096e52019-02-18 12:23:38 -060075 ),
76 ${p['persist']}
Matthew Barth7883f582019-02-14 14:24:46 -060077 ))
78 },
79 %endfor
80 %endif
81 %endfor
82 %endif
83 },
Matthew Barth702c4a52018-02-28 16:23:11 -060084 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 },
95 %endfor
96 },
97 std::vector<SetSpeedEvent>{
98 %for event in zone['events']:
99 %if ('pc' in event) and \
100 (event['pc'] is not None):
101 SetSpeedEvent{
Matthew Barth621a5772018-11-14 14:55:11 -0600102 "${event['pc']['pcname']}",
Matthew Barth06fa7812018-11-20 09:54:30 -0600103 Group
104 {
Matthew Barth702c4a52018-02-28 16:23:11 -0600105 %for group in event['pc']['pcgrps']:
106 %for member in group['members']:
Matthew Barth06fa7812018-11-20 09:54:30 -0600107 {"${member['object']}",
Matthew Barth146b7392018-03-08 16:17:58 -0600108 "${member['interface']}",
Matthew Barth06fa7812018-11-20 09:54:30 -0600109 "${member['property']}"},
Matthew Barth702c4a52018-02-28 16:23:11 -0600110 %endfor
111 %endfor
112 },
Matthew Barth06fa7812018-11-20 09:54:30 -0600113 ActionData{
Matthew Barth75d97352018-11-01 10:34:49 -0500114 {Group{},
Matthew Barth702c4a52018-02-28 16:23:11 -0600115 std::vector<Action>{
116 %for i, a in enumerate(event['pc']['pcact']):
Matthew Barth702c4a52018-02-28 16:23:11 -0600117 make_action(
118 precondition::${a['name']}(
Matthew Barth702c4a52018-02-28 16:23:11 -0600119 %for p in a['params']:
120 ${p['type']}${p['open']}
121 %for j, v in enumerate(p['values']):
122 %if (j+1) != len(p['values']):
123 ${v['value']},
124 %else:
125 ${v['value']}
126 %endif
127 %endfor
128 ${p['close']},
129 %endfor
Matthew Barth702c4a52018-02-28 16:23:11 -0600130 %endfor
131 std::vector<SetSpeedEvent>{
132 %for pcevt in event['pc']['pcevts']:
Matthew Barth621a5772018-11-14 14:55:11 -0600133 SetSpeedEvent{
134 "${pcevt['name']}",\
Matthew Barth702c4a52018-02-28 16:23:11 -0600135 ${indent(genSSE(event=pcevt), 6)}\
136 },
137 %endfor
138 %else:
Matthew Barth621a5772018-11-14 14:55:11 -0600139 SetSpeedEvent{
140 "${event['name']}",\
Matthew Barth702c4a52018-02-28 16:23:11 -0600141 ${indent(genSSE(event=event), 6)}
142 %endif
143 %if ('pc' in event) and (event['pc'] is not None):
144 }
Matthew Barth702c4a52018-02-28 16:23:11 -0600145 )),
Matthew Barth75d97352018-11-01 10:34:49 -0500146 }},
Matthew Barth06fa7812018-11-20 09:54:30 -0600147 },
Matthew Barth1b4de262018-03-06 13:03:16 -0600148 std::vector<Trigger>{
Matthew Barthd0b90fc2018-03-05 09:38:45 -0600149 %if ('timer' in event['pc']['triggers']) and \
150 (event['pc']['triggers']['timer'] is not None):
Matthew Barth1b4de262018-03-06 13:03:16 -0600151 make_trigger(trigger::timer(TimerConf{
Matthew Barthd0b90fc2018-03-05 09:38:45 -0600152 ${event['pc']['triggers']['pctime']['interval']},
153 ${event['pc']['triggers']['pctime']['type']}
Matthew Barth016bd242018-03-07 16:06:06 -0600154 })),
Matthew Barthd0b90fc2018-03-05 09:38:45 -0600155 %endif
Matthew Barth016bd242018-03-07 16:06:06 -0600156 %if ('pcsigs' in event['pc']['triggers']) and \
157 (event['pc']['triggers']['pcsigs'] is not None):
158 %for s in event['pc']['triggers']['pcsigs']:
159 make_trigger(trigger::signal(
Matthew Barth18c91032019-01-29 15:36:00 -0600160 %if ('match' in s) and \
161 (s['match'] is not None):
Matthew Barth702c4a52018-02-28 16:23:11 -0600162 match::${s['match']}(
Matthew Barth926df662018-10-09 09:51:12 -0500163 %for i, mp in enumerate(s['mparams']['params']):
164 %if (i+1) != len(s['mparams']['params']):
165 ${indent(s['mparams'][mp], 1)},
Matthew Barth702c4a52018-02-28 16:23:11 -0600166 %else:
Matthew Barth926df662018-10-09 09:51:12 -0500167 ${indent(s['mparams'][mp], 1)}
Matthew Barth702c4a52018-02-28 16:23:11 -0600168 %endif
169 %endfor
170 ),
Matthew Barth18c91032019-01-29 15:36:00 -0600171 %else:
172 "",
173 %endif
Matthew Barth926df662018-10-09 09:51:12 -0500174 make_handler<SignalHandler>(\
175 ${indent(genSignal(sig=s), 9)}\
Matthew Barth702c4a52018-02-28 16:23:11 -0600176 )
Matthew Barth016bd242018-03-07 16:06:06 -0600177 )),
178 %endfor
179 %endif
Matthew Barthcd3bfbc2018-03-07 16:26:03 -0600180 %if ('init' in event['pc']['triggers']):
181 %for i in event['pc']['triggers']['init']:
182 make_trigger(trigger::init(
Matthew Barth926df662018-10-09 09:51:12 -0500183 %if ('method' in i):
184 make_handler<MethodHandler>(\
185 ${indent(genMethod(meth=i), 3)}\
Matthew Barthcd3bfbc2018-03-07 16:26:03 -0600186 )
187 %endif
188 )),
189 %endfor
190 %endif
Matthew Barth016bd242018-03-07 16:06:06 -0600191 },
Matthew Barth702c4a52018-02-28 16:23:11 -0600192 %endif
193 },
194 %endfor
195 }
196 },
197 %endfor
198 }
199 },
200%endfor
201};