blob: a4ba61595231cd7245538a075ed3ba4aae92d6e5 [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"
14
15using namespace phosphor::fan::control;
16
17const unsigned int Manager::_powerOnDelay{${mgr_data['power_on_delay']}};
18
19const std::vector<ZoneGroup> Manager::_zoneLayouts
20{
21%for zone_group in zones:
22 ZoneGroup{
23 std::vector<Condition>{
24 %for condition in zone_group['conditions']:
25 Condition{
26 "${condition['type']}",
27 std::vector<ConditionProperty>{
28 %for property in condition['properties']:
29 ConditionProperty{
30 "${property['property']}",
31 "${property['interface']}",
32 "${property['path']}",
33 static_cast<${property['type']}>(${property['value']}),
34 },
35 %endfor
36 },
37 },
38 %endfor
39 },
40 std::vector<ZoneDefinition>{
41 %for zone in zone_group['zones']:
42 ZoneDefinition{
43 ${zone['num']},
44 ${zone['full_speed']},
45 ${zone['default_floor']},
46 ${zone['increase_delay']},
47 ${zone['decrease_interval']},
Matthew Barth7883f582019-02-14 14:24:46 -060048 std::vector<ZoneHandler>{
49 %if ('ifaces' in zone) and \
50 (zone['ifaces'] is not None):
51 %for i in zone['ifaces']:
52 %if ('props' in i) and \
53 (i['props'] is not None):
54 %for p in i['props']:
55 ZoneHandler{
56 make_zoneHandler(handler::setZoneProperty(
Matthew Barth59096e52019-02-18 12:23:38 -060057 "${i['name']}",
58 "${p['name']}",
59 &Zone::${p['func']},
Matthew Barth7883f582019-02-14 14:24:46 -060060 static_cast<${p['type']}>(
61 %if "vector" in p['type'] or "map" in p['type']:
62 ${p['type']}{
63 %endif
Matthew Barth59096e52019-02-18 12:23:38 -060064 %for j, v in enumerate(p['values']):
65 %if (j+1) != len(p['values']):
Matthew Barth7883f582019-02-14 14:24:46 -060066 ${v},
67 %else:
68 ${v}
69 %endif
70 %endfor
71 %if "vector" in p['type'] or "map" in p['type']:
72 }
73 %endif
Matthew Barth59096e52019-02-18 12:23:38 -060074 ),
75 ${p['persist']}
Matthew Barth7883f582019-02-14 14:24:46 -060076 ))
77 },
78 %endfor
79 %endif
80 %endfor
81 %endif
82 },
Matthew Barth702c4a52018-02-28 16:23:11 -060083 std::vector<FanDefinition>{
84 %for fan in zone['fans']:
85 FanDefinition{
86 "${fan['name']}",
87 std::vector<std::string>{
88 %for sensor in fan['sensors']:
89 "${sensor}",
90 %endfor
91 },
92 "${fan['target_interface']}"
93 },
94 %endfor
95 },
96 std::vector<SetSpeedEvent>{
97 %for event in zone['events']:
98 %if ('pc' in event) and \
99 (event['pc'] is not None):
100 SetSpeedEvent{
101 Group{
102 %for group in event['pc']['pcgrps']:
103 %for member in group['members']:
104 {
105 "${member['object']}",
106 {"${member['interface']}",
107 "${member['property']}"}
108 },
109 %endfor
110 %endfor
111 },
112 std::vector<Action>{
113 %for i, a in enumerate(event['pc']['pcact']):
114 %if len(a['params']) != 0:
115 make_action(
116 precondition::${a['name']}(
117 %else:
118 make_action(
119 precondition::${a['name']}
120 %endif
121 %for p in a['params']:
122 ${p['type']}${p['open']}
123 %for j, v in enumerate(p['values']):
124 %if (j+1) != len(p['values']):
125 ${v['value']},
126 %else:
127 ${v['value']}
128 %endif
129 %endfor
130 ${p['close']},
131 %endfor
132 %if (i+1) != len(event['pc']['pcact']):
133 %if len(a['params']) != 0:
134 )),
135 %else:
136 ),
137 %endif
138 %endif
139 %endfor
140 std::vector<SetSpeedEvent>{
141 %for pcevt in event['pc']['pcevts']:
142 SetSpeedEvent{\
143 ${indent(genSSE(event=pcevt), 6)}\
144 },
145 %endfor
146 %else:
147 SetSpeedEvent{\
148 ${indent(genSSE(event=event), 6)}
149 %endif
150 %if ('pc' in event) and (event['pc'] is not None):
151 }
152 %if len(event['pc']['pcact'][-1]['params']) != 0:
153 )),
154 %else:
155 ),
156 %endif
157 },
William A. Kennington III122b8432018-10-30 18:39:21 -0700158 TimerConf{
Matthew Barth702c4a52018-02-28 16:23:11 -0600159 ${event['pc']['pctime']['interval']},
160 ${event['pc']['pctime']['type']}
161 },
162 std::vector<Signal>{
Matthew Barthf20c3212018-03-02 14:42:55 -0600163 %for s in event['pc']['triggers']['pcsigs']:
Matthew Barth702c4a52018-02-28 16:23:11 -0600164 Signal{
Matthew Barth18c91032019-01-29 15:36:00 -0600165 %if ('match' in s) and \
166 (s['match'] is not None):
Matthew Barth702c4a52018-02-28 16:23:11 -0600167 match::${s['match']}(
168 %for i, mp in enumerate(s['mparams']):
169 %if (i+1) != len(s['mparams']):
170 "${mp}",
171 %else:
172 "${mp}"
173 %endif
174 %endfor
175 ),
Matthew Barth18c91032019-01-29 15:36:00 -0600176 %else:
177 "",
178 %endif
Matthew Barth702c4a52018-02-28 16:23:11 -0600179 make_handler(\
180 ${indent(genHandler(sig=s), 9)}\
181 )
182 },
183 %endfor
184 }
185 %endif
186 },
187 %endfor
188 }
189 },
190 %endfor
191 }
192 },
193%endfor
194};