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
|
{#
# Copyright (C) 2021 The Qt Company Ltd.
# Copyright (C) 2019 Luxoft Sweden AB
# Copyright (C) 2018 Pelagicore AG
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#}
{% include "common/generated_comment.qml.jinja" %}
import QtQuick
import {{module|qml_type}}.simulation
{% set interface_zoned = interface.tags.config and interface.tags.config.zoned %}
{{interface|upperfirst}}Backend {
id: backend
property QtObject d: QtObject {
id: d
property var settings: IfSimulator.findData(IfSimulator.simulationData, "{{interface}}")
property bool defaultInitialized: false
property LoggingCategory qLc{{interface|upperfirst}}: LoggingCategory {
name: "{{module|qml_type|lower}}.simulation.{{interface|lower}}backend"
}
}
function initialize() {
console.log(d.qLc{{interface|upperfirst}}, "INITIALIZE")
if (!d.defaultInitialized) {
IfSimulator.initializeDefault(d.settings, backend)
d.defaultInitialized = true
}
Base.initialize()
}
{% if interface_zoned %}
function availableZones() {
return d.settings.zones;
}
{% endif %}
{% for property in interface.properties %}
{% if interface_zoned %}
function {{property|setter_name}}({{property}}, zone) {
if ("{{property}}" in d.settings && !IfSimulator.checkSettings(d.settings["{{property}}"], {{property}}, zone)) {
console.error(d.qLc{{interface|upperfirst}}, "SIMULATION changing {{property}} is not possible: provided: " + {{property}} + " constraint: " + IfSimulator.constraint(d.settings["{{property}}"], zone));
return;
}
if (zone) {
console.log(d.qLc{{interface|upperfirst}}, "SIMULATION {{ property }} for zone: " + zone + " changed to: " + {{property}});
backend.zones[zone].{{property}} = {{property}}
} else {
console.log(d.qLc{{interface|upperfirst}}, "SIMULATION {{ property }} changed to: " + {{property}});
backend.{{property}} = {{property}}
}
}
{% else %}
function {{property|setter_name}}({{property}}) {
if ("{{property}}" in d.settings && !IfSimulator.checkSettings(d.settings["{{property}}"], {{property}})) {
console.error(d.qLc{{interface|upperfirst}}, "SIMULATION changing {{property}} is not possible: provided: " + {{property}} + " constraint: " + IfSimulator.constraint(d.settings["{{property}}"]));
return;
}
console.log(d.qLc{{interface|upperfirst}}, "SIMULATION {{ property }} changed to: " + {{property}});
backend.{{property}} = {{property}}
}
{% endif %}
{% endfor %}
}
|