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{ |
| 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 Barth | 1b4de26 | 2018-03-06 13:03:16 -0600 | [diff] [blame^] | 159 | std::vector<Trigger>{ |
Matthew Barth | d0b90fc | 2018-03-05 09:38:45 -0600 | [diff] [blame] | 160 | %if ('timer' in event['pc']['triggers']) and \ |
| 161 | (event['pc']['triggers']['timer'] is not None): |
Matthew Barth | 1b4de26 | 2018-03-06 13:03:16 -0600 | [diff] [blame^] | 162 | make_trigger(trigger::timer(TimerConf{ |
Matthew Barth | d0b90fc | 2018-03-05 09:38:45 -0600 | [diff] [blame] | 163 | ${event['pc']['triggers']['pctime']['interval']}, |
| 164 | ${event['pc']['triggers']['pctime']['type']} |
Matthew Barth | 1b4de26 | 2018-03-06 13:03:16 -0600 | [diff] [blame^] | 165 | })) |
Matthew Barth | d0b90fc | 2018-03-05 09:38:45 -0600 | [diff] [blame] | 166 | %endif |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 167 | }, |
| 168 | std::vector<Signal>{ |
Matthew Barth | f20c321 | 2018-03-02 14:42:55 -0600 | [diff] [blame] | 169 | %for s in event['pc']['triggers']['pcsigs']: |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 170 | Signal{ |
Matthew Barth | 18c9103 | 2019-01-29 15:36:00 -0600 | [diff] [blame] | 171 | %if ('match' in s) and \ |
| 172 | (s['match'] is not None): |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 173 | 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 Barth | 18c9103 | 2019-01-29 15:36:00 -0600 | [diff] [blame] | 182 | %else: |
| 183 | "", |
| 184 | %endif |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 185 | 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 | }; |