1 <%include file="defs.mako"/>\
2 <%namespace file="defs.mako" import="*"/>\
3 <%!
4 def 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 
15 using namespace phosphor::fan::control;
16 
17 const unsigned int Manager::_powerOnDelay{${mgr_data['power_on_delay']}};
18 
19 const 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']},
48                 std::vector<FanDefinition>{
49                 %for fan in zone['fans']:
50                     FanDefinition{
51                         "${fan['name']}",
52                         std::vector<std::string>{
53                         %for sensor in fan['sensors']:
54                             "${sensor}",
55                         %endfor
56                         },
57                         "${fan['target_interface']}"
58                     },
59                 %endfor
60                 },
61                 std::vector<SetSpeedEvent>{
62                 %for event in zone['events']:
63                     %if ('pc' in event) and \
64                         (event['pc'] is not None):
65                     SetSpeedEvent{
66                         Group{
67                         %for group in event['pc']['pcgrps']:
68                         %for member in group['members']:
69                         {
70                             "${member['object']}",
71                             {"${member['interface']}",
72                              "${member['property']}"}
73                         },
74                         %endfor
75                         %endfor
76                         },
77                         std::vector<Action>{
78                         %for i, a in enumerate(event['pc']['pcact']):
79                         %if len(a['params']) != 0:
80                         make_action(
81                             precondition::${a['name']}(
82                         %else:
83                         make_action(
84                             precondition::${a['name']}
85                         %endif
86                         %for p in a['params']:
87                         ${p['type']}${p['open']}
88                         %for j, v in enumerate(p['values']):
89                         %if (j+1) != len(p['values']):
90                             ${v['value']},
91                         %else:
92                             ${v['value']}
93                         %endif
94                         %endfor
95                         ${p['close']},
96                         %endfor
97                         %if (i+1) != len(event['pc']['pcact']):
98                         %if len(a['params']) != 0:
99                         )),
100                         %else:
101                         ),
102                         %endif
103                         %endif
104                         %endfor
105                     std::vector<SetSpeedEvent>{
106                     %for pcevt in event['pc']['pcevts']:
107                     SetSpeedEvent{\
108                     ${indent(genSSE(event=pcevt), 6)}\
109                     },
110                     %endfor
111                     %else:
112                     SetSpeedEvent{\
113                     ${indent(genSSE(event=event), 6)}
114                     %endif
115                     %if ('pc' in event) and (event['pc'] is not None):
116                     }
117                         %if len(event['pc']['pcact'][-1]['params']) != 0:
118                         )),
119                         %else:
120                         ),
121                         %endif
122                         },
123                         TimerConf{
124                             ${event['pc']['pctime']['interval']},
125                             ${event['pc']['pctime']['type']}
126                         },
127                         std::vector<Signal>{
128                         %for s in event['pc']['pcsigs']:
129                             Signal{
130                                 %if ('match' in s) and \
131                                     (s['match'] is not None):
132                                 match::${s['match']}(
133                                 %for i, mp in enumerate(s['mparams']):
134                                 %if (i+1) != len(s['mparams']):
135                                 "${mp}",
136                                 %else:
137                                 "${mp}"
138                                 %endif
139                                 %endfor
140                                 ),
141                                 %else:
142                                 "",
143                                 %endif
144                                 make_handler(\
145                                 ${indent(genHandler(sig=s), 9)}\
146                                 )
147                             },
148                         %endfor
149                         }
150                     %endif
151                     },
152                 %endfor
153                 }
154             },
155         %endfor
156         }
157     },
158 %endfor
159 };
160