Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 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" |
Matthew Barth | 1b4de26 | 2018-03-06 13:03:16 -0600 | [diff] [blame] | 14 | #include "triggers.hpp" |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 15 | |
| 16 | using namespace phosphor::fan::control; |
| 17 | |
| 18 | const unsigned int Manager::_powerOnDelay{${mgr_data['power_on_delay']}}; |
| 19 | |
| 20 | const 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 Barth | 7883f58 | 2019-02-14 14:24:46 -0600 | [diff] [blame] | 49 | 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 Barth | 59096e5 | 2019-02-18 12:23:38 -0600 | [diff] [blame] | 58 | "${i['name']}", |
| 59 | "${p['name']}", |
| 60 | &Zone::${p['func']}, |
Matthew Barth | 7883f58 | 2019-02-14 14:24:46 -0600 | [diff] [blame] | 61 | static_cast<${p['type']}>( |
| 62 | %if "vector" in p['type'] or "map" in p['type']: |
| 63 | ${p['type']}{ |
| 64 | %endif |
Matthew Barth | 59096e5 | 2019-02-18 12:23:38 -0600 | [diff] [blame] | 65 | %for j, v in enumerate(p['values']): |
| 66 | %if (j+1) != len(p['values']): |
Matthew Barth | 7883f58 | 2019-02-14 14:24:46 -0600 | [diff] [blame] | 67 | ${v}, |
| 68 | %else: |
| 69 | ${v} |
| 70 | %endif |
| 71 | %endfor |
| 72 | %if "vector" in p['type'] or "map" in p['type']: |
| 73 | } |
| 74 | %endif |
Matthew Barth | 59096e5 | 2019-02-18 12:23:38 -0600 | [diff] [blame] | 75 | ), |
| 76 | ${p['persist']} |
Matthew Barth | 7883f58 | 2019-02-14 14:24:46 -0600 | [diff] [blame] | 77 | )) |
| 78 | }, |
| 79 | %endfor |
| 80 | %endif |
| 81 | %endfor |
| 82 | %endif |
| 83 | }, |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 84 | 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 Barth | 621a577 | 2018-11-14 14:55:11 -0600 | [diff] [blame^] | 102 | "${event['pc']['pcname']}", |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 103 | Group{ |
| 104 | %for group in event['pc']['pcgrps']: |
| 105 | %for member in group['members']: |
| 106 | { |
| 107 | "${member['object']}", |
Matthew Barth | 146b739 | 2018-03-08 16:17:58 -0600 | [diff] [blame] | 108 | "${member['interface']}", |
| 109 | "${member['property']}" |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 110 | }, |
| 111 | %endfor |
| 112 | %endfor |
| 113 | }, |
| 114 | std::vector<Action>{ |
| 115 | %for i, a in enumerate(event['pc']['pcact']): |
| 116 | %if len(a['params']) != 0: |
| 117 | make_action( |
| 118 | precondition::${a['name']}( |
| 119 | %else: |
| 120 | make_action( |
| 121 | precondition::${a['name']} |
| 122 | %endif |
| 123 | %for p in a['params']: |
| 124 | ${p['type']}${p['open']} |
| 125 | %for j, v in enumerate(p['values']): |
| 126 | %if (j+1) != len(p['values']): |
| 127 | ${v['value']}, |
| 128 | %else: |
| 129 | ${v['value']} |
| 130 | %endif |
| 131 | %endfor |
| 132 | ${p['close']}, |
| 133 | %endfor |
| 134 | %if (i+1) != len(event['pc']['pcact']): |
| 135 | %if len(a['params']) != 0: |
| 136 | )), |
| 137 | %else: |
| 138 | ), |
| 139 | %endif |
| 140 | %endif |
| 141 | %endfor |
| 142 | std::vector<SetSpeedEvent>{ |
| 143 | %for pcevt in event['pc']['pcevts']: |
Matthew Barth | 621a577 | 2018-11-14 14:55:11 -0600 | [diff] [blame^] | 144 | SetSpeedEvent{ |
| 145 | "${pcevt['name']}",\ |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 146 | ${indent(genSSE(event=pcevt), 6)}\ |
| 147 | }, |
| 148 | %endfor |
| 149 | %else: |
Matthew Barth | 621a577 | 2018-11-14 14:55:11 -0600 | [diff] [blame^] | 150 | SetSpeedEvent{ |
| 151 | "${event['name']}",\ |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 152 | ${indent(genSSE(event=event), 6)} |
| 153 | %endif |
| 154 | %if ('pc' in event) and (event['pc'] is not None): |
| 155 | } |
| 156 | %if len(event['pc']['pcact'][-1]['params']) != 0: |
| 157 | )), |
| 158 | %else: |
| 159 | ), |
| 160 | %endif |
| 161 | }, |
Matthew Barth | 1b4de26 | 2018-03-06 13:03:16 -0600 | [diff] [blame] | 162 | std::vector<Trigger>{ |
Matthew Barth | d0b90fc | 2018-03-05 09:38:45 -0600 | [diff] [blame] | 163 | %if ('timer' in event['pc']['triggers']) and \ |
| 164 | (event['pc']['triggers']['timer'] is not None): |
Matthew Barth | 1b4de26 | 2018-03-06 13:03:16 -0600 | [diff] [blame] | 165 | make_trigger(trigger::timer(TimerConf{ |
Matthew Barth | d0b90fc | 2018-03-05 09:38:45 -0600 | [diff] [blame] | 166 | ${event['pc']['triggers']['pctime']['interval']}, |
| 167 | ${event['pc']['triggers']['pctime']['type']} |
Matthew Barth | 016bd24 | 2018-03-07 16:06:06 -0600 | [diff] [blame] | 168 | })), |
Matthew Barth | d0b90fc | 2018-03-05 09:38:45 -0600 | [diff] [blame] | 169 | %endif |
Matthew Barth | 016bd24 | 2018-03-07 16:06:06 -0600 | [diff] [blame] | 170 | %if ('pcsigs' in event['pc']['triggers']) and \ |
| 171 | (event['pc']['triggers']['pcsigs'] is not None): |
| 172 | %for s in event['pc']['triggers']['pcsigs']: |
| 173 | make_trigger(trigger::signal( |
Matthew Barth | 18c9103 | 2019-01-29 15:36:00 -0600 | [diff] [blame] | 174 | %if ('match' in s) and \ |
| 175 | (s['match'] is not None): |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 176 | match::${s['match']}( |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 177 | %for i, mp in enumerate(s['mparams']['params']): |
| 178 | %if (i+1) != len(s['mparams']['params']): |
| 179 | ${indent(s['mparams'][mp], 1)}, |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 180 | %else: |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 181 | ${indent(s['mparams'][mp], 1)} |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 182 | %endif |
| 183 | %endfor |
| 184 | ), |
Matthew Barth | 18c9103 | 2019-01-29 15:36:00 -0600 | [diff] [blame] | 185 | %else: |
| 186 | "", |
| 187 | %endif |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 188 | make_handler<SignalHandler>(\ |
| 189 | ${indent(genSignal(sig=s), 9)}\ |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 190 | ) |
Matthew Barth | 016bd24 | 2018-03-07 16:06:06 -0600 | [diff] [blame] | 191 | )), |
| 192 | %endfor |
| 193 | %endif |
Matthew Barth | cd3bfbc | 2018-03-07 16:26:03 -0600 | [diff] [blame] | 194 | %if ('init' in event['pc']['triggers']): |
| 195 | %for i in event['pc']['triggers']['init']: |
| 196 | make_trigger(trigger::init( |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 197 | %if ('method' in i): |
| 198 | make_handler<MethodHandler>(\ |
| 199 | ${indent(genMethod(meth=i), 3)}\ |
Matthew Barth | cd3bfbc | 2018-03-07 16:26:03 -0600 | [diff] [blame] | 200 | ) |
| 201 | %endif |
| 202 | )), |
| 203 | %endfor |
| 204 | %endif |
Matthew Barth | 016bd24 | 2018-03-07 16:06:06 -0600 | [diff] [blame] | 205 | }, |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 206 | %endif |
| 207 | }, |
| 208 | %endfor |
| 209 | } |
| 210 | }, |
| 211 | %endfor |
| 212 | } |
| 213 | }, |
| 214 | %endfor |
| 215 | }; |