summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mkspecs/features/ivigenerator.prf13
-rw-r--r--src/ivicore/configure.json14
-rw-r--r--src/src.pro12
-rwxr-xr-xsrc/tools/ivigenerator/generate.py15
-rw-r--r--src/tools/ivigenerator/ivigenerator.pro30
-rw-r--r--src/tools/ivigenerator/templates_backend_simulator/backend.cpp.tpl44
-rw-r--r--src/tools/ivigenerator/templates_backend_simulator/backend.h.tpl12
-rw-r--r--src/tools/ivigenerator/templates_backend_simulator/plugin.pri.tpl4
-rw-r--r--src/tools/ivigenerator/templates_control_panel/interface.cpp.tpl96
-rw-r--r--src/tools/ivigenerator/templates_control_panel/interface.h.tpl18
-rw-r--r--src/tools/ivigenerator/templates_control_panel/interface.qml.tpl41
-rw-r--r--src/tools/ivigenerator/templates_control_panel/main.cpp.tpl2
-rw-r--r--src/tools/ivigenerator/templates_control_panel/module.cpp.tpl34
-rw-r--r--src/tools/ivigenerator/templates_control_panel/module.h.tpl8
-rw-r--r--src/tools/ivigenerator/templates_control_panel/ui.pri.tpl1
-rw-r--r--src/tools/ivigenerator/templates_frontend/module.cpp.tpl17
-rw-r--r--src/tools/ivigenerator/templates_frontend/module.h.tpl5
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro9
18 files changed, 321 insertions, 54 deletions
diff --git a/mkspecs/features/ivigenerator.prf b/mkspecs/features/ivigenerator.prf
index 65c497e..74cac03 100644
--- a/mkspecs/features/ivigenerator.prf
+++ b/mkspecs/features/ivigenerator.prf
@@ -30,6 +30,10 @@ QFACE_BASE_NAME = $$replace(QFACE_FILE, .qface, )
QFACE_YAML = $$QFACE_ABS_PWD/$${QFACE_BASE_NAME}.yaml
OTHER_FILES += $$QFACE_FILE
+# The 'click' library used by the generator needs to have a utf8 locale setup.
+win32: ENV = chcp 65001 &&
+else: ENV = LC_ALL="en_US.UTF-8"
+
# Detect whether we are using the feature inside the qtivi repository
VIRTUALENV_PATH = $$[QT_HOST_BINS]/ivigenerator/qtivi_qface_virtualenv
INTERNAL_VIRTUALENV_PATH = $$QTIVI_BUILD_ROOT/src/tools/ivigenerator/qtivi_qface_virtualenv
@@ -40,20 +44,15 @@ QTEST_ENVIRONMENT = $$upper($$(QTEST_ENVIRONMENT))
# Because of the two stage build of COIN, it might not exist, but the installed version should still be there
!isEmpty(QTIVI_BUILD_ROOT):!equals(QTEST_ENVIRONMENT, CI):!qtConfig(system-ivigenerator) {
VIRTUALENV_PATH = $$INTERNAL_VIRTUALENV_PATH
-}
-
-!isEmpty(QTIVI_BUILD_ROOT):!equals(QTEST_ENVIRONMENT, CI):!qtConfig(system-ivigenerator) {
IVI_GENERATOR_PATH = $$QTIVI_ROOT/src/tools/ivigenerator
+ win32: ENV += set IVIGENERATOR_CONFIG="$$shell_path($$QTIVI_BUILD_ROOT/src/tools/ivigenerator/.config)" &&
+ else: ENV += IVIGENERATOR_CONFIG="$$shell_path($$QTIVI_BUILD_ROOT/src/tools/ivigenerator/.config)"
}
win32: VIRTUALENV_PYTHON = $$VIRTUALENV_PATH/Scripts/python.exe
else: VIRTUALENV_PYTHON = $$VIRTUALENV_PATH/bin/python
IVI_GENERATOR = $$VIRTUALENV_PYTHON $$IVI_GENERATOR_PATH/generate.py
-# The 'click' library used by the generator needs to have a utf8 locale setup.
-win32: ENV = chcp 65001 &&
-else: ENV = LC_ALL="en_US.UTF-8"
-
# TODO make this work with multiple input files, or only support one QFACE_SOURCE
# Although this could be extra_compiler it is a normal EXTRA_TARGET for a reason.
# In the debug_and_release configuration, we want to have the generator executed
diff --git a/src/ivicore/configure.json b/src/ivicore/configure.json
index f7465a1..ece6c51 100644
--- a/src/ivicore/configure.json
+++ b/src/ivicore/configure.json
@@ -55,6 +55,11 @@
"label": "Only build the host tools",
"condition": "input.host-tools-only == 'yes'",
"output": [ "privateFeature" ]
+ },
+ "simulator": {
+ "label": "QtSimulator Support",
+ "condition": "module.simulator",
+ "output": [ "publicFeature" ]
}
},
@@ -65,6 +70,12 @@
"message": "Cannot build the IVI Generator because its dependencies are not satisfied.
The IVI Generator provides tooling to generate source code out of IDL files.
Make sure that python3 and its 'virtualenv' packages are installed."
+ },
+ {
+ "type": "warning",
+ "condition": "!features.simulator",
+ "message": "Cannot enable the QtSimulator Support because the QtSimulator module is not installed.
+The QtSimulator Support is needed for the communication between the simulation backends and its control panel(controller)."
}
],
@@ -81,7 +92,8 @@ Make sure that python3 and its 'virtualenv' packages are installed."
"python3-virtualenv"
]
},
- "ivigenerator"
+ "ivigenerator",
+ "simulator"
]
}
]
diff --git a/src/src.pro b/src/src.pro
index 46efc1c..bb21da8 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -30,7 +30,7 @@ QT_FOR_CONFIG += geniviextras-private ivicore ivicore-private
qtConfig(dlt): SUBDIRS += geniviextras
}
-!qtConfig(geniviextras-only): {
+!qtConfig(geniviextras-only) {
qtConfig(ivigenerator) {
!qtConfig(system-ivigenerator) {
src_tools_ivigenerator.subdir = tools/ivigenerator
@@ -38,10 +38,12 @@ QT_FOR_CONFIG += geniviextras-private ivicore ivicore-private
SUBDIRS += src_tools_ivigenerator
}
- src_tools_ivivehiclefunctions-controller.subdir = tools/vehiclefunctions-controller
- !qtConfig(system-ivigenerator): src_tools_ivivehiclefunctions-controller.depends += sub-ivigenerator
- src_tools_ivivehiclefunctions-controller.target = sub-ivivehiclefunctions-controller
- SUBDIRS += src_tools_ivivehiclefunctions-controller
+ qtConfig(simulator) {
+ src_tools_ivivehiclefunctions-controller.subdir = tools/vehiclefunctions-controller
+ !qtConfig(system-ivigenerator): src_tools_ivivehiclefunctions-controller.depends += sub-ivigenerator
+ src_tools_ivivehiclefunctions-controller.target = sub-ivivehiclefunctions-controller
+ SUBDIRS += src_tools_ivivehiclefunctions-controller
+ }
}
}
diff --git a/src/tools/ivigenerator/generate.py b/src/tools/ivigenerator/generate.py
index 157be8b..283fef9 100755
--- a/src/tools/ivigenerator/generate.py
+++ b/src/tools/ivigenerator/generate.py
@@ -57,7 +57,7 @@ log = logging.getLogger(__file__)
Filters.classPrefix = ''
-QT_AS_VERSION = 2.0
+builtin_config = {}
IVI_DEFAULT_TEMPLATES = ['frontend', 'backend_simulator', 'generation_validator', 'control_panel']
def tag_by_path(symbol, path, default_value=False):
@@ -316,7 +316,7 @@ def json_domain(properties):
"""
data = {}
if len(properties):
- data["iviVersion"] = QT_AS_VERSION
+ data["iviVersion"] = builtin_config["VERSION"]
for property in properties:
if 'config_simulator' in property.tags:
for p in ['range', 'domain', 'minimum', 'maximum']:
@@ -521,7 +521,7 @@ def generate(tplconfig, moduleConfig, src, dst):
srcFile = os.path.basename(src[0])
srcBase = os.path.splitext(srcFile)[0]
- ctx = {'dst': dst, 'qtASVersion': QT_AS_VERSION, 'srcFile':srcFile, 'srcBase':srcBase}
+ ctx = {'dst': dst, 'qtASVersion': builtin_config["VERSION"], 'srcFile':srcFile, 'srcBase':srcBase, 'features': builtin_config["FEATURES"]}
gen_config = yaml.load(open(here / '{0}.yaml'.format(os.path.basename(tplconfig))))
for module in system.modules:
log.debug('generate code for module %s', module)
@@ -578,6 +578,15 @@ def run(format, moduleConfig, src, dst):
def app(src, dst, format, reload, module, validation_info):
"""Takes several files or directories as src and generates the code
in the given dst directory."""
+
+ global builtin_config
+ builtin_config_path = here / '.config'
+ if 'IVIGENERATOR_CONFIG' in os.environ:
+ builtin_config_path = os.environ['IVIGENERATOR_CONFIG']
+ builtin_config = yaml.load(open(builtin_config_path))
+ if not 'VERSION' in builtin_config or not 'FEATURES' in builtin_config:
+ sys.exit("Invalid builtin config")
+
if reload:
script = '{0} {1} {2}'.format(Path(__file__).abspath(), ' '.join(src), dst)
monitor(src, script)
diff --git a/src/tools/ivigenerator/ivigenerator.pro b/src/tools/ivigenerator/ivigenerator.pro
index 15edf97..e56bc41 100644
--- a/src/tools/ivigenerator/ivigenerator.pro
+++ b/src/tools/ivigenerator/ivigenerator.pro
@@ -1,5 +1,7 @@
TEMPLATE = aux
+QT_FOR_CONFIG += ivicore
+
!contains(CONFIG, no_internal_qface): include(qface_internal_build.pri)
# Make sure to only build this once in a debug_and_release config
@@ -71,13 +73,19 @@ templates_control_panel.path = $$[QT_HOST_BINS]/ivigenerator/templates_control_p
generator.files += \
generate.py \
+ $$OUT_PWD/.config \
templates_frontend.yaml \
templates_backend_simulator.yaml \
templates_generation_validator.yaml \
- templates_control_panel.yaml
+
generator.path = $$[QT_HOST_BINS]/ivigenerator
-INSTALLS += templates_frontend templates_backend_simulator templates_generation_validator templates_control_panel generator
+qtConfig(simulator) {
+ generator.files += templates_control_panel.yaml
+ INSTALLS += templates_control_panel
+}
+
+INSTALLS += templates_frontend templates_backend_simulator templates_generation_validator generator
# Ensure files are installed to qtbase for non-prefixed builds
!force_independent:if(!debug_and_release|!build_all|CONFIG(release, debug|release)) {
@@ -93,3 +101,21 @@ INSTALLS += templates_frontend templates_backend_simulator templates_generation_
QMAKE_EXTRA_COMPILERS += $${install_target}_copy
}
}
+
+defineTest(createConfig) {
+ write_file($$OUT_PWD/.config, $$list("---"))
+ for(var, ARGS) {
+ isEmpty($$var):out = "$$var: ~"
+ else:count($$var, 1):out = "$$var: \"$$first($$var)\""
+ else {
+ out = "$$var:"
+ for(val, $$var):out += " - \"$$val\""
+ out=$$join(out, "$$escape_expand(\\n)")
+ }
+ write_file($$OUT_PWD/.config, out, append)
+ }
+}
+
+VERSION = $$MODULE_VERSION
+FEATURES = $${QT.ivicore.enabled_features}
+createConfig(VERSION, FEATURES)
diff --git a/src/tools/ivigenerator/templates_backend_simulator/backend.cpp.tpl b/src/tools/ivigenerator/templates_backend_simulator/backend.cpp.tpl
index 8516302..2c8f98d 100644
--- a/src/tools/ivigenerator/templates_backend_simulator/backend.cpp.tpl
+++ b/src/tools/ivigenerator/templates_backend_simulator/backend.cpp.tpl
@@ -51,6 +51,10 @@
#include <QDebug>
+{% if 'simulator' in features %}
+#include <QtSimulator>
+{% endif %}
+
QT_BEGIN_NAMESPACE
/*!
@@ -65,6 +69,9 @@ QT_BEGIN_NAMESPACE
, m_{{ property }}({{property|default_value}})
{% endif %}
{% endfor %}
+{% if 'simulator' in features %}
+ , mWorker(nullptr)
+{% endif %}
{
{{module.module_name}}Module::registerTypes();
@@ -77,7 +84,6 @@ QT_BEGIN_NAMESPACE
{% endif %}
{% endfor %}
m_zoneMap.insert("{{zone_id}}", {{zone_name}}Zone);
-
{% endfor %}
}
@@ -133,6 +139,21 @@ void {{class}}::initialize()
{% endfor %}
}
{% endif %}
+
+{% if 'simulator' in features %}
+ qDebug() << "CONNECTING";
+ mConnection = new QSimulatorConnection("{{interface}}", QVersionNumber(1, 0, 0));
+ mConnection->addPeerInfo("versionInfo", "1.0.0");
+ mConnection->addPeerInfo("name", "{{class}}");
+ QString hostname = QSimulatorConnection::simulatorHostName(false);
+ if (hostname.isEmpty())
+ hostname = QLatin1String("localhost");
+ mWorker = mConnection->connectToHost(hostname, 0xbeef+3);
+ if (!mWorker)
+ return;
+
+ mWorker->addReceiver(this);
+{% endif %}
}
{% for property in interface.properties %}
@@ -169,6 +190,10 @@ void {{class}}::set{{property|upperfirst}}({{ property|parameter_type }})
m_zoneMap[zone].{{property}} = {{property}};
emit {{ property }}Changed({{property}}, zone);
+{% if 'simulator' in features %}
+ if (mWorker)
+ mWorker->call("{{property|setter_name}}", {{property}}, zone);
+{% endif %}
{% else %}
if ({% if interface_zoned %}!zone.isEmpty() || {%endif%}m_{{ property }} == {{property}})
return;
@@ -177,6 +202,10 @@ void {{class}}::set{{property|upperfirst}}({{ property|parameter_type }})
m_{{property}} = {{property}};
emit {{property}}Changed(m_{{property}}{% if interface_zoned%}, QString(){% endif %});
+{% if 'simulator' in features %}
+ if (mWorker)
+ mWorker->call("{{property|setter_name}}", {{property}}{% if interface_zoned%}, QString(){% endif %});
+{% endif %}
{% endif %}
{% endif %}
}
@@ -206,6 +235,19 @@ void {{class}}::set{{property|upperfirst}}({{ property|parameter_type }})
{% if interface_zoned %}
Q_UNUSED(zone);
{% endif %}
+{% set function_parameters = operation.parameters|join(', ') %}
+{% if interface_zoned %}
+{% if operation.parameters|length %}
+{% set function_parameters = function_parameters + ', ' %}
+{% endif %}
+{% set function_parameters = function_parameters + 'zone' %}
+{% endif%}
+
+{% if 'simulator' in features %}
+ if (mWorker)
+ mWorker->call("{{operation}}" {% if function_parameters is not equalto "" %}, {{function_parameters}} {% endif %});
+{% endif %}
+
qWarning() << "Not implemented!";
return {{operation|default_value}};
}
diff --git a/src/tools/ivigenerator/templates_backend_simulator/backend.h.tpl b/src/tools/ivigenerator/templates_backend_simulator/backend.h.tpl
index c854379..85529fc 100644
--- a/src/tools/ivigenerator/templates_backend_simulator/backend.h.tpl
+++ b/src/tools/ivigenerator/templates_backend_simulator/backend.h.tpl
@@ -53,8 +53,15 @@
QT_BEGIN_NAMESPACE
+{% if 'simulator' in features %}
+class QSimulatorConnection;
+class QSimulatorConnectionWorker;
+{% endif %}
+
class {{class}} : public {{class}}Interface
{
+ Q_OBJECT
+
public:
explicit {{class}}(QObject *parent = nullptr);
~{{class}}();
@@ -64,6 +71,7 @@ public:
{% endif %}
void initialize() override;
+public Q_SLOTS:
{% for property in interface.properties %}
{% if not property.readonly and not property.const %}
{% if interface_zoned %}
@@ -103,6 +111,10 @@ protected:
};
QMap<QString,ZoneBackend> m_zoneMap;
{% endif %}
+{% if 'simulator' in features %}
+ QSimulatorConnection *mConnection;
+ QSimulatorConnectionWorker *mWorker;
+{% endif %}
};
QT_END_NAMESPACE
diff --git a/src/tools/ivigenerator/templates_backend_simulator/plugin.pri.tpl b/src/tools/ivigenerator/templates_backend_simulator/plugin.pri.tpl
index c8f10e2..7140507 100644
--- a/src/tools/ivigenerator/templates_backend_simulator/plugin.pri.tpl
+++ b/src/tools/ivigenerator/templates_backend_simulator/plugin.pri.tpl
@@ -41,6 +41,10 @@
## Do not edit! All changes made to it will be lost.
#############################################################################
+{% if 'simulator' in features %}
+QT += simulator
+{% endif %}
+
HEADERS += \
{% for interface in module.interfaces %}
$$PWD/{{interface|lower}}backend.h \
diff --git a/src/tools/ivigenerator/templates_control_panel/interface.cpp.tpl b/src/tools/ivigenerator/templates_control_panel/interface.cpp.tpl
index a80ba9c..245dbbe 100644
--- a/src/tools/ivigenerator/templates_control_panel/interface.cpp.tpl
+++ b/src/tools/ivigenerator/templates_control_panel/interface.cpp.tpl
@@ -45,6 +45,7 @@
#include <QQmlEngine>
#include <QDebug>
+#include <QtSimulator>
namespace {
const QString INITIAL_MAIN_ZONE = "MainZone";
@@ -69,13 +70,46 @@ QT_BEGIN_NAMESPACE
{% for zone_name, zone_id in zones.items() %}
addZone("{{zone_id}}");
{% endfor %}
-}
{% else %}
{{class}}::{{class}}(QObject *parent)
: QObject(parent)
{
-}
{% endif %}
+ QVariantMap peerInfo({{ '{{' }}"control_panel",""{{ '}}' }});
+ QSimulatorServer *server = {{module.module_name}}Module::simulationServer();
+ server->registerServer("{{interface}}", QVersionNumber(1, 0, 0), peerInfo, [=](QSimulatorConnectionWorker *client) {
+ m_worker = client;
+ connect(m_worker, &QSimulatorConnectionWorker::disconnected, this, [=]() {
+ qDebug() << "DISCONNECTED";
+ //Deleting it on the mainZone is enough as QPointer does the rest of the work for us.
+ m_worker = 0;
+ });
+ m_worker->addReceiver(this);
+ qDebug() << "connected: " << client->peerInfo();
+{% if interface.tags.config.zoned %}
+ auto i = m_zoneHash.constBegin();
+ while (i != m_zoneHash.constEnd()) {
+ i.value()->m_worker = client;
+{% for property in interface.properties %}
+{% set function_name = property|setter_name %}
+{% if property.readonly or property.const %}
+{% set function_name = property.name + 'Changed' %}
+{% endif %}
+ m_worker->call("{{function_name}}", i.value()->m_{{property}}, i.value()->m_currentZone);
+{% endfor %}
+ ++i;
+ }
+{% else %}
+{% for property in interface.properties %}
+{% set function_name = property|setter_name %}
+{% if property.readonly or property.const %}
+{% set function_name = property.name + 'Changed' %}
+{% endif %}
+ m_worker->call("{{function_name}}", m_{{property}});
+{% endfor %}
+{% endif %}
+ });
+}
{{class}}::~{{class}}()
{
@@ -102,6 +136,7 @@ void {{class}}::addZone(const QString &newZone)
return;
{{class}} *zoneObject = new {{class}}(newZone, this);
+ zoneObject->m_worker = m_worker;
m_zoneHash.insert(newZone, zoneObject);
m_zoneMap.insert(newZone, QVariant::fromValue(zoneObject));
@@ -136,20 +171,65 @@ void {{class}}::{{property|setter_name}}({{ property|parameter_type }})
{
if (m_{{property}} == {{property}})
return;
- m_{{property}} = {{property}};
- emit {{property}}Changed({{property}});
+ m_{{property}} = {{property}};
+ emit {{property}}Changed({{property}});
+ auto w = worker();
+ if (w)
+{% set function_name = property|setter_name %}
+{% if property.readonly or property.const %}
+{% set function_name = property.name + 'Changed' %}
+{% endif %}
+{% if interface.tags.config.zoned %}
+ w->call("{{function_name}}", {{property}}, m_currentZone);
+{% else %}
+ w->call("{{function_name}}", {{property}});
+{% endif %}
}
-{% endfor %}
+{% if interface.tags.config.zoned %}
+void {{class}}::{{property|setter_name}}({{property|parameter_type}}, const QString &zone)
+{
+ QString z = zone;
+ if (z.isEmpty())
+ z = INITIAL_MAIN_ZONE;
-{%- for operation in interface.operations %}
+ if (!m_zoneMap.contains(z)) {
+ return;
+ }
-{{operation|return_type}} {{class}}::{{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){% if operation.const %} const{% endif %}
+ // the setter cannot be used as it would update the simulation connection
+ // and by this create a async loop
+ if (m_zoneHash[z]->m_{{property}} == {{property}})
+ return;
+ m_zoneHash[z]->m_{{property}} = {{property}};
+ emit m_zoneHash[z]->{{property}}Changed({{property}});
+}
+{% endif %}
+
+{% endfor %}
+{% for signal in interface.signals %}
+void {{class}}::{{signal}}({{signal.parameters|map('parameter_type')|join(', ')}})
{
- return {{operation|default_type_value}};
+ auto w = worker();
+ if (w)
+ w->call("{{signal}}", {{signal.parameters|join(', ')}}{% if interface.tags.config.zoned %}, m_currentZone{% endif %});
}
{% endfor %}
+QSimulatorConnectionWorker *{{class}}::worker()
+{
+{% if interface.tags.config.zoned %}
+ if (m_currentZone.isEmpty())
+ return m_worker;
+ {{class}}* globalZone = qobject_cast<{{class}}*>(parent());
+ if (globalZone)
+ return globalZone->m_worker;
+ return nullptr;
+{% else %}
+ return m_worker;
+{% endif %}
+}
+
QT_END_NAMESPACE
diff --git a/src/tools/ivigenerator/templates_control_panel/interface.h.tpl b/src/tools/ivigenerator/templates_control_panel/interface.h.tpl
index 7a4731b..d242efb 100644
--- a/src/tools/ivigenerator/templates_control_panel/interface.h.tpl
+++ b/src/tools/ivigenerator/templates_control_panel/interface.h.tpl
@@ -55,6 +55,7 @@ QT_BEGIN_NAMESPACE
class {{class}}Private;
class {{class}}BackendInterface;
+class QSimulatorConnectionWorker;
class {{exportsymbol}} {{class}} : public QObject {
Q_OBJECT
@@ -88,26 +89,30 @@ public:
{% endfor %}
public Q_SLOTS:
-{% for operation in interface.operations %}
- {{operation|return_type}} {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){% if operation.const %} const{% endif %};
-{% endfor %}
{% for property in interface.properties %}
void {{property|setter_name}}({{property|parameter_type}});
+{% if interface_zoned %}
+ void {{property|setter_name}}({{property|parameter_type}}, const QString &zone);
+{% endif %}
+{% endfor %}
+{% for signal in interface.signals %}
+ void {{signal}}({{signal.parameters|map('parameter_type')|join(', ')}});
{% endfor %}
Q_SIGNALS:
+{% for operation in interface.operations %}
+ {{operation|return_type}} {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){% if operation.const %} const{% endif %};
+{% endfor %}
{% if interface_zoned %}
void currentZoneChanged();
void zonesChanged();
{% endif %}
-{% for signal in interface.signals %}
- void {{signal}}({{signal.parameters|map('parameter_type')|join(', ')}});
-{% endfor %}
{% for property in interface.properties %}
void {{property}}Changed({{property|parameter_type}});
{% endfor %}
private:
+ QSimulatorConnectionWorker *worker();
{% for property in interface.properties %}
{{ property|return_type }} m_{{ property }};
{% endfor %}
@@ -116,6 +121,7 @@ private:
QVariantMap m_zoneMap;
QString m_currentZone;
{% endif %}
+ QSimulatorConnectionWorker *m_worker;
};
QT_END_NAMESPACE
diff --git a/src/tools/ivigenerator/templates_control_panel/interface.qml.tpl b/src/tools/ivigenerator/templates_control_panel/interface.qml.tpl
index 5256b1f..c00013c 100644
--- a/src/tools/ivigenerator/templates_control_panel/interface.qml.tpl
+++ b/src/tools/ivigenerator/templates_control_panel/interface.qml.tpl
@@ -120,55 +120,58 @@ Flickable {
{{property|qml_control(backend_obj)}}
}
{% endfor %}
-{% if interface.operations|count %}
-
+{% if interface.signals|count %}
ToolSeparator {
orientation: Qt.Horizontal
}
Text {
- text: "Operations"
+ text: "Signals"
}
-{% for operation in interface.operations %}
- // Button for operation call
+{% for signal in interface.signals %}
+ // Button for signal call
RowLayout {
spacing: 2
height: 20
Button {
- text: "{{operation}}"
+ text: "{{signal}}"
}
-{% for param in operation.parameters %}
+{% for param in signal.parameters %}
Text {
text: "{{param}}"
}
{{param|qml_control(backend_obj)}}
{% endfor%}
- }
-{% endfor %}
+ }
+{% endfor %}
{% endif %}
{% if interface.operations|count %}
+
ToolSeparator {
orientation: Qt.Horizontal
}
Text {
- text: "Signals"
+ text: "Operations"
}
-{% for signal in interface.signals %}
- // Button for signal emission
- Row {
+{% for operation in interface.operations %}
+ // Button for operation call
+ RowLayout {
spacing: 2
height: 20
-
Button {
- text: "{{signal}}"
+ text: "{{operation}}"
+ }
+{% for param in operation.parameters %}
+ Text {
+ text: "{{param}}"
}
-{% for param in signal.parameters %}
{{param|qml_control(backend_obj)}}
-{% endfor %}
- }
-{% endfor %}
+
+{% endfor%}
+ }
+{% endfor %}
{% endif %}
Item {
//spacer
diff --git a/src/tools/ivigenerator/templates_control_panel/main.cpp.tpl b/src/tools/ivigenerator/templates_control_panel/main.cpp.tpl
index 006f67f..5a3ae52 100644
--- a/src/tools/ivigenerator/templates_control_panel/main.cpp.tpl
+++ b/src/tools/ivigenerator/templates_control_panel/main.cpp.tpl
@@ -42,6 +42,7 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
+#include "{{module.module_name|lower}}module.h"
{% for iface in module.interfaces %}
#include "{{iface|lower}}.h"
{% endfor %}
@@ -51,6 +52,7 @@ int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
+ {{module.module_name}}Module::registerTypes();
{% for interface in module.interfaces %}
{{interface}}::registerQmlTypes(QLatin1String("QtIvi.ControlPanel"), 1, 0,
QLatin1String("{{interface|qml_type}}"));
diff --git a/src/tools/ivigenerator/templates_control_panel/module.cpp.tpl b/src/tools/ivigenerator/templates_control_panel/module.cpp.tpl
index 4b5ed63..66978f9 100644
--- a/src/tools/ivigenerator/templates_control_panel/module.cpp.tpl
+++ b/src/tools/ivigenerator/templates_control_panel/module.cpp.tpl
@@ -45,6 +45,9 @@
#include "{{interface|lower}}.h"
{% endfor %}
#include <QQmlEngine>
+#include <QDebug>
+#include <QDataStream>
+#include <QtSimulator>
QT_BEGIN_NAMESPACE
@@ -70,6 +73,7 @@ void {{class}}::registerTypes()
{
{% for enum in module.enums %}
qRegisterMetaType<{{class}}::{{enum|flag_type}}>();
+ qRegisterMetaTypeStreamOperators<{{class}}::{{enum|flag_type}}>();
{% endfor %}
{% for struct in module.structs %}
qRegisterMetaType<{{struct}}>();
@@ -87,4 +91,34 @@ void {{class}}::registerQmlTypes(const QString& uri, int majorVersion, int minor
{% endfor %}
}
+QSimulatorServer *{{class}}::simulationServer()
+{
+ static QSimulatorServer *server = nullptr;
+
+ if (!server) {
+ server = new QSimulatorServer;
+ QString error;
+ server->startServer(0xbeef+3, &error);
+ if (!error.isEmpty())
+ qWarning("ERROR: %s", qPrintable(error));
+ }
+
+ return server;
+}
+
+{% for enum in module.enums %}
+QDataStream &operator<<(QDataStream &out, {{class}}::{{enum|flag_type}} var)
+{
+ out << (int)var;
+ return out;
+}
+QDataStream &operator>>(QDataStream &in, {{class}}::{{enum|flag_type}} &var)
+{
+ int temp;
+ in >> temp;
+ var = ({{class}}::{{enum|flag_type}})temp;
+ return in;
+}
+{% endfor %}
+
QT_END_NAMESPACE
diff --git a/src/tools/ivigenerator/templates_control_panel/module.h.tpl b/src/tools/ivigenerator/templates_control_panel/module.h.tpl
index 1bc7466..bd23ccc 100644
--- a/src/tools/ivigenerator/templates_control_panel/module.h.tpl
+++ b/src/tools/ivigenerator/templates_control_panel/module.h.tpl
@@ -49,6 +49,7 @@
#include <QObject>
QT_BEGIN_NAMESPACE
+class QSimulatorServer;
class {{exportsymbol}} {{class}} : public QObject {
Q_OBJECT
@@ -72,8 +73,15 @@ public:
static void registerTypes();
static void registerQmlTypes(const QString& uri, int majorVersion = 1, int minorVersion = 0);
+
+ static QSimulatorServer *simulationServer();
};
+{% for enum in module.enums %}
+QDataStream &operator<<(QDataStream &out, {{class}}::{{enum|flag_type}} var);
+QDataStream &operator>>(QDataStream &in, {{class}}::{{enum|flag_type}} &var);
+{% endfor %}
+
QT_END_NAMESPACE
#endif // {{oncedefine}}
diff --git a/src/tools/ivigenerator/templates_control_panel/ui.pri.tpl b/src/tools/ivigenerator/templates_control_panel/ui.pri.tpl
index 0309fea..f96eacc 100644
--- a/src/tools/ivigenerator/templates_control_panel/ui.pri.tpl
+++ b/src/tools/ivigenerator/templates_control_panel/ui.pri.tpl
@@ -20,3 +20,4 @@ HEADERS += \
$$PWD/{{module.module_name|lower}}global.h
RESOURCES += $$PWD/qml.qrc
+QT *= simulator
diff --git a/src/tools/ivigenerator/templates_frontend/module.cpp.tpl b/src/tools/ivigenerator/templates_frontend/module.cpp.tpl
index 191acae..2ce7b9b 100644
--- a/src/tools/ivigenerator/templates_frontend/module.cpp.tpl
+++ b/src/tools/ivigenerator/templates_frontend/module.cpp.tpl
@@ -46,6 +46,7 @@
#include "{{interface|lower}}.h"
{% endfor %}
#include <QQmlEngine>
+#include <QDataStream>
QT_BEGIN_NAMESPACE
@@ -83,6 +84,7 @@ void {{class}}::registerTypes()
{
{% for enum in module.enums %}
qRegisterMetaType<{{class}}::{{enum|flag_type}}>();
+ qRegisterMetaTypeStreamOperators<{{class}}::{{enum|flag_type}}>();
{% endfor %}
{% for struct in module.structs %}
qRegisterMetaType<{{struct}}>();
@@ -100,4 +102,19 @@ void {{class}}::registerQmlTypes(const QString& uri, int majorVersion, int minor
{% endfor %}
}
+{% for enum in module.enums %}
+QDataStream &operator<<(QDataStream &out, {{class}}::{{enum|flag_type}} var)
+{
+ out << (int)var;
+ return out;
+}
+QDataStream &operator>>(QDataStream &in, {{class}}::{{enum|flag_type}} &var)
+{
+ int temp;
+ in >> temp;
+ var = ({{class}}::{{enum|flag_type}})temp;
+ return in;
+}
+{% endfor %}
+
QT_END_NAMESPACE
diff --git a/src/tools/ivigenerator/templates_frontend/module.h.tpl b/src/tools/ivigenerator/templates_frontend/module.h.tpl
index c7cadb7..6520091 100644
--- a/src/tools/ivigenerator/templates_frontend/module.h.tpl
+++ b/src/tools/ivigenerator/templates_frontend/module.h.tpl
@@ -78,6 +78,11 @@ public:
static void registerQmlTypes(const QString& uri, int majorVersion = 1, int minorVersion = 0);
};
+{% for enum in module.enums %}
+QDataStream &operator<<(QDataStream &out, {{class}}::{{enum|flag_type}} var);
+QDataStream &operator>>(QDataStream &in, {{class}}::{{enum|flag_type}} &var);
+{% endfor %}
+
QT_END_NAMESPACE
#endif // {{oncedefine}}
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro
index 84e7275..8922ad6 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro
@@ -1,9 +1,14 @@
TEMPLATE = subdirs
+QT_FOR_CONFIG += ivicore
+
SUBDIRS = frontend \
backend_simulator \
- validator \
- control_panel \
+ validator
+
+qtConfig(simulator) {
+ SUBDIRS += control_panel
+}
backend_simulator.depends = frontend
validator.depends = frontend