summaryrefslogtreecommitdiffstats
path: root/control/templates/fan_zone_defs.mako.cpp
blob: a73449fad79f3e5ad02ac547a9102429e1d58ee5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<%include file="defs.mako"/>\
<%namespace file="defs.mako" import="*"/>\
<%!
def indent(str, depth):
    return ''.join(4*' '*depth+line for line in str.splitlines(True))
%>\
/* This is a generated file. */
#include "manager.hpp"
#include "functor.hpp"
#include "actions.hpp"
#include "handlers.hpp"
#include "preconditions.hpp"
#include "matches.hpp"

using namespace phosphor::fan::control;

const unsigned int Manager::_powerOnDelay{${mgr_data['power_on_delay']}};

const std::vector<ZoneGroup> Manager::_zoneLayouts
{
%for zone_group in zones:
    ZoneGroup{
        std::vector<Condition>{
        %for condition in zone_group['conditions']:
            Condition{
                "${condition['type']}",
                std::vector<ConditionProperty>{
                %for property in condition['properties']:
                    ConditionProperty{
                        "${property['property']}",
                        "${property['interface']}",
                        "${property['path']}",
                        static_cast<${property['type']}>(${property['value']}),
                    },
                    %endfor
                },
            },
            %endfor
        },
        std::vector<ZoneDefinition>{
        %for zone in zone_group['zones']:
            ZoneDefinition{
                ${zone['num']},
                ${zone['full_speed']},
                ${zone['default_floor']},
                ${zone['increase_delay']},
                ${zone['decrease_interval']},
                std::vector<FanDefinition>{
                %for fan in zone['fans']:
                    FanDefinition{
                        "${fan['name']}",
                        std::vector<std::string>{
                        %for sensor in fan['sensors']:
                            "${sensor}",
                        %endfor
                        },
                        "${fan['target_interface']}"
                    },
                %endfor
                },
                std::vector<SetSpeedEvent>{
                %for event in zone['events']:
                    %if ('pc' in event) and \
                        (event['pc'] is not None):
                    SetSpeedEvent{
                        Group{
                        %for group in event['pc']['pcgrps']:
                        %for member in group['members']:
                        {
                            "${member['object']}",
                            {"${member['interface']}",
                             "${member['property']}"}
                        },
                        %endfor
                        %endfor
                        },
                        std::vector<Action>{
                        %for i, a in enumerate(event['pc']['pcact']):
                        %if len(a['params']) != 0:
                        make_action(
                            precondition::${a['name']}(
                        %else:
                        make_action(
                            precondition::${a['name']}
                        %endif
                        %for p in a['params']:
                        ${p['type']}${p['open']}
                        %for j, v in enumerate(p['values']):
                        %if (j+1) != len(p['values']):
                            ${v['value']},
                        %else:
                            ${v['value']}
                        %endif
                        %endfor
                        ${p['close']},
                        %endfor
                        %if (i+1) != len(event['pc']['pcact']):
                        %if len(a['params']) != 0:
                        )),
                        %else:
                        ),
                        %endif
                        %endif
                        %endfor
                    std::vector<SetSpeedEvent>{
                    %for pcevt in event['pc']['pcevts']:
                    SetSpeedEvent{\
                    ${indent(genSSE(event=pcevt), 6)}\
                    },
                    %endfor
                    %else:
                    SetSpeedEvent{\
                    ${indent(genSSE(event=event), 6)}
                    %endif
                    %if ('pc' in event) and (event['pc'] is not None):
                    }
                        %if len(event['pc']['pcact'][-1]['params']) != 0:
                        )),
                        %else:
                        ),
                        %endif
                        },
                        TimerConf{
                            ${event['pc']['pctime']['interval']},
                            ${event['pc']['pctime']['type']}
                        },
                        std::vector<Signal>{
                        %for s in event['pc']['pcsigs']:
                            Signal{
                                %if ('match' in s) and \
                                    (s['match'] is not None):
                                match::${s['match']}(
                                %for i, mp in enumerate(s['mparams']):
                                %if (i+1) != len(s['mparams']):
                                "${mp}",
                                %else:
                                "${mp}"
                                %endif
                                %endfor
                                ),
                                %else:
                                "",
                                %endif
                                make_handler(\
                                ${indent(genHandler(sig=s), 9)}\
                                )
                            },
                        %endfor
                        }
                    %endif
                    },
                %endfor
                }
            },
        %endfor
        }
    },
%endfor
};
OpenPOWER on IntegriCloud