aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@pelagicore.com>2018-10-16 15:20:36 +0200
committerDominik Holland <dominik.holland@pelagicore.com>2018-10-29 13:21:57 +0000
commit26e8742261c9b516814edd78217a93db74d43802 (patch)
treec3a17bb72cab61ddbe2648503590cf34ea41798c
parent6760408aa2d78fb3dd1a471f787d3c2f4e53e00f (diff)
ivigenerator: Autogenerate QML simulation files
Default QML simulation files are now generated in the "backend_simulator" template. The new generated QML files also use the IviSimulator API to load it's simulation data from a JSON file. Task-number: AUTOSUITE-629 Change-Id: I956de319cd3731ad5ee32025da348e25be4e238f Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
-rw-r--r--src/tools/ivigenerator/ivigenerator.pro2
-rw-r--r--src/tools/ivigenerator/templates_backend_simulator.yaml4
-rw-r--r--src/tools/ivigenerator/templates_backend_simulator/backend.qml.tpl73
-rw-r--r--src/tools/ivigenerator/templates_backend_simulator/data.qrc.tpl4
-rw-r--r--src/tools/ivigenerator/templates_backend_simulator/plugin.cpp.tpl4
-rw-r--r--src/tools/ivigenerator/templates_backend_simulator/plugin.qml.tpl49
6 files changed, 134 insertions, 2 deletions
diff --git a/src/tools/ivigenerator/ivigenerator.pro b/src/tools/ivigenerator/ivigenerator.pro
index 8d02e5d..16af6dd 100644
--- a/src/tools/ivigenerator/ivigenerator.pro
+++ b/src/tools/ivigenerator/ivigenerator.pro
@@ -35,6 +35,7 @@ templates_frontend.path = $$[QT_HOST_BINS]/ivigenerator/templates_frontend
templates_backend_simulator.files += \
templates_backend_simulator/backend.cpp.tpl \
templates_backend_simulator/backend.h.tpl \
+ templates_backend_simulator/backend.qml.tpl \
templates_backend_simulator/pagingmodel.h.tpl \
templates_backend_simulator/pagingmodel.cpp.tpl \
templates_backend_simulator/plugin.cpp.tpl \
@@ -42,6 +43,7 @@ templates_backend_simulator.files += \
templates_backend_simulator/plugin.json \
templates_backend_simulator/plugin.pri.tpl \
templates_backend_simulator/plugin.pro \
+ templates_backend_simulator/plugin.qml.tpl \
templates_backend_simulator/simulation_data.json.tpl \
templates_backend_simulator/data.qrc.tpl
templates_backend_simulator.path = $$[QT_HOST_BINS]/ivigenerator/templates_backend_simulator
diff --git a/src/tools/ivigenerator/templates_backend_simulator.yaml b/src/tools/ivigenerator/templates_backend_simulator.yaml
index 9544372..f9749d5 100644
--- a/src/tools/ivigenerator/templates_backend_simulator.yaml
+++ b/src/tools/ivigenerator/templates_backend_simulator.yaml
@@ -4,6 +4,8 @@ generate_rules:
template_file: "plugin.h.tpl"
- dest_file: "{{module.module_name|lower}}plugin.cpp"
template_file: "plugin.cpp.tpl"
+ - dest_file: "{{module.module_name|lower}}_simulation.qml"
+ template_file: "plugin.qml.tpl"
- dest_file: "{{module.module_name|lower}}.json"
template_file: "plugin.json"
- dest_file: "{{module.module_name|lower}}_simulation_data.json"
@@ -17,5 +19,7 @@ generate_rules:
template_file: 'backend.h.tpl'
- dest_file: '{{interface|lower}}backend.cpp'
template_file: 'backend.cpp.tpl'
+ - dest_file: '{{interface|upperfirst}}Simulation.qml'
+ template_file: 'backend.qml.tpl'
struct_rules:
diff --git a/src/tools/ivigenerator/templates_backend_simulator/backend.qml.tpl b/src/tools/ivigenerator/templates_backend_simulator/backend.qml.tpl
new file mode 100644
index 0000000..0107549
--- /dev/null
+++ b/src/tools/ivigenerator/templates_backend_simulator/backend.qml.tpl
@@ -0,0 +1,73 @@
+{#
+# Copyright (C) 2018 Pelagicore AG
+# Contact: https://www.qt.io/licensing/
+#
+# This file is part of the QtIvi module of the Qt Toolkit.
+#
+# $QT_BEGIN_LICENSE:LGPL-QTAS$
+# Commercial License Usage
+# Licensees holding valid commercial Qt Automotive Suite licenses may use
+# this file in accordance with the commercial license agreement provided
+# with the Software or, alternatively, in accordance with the terms
+# contained in a written agreement between you and The Qt Company. For
+# licensing terms and conditions see https://www.qt.io/terms-conditions.
+# For further information use the contact form at https://www.qt.io/contact-us.
+#
+# GNU Lesser General Public License Usage
+# Alternatively, this file may be used under the terms of the GNU Lesser
+# General Public License version 3 as published by the Free Software
+# Foundation and appearing in the file LICENSE.LGPL3 included in the
+# packaging of this file. Please review the following information to
+# ensure the GNU Lesser General Public License version 3 requirements
+# will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+#
+# GNU General Public License Usage
+# Alternatively, this file may be used under the terms of the GNU
+# General Public License version 2.0 or (at your option) the GNU General
+# Public license version 3 or any later version approved by the KDE Free
+# Qt Foundation. The licenses are as published by the Free Software
+# Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+# included in the packaging of this file. Please review the following
+# information to ensure the GNU General Public License requirements will
+# be met: https://www.gnu.org/licenses/gpl-2.0.html and
+# https://www.gnu.org/licenses/gpl-3.0.html.
+#
+# $QT_END_LICENSE$
+#
+# SPDX-License-Identifier: LGPL-3.0
+#}
+
+import QtQuick 2.0
+import {{module.name|lower}}.simulation 1.0
+
+{% set interface_zoned = interface.tags.config and interface.tags.config.zoned %}
+
+QtObject {
+ property var settings : IviSimulator.findData(IviSimulator.simulationData, "{{interface}}")
+ property var backend : {{interface|upperfirst}}Backend {
+
+
+ function initialize() {
+ print("{{interface}}Simulation INITIALIZE")
+ IviSimulator.initializeDefault(settings, backend)
+ Base.initialize()
+ }
+
+{% if interface_zoned %}
+ function availableZones() {
+ return settings.zones;
+ }
+{% endif %}
+
+{% for property in interface.properties %}
+ function {{property|setter_name}}({{property}}) {
+ if (IviSimulator.checkSettings({{property}}, settings["{{property}}"])) {
+ console.log("SIMULATION {{ property }} changed to: " + {{property}});
+ backend.{{property}} = {{property}}
+ } else {
+ setError("SIMULATION changing {{property}} is not possible: provided: " + {{property}} + "constraint: " + IviSimulator.constraint_string(settings["{{property}}"]));
+ }
+ }
+{% endfor %}
+ }
+}
diff --git a/src/tools/ivigenerator/templates_backend_simulator/data.qrc.tpl b/src/tools/ivigenerator/templates_backend_simulator/data.qrc.tpl
index cd3e510..bb0bb18 100644
--- a/src/tools/ivigenerator/templates_backend_simulator/data.qrc.tpl
+++ b/src/tools/ivigenerator/templates_backend_simulator/data.qrc.tpl
@@ -39,5 +39,9 @@
<RCC>
<qresource prefix="/simulation">
<file>{{module.module_name|lower}}_simulation_data.json</file>
+ <file>{{module.module_name|lower}}_simulation.qml</file>
+{% for iface in module.interfaces %}
+ <file>{{iface|upperfirst}}Simulation.qml</file>
+{% endfor %}
</qresource>
</RCC>
diff --git a/src/tools/ivigenerator/templates_backend_simulator/plugin.cpp.tpl b/src/tools/ivigenerator/templates_backend_simulator/plugin.cpp.tpl
index 0a421bb..39b67ae 100644
--- a/src/tools/ivigenerator/templates_backend_simulator/plugin.cpp.tpl
+++ b/src/tools/ivigenerator/templates_backend_simulator/plugin.cpp.tpl
@@ -79,10 +79,10 @@ extern {{class}}::InterfaceBuilder {{module.tags.config.interfaceBuilder}};
{% if module.tags.config_simulator and module.tags.config_simulator.simulationFile %}
{% set simulationFile = module.tags.config_simulator.simulationFile %}
{% else %}
-{% set simulationFile = module.module_name|lower + '_simulation.qml' %}
+{% set simulationFile = "qrc:///simulation/" + module.module_name|lower + '_simulation.qml' %}
{% endif %}
m_simulationEngine->loadSimulationData(QStringLiteral(":/simulation/{{module.module_name|lower}}_simulation_data.json"));
- m_simulationEngine->loadSimulation(QStringLiteral("{{simulationFile}}"));
+ m_simulationEngine->loadSimulation(QUrl(QStringLiteral("{{simulationFile}}")));
{% endif %}
}
diff --git a/src/tools/ivigenerator/templates_backend_simulator/plugin.qml.tpl b/src/tools/ivigenerator/templates_backend_simulator/plugin.qml.tpl
new file mode 100644
index 0000000..5e6c233
--- /dev/null
+++ b/src/tools/ivigenerator/templates_backend_simulator/plugin.qml.tpl
@@ -0,0 +1,49 @@
+{#
+# Copyright (C) 2018 Pelagicore AG
+# Contact: https://www.qt.io/licensing/
+#
+# This file is part of the QtIvi module of the Qt Toolkit.
+#
+# $QT_BEGIN_LICENSE:LGPL-QTAS$
+# Commercial License Usage
+# Licensees holding valid commercial Qt Automotive Suite licenses may use
+# this file in accordance with the commercial license agreement provided
+# with the Software or, alternatively, in accordance with the terms
+# contained in a written agreement between you and The Qt Company. For
+# licensing terms and conditions see https://www.qt.io/terms-conditions.
+# For further information use the contact form at https://www.qt.io/contact-us.
+#
+# GNU Lesser General Public License Usage
+# Alternatively, this file may be used under the terms of the GNU Lesser
+# General Public License version 3 as published by the Free Software
+# Foundation and appearing in the file LICENSE.LGPL3 included in the
+# packaging of this file. Please review the following information to
+# ensure the GNU Lesser General Public License version 3 requirements
+# will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+#
+# GNU General Public License Usage
+# Alternatively, this file may be used under the terms of the GNU
+# General Public License version 2.0 or (at your option) the GNU General
+# Public license version 3 or any later version approved by the KDE Free
+# Qt Foundation. The licenses are as published by the Free Software
+# Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+# included in the packaging of this file. Please review the following
+# information to ensure the GNU General Public License requirements will
+# be met: https://www.gnu.org/licenses/gpl-2.0.html and
+# https://www.gnu.org/licenses/gpl-3.0.html.
+#
+# $QT_END_LICENSE$
+#
+# SPDX-License-Identifier: LGPL-3.0
+#}
+
+import QtQuick 2.0
+import {{module.name|lower}}.simulation 1.0
+
+QtObject {
+{% for iface in module.interfaces %}
+ property var {{iface|lower}} : {{iface|upperfirst}}Simulation {
+ id: {{iface|lower}}
+ }
+{% endfor %}
+}