This repository was archived by the owner on Feb 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspecial-sensor-declaration.liquid
More file actions
61 lines (61 loc) · 2.09 KB
/
special-sensor-declaration.liquid
File metadata and controls
61 lines (61 loc) · 2.09 KB
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
{%
assign className = currentClass.friendlyName | downcase | underscore_spaces %}{%
assign parentName = currentClass.inheritance | downcase | underscore_spaces %}{%
for line in currentClass.description %}
// {{ line }}{%
endfor %}
class {{ className }} : public {{ parentName }}
{
public:
{{className}}(address_type address = INPUT_AUTO);
{% for prop in currentClass.propertyValues %}{%
assign prefix = prop.propertyName | downcase | underscore_spaces %}{%
for value in prop.values %}{%
for line in value.description %}
// {{ line }}{%
endfor %}{%
assign cppName = value.name | downcase | underscore_non_wc %}
static constexpr char {{ prefix }}_{{cppName}}[] = "{{ value.name }}";
{% endfor %}{%
endfor %}
{% for mapping in currentClass.sensorValueMappings %}{%
assign name = mapping.name | downcase | underscore_spaces %}{%
for line in mapping.description %}
// {{ line }}{%
endfor %}{%
assign mode = mapping.requiredMode | downcase | underscore_non_wc %}{%
assign num_values = mapping.type | size %}{%
if num_values == 1 %}{%
assign type = mapping.type[0] %}{%
assign reader = 'value' %}{%
if type == 'float' %}{%
assign reader = 'float_value' %}{%
elsif type == 'boolean' %}{%
assign type = 'bool' %}{%
endif %}
{{ type }} {{ name }}(bool do_set_mode = true) {
if (do_set_mode) set_mode(mode_{{ mode }});
return {{ reader }}({{ mapping.sourceValue[0] }});
}
{% else %}
std::tuple<{%
for cur_type in mapping.type %}{%
assign type = cur_type %}{%
if type == 'boolean' %}{%
assign type = 'bool' %}{%
endif %}{{ type }}{%
unless forloop.last %}, {% endunless %}{%
endfor %}> {{ name }}(bool do_set_mode = true) {
if (do_set_mode) set_mode(mode_{{ mode }});
return std::make_tuple( {%
for value_index in mapping.sourceValue %}{%
assign reader = 'value' %}{%
if mapping.type[forloop.index] == 'float' %}{%
assign reader = 'float_value' %}{%
endif %}{{ reader }}({{ value_index }}){%
unless forloop.last %}, {% endunless %}{%
endfor %} );
}
{% endif %}{%
endfor %}
};