blob: cb4698694d08e5b6a5e7af0d79a4beaa8206484f [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(
57 &Zone::${p['name']},
58 static_cast<${p['type']}>(
59 %if "vector" in p['type'] or "map" in p['type']:
60 ${p['type']}{
61 %endif
62 %for i, v in enumerate(p['values']):
63 %if (i+1) != len(p['values']):
64 ${v},
65 %else:
66 ${v}
67 %endif
68 %endfor
69 %if "vector" in p['type'] or "map" in p['type']:
70 }
71 %endif
72 )
73 ))
74 },
75 %endfor
76 %endif
77 %endfor
78 %endif
79 },
Matthew Barth702c4a52018-02-28 16:23:11 -060080 std::vector<FanDefinition>{
81 %for fan in zone['fans']:
82 FanDefinition{
83 "${fan['name']}",
84 std::vector<std::string>{
85 %for sensor in fan['sensors']:
86 "${sensor}",
87 %endfor
88 },
89 "${fan['target_interface']}"
90 },
91 %endfor
92 },
93 std::vector<SetSpeedEvent>{
94 %for event in zone['events']:
95 %if ('pc' in event) and \
96 (event['pc'] is not None):
97 SetSpeedEvent{
98 Group{
99 %for group in event['pc']['pcgrps']:
100 %for member in group['members']:
101 {
102 "${member['object']}",
103 {"${member['interface']}",
104 "${member['property']}"}
105 },
106 %endfor
107 %endfor
108 },
109 std::vector<Action>{
110 %for i, a in enumerate(event['pc']['pcact']):
111 %if len(a['params']) != 0:
112 make_action(
113 precondition::${a['name']}(
114 %else:
115 make_action(
116 precondition::${a['name']}
117 %endif
118 %for p in a['params']:
119 ${p['type']}${p['open']}
120 %for j, v in enumerate(p['values']):
121 %if (j+1) != len(p['values']):
122 ${v['value']},
123 %else:
124 ${v['value']}
125 %endif
126 %endfor
127 ${p['close']},
128 %endfor
129 %if (i+1) != len(event['pc']['pcact']):
130 %if len(a['params']) != 0:
131 )),
132 %else:
133 ),
134 %endif
135 %endif
136 %endfor
137 std::vector<SetSpeedEvent>{
138 %for pcevt in event['pc']['pcevts']:
139 SetSpeedEvent{\
140 ${indent(genSSE(event=pcevt), 6)}\
141 },
142 %endfor
143 %else:
144 SetSpeedEvent{\
145 ${indent(genSSE(event=event), 6)}
146 %endif
147 %if ('pc' in event) and (event['pc'] is not None):
148 }
149 %if len(event['pc']['pcact'][-1]['params']) != 0:
150 )),
151 %else:
152 ),
153 %endif
154 },
William A. Kennington III122b8432018-10-30 18:39:21 -0700155 TimerConf{
Matthew Barth702c4a52018-02-28 16:23:11 -0600156 ${event['pc']['pctime']['interval']},
157 ${event['pc']['pctime']['type']}
158 },
159 std::vector<Signal>{
160 %for s in event['pc']['pcsigs']:
161 Signal{
Matthew Barth18c91032019-01-29 15:36:00 -0600162 %if ('match' in s) and \
163 (s['match'] is not None):
Matthew Barth702c4a52018-02-28 16:23:11 -0600164 match::${s['match']}(
165 %for i, mp in enumerate(s['mparams']):
166 %if (i+1) != len(s['mparams']):
167 "${mp}",
168 %else:
169 "${mp}"
170 %endif
171 %endfor
172 ),
Matthew Barth18c91032019-01-29 15:36:00 -0600173 %else:
174 "",
175 %endif
Matthew Barth702c4a52018-02-28 16:23:11 -0600176 make_handler(\
177 ${indent(genHandler(sig=s), 9)}\
178 )
179 },
180 %endfor
181 }
182 %endif
183 },
184 %endfor
185 }
186 },
187 %endfor
188 }
189 },
190%endfor
191};