blob: c04951643b9d0718548876af51495b77c584ae3e [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{
102 Group{
103 %for group in event['pc']['pcgrps']:
104 %for member in group['members']:
105 {
106 "${member['object']}",
107 {"${member['interface']}",
108 "${member['property']}"}
109 },
110 %endfor
111 %endfor
112 },
113 std::vector<Action>{
114 %for i, a in enumerate(event['pc']['pcact']):
115 %if len(a['params']) != 0:
116 make_action(
117 precondition::${a['name']}(
118 %else:
119 make_action(
120 precondition::${a['name']}
121 %endif
122 %for p in a['params']:
123 ${p['type']}${p['open']}
124 %for j, v in enumerate(p['values']):
125 %if (j+1) != len(p['values']):
126 ${v['value']},
127 %else:
128 ${v['value']}
129 %endif
130 %endfor
131 ${p['close']},
132 %endfor
133 %if (i+1) != len(event['pc']['pcact']):
134 %if len(a['params']) != 0:
135 )),
136 %else:
137 ),
138 %endif
139 %endif
140 %endfor
141 std::vector<SetSpeedEvent>{
142 %for pcevt in event['pc']['pcevts']:
143 SetSpeedEvent{\
144 ${indent(genSSE(event=pcevt), 6)}\
145 },
146 %endfor
147 %else:
148 SetSpeedEvent{\
149 ${indent(genSSE(event=event), 6)}
150 %endif
151 %if ('pc' in event) and (event['pc'] is not None):
152 }
153 %if len(event['pc']['pcact'][-1]['params']) != 0:
154 )),
155 %else:
156 ),
157 %endif
158 },
Matthew Barth1b4de262018-03-06 13:03:16 -0600159 std::vector<Trigger>{
Matthew Barthd0b90fc2018-03-05 09:38:45 -0600160 %if ('timer' in event['pc']['triggers']) and \
161 (event['pc']['triggers']['timer'] is not None):
Matthew Barth1b4de262018-03-06 13:03:16 -0600162 make_trigger(trigger::timer(TimerConf{
Matthew Barthd0b90fc2018-03-05 09:38:45 -0600163 ${event['pc']['triggers']['pctime']['interval']},
164 ${event['pc']['triggers']['pctime']['type']}
Matthew Barth1b4de262018-03-06 13:03:16 -0600165 }))
Matthew Barthd0b90fc2018-03-05 09:38:45 -0600166 %endif
Matthew Barth702c4a52018-02-28 16:23:11 -0600167 },
168 std::vector<Signal>{
Matthew Barthf20c3212018-03-02 14:42:55 -0600169 %for s in event['pc']['triggers']['pcsigs']:
Matthew Barth702c4a52018-02-28 16:23:11 -0600170 Signal{
Matthew Barth18c91032019-01-29 15:36:00 -0600171 %if ('match' in s) and \
172 (s['match'] is not None):
Matthew Barth702c4a52018-02-28 16:23:11 -0600173 match::${s['match']}(
174 %for i, mp in enumerate(s['mparams']):
175 %if (i+1) != len(s['mparams']):
176 "${mp}",
177 %else:
178 "${mp}"
179 %endif
180 %endfor
181 ),
Matthew Barth18c91032019-01-29 15:36:00 -0600182 %else:
183 "",
184 %endif
Matthew Barth702c4a52018-02-28 16:23:11 -0600185 make_handler(\
186 ${indent(genHandler(sig=s), 9)}\
187 )
188 },
189 %endfor
190 }
191 %endif
192 },
193 %endfor
194 }
195 },
196 %endfor
197 }
198 },
199%endfor
200};