From 7892fcc0c0bbe4f971f698130bf1d3a39a3c9d80 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Mon, 30 Mar 2015 12:35:22 +0200 Subject: Introduced 'make docs' support To make it work properly the modules needed to be renamed to match the qt modules naming convention. For this is also renamed the folders of the modules to make things easier --- .../climate_widget/climate_widget.pro | 2 +- src/core/core.pro | 36 -- src/core/qtiviabstractfeature.cpp | 150 -------- src/core/qtiviabstractfeature.h | 76 ---- src/core/qtiviglobal.h | 31 -- src/core/qtiviproxyserviceobject_p.cpp | 34 -- src/core/qtiviproxyserviceobject_p.h | 30 -- src/core/qtiviserviceinterface.h | 28 -- src/core/qtiviservicemanager.cpp | 291 -------------- src/core/qtiviservicemanager.h | 46 --- src/core/qtiviservicemanager_p.h | 63 --- src/core/qtiviserviceobject.cpp | 51 --- src/core/qtiviserviceobject.h | 35 -- src/core/qtivisimplediscoverymodel.cpp | 131 ------- src/core/qtivisimplediscoverymodel.h | 56 --- src/imports/core/core.pro | 2 +- src/imports/vehiclefunctions/vehiclefunctions.pro | 2 +- src/ivicore/doc/qtivicore.qdocconf | 52 +++ src/ivicore/ivicore.pro | 39 ++ src/ivicore/qtiviabstractfeature.cpp | 150 ++++++++ src/ivicore/qtiviabstractfeature.h | 76 ++++ src/ivicore/qtiviglobal.h | 31 ++ src/ivicore/qtiviproxyserviceobject_p.cpp | 34 ++ src/ivicore/qtiviproxyserviceobject_p.h | 30 ++ src/ivicore/qtiviserviceinterface.h | 28 ++ src/ivicore/qtiviservicemanager.cpp | 291 ++++++++++++++ src/ivicore/qtiviservicemanager.h | 46 +++ src/ivicore/qtiviservicemanager_p.h | 63 +++ src/ivicore/qtiviserviceobject.cpp | 51 +++ src/ivicore/qtiviserviceobject.h | 35 ++ src/ivicore/qtivisimplediscoverymodel.cpp | 131 +++++++ src/ivicore/qtivisimplediscoverymodel.h | 56 +++ .../doc/qtivivehiclefunctions.qdocconf | 52 +++ src/ivivehiclefunctions/ivivehiclefunctions.pro | 28 ++ src/ivivehiclefunctions/qtiviclimatecontrol.cpp | 425 +++++++++++++++++++++ src/ivivehiclefunctions/qtiviclimatecontrol.h | 208 ++++++++++ .../qtiviclimatecontrolbackendinterface.h | 68 ++++ .../qtivivehiclefunctionsglobal.h | 31 ++ .../climate_simulator/climate_simulator.json | 3 + .../climate_simulator/climate_simulator.pro | 28 ++ .../climate_simulator/climatecontrolbackend.cpp | 242 ++++++++++++ .../climate_simulator/climatecontrolbackend.h | 69 ++++ .../climate_simulator/climateplugin.cpp | 36 ++ .../climate_simulator/climateplugin.h | 34 ++ .../ivivehiclefunctions/ivivehiclefunctions.pro | 13 + src/plugins/plugins.pro | 2 +- .../climate_simulator/climate_simulator.json | 3 - .../climate_simulator/climate_simulator.pro | 28 -- .../climate_simulator/climatecontrolbackend.cpp | 242 ------------ .../climate_simulator/climatecontrolbackend.h | 69 ---- .../climate_simulator/climateplugin.cpp | 36 -- .../climate_simulator/climateplugin.h | 34 -- src/plugins/vehiclefunctions/vehiclefunctions.pro | 13 - src/src.pro | 4 +- src/vehiclefunctions/qtiviclimatecontrol.cpp | 425 --------------------- src/vehiclefunctions/qtiviclimatecontrol.h | 208 ---------- .../qtiviclimatecontrolbackendinterface.h | 68 ---- src/vehiclefunctions/qtivivehiclefunctionsglobal.h | 31 -- src/vehiclefunctions/vehiclefunctions.pro | 27 -- sync.profile | 4 +- .../core/servicemanagertest/servicemanagertest.pro | 2 +- .../climatecontroltest/climatecontroltest.pro | 2 +- 62 files changed, 2360 insertions(+), 2252 deletions(-) delete mode 100644 src/core/core.pro delete mode 100644 src/core/qtiviabstractfeature.cpp delete mode 100644 src/core/qtiviabstractfeature.h delete mode 100644 src/core/qtiviglobal.h delete mode 100644 src/core/qtiviproxyserviceobject_p.cpp delete mode 100644 src/core/qtiviproxyserviceobject_p.h delete mode 100644 src/core/qtiviserviceinterface.h delete mode 100644 src/core/qtiviservicemanager.cpp delete mode 100644 src/core/qtiviservicemanager.h delete mode 100644 src/core/qtiviservicemanager_p.h delete mode 100644 src/core/qtiviserviceobject.cpp delete mode 100644 src/core/qtiviserviceobject.h delete mode 100644 src/core/qtivisimplediscoverymodel.cpp delete mode 100644 src/core/qtivisimplediscoverymodel.h create mode 100644 src/ivicore/doc/qtivicore.qdocconf create mode 100644 src/ivicore/ivicore.pro create mode 100644 src/ivicore/qtiviabstractfeature.cpp create mode 100644 src/ivicore/qtiviabstractfeature.h create mode 100644 src/ivicore/qtiviglobal.h create mode 100644 src/ivicore/qtiviproxyserviceobject_p.cpp create mode 100644 src/ivicore/qtiviproxyserviceobject_p.h create mode 100644 src/ivicore/qtiviserviceinterface.h create mode 100644 src/ivicore/qtiviservicemanager.cpp create mode 100644 src/ivicore/qtiviservicemanager.h create mode 100644 src/ivicore/qtiviservicemanager_p.h create mode 100644 src/ivicore/qtiviserviceobject.cpp create mode 100644 src/ivicore/qtiviserviceobject.h create mode 100644 src/ivicore/qtivisimplediscoverymodel.cpp create mode 100644 src/ivicore/qtivisimplediscoverymodel.h create mode 100644 src/ivivehiclefunctions/doc/qtivivehiclefunctions.qdocconf create mode 100644 src/ivivehiclefunctions/ivivehiclefunctions.pro create mode 100644 src/ivivehiclefunctions/qtiviclimatecontrol.cpp create mode 100644 src/ivivehiclefunctions/qtiviclimatecontrol.h create mode 100644 src/ivivehiclefunctions/qtiviclimatecontrolbackendinterface.h create mode 100644 src/ivivehiclefunctions/qtivivehiclefunctionsglobal.h create mode 100644 src/plugins/ivivehiclefunctions/climate_simulator/climate_simulator.json create mode 100644 src/plugins/ivivehiclefunctions/climate_simulator/climate_simulator.pro create mode 100644 src/plugins/ivivehiclefunctions/climate_simulator/climatecontrolbackend.cpp create mode 100644 src/plugins/ivivehiclefunctions/climate_simulator/climatecontrolbackend.h create mode 100644 src/plugins/ivivehiclefunctions/climate_simulator/climateplugin.cpp create mode 100644 src/plugins/ivivehiclefunctions/climate_simulator/climateplugin.h create mode 100644 src/plugins/ivivehiclefunctions/ivivehiclefunctions.pro delete mode 100644 src/plugins/vehiclefunctions/climate_simulator/climate_simulator.json delete mode 100644 src/plugins/vehiclefunctions/climate_simulator/climate_simulator.pro delete mode 100644 src/plugins/vehiclefunctions/climate_simulator/climatecontrolbackend.cpp delete mode 100644 src/plugins/vehiclefunctions/climate_simulator/climatecontrolbackend.h delete mode 100644 src/plugins/vehiclefunctions/climate_simulator/climateplugin.cpp delete mode 100644 src/plugins/vehiclefunctions/climate_simulator/climateplugin.h delete mode 100644 src/plugins/vehiclefunctions/vehiclefunctions.pro delete mode 100644 src/vehiclefunctions/qtiviclimatecontrol.cpp delete mode 100644 src/vehiclefunctions/qtiviclimatecontrol.h delete mode 100644 src/vehiclefunctions/qtiviclimatecontrolbackendinterface.h delete mode 100644 src/vehiclefunctions/qtivivehiclefunctionsglobal.h delete mode 100644 src/vehiclefunctions/vehiclefunctions.pro diff --git a/examples/vehiclefunctions/climate_widget/climate_widget.pro b/examples/vehiclefunctions/climate_widget/climate_widget.pro index 6d0302f..6115199 100644 --- a/examples/vehiclefunctions/climate_widget/climate_widget.pro +++ b/examples/vehiclefunctions/climate_widget/climate_widget.pro @@ -8,7 +8,7 @@ # written consent of Pelagicore AG. ################################################################################################## -QT += core gui QtIVICore QtIVIVehicleFunctions +QT += core gui ivicore ivivehiclefunctions greaterThan(QT_MAJOR_VERSION, 4): QT += widgets diff --git a/src/core/core.pro b/src/core/core.pro deleted file mode 100644 index 58458f5..0000000 --- a/src/core/core.pro +++ /dev/null @@ -1,36 +0,0 @@ -################################################################################################## -# Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. -# -# This software, including documentation, is protected by copyright controlled by Pelagicore AG. -# All rights reserved. Copying, including reproducing, storing, adapting or translating, any or -# all of this material requires prior written consent of Pelagicore AG Corporation. This material -# also contains confidential information which may not be disclosed to others without the prior -# written consent of Pelagicore AG. -################################################################################################## - -MODULE = QtIVICore -TARGET = $$MODULE -QT = core qml -CONFIG += c++11 -VERSION = 1.0.0 - -CMAKE_MODULE_TESTS = '-' - -HEADERS += \ - qtiviservicemanager.h \ - qtiviserviceinterface.h \ - qtiviservicemanager_p.h \ - qtiviserviceobject.h \ - qtiviabstractfeature.h \ - qtivisimplediscoverymodel.h \ - qtiviglobal.h \ - qtiviproxyserviceobject_p.h - -SOURCES += \ - qtiviservicemanager.cpp \ - qtiviserviceobject.cpp \ - qtiviabstractfeature.cpp \ - qtivisimplediscoverymodel.cpp \ - qtiviproxyserviceobject_p.cpp - -load(qt_module) diff --git a/src/core/qtiviabstractfeature.cpp b/src/core/qtiviabstractfeature.cpp deleted file mode 100644 index 4bef086..0000000 --- a/src/core/qtiviabstractfeature.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#include "qtiviabstractfeature.h" - -#include "qtiviserviceobject.h" -#include "qtiviservicemanager.h" - -/*! - * \class QtIVIAbstractFeature - * \brief The QtIVIAbstractFeature is the base class for all QtIVI Featues - * - * QtIVIAbstractFeature is the base class for the front facing API towards the Developer. - * The QtIVIAbstractFeature provides you with a way to automatically connect to a Backend implementing - * your needed interface. This discovery is started by using the startAutoDiscovery() function. - * - * Once the auto discovery is done, it can be checked whether a backend has been found by using the - * isValid function. - * - * The auto discovery gives you a easy way to automatically connect to the right backend implementation. - * If you don't want to use the auto discovery, it's also possible to use QtIVIServiceManager to retrieve - * all Backends and search manually for the right one and connect it to the QtIVIAbstractFeature by calling - * setServiceObject() - * - * QtIVIAbstractFeature is a abstract base class which needs to be subclassed to create a API for your - * Feature. - * - * \chapter Subclassing - * - * When subclassing QtIVIAbstractFeature you must provide implementations of the following functions: - * \list - * \li acceptServiceObject() - * \li connectToServiceObject() - * \li disconnectFromServiceObject() - * \li clearServiceObject() - * \endlist - * - * Once a QtIVIServiceObject has be set, either by auto discovery or by manually setting it the acceptServiceObject() - * function will be called to make sure the QtIVIServiceObject provides everything which is needed by the Feature. - * - * If the interface provides signals you need to do all the connect statements in connectToServiceObject() and - * disconnect them again in disconnectFromServiceObject(). - * - * clearServiceObject() will be called once the Feature doesn't have a connection to a ServiceObject anymore and should - * reset it's state to sane defaults - */ - -QtIVIAbstractFeature::QtIVIAbstractFeature(const QString &interface, bool autoDiscovery, QObject *parent) - : QObject(parent) - , m_interface(interface) - , m_serviceObject(0) - , m_autoDiscovery(autoDiscovery) -{ - //Detect whether we got created from within QML - //If not call the autoDiscovery -} - -QtIVIAbstractFeature::~QtIVIAbstractFeature() -{ - -} - -void QtIVIAbstractFeature::setServiceObject(QtIVIServiceObject *so) -{ - if (m_serviceObject) { - disconnectFromServiceObject(m_serviceObject); - disconnect(so, SIGNAL(destroyed()), this, SLOT(serviceObjectDestroyed())); - } - - m_serviceObject = 0; - - if (!acceptServiceObject(so)) { - clearServiceObject(); - qWarning("ServiceObject is not accepted"); - } - - m_serviceObject = so; - emit serviceObjectChanged(); - emit isValidChanged(isValid()); - connectToServiceObject(m_serviceObject); - connect(so, SIGNAL(destroyed()), this, SLOT(serviceObjectDestroyed())); -} - -void QtIVIAbstractFeature::setAutoDiscovery(bool autoDiscovery) -{ - if (m_autoDiscovery == autoDiscovery) - return; - - m_autoDiscovery = autoDiscovery; - emit autoDiscoveryChanged(autoDiscovery); -} - -void QtIVIAbstractFeature::classBegin() -{ - -} - -void QtIVIAbstractFeature::componentComplete() -{ - if (m_autoDiscovery) { - startAutoDiscovery(); - } -} - -QtIVIServiceObject *QtIVIAbstractFeature::serviceObject() const -{ - return m_serviceObject; -} - -bool QtIVIAbstractFeature::autoDiscovery() const -{ - return m_autoDiscovery; -} - -void QtIVIAbstractFeature::startAutoDiscovery() -{ - setAutoDiscovery(true); - - QtIVIServiceManager* serviceManager = QtIVIServiceManager::instance(); - QList serviceObjects = serviceManager->findServiceByInterface(m_interface); - - if (serviceObjects.isEmpty()) { - qWarning() << "There is no backend implementing" << m_interface << "."; - return; - } - - if (serviceObjects.count() > 1) - qWarning() << "There is more than one backend implementing" << m_interface << "."; - - setServiceObject(serviceObjects.at(0)); -} - -bool QtIVIAbstractFeature::isValid() const -{ - return m_serviceObject != 0; -} - -void QtIVIAbstractFeature::serviceObjectDestroyed() -{ - m_serviceObject = 0; - clearServiceObject(); - emit serviceObjectChanged(); -} diff --git a/src/core/qtiviabstractfeature.h b/src/core/qtiviabstractfeature.h deleted file mode 100644 index 60e8dd5..0000000 --- a/src/core/qtiviabstractfeature.h +++ /dev/null @@ -1,76 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#ifndef QTIVIABSTRACTFEATURE_H -#define QTIVIABSTRACTFEATURE_H - -#include -#include - -#include - -class QtIVIServiceObject; - -class Q_QTIVICORE_EXPORT QtIVIAbstractFeature : public QObject, public QQmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QQmlParserStatus) - - //This makes only sense if the Object is loaded directly - //Maybe use a attached property instead ??? Feature.simulation = true; Feature.autoDiscovery = false - //Q_PROPERTY(bool simulation READ simulation WRITE setSimulation NOTIFY simulationChanged) - Q_PROPERTY(bool autoDiscovery READ autoDiscovery WRITE setAutoDiscovery NOTIFY autoDiscoveryChanged) - Q_PROPERTY(QtIVIServiceObject* serviceObject READ serviceObject WRITE setServiceObject NOTIFY serviceObjectChanged) - Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged) - -public: - - explicit QtIVIAbstractFeature(const QString &interface, bool autoDiscovery = true, QObject *parent = 0); - virtual ~QtIVIAbstractFeature(); - - QtIVIServiceObject *serviceObject() const; - bool autoDiscovery() const; - bool isValid() const; - - void startAutoDiscovery(); - -public slots: - void setServiceObject(QtIVIServiceObject *so); - void setAutoDiscovery(bool autoDiscovery); - -signals: - void serviceObjectChanged(); - void autoDiscoveryChanged(bool autoDiscovery); - void isValidChanged(bool arg); - -protected: - - //USE acceptService instead of the interface constructor, also in the simplediscoverymodel - virtual bool acceptServiceObject(QtIVIServiceObject*) = 0; - virtual void connectToServiceObject(QtIVIServiceObject*) = 0; - virtual void disconnectFromServiceObject(QtIVIServiceObject*) = 0; - virtual void clearServiceObject() = 0; - - //TODO This doesn't work for the C++ usecases we should use the constructor there instead - // Also this means a qml dependency in the core, do we want that ? - virtual void classBegin(); - virtual void componentComplete(); - -private slots: - void serviceObjectDestroyed(); - -private: - - QString m_interface; - QtIVIServiceObject* m_serviceObject; - bool m_autoDiscovery; -}; - -#endif // QTIVIABSTRACTFEATURE_H diff --git a/src/core/qtiviglobal.h b/src/core/qtiviglobal.h deleted file mode 100644 index 00f90f8..0000000 --- a/src/core/qtiviglobal.h +++ /dev/null @@ -1,31 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#ifndef QTIVIGLOBAL_H -#define QTIVIGLOBAL_H - -#include - -QT_BEGIN_NAMESPACE - -#ifndef QT_STATIC -# if defined(QT_BUILD_QTIVICORE_LIB) -# define Q_QTIVICORE_EXPORT Q_DECL_EXPORT -# else -# define Q_QTIVICORE_EXPORT Q_DECL_IMPORT -# endif -#else -# define Q_QTIVICORE_EXPORT -#endif - -QT_END_NAMESPACE - -#endif // QTIVIGLOBAL_H - diff --git a/src/core/qtiviproxyserviceobject_p.cpp b/src/core/qtiviproxyserviceobject_p.cpp deleted file mode 100644 index 7fc7e9e..0000000 --- a/src/core/qtiviproxyserviceobject_p.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#include "qtiviproxyserviceobject_p.h" - -QtIVIProxyServiceObject::QtIVIProxyServiceObject(QtIVIServiceInterface *interface) - : QtIVIServiceObject() - , m_interface(interface) -{ - -} - -QtIVIProxyServiceObject::~QtIVIProxyServiceObject() -{ - -} - -QStringList QtIVIProxyServiceObject::interfaces() const -{ - return m_interface->interfaces(); -} - -QObject *QtIVIProxyServiceObject::interfaceInstance(const QString &interface) const -{ - return m_interface->interfaceInstance(interface); -} - diff --git a/src/core/qtiviproxyserviceobject_p.h b/src/core/qtiviproxyserviceobject_p.h deleted file mode 100644 index f0b8bdf..0000000 --- a/src/core/qtiviproxyserviceobject_p.h +++ /dev/null @@ -1,30 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#ifndef QTIVIPROXYSERVICEOBJECT_H -#define QTIVIPROXYSERVICEOBJECT_H - -#include "qtiviserviceobject.h" - -class QtIVIProxyServiceObject : public QtIVIServiceObject -{ -public: - QtIVIProxyServiceObject(QtIVIServiceInterface* interface); - virtual ~QtIVIProxyServiceObject(); - - virtual QStringList interfaces() const; - virtual QObject* interfaceInstance(const QString& interface) const; - -private: - - QtIVIServiceInterface* m_interface; -}; - -#endif // QTIVIPROXYSERVICEOBJECT_H diff --git a/src/core/qtiviserviceinterface.h b/src/core/qtiviserviceinterface.h deleted file mode 100644 index bf0a807..0000000 --- a/src/core/qtiviserviceinterface.h +++ /dev/null @@ -1,28 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#ifndef QTIVISERVICEINTERFACE_H -#define QTIVISERVICEINTERFACE_H - -#include - -class QtIVIServiceInterface { - -public: - - virtual QStringList interfaces() const = 0; - virtual QObject* interfaceInstance(const QString& interface) const = 0; -}; - -Q_DECLARE_INTERFACE(QtIVIServiceInterface, "com.pelagicore.QtIVIServiceInterface") -Q_DECLARE_METATYPE(QtIVIServiceInterface*) - -#endif // QTIVISERVICEINTERFACE_H - diff --git a/src/core/qtiviservicemanager.cpp b/src/core/qtiviservicemanager.cpp deleted file mode 100644 index f7046ca..0000000 --- a/src/core/qtiviservicemanager.cpp +++ /dev/null @@ -1,291 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#include "qtiviservicemanager.h" - -#include "qtiviproxyserviceobject_p.h" -#include "qtiviservicemanager_p.h" - -#include -#include -#include -#include -#include -#include -#include - -#define QTIVI_PLUGIN_DIRECTORY "qtivi" - -QtIVIServiceManagerPrivate::QtIVIServiceManagerPrivate(QtIVIServiceManager *parent) : QObject(parent), q_ptr(parent) -{ -} - -QList QtIVIServiceManagerPrivate::findServiceByInterface(const QString &interface) -{ - QList list; - - foreach (Backend *backend, m_backends) { - - if (backend->metaData[QLatin1String("interfaces")].toStringList().contains(interface)) { - QtIVIServiceInterface *backendInterface = loadServiceBackendInterface(backend); - list.append(new QtIVIProxyServiceObject(backendInterface)); - } - } - - return list; -} - -void QtIVIServiceManagerPrivate::searchPlugins() -{ - bool found = false; - foreach (const QString &pluginDir, QCoreApplication::libraryPaths()) { - - QDir dir(pluginDir); - QString path = pluginDir + QDir::separator() + QLatin1Literal(QTIVI_PLUGIN_DIRECTORY); - //Check whether the directory exists - if (!QDir(path).exists(QStringLiteral("."))) - continue; - - QStringList plugins = QDir(path).entryList(QDir::Files); - foreach (const QString &pluginPath, plugins) { - QString fileName = QDir::cleanPath(path + QLatin1Char('/') + pluginPath); - QPluginLoader loader(dir.absoluteFilePath(fileName)); - registerBackend(loader.fileName(), loader.metaData()); - found = true; - } - } - if (!found) - { - qWarning() << "No plugins found in search path: " << QCoreApplication::libraryPaths().join(QLatin1String(":")); - } -} - -void QtIVIServiceManagerPrivate::registerBackend(const QString fileName, const QJsonObject metaData) -{ - QVariantMap backendMetaData = metaData.value(QLatin1String("MetaData")).toVariant().toMap(); - - if (backendMetaData[QLatin1String("interfaces")].isNull() || backendMetaData[QLatin1String("interfaces")].toList().isEmpty()) { - qDebug("PluginManager - Malformed metaData in '%s'. MetaData must contain a list of interfaces", qPrintable(fileName)); - return; - } - - //TODO check for other metaData like name etc. - - backendMetaData.insert(QLatin1String("fileName"), fileName); - - Backend* backend = new Backend; - backend->metaData = backendMetaData; - backend->interface = 0; - backend->interfaceObject = 0; - backend->loader = 0; - addBackend(backend); -} - -bool QtIVIServiceManagerPrivate::registerBackend(QObject *serviceBackendInterface, const QStringList &interfaces) -{ - if (interfaces.isEmpty()) { - return false; - } - - // Verify that the object implements the ServiceBackendInterface - QtIVIServiceInterface *interface = qobject_cast(serviceBackendInterface); - if (!interface) { - return false; - } - - QVariantMap metaData = QVariantMap(); - - metaData.insert(QLatin1String("interfaces"), interfaces); - - Backend *backend = new Backend; - backend->metaData = metaData; - backend->interface = interface; - backend->interfaceObject = serviceBackendInterface; - backend->loader = 0; - - addBackend(backend); - return true; -} - -void QtIVIServiceManagerPrivate::unloadAllBackends() -{ - Q_Q(QtIVIServiceManager); - - q->beginResetModel(); - for(int i=0; iloader) { - backend->loader->unload(); - delete backend->loader; - } else if (backend->interfaceObject) { - delete backend->interfaceObject; - } - - delete backend; - } - m_backends.clear(); - q->endResetModel(); -} - -void QtIVIServiceManagerPrivate::addBackend(Backend *backend) -{ - Q_Q(QtIVIServiceManager); - - q->beginInsertRows(QModelIndex(), m_backends.count(), m_backends.count()); - m_backends.append(backend); - q->endInsertRows(); - - foreach (const QString &interface, backend->metaData[QLatin1String("interfaces")].toStringList()) { - m_interfaceNames.insert(interface); - } -} - -QtIVIServiceInterface *QtIVIServiceManagerPrivate::loadServiceBackendInterface(struct Backend *backend) -{ - if (backend->interface) { - return backend->interface; - } - - QPluginLoader *loader = new QPluginLoader(backend->metaData[QLatin1String("fileName")].toString()); - QObject *plugin = loader->instance(); - if (plugin) { - - QtIVIServiceInterface *backendInterface = qobject_cast(plugin); - if (backendInterface) { - backend->interface = backendInterface; - backend->loader = loader; - return backend->interface; - } else { - qDebug("ServiceManager::serviceObjects - failed to cast to interface from '%s'", qPrintable(loader->fileName())); - } - - } else { - qDebug("ServiceManager::serviceObjects - failed to load '%s'", qPrintable(loader->fileName())); - } - - //Only delete the Loader right away if we didn't succeeded with loading the interfaces. - delete loader; - - return 0; -} - -/*! - * \class QtIVIServiceManager - * \brief QtIVIServiceManager provides the Backends to QtIVIAbstractFeature - * - * QtIVIServiceManager is the heart of QtIVI and provides you a easy way to detect what - * Backends and interfaces are available. - * - * By default QtIVIServiceManager reads the metaData of all plugins within the "qtivi" folder - * of your plugin path. The plugin itself will be loaded once it's explictly requested by - * the developer by using findServiceByInterface() - * - * The registerService() function can be used to add Backend classes without putting them into - * a plugin. - */ -QtIVIServiceManager::QtIVIServiceManager() - : QAbstractListModel(0) - , d_ptr(new QtIVIServiceManagerPrivate(this)) -{ - d_ptr->searchPlugins(); -} - -QtIVIServiceManager *QtIVIServiceManager::instance() -{ - static QtIVIServiceManager* instance = new QtIVIServiceManager(); - return instance; -} - -QtIVIServiceManager::~QtIVIServiceManager() -{ - -} - -/*! - * Returns a List of Backends which implementing the specified \a interface. - */ -QList QtIVIServiceManager::findServiceByInterface(const QString &interface) -{ - Q_D(QtIVIServiceManager); - return d->findServiceByInterface(interface); -} - -/*! - * Register a backend. The provided \a serviceBackendInterface must implement the ServiceBackendInterface else - * the registration will fail. - * - * \param serviceBackendInterface an QObject instance which implements the ServiceBackendInterface - * \param interfaces a list with interfaces which the backend handles. At least one interface is required - * \return true if the backend was successfully registered else false - * \sa ServiceBackendInterface - */ -bool QtIVIServiceManager::registerService(QObject *serviceBackendInterface, const QStringList &interfaces) -{ - Q_D(QtIVIServiceManager); - return d->registerBackend(serviceBackendInterface, interfaces); -} - -void QtIVIServiceManager::unloadAllBackends() -{ - Q_D(QtIVIServiceManager); - return d->unloadAllBackends(); -} - -/*! - * Returns true if the specified \a interface has been registered. - - * \param interface the interface - * \return true if the specified \a interface has been registered else false - */ -bool QtIVIServiceManager::hasInterface(const QString &interface) const -{ - Q_D(const QtIVIServiceManager); - return d->m_interfaceNames.contains(interface); -} - -/*! - * Implements QAbstractListModel::rowCount() - * - * \param parent the model index, typically an empty model index - * \return the number of interfaces available - * \sa QAbstractListModel::data() - */ -int QtIVIServiceManager::rowCount(const QModelIndex &parent) const -{ - Q_D(const QtIVIServiceManager); - return parent.isValid() ? 0 : d->m_backends.count(); -} - -/*! - * Implements QAbstractListModel::data() - * - * \param index the index - * \param role the role - * \return the data for the spcified index and role - * \sa QAbstractListModel::data() - */ -QVariant QtIVIServiceManager::data(const QModelIndex &index, int role) const -{ - Q_D(const QtIVIServiceManager); - - if (!index.isValid()) - return QVariant(); - - int row = index.row(); - - if (row >= 0 && row < d->m_backends.count() && role == Qt::DisplayRole) { - return QVariant::fromValue(d->m_backends.at(index.row())->interface); - } - - return QVariant(); -} diff --git a/src/core/qtiviservicemanager.h b/src/core/qtiviservicemanager.h deleted file mode 100644 index f4c33ef..0000000 --- a/src/core/qtiviservicemanager.h +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#ifndef QTIVISERVICEMANAGER_H -#define QTIVISERVICEMANAGER_H - -#include - -#include - -class QtIVIServiceObject; -class QtIVIServiceManagerPrivate; - -//TODO Detect simulation plugins -//TODO make it possible to only search there e.g. by a SearchFlag BitField -class Q_QTIVICORE_EXPORT QtIVIServiceManager : public QAbstractListModel -{ - Q_OBJECT -public: - static QtIVIServiceManager *instance(); - virtual ~QtIVIServiceManager(); - - QList findServiceByInterface(const QString &interface); - bool hasInterface(const QString &interface) const; - - bool registerService(QObject *serviceBackendInterface, const QStringList &interfaces); - void unloadAllBackends(); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role) const; -signals: - -private: - explicit QtIVIServiceManager(); - QtIVIServiceManagerPrivate * const d_ptr; - Q_DECLARE_PRIVATE(QtIVIServiceManager) -}; - -#endif // QTIVISERVICEMANAGER_H diff --git a/src/core/qtiviservicemanager_p.h b/src/core/qtiviservicemanager_p.h deleted file mode 100644 index 4d14a3e..0000000 --- a/src/core/qtiviservicemanager_p.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#ifndef QTIVISERVICEMANAGER_P_H -#define QTIVISERVICEMANAGER_P_H - -#include -#include -#include -#include - -class QPluginLoader; -class QtIVIServiceInterface; -class QtIVIServiceObject; -class QtIVIServiceManager; - -struct Backend{ - QVariantMap metaData; - QtIVIServiceInterface *interface; - QObject *interfaceObject; - QPluginLoader *loader; -}; - -class QtIVIServiceManagerPrivate : public QObject -{ - Q_OBJECT - -public: - explicit QtIVIServiceManagerPrivate(QtIVIServiceManager *parent); - - QList findServiceByInterface(const QString &interface); - - void searchPlugins(); - void registerBackend(const QString fileName, const QJsonObject metaData); - bool registerBackend(QObject *serviceBackendInterface, const QStringList &interfaces); - void addBackend(struct Backend *backend); - - void unloadAllBackends(); - - QtIVIServiceInterface *loadServiceBackendInterface(struct Backend *backend); - - QList m_backends; - QSet m_interfaceNames; - - - QtIVIServiceManager * const q_ptr; - Q_DECLARE_PUBLIC(QtIVIServiceManager) - -signals: - void beginInsertRows(const QModelIndex &index, int start, int end); - void endInsertRows(); - -}; - -#endif // QTIVISERVICEMANAGER_P_H - diff --git a/src/core/qtiviserviceobject.cpp b/src/core/qtiviserviceobject.cpp deleted file mode 100644 index 6fa35ab..0000000 --- a/src/core/qtiviserviceobject.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#include "qtiviserviceobject.h" - -#include - -/*! - * \class QtIVIServiceObject - * \brief QtIVIServiceObject is the connection point to a Backend Service - * - * QtIVIServiceObject provides you with a list of interfaces the Backend implements. - * - * By using interfaceInstance() a QObject implementing this interface will be returned. - * The returned interface can contain signals which needs to be connected to by the Feature - * implementing this interface. - * - * \sa QtIVIAbstractFeature - */ - -QtIVIServiceObject::QtIVIServiceObject(QObject *parent) - : QObject(parent) -{ - -} - -QtIVIServiceObject::~QtIVIServiceObject() -{ - -} - -/*! - * The id() function can be overloaded to control the generation of - * the unique ID used by this Object. - * - * By default QUuid::createUuid() is used. - */ -QString QtIVIServiceObject::id() const -{ - static QUuid id = QUuid::createUuid(); - return id.toString(); -} - - diff --git a/src/core/qtiviserviceobject.h b/src/core/qtiviserviceobject.h deleted file mode 100644 index c1e63a8..0000000 --- a/src/core/qtiviserviceobject.h +++ /dev/null @@ -1,35 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#ifndef QTIVISERVICEOBJECT_H -#define QTIVISERVICEOBJECT_H - -#include - -#include "qtiviserviceinterface.h" -#include "qtiviglobal.h" - -class Q_QTIVICORE_EXPORT QtIVIServiceObject : public QObject, public QtIVIServiceInterface -{ - Q_OBJECT - Q_INTERFACES(QtIVIServiceInterface) - - Q_PROPERTY(QString id READ id CONSTANT) - -public: - explicit QtIVIServiceObject(QObject *parent = 0); - virtual ~QtIVIServiceObject(); - - virtual QString id() const; - -private: -}; - -#endif // QTIVISERVICEOBJECT_H diff --git a/src/core/qtivisimplediscoverymodel.cpp b/src/core/qtivisimplediscoverymodel.cpp deleted file mode 100644 index c978a29..0000000 --- a/src/core/qtivisimplediscoverymodel.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#include "qtivisimplediscoverymodel.h" - -#include "qtiviserviceobject.h" - -template QtIVISimpleDiscoveryModel::QtIVISimpleDiscoveryModel(QString interface, QObject *parent) - : QAbstractListModel(parent) - , m_interface(interface) -{ - m_roles.insert(ServiceObject, "serviceObject"); - - // Initialize the list of properties this instance of the model knows about - for(int propertyIndex = 0; propertyIndex < T::staticMetaObject.propertyCount(); propertyIndex++) - { - QMetaProperty property = T::staticMetaObject.property(propertyIndex); - const int roleNumber = Qt::UserRole + 1 + propertyIndex; - if(property.isEnumType()) - { - m_enumProperties.insert(roleNumber); - } - m_roles.insert(roleNumber, property.name()); - } - - connect(this, &QtIVISimpleDiscoveryModel::rowsInserted, this, &QtIVISimpleDiscoveryModel::countChanged); - connect(this, &QtIVISimpleDiscoveryModel::rowsRemoved, this, &QtIVISimpleDiscoveryModel::countChanged); - connect(this, &QtIVISimpleDiscoveryModel::layoutChanged, this, &QtIVISimpleDiscoveryModel::countChanged); - connect(this, &QtIVISimpleDiscoveryModel::modelReset, this, &QtIVISimpleDiscoveryModel::countChanged); -} - -template QtIVISimpleDiscoveryModel::~QtIVISimpleDiscoveryModel() -{ - -} - -template QHash QtIVISimpleDiscoveryModel::roleNames() const -{ - return m_roles; -} - -template int QtIVISimpleDiscoveryModel::rowCount(const QModelIndex &parent) const -{ - return parent.isValid() ? 0 : m_serviceObjects.count(); -} - -template QVariant QtIVISimpleDiscoveryModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - int row = index.row(); - - if (row >= 0 && row < m_serviceObjects.count()) { - QtIVIServiceObject* so= serviceObjectAt(row); - - if (role == ServiceObject) - return QVariant::fromValue(so); - - QObject* instance = so->interfaceInstance(m_interface); - if (!instance) - return QVariant(); - - T* obj = qobject_cast(instance); - if(!obj) - return QVariant(); - - QVariant ret = obj->property(m_roles.value(role)); - if(m_enumProperties.contains(role)) - { - ret = ret.toInt(); - } - return ret; - } - - return QVariant(); -} - -template T *QtIVISimpleDiscoveryModel::at(int index) -{ - QtIVIServiceObject* so = serviceObjectAt(index); - if (!so) - return 0; - - QObject* instance = so->interfaceInstance(m_interface); - if (!instance) - return 0; - - T* obj = qobject_cast(instance); - if(!obj) - return 0; - - return obj; -} - -template QtIVIServiceObject *QtIVISimpleDiscoveryModel::serviceObjectAt(int index) -{ - if (index >= 0 && index < m_serviceObjects.count()) { - return m_serviceObjects.at(index); - } - - return 0; -} - -template void QtIVISimpleDiscoveryModel::updateServiceObjects(QList objects) -{ - //Do a logic here to call update for as many buckets as possible -} - -template void QtIVISimpleDiscoveryModel::addServiceObjects(QList objects) -{ - beginInsertRows(QModelIndex(), m_serviceObjects.count(), m_serviceObjects.count()); - m_serviceObjects += objects; - endInsertRows(); -} - -template void QtIVISimpleDiscoveryModel::removeServiceObjects(QList objects) -{ - //FIXME - beginRemoveRows(QModelIndex(), m_serviceObjects.count(), m_serviceObjects.count()); - m_serviceObjects -= objects; - endRemoveRows(); -} - diff --git a/src/core/qtivisimplediscoverymodel.h b/src/core/qtivisimplediscoverymodel.h deleted file mode 100644 index e2f5b27..0000000 --- a/src/core/qtivisimplediscoverymodel.h +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#ifndef QTIVISIMPLEDISCOVERYMODEL_H -#define QTIVISIMPLEDISCOVERYMODEL_H - -#include - -class QtIVIServiceObject; - -template -class QtIVISimpleDiscoveryModel : public QAbstractListModel -{ - Q_PROPERTY(int count READ rowCount NOTIFY countChanged) - -public: - enum ModelRoles { - ServiceObject = Qt::UserRole + 1 - }; - - QtIVISimpleDiscoveryModel(QString interface, QObject* parent = 0); - virtual ~QtIVISimpleDiscoveryModel(); - - QHash roleNames() const; - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role) const; - - Q_INVOKABLE T* at(int index); - Q_INVOKABLE QtIVIServiceObject* serviceObjectAt(int index); - -signals: - void countChanged(); - -protected: - virtual void updateServiceObjects(QList); - virtual void addServiceObjects(QList); - virtual void removeServiceObjects(QList); - -private: - - QString m_interface; - QList m_serviceObjects; - QHash< QByteArray, int > m_reverseRoles; - QHash< int, QByteArray > m_roles; - QSet< int > m_enumProperties; -}; - -#endif // QTIVISIMPLEDISCOVERYMODEL_H diff --git a/src/imports/core/core.pro b/src/imports/core/core.pro index c0d61cf..b3c29b5 100644 --- a/src/imports/core/core.pro +++ b/src/imports/core/core.pro @@ -15,6 +15,6 @@ TARGETPATH = QtIVICore SOURCES += \ plugin.cpp -QT += QtIVICore +QT += ivicore load(qml_plugin) diff --git a/src/imports/vehiclefunctions/vehiclefunctions.pro b/src/imports/vehiclefunctions/vehiclefunctions.pro index 9630f74..6b973b4 100644 --- a/src/imports/vehiclefunctions/vehiclefunctions.pro +++ b/src/imports/vehiclefunctions/vehiclefunctions.pro @@ -15,6 +15,6 @@ TARGETPATH = QtIVIVehicleFunctions SOURCES += \ plugin.cpp -QT += QtIVICore QtIVIVehicleFunctions +QT += ivicore ivivehiclefunctions load(qml_plugin) diff --git a/src/ivicore/doc/qtivicore.qdocconf b/src/ivicore/doc/qtivicore.qdocconf new file mode 100644 index 0000000..7f6ee99 --- /dev/null +++ b/src/ivicore/doc/qtivicore.qdocconf @@ -0,0 +1,52 @@ +include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) + +project = QtIVICore +description = Qt IVI Core Reference Documentation +version = $QT_VERSION + + + +qhp.projects = QtIVICore + +qhp.QtIVICore.file = qtivicore.qhp +qhp.QtIVICore.namespace = org.qt-project.qtivicore.$QT_VERSION_TAG +qhp.QtIVICore.virtualFolder = qtivicore +qhp.QtIVICore.indexTitle = Qt IVI Core +qhp.QtIVICore.indexRoot = + +qhp.QtIVICore.filterAttributes = qtivicore $QT_VERSION qtrefdoc +qhp.QtIVICore.customFilters.Qt.name = QtIVICore $QT_VERSION +qhp.QtIVICore.customFilters.Qt.filterAttributes = qtIVICore $QT_VERSION +qhp.QtIVICore.subprojects = overviews classes qml examples +qhp.QtIVICore.subprojects.classes.title = C++ Classes +qhp.QtIVICore.subprojects.classes.indexTitle = Qt IVI Core C++ Classes +qhp.QtIVICore.subprojects.classes.selectors = class fake:headerfile +qhp.QtIVICore.subprojects.classes.sortPages = true +qhp.QtIVICore.subprojects.qml.title = QML Types +qhp.QtIVICore.subprojects.qml.indexTitle = Qt IVI Core QML Types +qhp.QtIVICore.subprojects.qml.selectors = fake:headerfile +qhp.QtIVICore.subprojects.qml.sortPages = true +qhp.QtIVICore.subprojects.overviews.title = Overviews +qhp.QtIVICore.subprojects.overviews.indexTitle = Qt IVI Core Overview +qhp.QtIVICore.subprojects.overviews.selectors = fake:page,group,module +qhp.QtIVICore.subprojects.examples.title = Qt IVI Core Examples +qhp.QtIVICore.subprojects.examples.indexTitle = Qt IVI Core Examples +qhp.QtIVICore.subprojects.examples.selectors = fake:example + +tagfile = ../../../doc/qtivicore/qtivicore.tags + +depends += qtcore qtdoc qtquick qtqml + +headerdirs += .. \ + ../../imports/core + +sourcedirs += .. \ + ../../imports/core \ + +examplesinstallpath = qtivicore + +#imagedirs += images + +navigation.landingpage = "Qt IVI Core" +navigation.cppclassespage = "Qt IVI Core C++ Classes" +navigation.qmltypespage = "Qt IVI Core QML Types" diff --git a/src/ivicore/ivicore.pro b/src/ivicore/ivicore.pro new file mode 100644 index 0000000..202f71c --- /dev/null +++ b/src/ivicore/ivicore.pro @@ -0,0 +1,39 @@ +################################################################################################## +# Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. +# +# This software, including documentation, is protected by copyright controlled by Pelagicore AG. +# All rights reserved. Copying, including reproducing, storing, adapting or translating, any or +# all of this material requires prior written consent of Pelagicore AG Corporation. This material +# also contains confidential information which may not be disclosed to others without the prior +# written consent of Pelagicore AG. +################################################################################################## + +TARGET = QtIVICore + +QT = core qml +CONFIG += c++11 +VERSION = 1.0.0 + +QMAKE_DOCS = $$PWD/doc/qtivicore.qdocconf +OTHER_FILES += $$PWD/doc/*.qdoc + +CMAKE_MODULE_TESTS = '-' + +HEADERS += \ + qtiviservicemanager.h \ + qtiviserviceinterface.h \ + qtiviservicemanager_p.h \ + qtiviserviceobject.h \ + qtiviabstractfeature.h \ + qtivisimplediscoverymodel.h \ + qtiviglobal.h \ + qtiviproxyserviceobject_p.h + +SOURCES += \ + qtiviservicemanager.cpp \ + qtiviserviceobject.cpp \ + qtiviabstractfeature.cpp \ + qtivisimplediscoverymodel.cpp \ + qtiviproxyserviceobject_p.cpp + +load(qt_module) diff --git a/src/ivicore/qtiviabstractfeature.cpp b/src/ivicore/qtiviabstractfeature.cpp new file mode 100644 index 0000000..4bef086 --- /dev/null +++ b/src/ivicore/qtiviabstractfeature.cpp @@ -0,0 +1,150 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#include "qtiviabstractfeature.h" + +#include "qtiviserviceobject.h" +#include "qtiviservicemanager.h" + +/*! + * \class QtIVIAbstractFeature + * \brief The QtIVIAbstractFeature is the base class for all QtIVI Featues + * + * QtIVIAbstractFeature is the base class for the front facing API towards the Developer. + * The QtIVIAbstractFeature provides you with a way to automatically connect to a Backend implementing + * your needed interface. This discovery is started by using the startAutoDiscovery() function. + * + * Once the auto discovery is done, it can be checked whether a backend has been found by using the + * isValid function. + * + * The auto discovery gives you a easy way to automatically connect to the right backend implementation. + * If you don't want to use the auto discovery, it's also possible to use QtIVIServiceManager to retrieve + * all Backends and search manually for the right one and connect it to the QtIVIAbstractFeature by calling + * setServiceObject() + * + * QtIVIAbstractFeature is a abstract base class which needs to be subclassed to create a API for your + * Feature. + * + * \chapter Subclassing + * + * When subclassing QtIVIAbstractFeature you must provide implementations of the following functions: + * \list + * \li acceptServiceObject() + * \li connectToServiceObject() + * \li disconnectFromServiceObject() + * \li clearServiceObject() + * \endlist + * + * Once a QtIVIServiceObject has be set, either by auto discovery or by manually setting it the acceptServiceObject() + * function will be called to make sure the QtIVIServiceObject provides everything which is needed by the Feature. + * + * If the interface provides signals you need to do all the connect statements in connectToServiceObject() and + * disconnect them again in disconnectFromServiceObject(). + * + * clearServiceObject() will be called once the Feature doesn't have a connection to a ServiceObject anymore and should + * reset it's state to sane defaults + */ + +QtIVIAbstractFeature::QtIVIAbstractFeature(const QString &interface, bool autoDiscovery, QObject *parent) + : QObject(parent) + , m_interface(interface) + , m_serviceObject(0) + , m_autoDiscovery(autoDiscovery) +{ + //Detect whether we got created from within QML + //If not call the autoDiscovery +} + +QtIVIAbstractFeature::~QtIVIAbstractFeature() +{ + +} + +void QtIVIAbstractFeature::setServiceObject(QtIVIServiceObject *so) +{ + if (m_serviceObject) { + disconnectFromServiceObject(m_serviceObject); + disconnect(so, SIGNAL(destroyed()), this, SLOT(serviceObjectDestroyed())); + } + + m_serviceObject = 0; + + if (!acceptServiceObject(so)) { + clearServiceObject(); + qWarning("ServiceObject is not accepted"); + } + + m_serviceObject = so; + emit serviceObjectChanged(); + emit isValidChanged(isValid()); + connectToServiceObject(m_serviceObject); + connect(so, SIGNAL(destroyed()), this, SLOT(serviceObjectDestroyed())); +} + +void QtIVIAbstractFeature::setAutoDiscovery(bool autoDiscovery) +{ + if (m_autoDiscovery == autoDiscovery) + return; + + m_autoDiscovery = autoDiscovery; + emit autoDiscoveryChanged(autoDiscovery); +} + +void QtIVIAbstractFeature::classBegin() +{ + +} + +void QtIVIAbstractFeature::componentComplete() +{ + if (m_autoDiscovery) { + startAutoDiscovery(); + } +} + +QtIVIServiceObject *QtIVIAbstractFeature::serviceObject() const +{ + return m_serviceObject; +} + +bool QtIVIAbstractFeature::autoDiscovery() const +{ + return m_autoDiscovery; +} + +void QtIVIAbstractFeature::startAutoDiscovery() +{ + setAutoDiscovery(true); + + QtIVIServiceManager* serviceManager = QtIVIServiceManager::instance(); + QList serviceObjects = serviceManager->findServiceByInterface(m_interface); + + if (serviceObjects.isEmpty()) { + qWarning() << "There is no backend implementing" << m_interface << "."; + return; + } + + if (serviceObjects.count() > 1) + qWarning() << "There is more than one backend implementing" << m_interface << "."; + + setServiceObject(serviceObjects.at(0)); +} + +bool QtIVIAbstractFeature::isValid() const +{ + return m_serviceObject != 0; +} + +void QtIVIAbstractFeature::serviceObjectDestroyed() +{ + m_serviceObject = 0; + clearServiceObject(); + emit serviceObjectChanged(); +} diff --git a/src/ivicore/qtiviabstractfeature.h b/src/ivicore/qtiviabstractfeature.h new file mode 100644 index 0000000..60e8dd5 --- /dev/null +++ b/src/ivicore/qtiviabstractfeature.h @@ -0,0 +1,76 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#ifndef QTIVIABSTRACTFEATURE_H +#define QTIVIABSTRACTFEATURE_H + +#include +#include + +#include + +class QtIVIServiceObject; + +class Q_QTIVICORE_EXPORT QtIVIAbstractFeature : public QObject, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + + //This makes only sense if the Object is loaded directly + //Maybe use a attached property instead ??? Feature.simulation = true; Feature.autoDiscovery = false + //Q_PROPERTY(bool simulation READ simulation WRITE setSimulation NOTIFY simulationChanged) + Q_PROPERTY(bool autoDiscovery READ autoDiscovery WRITE setAutoDiscovery NOTIFY autoDiscoveryChanged) + Q_PROPERTY(QtIVIServiceObject* serviceObject READ serviceObject WRITE setServiceObject NOTIFY serviceObjectChanged) + Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged) + +public: + + explicit QtIVIAbstractFeature(const QString &interface, bool autoDiscovery = true, QObject *parent = 0); + virtual ~QtIVIAbstractFeature(); + + QtIVIServiceObject *serviceObject() const; + bool autoDiscovery() const; + bool isValid() const; + + void startAutoDiscovery(); + +public slots: + void setServiceObject(QtIVIServiceObject *so); + void setAutoDiscovery(bool autoDiscovery); + +signals: + void serviceObjectChanged(); + void autoDiscoveryChanged(bool autoDiscovery); + void isValidChanged(bool arg); + +protected: + + //USE acceptService instead of the interface constructor, also in the simplediscoverymodel + virtual bool acceptServiceObject(QtIVIServiceObject*) = 0; + virtual void connectToServiceObject(QtIVIServiceObject*) = 0; + virtual void disconnectFromServiceObject(QtIVIServiceObject*) = 0; + virtual void clearServiceObject() = 0; + + //TODO This doesn't work for the C++ usecases we should use the constructor there instead + // Also this means a qml dependency in the core, do we want that ? + virtual void classBegin(); + virtual void componentComplete(); + +private slots: + void serviceObjectDestroyed(); + +private: + + QString m_interface; + QtIVIServiceObject* m_serviceObject; + bool m_autoDiscovery; +}; + +#endif // QTIVIABSTRACTFEATURE_H diff --git a/src/ivicore/qtiviglobal.h b/src/ivicore/qtiviglobal.h new file mode 100644 index 0000000..00f90f8 --- /dev/null +++ b/src/ivicore/qtiviglobal.h @@ -0,0 +1,31 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#ifndef QTIVIGLOBAL_H +#define QTIVIGLOBAL_H + +#include + +QT_BEGIN_NAMESPACE + +#ifndef QT_STATIC +# if defined(QT_BUILD_QTIVICORE_LIB) +# define Q_QTIVICORE_EXPORT Q_DECL_EXPORT +# else +# define Q_QTIVICORE_EXPORT Q_DECL_IMPORT +# endif +#else +# define Q_QTIVICORE_EXPORT +#endif + +QT_END_NAMESPACE + +#endif // QTIVIGLOBAL_H + diff --git a/src/ivicore/qtiviproxyserviceobject_p.cpp b/src/ivicore/qtiviproxyserviceobject_p.cpp new file mode 100644 index 0000000..7fc7e9e --- /dev/null +++ b/src/ivicore/qtiviproxyserviceobject_p.cpp @@ -0,0 +1,34 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#include "qtiviproxyserviceobject_p.h" + +QtIVIProxyServiceObject::QtIVIProxyServiceObject(QtIVIServiceInterface *interface) + : QtIVIServiceObject() + , m_interface(interface) +{ + +} + +QtIVIProxyServiceObject::~QtIVIProxyServiceObject() +{ + +} + +QStringList QtIVIProxyServiceObject::interfaces() const +{ + return m_interface->interfaces(); +} + +QObject *QtIVIProxyServiceObject::interfaceInstance(const QString &interface) const +{ + return m_interface->interfaceInstance(interface); +} + diff --git a/src/ivicore/qtiviproxyserviceobject_p.h b/src/ivicore/qtiviproxyserviceobject_p.h new file mode 100644 index 0000000..f0b8bdf --- /dev/null +++ b/src/ivicore/qtiviproxyserviceobject_p.h @@ -0,0 +1,30 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#ifndef QTIVIPROXYSERVICEOBJECT_H +#define QTIVIPROXYSERVICEOBJECT_H + +#include "qtiviserviceobject.h" + +class QtIVIProxyServiceObject : public QtIVIServiceObject +{ +public: + QtIVIProxyServiceObject(QtIVIServiceInterface* interface); + virtual ~QtIVIProxyServiceObject(); + + virtual QStringList interfaces() const; + virtual QObject* interfaceInstance(const QString& interface) const; + +private: + + QtIVIServiceInterface* m_interface; +}; + +#endif // QTIVIPROXYSERVICEOBJECT_H diff --git a/src/ivicore/qtiviserviceinterface.h b/src/ivicore/qtiviserviceinterface.h new file mode 100644 index 0000000..bf0a807 --- /dev/null +++ b/src/ivicore/qtiviserviceinterface.h @@ -0,0 +1,28 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#ifndef QTIVISERVICEINTERFACE_H +#define QTIVISERVICEINTERFACE_H + +#include + +class QtIVIServiceInterface { + +public: + + virtual QStringList interfaces() const = 0; + virtual QObject* interfaceInstance(const QString& interface) const = 0; +}; + +Q_DECLARE_INTERFACE(QtIVIServiceInterface, "com.pelagicore.QtIVIServiceInterface") +Q_DECLARE_METATYPE(QtIVIServiceInterface*) + +#endif // QTIVISERVICEINTERFACE_H + diff --git a/src/ivicore/qtiviservicemanager.cpp b/src/ivicore/qtiviservicemanager.cpp new file mode 100644 index 0000000..f7046ca --- /dev/null +++ b/src/ivicore/qtiviservicemanager.cpp @@ -0,0 +1,291 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#include "qtiviservicemanager.h" + +#include "qtiviproxyserviceobject_p.h" +#include "qtiviservicemanager_p.h" + +#include +#include +#include +#include +#include +#include +#include + +#define QTIVI_PLUGIN_DIRECTORY "qtivi" + +QtIVIServiceManagerPrivate::QtIVIServiceManagerPrivate(QtIVIServiceManager *parent) : QObject(parent), q_ptr(parent) +{ +} + +QList QtIVIServiceManagerPrivate::findServiceByInterface(const QString &interface) +{ + QList list; + + foreach (Backend *backend, m_backends) { + + if (backend->metaData[QLatin1String("interfaces")].toStringList().contains(interface)) { + QtIVIServiceInterface *backendInterface = loadServiceBackendInterface(backend); + list.append(new QtIVIProxyServiceObject(backendInterface)); + } + } + + return list; +} + +void QtIVIServiceManagerPrivate::searchPlugins() +{ + bool found = false; + foreach (const QString &pluginDir, QCoreApplication::libraryPaths()) { + + QDir dir(pluginDir); + QString path = pluginDir + QDir::separator() + QLatin1Literal(QTIVI_PLUGIN_DIRECTORY); + //Check whether the directory exists + if (!QDir(path).exists(QStringLiteral("."))) + continue; + + QStringList plugins = QDir(path).entryList(QDir::Files); + foreach (const QString &pluginPath, plugins) { + QString fileName = QDir::cleanPath(path + QLatin1Char('/') + pluginPath); + QPluginLoader loader(dir.absoluteFilePath(fileName)); + registerBackend(loader.fileName(), loader.metaData()); + found = true; + } + } + if (!found) + { + qWarning() << "No plugins found in search path: " << QCoreApplication::libraryPaths().join(QLatin1String(":")); + } +} + +void QtIVIServiceManagerPrivate::registerBackend(const QString fileName, const QJsonObject metaData) +{ + QVariantMap backendMetaData = metaData.value(QLatin1String("MetaData")).toVariant().toMap(); + + if (backendMetaData[QLatin1String("interfaces")].isNull() || backendMetaData[QLatin1String("interfaces")].toList().isEmpty()) { + qDebug("PluginManager - Malformed metaData in '%s'. MetaData must contain a list of interfaces", qPrintable(fileName)); + return; + } + + //TODO check for other metaData like name etc. + + backendMetaData.insert(QLatin1String("fileName"), fileName); + + Backend* backend = new Backend; + backend->metaData = backendMetaData; + backend->interface = 0; + backend->interfaceObject = 0; + backend->loader = 0; + addBackend(backend); +} + +bool QtIVIServiceManagerPrivate::registerBackend(QObject *serviceBackendInterface, const QStringList &interfaces) +{ + if (interfaces.isEmpty()) { + return false; + } + + // Verify that the object implements the ServiceBackendInterface + QtIVIServiceInterface *interface = qobject_cast(serviceBackendInterface); + if (!interface) { + return false; + } + + QVariantMap metaData = QVariantMap(); + + metaData.insert(QLatin1String("interfaces"), interfaces); + + Backend *backend = new Backend; + backend->metaData = metaData; + backend->interface = interface; + backend->interfaceObject = serviceBackendInterface; + backend->loader = 0; + + addBackend(backend); + return true; +} + +void QtIVIServiceManagerPrivate::unloadAllBackends() +{ + Q_Q(QtIVIServiceManager); + + q->beginResetModel(); + for(int i=0; iloader) { + backend->loader->unload(); + delete backend->loader; + } else if (backend->interfaceObject) { + delete backend->interfaceObject; + } + + delete backend; + } + m_backends.clear(); + q->endResetModel(); +} + +void QtIVIServiceManagerPrivate::addBackend(Backend *backend) +{ + Q_Q(QtIVIServiceManager); + + q->beginInsertRows(QModelIndex(), m_backends.count(), m_backends.count()); + m_backends.append(backend); + q->endInsertRows(); + + foreach (const QString &interface, backend->metaData[QLatin1String("interfaces")].toStringList()) { + m_interfaceNames.insert(interface); + } +} + +QtIVIServiceInterface *QtIVIServiceManagerPrivate::loadServiceBackendInterface(struct Backend *backend) +{ + if (backend->interface) { + return backend->interface; + } + + QPluginLoader *loader = new QPluginLoader(backend->metaData[QLatin1String("fileName")].toString()); + QObject *plugin = loader->instance(); + if (plugin) { + + QtIVIServiceInterface *backendInterface = qobject_cast(plugin); + if (backendInterface) { + backend->interface = backendInterface; + backend->loader = loader; + return backend->interface; + } else { + qDebug("ServiceManager::serviceObjects - failed to cast to interface from '%s'", qPrintable(loader->fileName())); + } + + } else { + qDebug("ServiceManager::serviceObjects - failed to load '%s'", qPrintable(loader->fileName())); + } + + //Only delete the Loader right away if we didn't succeeded with loading the interfaces. + delete loader; + + return 0; +} + +/*! + * \class QtIVIServiceManager + * \brief QtIVIServiceManager provides the Backends to QtIVIAbstractFeature + * + * QtIVIServiceManager is the heart of QtIVI and provides you a easy way to detect what + * Backends and interfaces are available. + * + * By default QtIVIServiceManager reads the metaData of all plugins within the "qtivi" folder + * of your plugin path. The plugin itself will be loaded once it's explictly requested by + * the developer by using findServiceByInterface() + * + * The registerService() function can be used to add Backend classes without putting them into + * a plugin. + */ +QtIVIServiceManager::QtIVIServiceManager() + : QAbstractListModel(0) + , d_ptr(new QtIVIServiceManagerPrivate(this)) +{ + d_ptr->searchPlugins(); +} + +QtIVIServiceManager *QtIVIServiceManager::instance() +{ + static QtIVIServiceManager* instance = new QtIVIServiceManager(); + return instance; +} + +QtIVIServiceManager::~QtIVIServiceManager() +{ + +} + +/*! + * Returns a List of Backends which implementing the specified \a interface. + */ +QList QtIVIServiceManager::findServiceByInterface(const QString &interface) +{ + Q_D(QtIVIServiceManager); + return d->findServiceByInterface(interface); +} + +/*! + * Register a backend. The provided \a serviceBackendInterface must implement the ServiceBackendInterface else + * the registration will fail. + * + * \param serviceBackendInterface an QObject instance which implements the ServiceBackendInterface + * \param interfaces a list with interfaces which the backend handles. At least one interface is required + * \return true if the backend was successfully registered else false + * \sa ServiceBackendInterface + */ +bool QtIVIServiceManager::registerService(QObject *serviceBackendInterface, const QStringList &interfaces) +{ + Q_D(QtIVIServiceManager); + return d->registerBackend(serviceBackendInterface, interfaces); +} + +void QtIVIServiceManager::unloadAllBackends() +{ + Q_D(QtIVIServiceManager); + return d->unloadAllBackends(); +} + +/*! + * Returns true if the specified \a interface has been registered. + + * \param interface the interface + * \return true if the specified \a interface has been registered else false + */ +bool QtIVIServiceManager::hasInterface(const QString &interface) const +{ + Q_D(const QtIVIServiceManager); + return d->m_interfaceNames.contains(interface); +} + +/*! + * Implements QAbstractListModel::rowCount() + * + * \param parent the model index, typically an empty model index + * \return the number of interfaces available + * \sa QAbstractListModel::data() + */ +int QtIVIServiceManager::rowCount(const QModelIndex &parent) const +{ + Q_D(const QtIVIServiceManager); + return parent.isValid() ? 0 : d->m_backends.count(); +} + +/*! + * Implements QAbstractListModel::data() + * + * \param index the index + * \param role the role + * \return the data for the spcified index and role + * \sa QAbstractListModel::data() + */ +QVariant QtIVIServiceManager::data(const QModelIndex &index, int role) const +{ + Q_D(const QtIVIServiceManager); + + if (!index.isValid()) + return QVariant(); + + int row = index.row(); + + if (row >= 0 && row < d->m_backends.count() && role == Qt::DisplayRole) { + return QVariant::fromValue(d->m_backends.at(index.row())->interface); + } + + return QVariant(); +} diff --git a/src/ivicore/qtiviservicemanager.h b/src/ivicore/qtiviservicemanager.h new file mode 100644 index 0000000..f4c33ef --- /dev/null +++ b/src/ivicore/qtiviservicemanager.h @@ -0,0 +1,46 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#ifndef QTIVISERVICEMANAGER_H +#define QTIVISERVICEMANAGER_H + +#include + +#include + +class QtIVIServiceObject; +class QtIVIServiceManagerPrivate; + +//TODO Detect simulation plugins +//TODO make it possible to only search there e.g. by a SearchFlag BitField +class Q_QTIVICORE_EXPORT QtIVIServiceManager : public QAbstractListModel +{ + Q_OBJECT +public: + static QtIVIServiceManager *instance(); + virtual ~QtIVIServiceManager(); + + QList findServiceByInterface(const QString &interface); + bool hasInterface(const QString &interface) const; + + bool registerService(QObject *serviceBackendInterface, const QStringList &interfaces); + void unloadAllBackends(); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role) const; +signals: + +private: + explicit QtIVIServiceManager(); + QtIVIServiceManagerPrivate * const d_ptr; + Q_DECLARE_PRIVATE(QtIVIServiceManager) +}; + +#endif // QTIVISERVICEMANAGER_H diff --git a/src/ivicore/qtiviservicemanager_p.h b/src/ivicore/qtiviservicemanager_p.h new file mode 100644 index 0000000..4d14a3e --- /dev/null +++ b/src/ivicore/qtiviservicemanager_p.h @@ -0,0 +1,63 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#ifndef QTIVISERVICEMANAGER_P_H +#define QTIVISERVICEMANAGER_P_H + +#include +#include +#include +#include + +class QPluginLoader; +class QtIVIServiceInterface; +class QtIVIServiceObject; +class QtIVIServiceManager; + +struct Backend{ + QVariantMap metaData; + QtIVIServiceInterface *interface; + QObject *interfaceObject; + QPluginLoader *loader; +}; + +class QtIVIServiceManagerPrivate : public QObject +{ + Q_OBJECT + +public: + explicit QtIVIServiceManagerPrivate(QtIVIServiceManager *parent); + + QList findServiceByInterface(const QString &interface); + + void searchPlugins(); + void registerBackend(const QString fileName, const QJsonObject metaData); + bool registerBackend(QObject *serviceBackendInterface, const QStringList &interfaces); + void addBackend(struct Backend *backend); + + void unloadAllBackends(); + + QtIVIServiceInterface *loadServiceBackendInterface(struct Backend *backend); + + QList m_backends; + QSet m_interfaceNames; + + + QtIVIServiceManager * const q_ptr; + Q_DECLARE_PUBLIC(QtIVIServiceManager) + +signals: + void beginInsertRows(const QModelIndex &index, int start, int end); + void endInsertRows(); + +}; + +#endif // QTIVISERVICEMANAGER_P_H + diff --git a/src/ivicore/qtiviserviceobject.cpp b/src/ivicore/qtiviserviceobject.cpp new file mode 100644 index 0000000..6fa35ab --- /dev/null +++ b/src/ivicore/qtiviserviceobject.cpp @@ -0,0 +1,51 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#include "qtiviserviceobject.h" + +#include + +/*! + * \class QtIVIServiceObject + * \brief QtIVIServiceObject is the connection point to a Backend Service + * + * QtIVIServiceObject provides you with a list of interfaces the Backend implements. + * + * By using interfaceInstance() a QObject implementing this interface will be returned. + * The returned interface can contain signals which needs to be connected to by the Feature + * implementing this interface. + * + * \sa QtIVIAbstractFeature + */ + +QtIVIServiceObject::QtIVIServiceObject(QObject *parent) + : QObject(parent) +{ + +} + +QtIVIServiceObject::~QtIVIServiceObject() +{ + +} + +/*! + * The id() function can be overloaded to control the generation of + * the unique ID used by this Object. + * + * By default QUuid::createUuid() is used. + */ +QString QtIVIServiceObject::id() const +{ + static QUuid id = QUuid::createUuid(); + return id.toString(); +} + + diff --git a/src/ivicore/qtiviserviceobject.h b/src/ivicore/qtiviserviceobject.h new file mode 100644 index 0000000..c1e63a8 --- /dev/null +++ b/src/ivicore/qtiviserviceobject.h @@ -0,0 +1,35 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#ifndef QTIVISERVICEOBJECT_H +#define QTIVISERVICEOBJECT_H + +#include + +#include "qtiviserviceinterface.h" +#include "qtiviglobal.h" + +class Q_QTIVICORE_EXPORT QtIVIServiceObject : public QObject, public QtIVIServiceInterface +{ + Q_OBJECT + Q_INTERFACES(QtIVIServiceInterface) + + Q_PROPERTY(QString id READ id CONSTANT) + +public: + explicit QtIVIServiceObject(QObject *parent = 0); + virtual ~QtIVIServiceObject(); + + virtual QString id() const; + +private: +}; + +#endif // QTIVISERVICEOBJECT_H diff --git a/src/ivicore/qtivisimplediscoverymodel.cpp b/src/ivicore/qtivisimplediscoverymodel.cpp new file mode 100644 index 0000000..c978a29 --- /dev/null +++ b/src/ivicore/qtivisimplediscoverymodel.cpp @@ -0,0 +1,131 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#include "qtivisimplediscoverymodel.h" + +#include "qtiviserviceobject.h" + +template QtIVISimpleDiscoveryModel::QtIVISimpleDiscoveryModel(QString interface, QObject *parent) + : QAbstractListModel(parent) + , m_interface(interface) +{ + m_roles.insert(ServiceObject, "serviceObject"); + + // Initialize the list of properties this instance of the model knows about + for(int propertyIndex = 0; propertyIndex < T::staticMetaObject.propertyCount(); propertyIndex++) + { + QMetaProperty property = T::staticMetaObject.property(propertyIndex); + const int roleNumber = Qt::UserRole + 1 + propertyIndex; + if(property.isEnumType()) + { + m_enumProperties.insert(roleNumber); + } + m_roles.insert(roleNumber, property.name()); + } + + connect(this, &QtIVISimpleDiscoveryModel::rowsInserted, this, &QtIVISimpleDiscoveryModel::countChanged); + connect(this, &QtIVISimpleDiscoveryModel::rowsRemoved, this, &QtIVISimpleDiscoveryModel::countChanged); + connect(this, &QtIVISimpleDiscoveryModel::layoutChanged, this, &QtIVISimpleDiscoveryModel::countChanged); + connect(this, &QtIVISimpleDiscoveryModel::modelReset, this, &QtIVISimpleDiscoveryModel::countChanged); +} + +template QtIVISimpleDiscoveryModel::~QtIVISimpleDiscoveryModel() +{ + +} + +template QHash QtIVISimpleDiscoveryModel::roleNames() const +{ + return m_roles; +} + +template int QtIVISimpleDiscoveryModel::rowCount(const QModelIndex &parent) const +{ + return parent.isValid() ? 0 : m_serviceObjects.count(); +} + +template QVariant QtIVISimpleDiscoveryModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + int row = index.row(); + + if (row >= 0 && row < m_serviceObjects.count()) { + QtIVIServiceObject* so= serviceObjectAt(row); + + if (role == ServiceObject) + return QVariant::fromValue(so); + + QObject* instance = so->interfaceInstance(m_interface); + if (!instance) + return QVariant(); + + T* obj = qobject_cast(instance); + if(!obj) + return QVariant(); + + QVariant ret = obj->property(m_roles.value(role)); + if(m_enumProperties.contains(role)) + { + ret = ret.toInt(); + } + return ret; + } + + return QVariant(); +} + +template T *QtIVISimpleDiscoveryModel::at(int index) +{ + QtIVIServiceObject* so = serviceObjectAt(index); + if (!so) + return 0; + + QObject* instance = so->interfaceInstance(m_interface); + if (!instance) + return 0; + + T* obj = qobject_cast(instance); + if(!obj) + return 0; + + return obj; +} + +template QtIVIServiceObject *QtIVISimpleDiscoveryModel::serviceObjectAt(int index) +{ + if (index >= 0 && index < m_serviceObjects.count()) { + return m_serviceObjects.at(index); + } + + return 0; +} + +template void QtIVISimpleDiscoveryModel::updateServiceObjects(QList objects) +{ + //Do a logic here to call update for as many buckets as possible +} + +template void QtIVISimpleDiscoveryModel::addServiceObjects(QList objects) +{ + beginInsertRows(QModelIndex(), m_serviceObjects.count(), m_serviceObjects.count()); + m_serviceObjects += objects; + endInsertRows(); +} + +template void QtIVISimpleDiscoveryModel::removeServiceObjects(QList objects) +{ + //FIXME + beginRemoveRows(QModelIndex(), m_serviceObjects.count(), m_serviceObjects.count()); + m_serviceObjects -= objects; + endRemoveRows(); +} + diff --git a/src/ivicore/qtivisimplediscoverymodel.h b/src/ivicore/qtivisimplediscoverymodel.h new file mode 100644 index 0000000..e2f5b27 --- /dev/null +++ b/src/ivicore/qtivisimplediscoverymodel.h @@ -0,0 +1,56 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#ifndef QTIVISIMPLEDISCOVERYMODEL_H +#define QTIVISIMPLEDISCOVERYMODEL_H + +#include + +class QtIVIServiceObject; + +template +class QtIVISimpleDiscoveryModel : public QAbstractListModel +{ + Q_PROPERTY(int count READ rowCount NOTIFY countChanged) + +public: + enum ModelRoles { + ServiceObject = Qt::UserRole + 1 + }; + + QtIVISimpleDiscoveryModel(QString interface, QObject* parent = 0); + virtual ~QtIVISimpleDiscoveryModel(); + + QHash roleNames() const; + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role) const; + + Q_INVOKABLE T* at(int index); + Q_INVOKABLE QtIVIServiceObject* serviceObjectAt(int index); + +signals: + void countChanged(); + +protected: + virtual void updateServiceObjects(QList); + virtual void addServiceObjects(QList); + virtual void removeServiceObjects(QList); + +private: + + QString m_interface; + QList m_serviceObjects; + QHash< QByteArray, int > m_reverseRoles; + QHash< int, QByteArray > m_roles; + QSet< int > m_enumProperties; +}; + +#endif // QTIVISIMPLEDISCOVERYMODEL_H diff --git a/src/ivivehiclefunctions/doc/qtivivehiclefunctions.qdocconf b/src/ivivehiclefunctions/doc/qtivivehiclefunctions.qdocconf new file mode 100644 index 0000000..5a41ee4 --- /dev/null +++ b/src/ivivehiclefunctions/doc/qtivivehiclefunctions.qdocconf @@ -0,0 +1,52 @@ +include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) + +project = QtIVIVehicleFunctions +description = Qt IVI Vehicle Functions Reference Documentation +version = $QT_VERSION + + + +qhp.projects = QtIVIVehicleFunctions + +qhp.QtIVIVehicleFunctions.file = qtivivehiclefunctions.qhp +qhp.QtIVIVehicleFunctions.namespace = org.qt-project.qtivicore.$QT_VERSION_TAG +qhp.QtIVIVehicleFunctions.virtualFolder = qtivivehiclefunctions +qhp.QtIVIVehicleFunctions.indexTitle = Qt IVI Vehicle Functions +qhp.QtIVIVehicleFunctions.indexRoot = + +qhp.QtIVIVehicleFunctions.filterAttributes = qtivivehiclefunctions $QT_VERSION qtrefdoc +qhp.QtIVIVehicleFunctions.customFilters.Qt.name = QtIVIVehicleFunctions $QT_VERSION +qhp.QtIVIVehicleFunctions.customFilters.Qt.filterAttributes = qtIVIVehicleFunctions $QT_VERSION +qhp.QtIVIVehicleFunctions.subprojects = overviews classes qml examples +qhp.QtIVIVehicleFunctions.subprojects.classes.title = C++ Classes +qhp.QtIVIVehicleFunctions.subprojects.classes.indexTitle = Qt IVI Vehicle Functions C++ Classes +qhp.QtIVIVehicleFunctions.subprojects.classes.selectors = class fake:headerfile +qhp.QtIVIVehicleFunctions.subprojects.classes.sortPages = true +qhp.QtIVIVehicleFunctions.subprojects.qml.title = QML Types +qhp.QtIVIVehicleFunctions.subprojects.qml.indexTitle = Qt IVI Vehicle Functions QML Types +qhp.QtIVIVehicleFunctions.subprojects.qml.selectors = fake:headerfile +qhp.QtIVIVehicleFunctions.subprojects.qml.sortPages = true +qhp.QtIVIVehicleFunctions.subprojects.overviews.title = Overviews +qhp.QtIVIVehicleFunctions.subprojects.overviews.indexTitle = Qt IVI Vehicle Functions Overview +qhp.QtIVIVehicleFunctions.subprojects.overviews.selectors = fake:page,group,module +qhp.QtIVIVehicleFunctions.subprojects.examples.title = Qt IVI Vehicle Functions Examples +qhp.QtIVIVehicleFunctions.subprojects.examples.indexTitle = Qt IVI Vehicle Functions Examples +qhp.QtIVIVehicleFunctions.subprojects.examples.selectors = fake:example + +tagfile = ../../../doc/qtivivehiclefunctions/qtivivehiclefunctions.tags + +depends += qtcore qtdoc qtquick qtqml qtivicore + +headerdirs += .. \ + ../../imports/vehiclefunctions + +sourcedirs += .. \ + ../../imports/vehiclefunctions \ + +examplesinstallpath = qtivivehiclefunctions + +#imagedirs += images + +navigation.landingpage = "Qt IVI Vehicle Functions" +navigation.cppclassespage = "Qt IVI Vehicle Functions C++ Classes" +navigation.qmltypespage = "Qt IVI Vehicle Functions QML Types" diff --git a/src/ivivehiclefunctions/ivivehiclefunctions.pro b/src/ivivehiclefunctions/ivivehiclefunctions.pro new file mode 100644 index 0000000..6ecb607 --- /dev/null +++ b/src/ivivehiclefunctions/ivivehiclefunctions.pro @@ -0,0 +1,28 @@ +################################################################################################## +# Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. +# +# This software, including documentation, is protected by copyright controlled by Pelagicore AG. +# All rights reserved. Copying, including reproducing, storing, adapting or translating, any or +# all of this material requires prior written consent of Pelagicore AG Corporation. This material +# also contains confidential information which may not be disclosed to others without the prior +# written consent of Pelagicore AG. +################################################################################################## + +TARGET = QtIVIVehicleFunctions +QT = core qml ivicore +CONFIG += c++11 +VERSION = 1.0.0 + +QMAKE_DOCS = $$PWD/doc/qtivivehiclefunctions.qdocconf + +CMAKE_MODULE_TESTS = '-' + +HEADERS += \ + qtiviclimatecontrol.h \ + qtiviclimatecontrolbackendinterface.h \ + qtivivehiclefunctionsglobal.h + +SOURCES += \ + qtiviclimatecontrol.cpp + +load(qt_module) diff --git a/src/ivivehiclefunctions/qtiviclimatecontrol.cpp b/src/ivivehiclefunctions/qtiviclimatecontrol.cpp new file mode 100644 index 0000000..6bb1ff3 --- /dev/null +++ b/src/ivivehiclefunctions/qtiviclimatecontrol.cpp @@ -0,0 +1,425 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#include "qtiviclimatecontrol.h" + +#include "qtiviclimatecontrolbackendinterface.h" + + + + +QString QtIVIClimateControlBackendInterface::interfaceName = QLatin1String("com.pelagicore.ClimateControl"); + + + + +QtIVIClimateZone::QtIVIClimateZone(Zone zone, QtIVIClimateControl *parent) + : QObject(parent) + , m_zone(zone) + , m_hasTargetTemperature(false) + , m_hasSeatCooler(false) + , m_hasSeatHeater(false) + , m_targetTemperature(0) + , m_seatCooler(0) + , m_seatHeater(0) +{ + +} + +QtIVIClimateZone::Zone QtIVIClimateZone::zone() const +{ + return m_zone; +} + +bool QtIVIClimateZone::hasTargetTemperature() const +{ + return m_hasTargetTemperature; +} + +int QtIVIClimateZone::targetTemperature() const +{ + if (m_hasTargetTemperature) + return m_targetTemperature; + else + return 0; +} + +void QtIVIClimateZone::setTargetTemperature(int t) +{ + if (m_hasTargetTemperature) + qobject_cast(parent())->backend()->setTargetTemperature(m_zone, t); + else + qWarning() << "Trying to set ClimateZone::targetTemperature in an unsupported zone or without a backend."; +} + +bool QtIVIClimateZone::hasSeatCooler() const +{ + return m_hasSeatCooler; +} + +int QtIVIClimateZone::seatCooler() const +{ + if (m_hasSeatCooler) + return m_seatCooler; + else + return 0; +} + +void QtIVIClimateZone::setSeatCooler(int t) +{ + if (t < 0 || t > 10) { + qWarning() << "Trying to set ClimateZone::seatCooler to " << t << " which is out of range (0-10)."; + return; + } + + if (m_hasSeatCooler) + qobject_cast(parent())->backend()->setSeatCooler(m_zone, t); + else + qWarning() << "Trying to set ClimateZone::seatCooler in an unsupported zone or without a backend."; +} + +bool QtIVIClimateZone::hasSeatHeater() const +{ + return m_hasSeatHeater; +} + +int QtIVIClimateZone::seatHeater() const +{ + if (m_hasSeatHeater) + return m_seatHeater; + else + return 0; +} + +void QtIVIClimateZone::setSeatHeater(int t) +{ + if (t < 0 || t > 10) { + qWarning() << "Trying to set ClimateZone::seatHeater to " << t << " which is out of range (0-10)."; + return; + } + + if (m_hasSeatHeater) + qobject_cast(parent())->backend()->setSeatHeater(m_zone, t); + else + qWarning() << "Trying to set ClimateZone::seatHeater in an unsupported zone or without a backend."; +} + +void QtIVIClimateZone::onTargetTemperatureChanged(QtIVIClimateZone::Zone z, int t) +{ + if (z == m_zone) { + m_targetTemperature = t; + if (m_hasTargetTemperature) + emit targetTemperatureChanged(m_targetTemperature); + } +} + +void QtIVIClimateZone::onSeatCoolerChanged(QtIVIClimateZone::Zone z, int t) +{ + if (z == m_zone) { + m_seatCooler = t; + if (m_hasSeatCooler) + emit seatCoolerChanged(m_seatCooler); + } +} + +void QtIVIClimateZone::onSeatHeaterChanged(QtIVIClimateZone::Zone z, int t) +{ + if (z == m_zone) { + m_seatHeater = t; + if (m_hasSeatHeater) + emit seatHeaterChanged(m_seatHeater); + } +} + +void QtIVIClimateZone::setHasTargetTemperature(bool e) +{ + if(e != m_hasTargetTemperature) { + m_hasTargetTemperature = e; + emit hasTargetTemperatureChanged(m_hasTargetTemperature); + + onTargetTemperatureChanged(m_zone, targetTemperature()); + } +} + +void QtIVIClimateZone::setHasSeatCooler(bool e) +{ + if(e != m_hasSeatCooler) { + m_hasSeatCooler = e; + emit hasSeatCoolerChanged(m_hasSeatCooler); + + onSeatCoolerChanged(m_zone, seatCooler()); + } +} + +void QtIVIClimateZone::setHasSeatHeater(bool e) +{ + if(e != m_hasSeatHeater) { + m_hasSeatHeater = e; + emit hasSeatHeaterChanged(m_hasSeatHeater); + + onSeatHeaterChanged(m_zone, seatHeater()); + } +} + + + + + +QtIVIClimateControl::QtIVIClimateControl(QObject *parent) + : QtIVIAbstractFeature(QtIVIClimateControlBackendInterface::interfaceName, true, parent) + , m_airflowDirection(QtIVIClimateControl::BiLevel) + , m_airConditioning(false) + , m_heater(false) + , m_airRecirculation(false) + , m_steeringWheelHeater(0) + , m_fanSpeedLevel(0) +{ + QList zones; + zones << QtIVIClimateZone::FrontLeft << QtIVIClimateZone::FrontCenter << QtIVIClimateZone::FrontRight + << QtIVIClimateZone::RearLeft << QtIVIClimateZone::RearCenter << QtIVIClimateZone::RearRight; + foreach(QtIVIClimateZone::Zone z, zones) + m_zones[z] = new QtIVIClimateZone(z, this); +} + +QtIVIClimateControl::AirflowDirection QtIVIClimateControl::airflowDirection() const +{ + return m_airflowDirection; +} + +bool QtIVIClimateControl::isAirConditioningEnabled() const +{ + return m_airConditioning; +} + +bool QtIVIClimateControl::isHeaterEnabled() const +{ + return m_heater; +} + +bool QtIVIClimateControl::isAirRecirculationEnabled() const +{ + return m_airRecirculation; +} + +int QtIVIClimateControl::steeringWheelHeater() const +{ + return m_steeringWheelHeater; +} + +int QtIVIClimateControl::fanSpeedLevel() const +{ + return m_fanSpeedLevel; +} + +QtIVIClimateZone *QtIVIClimateControl::climateZone(QtIVIClimateZone::Zone z) const +{ + return m_zones[z]; +} + +QtIVIClimateZone *QtIVIClimateControl::driver() const +{ + if (backend()) + return m_zones[backend()->driverZone()]; + else { + qWarning() << "Returning driver zone without a backend, using default driver zone."; + return m_zones[QtIVIClimateZone::FrontLeft]; + } +} + +QtIVIClimateZone *QtIVIClimateControl::frontLeftZone() const +{ + return m_zones[QtIVIClimateZone::FrontLeft]; +} + +QtIVIClimateZone *QtIVIClimateControl::frontCenterZone() const +{ + return m_zones[QtIVIClimateZone::FrontCenter]; +} + +QtIVIClimateZone *QtIVIClimateControl::frontRightZone() const +{ + return m_zones[QtIVIClimateZone::FrontRight]; +} + +QtIVIClimateZone *QtIVIClimateControl::rearLeftZone() const +{ + return m_zones[QtIVIClimateZone::RearLeft]; +} + +QtIVIClimateZone *QtIVIClimateControl::rearCenterZone() const +{ + return m_zones[QtIVIClimateZone::RearCenter]; +} + +QtIVIClimateZone *QtIVIClimateControl::rearRightZone() const +{ + return m_zones[QtIVIClimateZone::RearRight]; +} + +void QtIVIClimateControl::setAirflowDirection(QtIVIClimateControl::AirflowDirection ad) +{ + if(backend()) + backend()->setAirflowDirection(ad); +} + +void QtIVIClimateControl::setAirConditioningEnabled(bool e) +{ + if(backend()) + backend()->setAirConditioningEnabled(e); +} + +void QtIVIClimateControl::setHeaterEnabled(bool e) +{ + if(backend()) + backend()->setHeaterEnabled(e); +} + +void QtIVIClimateControl::setAirRecirculationEnabled(bool e) +{ + if(backend()) + backend()->setAirRecirculationEnabled(e); +} + +void QtIVIClimateControl::setSteeringWheelHeater(int t) +{ + if(backend()) + backend()->setSteeringWheelHeater(t); +} + +void QtIVIClimateControl::setFanSpeedLevel(int fsl) +{ + if(backend()) + backend()->setFanSpeedLevel(fsl); +} + +bool QtIVIClimateControl::acceptServiceObject(QtIVIServiceObject *so) +{ + return (qobject_cast(so->interfaceInstance(QtIVIClimateControlBackendInterface::interfaceName)) != NULL); +} + +void QtIVIClimateControl::connectToServiceObject(QtIVIServiceObject *so) +{ + QtIVIClimateControlBackendInterface *backend = qobject_cast(so->interfaceInstance(QtIVIClimateControlBackendInterface::interfaceName)); + + QList zones; + zones << QtIVIClimateZone::FrontLeft << QtIVIClimateZone::FrontCenter << QtIVIClimateZone::FrontRight + << QtIVIClimateZone::RearLeft << QtIVIClimateZone::RearCenter << QtIVIClimateZone::RearRight; + foreach(QtIVIClimateZone::Zone z, zones) { + connect(backend, &QtIVIClimateControlBackendInterface::targetTemperatureChanged, m_zones[z], &QtIVIClimateZone::onTargetTemperatureChanged); + connect(backend, &QtIVIClimateControlBackendInterface::seatCoolerChanged, m_zones[z], &QtIVIClimateZone::onSeatCoolerChanged); + connect(backend, &QtIVIClimateControlBackendInterface::seatHeaterChanged, m_zones[z], &QtIVIClimateZone::onSeatHeaterChanged); + m_zones[z]->onTargetTemperatureChanged(z, backend->targetTemperature(z)); + m_zones[z]->onSeatCoolerChanged(z, backend->seatCooler(z)); + m_zones[z]->onSeatHeaterChanged(z, backend->seatHeater(z)); + /* Set the has properties last to ensure that the value is available when signalling */ + m_zones[z]->setHasTargetTemperature(backend->hasTargetTemperature(z)); + m_zones[z]->setHasSeatCooler(backend->hasSeatCooler(z)); + m_zones[z]->setHasSeatHeater(backend->hasSeatHeater(z)); + } + + connect(backend, &QtIVIClimateControlBackendInterface::airflowDirectionChanged, this, &QtIVIClimateControl::onAirflowDirectionChanged); + connect(backend, &QtIVIClimateControlBackendInterface::airConditioningEnabledChanged, this, &QtIVIClimateControl::onAirConditioningEnabledChanged); + connect(backend, &QtIVIClimateControlBackendInterface::heaterEnabledChanged, this, &QtIVIClimateControl::onHeaterEnabledChanged); + connect(backend, &QtIVIClimateControlBackendInterface::airRecirculationEnabledChanged, this, &QtIVIClimateControl::onAirRecirculationEnabledChanged); + connect(backend, &QtIVIClimateControlBackendInterface::steeringWheelHeaterChanged, this, &QtIVIClimateControl::onSteeringWheelHeaterChanged); + connect(backend, &QtIVIClimateControlBackendInterface::fanSpeedLevelChanged, this, &QtIVIClimateControl::onFanSpeedLevelChanged); + + onAirflowDirectionChanged(backend->airflowDirection()); + onAirConditioningEnabledChanged(backend->airConditioningEnabled()); + onHeaterEnabledChanged(backend->heaterEnabled()); + onAirRecirculationEnabledChanged(backend->airRecirculationEnabled()); + onSteeringWheelHeaterChanged(backend->steeringWheelHeater()); + onFanSpeedLevelChanged(backend->fanSpeedLevel()); +} + +void QtIVIClimateControl::disconnectFromServiceObject(QtIVIServiceObject *so) +{ + QtIVIClimateControlBackendInterface *backend = qobject_cast(so->interfaceInstance(QtIVIClimateControlBackendInterface::interfaceName)); + + QList zones; + zones << QtIVIClimateZone::FrontLeft << QtIVIClimateZone::FrontCenter << QtIVIClimateZone::FrontRight + << QtIVIClimateZone::RearLeft << QtIVIClimateZone::RearCenter << QtIVIClimateZone::RearRight; + foreach(QtIVIClimateZone::Zone z, zones) { + disconnect(backend, &QtIVIClimateControlBackendInterface::targetTemperatureChanged, m_zones[z], &QtIVIClimateZone::onTargetTemperatureChanged); + disconnect(backend, &QtIVIClimateControlBackendInterface::seatCoolerChanged, m_zones[z], &QtIVIClimateZone::onSeatCoolerChanged); + disconnect(backend, &QtIVIClimateControlBackendInterface::seatHeaterChanged, m_zones[z], &QtIVIClimateZone::onSeatHeaterChanged); + } + + disconnect(backend, &QtIVIClimateControlBackendInterface::airflowDirectionChanged, this, &QtIVIClimateControl::onAirflowDirectionChanged); + disconnect(backend, &QtIVIClimateControlBackendInterface::airConditioningEnabledChanged, this, &QtIVIClimateControl::onAirConditioningEnabledChanged); + disconnect(backend, &QtIVIClimateControlBackendInterface::heaterEnabledChanged, this, &QtIVIClimateControl::onHeaterEnabledChanged); + disconnect(backend, &QtIVIClimateControlBackendInterface::airRecirculationEnabledChanged, this, &QtIVIClimateControl::onAirRecirculationEnabledChanged); + disconnect(backend, &QtIVIClimateControlBackendInterface::steeringWheelHeaterChanged, this, &QtIVIClimateControl::onSteeringWheelHeaterChanged); + disconnect(backend, &QtIVIClimateControlBackendInterface::fanSpeedLevelChanged, this, &QtIVIClimateControl::onFanSpeedLevelChanged); +} + +void QtIVIClimateControl::clearServiceObject() +{ + /* Safe defaults */ + onAirflowDirectionChanged(QtIVIClimateControl::BiLevel); + onAirConditioningEnabledChanged(false); + onHeaterEnabledChanged(false); + onAirRecirculationEnabledChanged(false); + onSteeringWheelHeaterChanged(0); + onFanSpeedLevelChanged(0); + + QList zones; + zones << QtIVIClimateZone::FrontLeft << QtIVIClimateZone::FrontCenter << QtIVIClimateZone::FrontRight + << QtIVIClimateZone::RearLeft << QtIVIClimateZone::RearCenter << QtIVIClimateZone::RearRight; + foreach(QtIVIClimateZone::Zone z, zones) { + m_zones[z]->setHasTargetTemperature(false); + m_zones[z]->setHasSeatCooler(false); + m_zones[z]->setHasSeatHeater(false); + } +} + +void QtIVIClimateControl::onAirflowDirectionChanged(QtIVIClimateControl::AirflowDirection airflowDirection) +{ + m_airflowDirection = airflowDirection; + emit airflowDirectionChanged(m_airflowDirection); +} + +void QtIVIClimateControl::onAirConditioningEnabledChanged(bool airConditioning) +{ + m_airConditioning = airConditioning; + emit airConditioningEnabledChanged(m_airConditioning); +} + +void QtIVIClimateControl::onHeaterEnabledChanged(bool heater) +{ + m_heater = heater; + emit heaterEnabledChanged(m_heater); +} + +void QtIVIClimateControl::onAirRecirculationEnabledChanged(bool airRecirculation) +{ + m_airRecirculation = airRecirculation; + emit airRecirculationEnabledChanged(m_airRecirculation); +} + +void QtIVIClimateControl::onSteeringWheelHeaterChanged(int steeringWheelHeater) +{ + m_steeringWheelHeater = steeringWheelHeater; + emit steeringWheelHeaterChanged(m_steeringWheelHeater); +} + +void QtIVIClimateControl::onFanSpeedLevelChanged(int fanSpeedLevel) +{ + m_fanSpeedLevel = fanSpeedLevel; + emit fanSpeedLevelChanged(m_fanSpeedLevel); +} + +QtIVIClimateControlBackendInterface *QtIVIClimateControl::backend() const +{ + if (serviceObject()) + return qobject_cast(serviceObject()->interfaceInstance(QtIVIClimateControlBackendInterface::interfaceName)); + else + return 0; +} diff --git a/src/ivivehiclefunctions/qtiviclimatecontrol.h b/src/ivivehiclefunctions/qtiviclimatecontrol.h new file mode 100644 index 0000000..cce6c07 --- /dev/null +++ b/src/ivivehiclefunctions/qtiviclimatecontrol.h @@ -0,0 +1,208 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#ifndef CLIMATECONTROL_H +#define CLIMATECONTROL_H + +#include + +#include +#include +#include + +class QtIVIClimateControl; +class QtIVIClimateControlBackendInterface; + +/* Properties based on http://www.w3.org/2014/automotive/data_spec.html#idl-def-ClimateControl + * This list contains properties per zone. + */ +class Q_QTIVIVEHICLEFUNCTIONS_EXPORT QtIVIClimateZone : public QObject +{ + Q_OBJECT + + Q_PROPERTY(Zone zone READ zone CONSTANT) + Q_PROPERTY(bool hasTargetTemperature READ hasTargetTemperature NOTIFY hasTargetTemperatureChanged) + Q_PROPERTY(bool hasSeatCooler READ hasSeatCooler NOTIFY hasSeatCoolerChanged) + Q_PROPERTY(bool hasSeatHeater READ hasSeatHeater NOTIFY hasSeatHeaterChanged) + /* current setting of the desired temperature (Unit: celsius) */ + Q_PROPERTY(int targetTemperature READ targetTemperature WRITE setTargetTemperature NOTIFY targetTemperatureChanged) + /* current status of the seat ventilation ( 0: off, 1: least warm, 10: warmest ) */ + Q_PROPERTY(int seatCooler READ seatCooler WRITE setSeatCooler NOTIFY seatCoolerChanged) + /* current status of the seat warmer ( 0: off, 1: least warm, 10: warmest ) */ + Q_PROPERTY(int seatHeater READ seatHeater WRITE setSeatHeater NOTIFY seatHeaterChanged) + + Q_ENUMS(Zone) + +public: + /* Based on http://www.w3.org/2014/automotive/vehicle_spec.html#idl-def-Zone */ + enum Zone { + FrontLeft, + FrontCenter, + FrontRight, + RearLeft, + RearCenter, + RearRight + }; + + QtIVIClimateZone(Zone zone, QtIVIClimateControl *parent); + + Zone zone() const; + + bool hasTargetTemperature() const; + bool hasSeatCooler() const; + bool hasSeatHeater() const; + + int targetTemperature() const; + int seatCooler() const; + int seatHeater() const; + +public slots: + void setTargetTemperature(int); + void setSeatCooler(int); + void setSeatHeater(int); + +signals: + void hasTargetTemperatureChanged(bool hasTargetTemperature); + void hasSeatCoolerChanged(bool hasSeatCooler); + void hasSeatHeaterChanged(bool hasSeatHeater); + + void targetTemperatureChanged(int targetTemperature); + void seatCoolerChanged(int seatCooler); + void seatHeaterChanged(int seatHeater); + +private slots: + void onTargetTemperatureChanged(QtIVIClimateZone::Zone z, int t); + void onSeatCoolerChanged(QtIVIClimateZone::Zone z, int t); + void onSeatHeaterChanged(QtIVIClimateZone::Zone z, int t); + +private: + friend class QtIVIClimateControl; + + void setHasTargetTemperature(bool); + void setHasSeatCooler(bool); + void setHasSeatHeater(bool); + + Zone m_zone; + + bool m_hasTargetTemperature; + bool m_hasSeatCooler; + bool m_hasSeatHeater; + + int m_targetTemperature; + int m_seatCooler; + int m_seatHeater; +}; + + +/* Properties based on http://www.w3.org/2014/automotive/data_spec.html#idl-def-ClimateControl + * This list contains the properties for the whole car. + */ +class Q_QTIVIVEHICLEFUNCTIONS_EXPORT QtIVIClimateControl : public QtIVIAbstractFeature +{ + Q_OBJECT + + Q_PROPERTY(AirflowDirection airflowDirection READ airflowDirection WRITE setAirflowDirection NOTIFY airflowDirectionChanged) + /* current status of the air conditioning system: on (true) or off (false) */ + Q_PROPERTY(bool airConditioning READ isAirConditioningEnabled WRITE setAirConditioningEnabled NOTIFY airConditioningEnabledChanged) + /* current status of the heating system: on (true) or off (false) */ + Q_PROPERTY(bool heater READ isHeaterEnabled WRITE setHeaterEnabled NOTIFY heaterEnabledChanged) + /* current setting of air recirculation: on (true) or pulling in outside air (false) */ + Q_PROPERTY(bool airRecirculation READ isAirRecirculationEnabled WRITE setAirRecirculationEnabled NOTIFY airRecirculationEnabledChanged) + /* current status of steering wheel heater ( 0: off, 1: least warm, 10: warmest ) */ + Q_PROPERTY(int steeringWheelHeater READ steeringWheelHeater WRITE setSteeringWheelHeater NOTIFY steeringWheelHeaterChanged) + /* current status of the fan speed of the air flowing (0: off, 1: weakest, 10: strongest ) */ + Q_PROPERTY(int fanSpeedLevel READ fanSpeedLevel WRITE setFanSpeedLevel NOTIFY fanSpeedLevelChanged) + + Q_PROPERTY(QtIVIClimateZone* frontLeftZone READ frontLeftZone CONSTANT) + Q_PROPERTY(QtIVIClimateZone* frontCenterZone READ frontCenterZone CONSTANT) + Q_PROPERTY(QtIVIClimateZone* frontRightZone READ frontRightZone CONSTANT) + Q_PROPERTY(QtIVIClimateZone* rearLeftZone READ rearLeftZone CONSTANT) + Q_PROPERTY(QtIVIClimateZone* rearCenterZone READ rearCenterZone CONSTANT) + Q_PROPERTY(QtIVIClimateZone* rearRightZone READ rearRightZone CONSTANT) + + Q_PROPERTY(QtIVIClimateZone* driver READ driver CONSTANT) + + Q_ENUMS(AirflowDirection) + +public: + QtIVIClimateControl(QObject *parent=0); + + /* Based on http://www.w3.org/2014/automotive/data_spec.html#idl-def-AirflowDirection */ + enum AirflowDirection { + FloorPanel, + FloorDuct, + BiLevel, + DefrostFloor + }; + + AirflowDirection airflowDirection() const; + + bool isAirConditioningEnabled() const; + bool isHeaterEnabled() const; + bool isAirRecirculationEnabled() const; + int steeringWheelHeater() const; + int fanSpeedLevel() const; + + QtIVIClimateZone *climateZone(QtIVIClimateZone::Zone) const; + QtIVIClimateZone *driver() const; + + QtIVIClimateZone *frontLeftZone() const; + QtIVIClimateZone *frontCenterZone() const; + QtIVIClimateZone *frontRightZone() const; + QtIVIClimateZone *rearLeftZone() const; + QtIVIClimateZone *rearCenterZone() const; + QtIVIClimateZone *rearRightZone() const; + +public slots: + void setAirflowDirection(QtIVIClimateControl::AirflowDirection); + void setAirConditioningEnabled(bool); + void setHeaterEnabled(bool); + void setAirRecirculationEnabled(bool); + void setSteeringWheelHeater(int); + void setFanSpeedLevel(int); + +signals: + void airflowDirectionChanged(QtIVIClimateControl::AirflowDirection airflowDirection); + void airConditioningEnabledChanged(bool airConditioning); + void heaterEnabledChanged(bool heaterEnabled); + void airRecirculationEnabledChanged(bool airRecirculation); + void steeringWheelHeaterChanged(int steeringWheelHeater); + void fanSpeedLevelChanged(int fanSpeedLevel); + +protected: + virtual bool acceptServiceObject(QtIVIServiceObject *so); + virtual void connectToServiceObject(QtIVIServiceObject *so); + virtual void disconnectFromServiceObject(QtIVIServiceObject *so); + virtual void clearServiceObject(); + +private slots: + void onAirflowDirectionChanged(QtIVIClimateControl::AirflowDirection airflowDirection); + void onAirConditioningEnabledChanged(bool airConditioning); + void onHeaterEnabledChanged(bool heater); + void onAirRecirculationEnabledChanged(bool airRecirculation); + void onSteeringWheelHeaterChanged(int steeringWheelHeater); + void onFanSpeedLevelChanged(int fanSpeedLevel); + +private: + friend class QtIVIClimateZone; + + QtIVIClimateControlBackendInterface *backend() const; + + AirflowDirection m_airflowDirection; + bool m_airConditioning; + bool m_heater; + bool m_airRecirculation; + int m_steeringWheelHeater; + int m_fanSpeedLevel; + + QMap m_zones; +}; + +#endif // CLIMATECONTROL_H diff --git a/src/ivivehiclefunctions/qtiviclimatecontrolbackendinterface.h b/src/ivivehiclefunctions/qtiviclimatecontrolbackendinterface.h new file mode 100644 index 0000000..e4e046c --- /dev/null +++ b/src/ivivehiclefunctions/qtiviclimatecontrolbackendinterface.h @@ -0,0 +1,68 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#ifndef QTIVICLIMATECONTROLBACKENDINTERFACE_H +#define QTIVICLIMATECONTROLBACKENDINTERFACE_H + +#include + +#include "qtiviclimatecontrol.h" + +class Q_QTIVIVEHICLEFUNCTIONS_EXPORT QtIVIClimateControlBackendInterface : public QObject +{ + Q_OBJECT + +public: + QtIVIClimateControlBackendInterface(QObject *parent=0) : QObject(parent) {} + + static QString interfaceName; + + virtual bool hasTargetTemperature(QtIVIClimateZone::Zone) = 0; + virtual bool hasSeatCooler(QtIVIClimateZone::Zone) = 0; + virtual bool hasSeatHeater(QtIVIClimateZone::Zone) = 0; + virtual void setTargetTemperature(QtIVIClimateZone::Zone, int) = 0; + virtual void setSeatCooler(QtIVIClimateZone::Zone, int) = 0; + virtual void setSeatHeater(QtIVIClimateZone::Zone, int) = 0; + + virtual QtIVIClimateZone::Zone driverZone() const = 0; + + virtual void setAirflowDirection(QtIVIClimateControl::AirflowDirection) = 0; + virtual void setAirConditioningEnabled(bool) = 0; + virtual void setHeaterEnabled(bool) = 0; + virtual void setAirRecirculationEnabled(bool) = 0; + virtual void setSteeringWheelHeater(int) = 0; + virtual void setFanSpeedLevel(int) = 0; + + virtual int targetTemperature(QtIVIClimateZone::Zone) const = 0; + virtual int seatCooler(QtIVIClimateZone::Zone) const = 0; + virtual int seatHeater(QtIVIClimateZone::Zone) const = 0; + + virtual QtIVIClimateControl::AirflowDirection airflowDirection() const = 0; + virtual bool airConditioningEnabled() const = 0; + virtual bool heaterEnabled() const = 0; + virtual bool airRecirculationEnabled() const = 0; + virtual int steeringWheelHeater() const = 0; + virtual int fanSpeedLevel() const = 0; + +signals: + void targetTemperatureChanged(QtIVIClimateZone::Zone, int); + void seatCoolerChanged(QtIVIClimateZone::Zone, int); + void seatHeaterChanged(QtIVIClimateZone::Zone, int); + + void airflowDirectionChanged(QtIVIClimateControl::AirflowDirection); + void airConditioningEnabledChanged(bool); + void heaterEnabledChanged(bool); + void airRecirculationEnabledChanged(bool); + void steeringWheelHeaterChanged(int); + void fanSpeedLevelChanged(int); +}; + +#endif // QTIVICLIMATECONTROLBACKENDINTERFACE_H + diff --git a/src/ivivehiclefunctions/qtivivehiclefunctionsglobal.h b/src/ivivehiclefunctions/qtivivehiclefunctionsglobal.h new file mode 100644 index 0000000..dc6a21a --- /dev/null +++ b/src/ivivehiclefunctions/qtivivehiclefunctionsglobal.h @@ -0,0 +1,31 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#ifndef QTIVIVEHICLEFUNCTIONSGLOBAL_H +#define QTIVIVEHICLEFUNCTIONSGLOBAL_H + +#include + +QT_BEGIN_NAMESPACE + +#ifndef QT_STATIC +# if defined(QT_BUILD_QTIVIVEHICLEFUNCTIONS_LIB) +# define Q_QTIVIVEHICLEFUNCTIONS_EXPORT Q_DECL_EXPORT +# else +# define Q_QTIVIVEHICLEFUNCTIONS_EXPORT Q_DECL_IMPORT +# endif +#else +# define Q_QTIVICORE_EXPORT +#endif + +QT_END_NAMESPACE + +#endif // QTIVIVEHICLEFUNCTIONSGLOBAL_H + diff --git a/src/plugins/ivivehiclefunctions/climate_simulator/climate_simulator.json b/src/plugins/ivivehiclefunctions/climate_simulator/climate_simulator.json new file mode 100644 index 0000000..048376a --- /dev/null +++ b/src/plugins/ivivehiclefunctions/climate_simulator/climate_simulator.json @@ -0,0 +1,3 @@ +{ + "interfaces" : [ "com.pelagicore.ClimateControl" ] +} diff --git a/src/plugins/ivivehiclefunctions/climate_simulator/climate_simulator.pro b/src/plugins/ivivehiclefunctions/climate_simulator/climate_simulator.pro new file mode 100644 index 0000000..2c4e0b2 --- /dev/null +++ b/src/plugins/ivivehiclefunctions/climate_simulator/climate_simulator.pro @@ -0,0 +1,28 @@ +################################################################################################## +# Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. +# +# This software, including documentation, is protected by copyright controlled by Pelagicore AG. +# All rights reserved. Copying, including reproducing, storing, adapting or translating, any or +# all of this material requires prior written consent of Pelagicore AG Corporation. This material +# also contains confidential information which may not be disclosed to others without the prior +# written consent of Pelagicore AG. +################################################################################################## + +TARGET = climate_simulator + +PLUGIN_TYPE = qtivi +PLUGIN_EXTENDS = qtivi +PLUGIN_CLASS_NAME = QtIVIClimateControlBackendInterface + +QT += core ivicore ivivehiclefunctions + +load(qt_plugin) + + +SOURCES += climateplugin.cpp \ + climatecontrolbackend.cpp + +HEADERS += climateplugin.h \ + climatecontrolbackend.h + +DISTFILES += climate_simulator.json diff --git a/src/plugins/ivivehiclefunctions/climate_simulator/climatecontrolbackend.cpp b/src/plugins/ivivehiclefunctions/climate_simulator/climatecontrolbackend.cpp new file mode 100644 index 0000000..aab13a1 --- /dev/null +++ b/src/plugins/ivivehiclefunctions/climate_simulator/climatecontrolbackend.cpp @@ -0,0 +1,242 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#include "climatecontrolbackend.h" + +#include + +ClimateControlBackend::ClimateControlBackend(QObject *parent) : + QtIVIClimateControlBackendInterface(parent), + m_flowDirection(QtIVIClimateControl::BiLevel), + m_airCondition(true), + m_heater(true), + m_airRecirculation(false), + m_steeringWheelHeater(0), + m_fanSpeed(10) +{ + ZoneBackend leftZone; + leftZone.hasSeatCooler = true; + leftZone.seattCooler = 10; + leftZone.hasSeatHeater = true; + leftZone.seatHeater = 10; + leftZone.targetTemperature = 20; + + m_zoneMap.insert(QtIVIClimateZone::FrontLeft,leftZone); + + ZoneBackend rightZone; + rightZone.hasSeatCooler = false; + rightZone.seattCooler = 5; + rightZone.hasSeatHeater = false; + rightZone.seatHeater = 0; + rightZone.targetTemperature = 10; + + m_zoneMap.insert(QtIVIClimateZone::FrontRight,rightZone); +} + +ClimateControlBackend::~ClimateControlBackend() +{ +} + +bool ClimateControlBackend::hasTargetTemperature(QtIVIClimateZone::Zone zone) +{ + if (!m_zoneMap.contains(zone)) + return false; + + return m_zoneMap[zone].hasTargetTemperature; +} + +bool ClimateControlBackend::hasSeatCooler(QtIVIClimateZone::Zone zone) +{ + if (!m_zoneMap.contains(zone)) + return false; + + return m_zoneMap[zone].hasSeatCooler; +} + +bool ClimateControlBackend::hasSeatHeater(QtIVIClimateZone::Zone zone) +{ + if (!m_zoneMap.contains(zone)) + return false; + + return m_zoneMap[zone].hasSeatHeater; +} + +void ClimateControlBackend::setTargetTemperature(QtIVIClimateZone::Zone zone, int val) +{ + if (!m_zoneMap.contains(zone)) + return; + + if (m_zoneMap[zone].targetTemperature == val) + return; + + qWarning() << "SIMULATION TargetTemperature for Zone" << zone << "changed to" << val; + + m_zoneMap[zone].targetTemperature = val; + emit targetTemperatureChanged(zone, val); +} + +void ClimateControlBackend::setSeatCooler(QtIVIClimateZone::Zone zone, int val) +{ + if (!m_zoneMap.contains(zone)) + return; + + if (m_zoneMap[zone].seattCooler == val) + return; + + qWarning() << "SIMULATION SeatCooler for Zone" << zone << "changed to" << val; + + m_zoneMap[zone].seattCooler = val; + emit seatCoolerChanged(zone, val); +} + +void ClimateControlBackend::setSeatHeater(QtIVIClimateZone::Zone zone, int val) +{ + if (!m_zoneMap.contains(zone)) + return; + + if (m_zoneMap[zone].seatHeater == val) + return; + + qWarning() << "SIMULATION SeatHeater for Zone" << zone << "changed to" << val; + + m_zoneMap[zone].seatHeater = val; + emit seatHeaterChanged(zone, val); +} + +QtIVIClimateZone::Zone ClimateControlBackend::driverZone() const +{ + return QtIVIClimateZone::FrontLeft; +} + +void ClimateControlBackend::setAirflowDirection(QtIVIClimateControl::AirflowDirection direction) +{ + if (m_flowDirection == direction) + return; + + qWarning() << "SIMULATION AirflowDirection changed to" << direction; + + m_flowDirection = direction; + emit airflowDirectionChanged(direction); +} + +void ClimateControlBackend::setAirConditioningEnabled(bool val) +{ + if (m_airCondition == val) + return; + + qWarning() << "SIMULATION AirConditionEnabled changed to" << val; + + m_airCondition = val; + emit airConditioningEnabledChanged(val); +} + +void ClimateControlBackend::setHeaterEnabled(bool val) +{ + if (m_heater == val) + return; + + qWarning() << "SIMULATION HeaterEnabled changed to" << val; + + m_heater = val; + emit heaterEnabledChanged(val); +} + +void ClimateControlBackend::setAirRecirculationEnabled(bool val) +{ + if (m_heater == val) + return; + + qWarning() << "SIMULATION AirRecirculationEnabled changed to" << val; + + m_heater = val; + emit airRecirculationEnabledChanged(val); +} + +void ClimateControlBackend::setSteeringWheelHeater(int val) +{ + if (val < 0 || val > 10) { + qWarning() << "SIMULATION SteeringWheelHeater change out of range (0-10)" << val; + emit steeringWheelHeaterChanged(m_steeringWheelHeater); + return; + } + + if (m_steeringWheelHeater == val) + return; + + qWarning() << "SIMULATION SteeringWheelHeater changed to" << val; + + m_steeringWheelHeater = val; + emit steeringWheelHeaterChanged(val); +} + +void ClimateControlBackend::setFanSpeedLevel(int speed) +{ + if (m_fanSpeed == speed) + return; + + qWarning() << "SIMULATION FanSpeedLevel changed to" << speed; + + m_fanSpeed = speed; + emit fanSpeedLevelChanged(speed); +} + +int ClimateControlBackend::targetTemperature(QtIVIClimateZone::Zone zone) const +{ + if (!m_zoneMap.contains(zone)) + return -1; + + return m_zoneMap[zone].targetTemperature; +} + +int ClimateControlBackend::seatCooler(QtIVIClimateZone::Zone zone) const +{ + if (!m_zoneMap.contains(zone)) + return -1; + + return m_zoneMap[zone].seattCooler; +} + +int ClimateControlBackend::seatHeater(QtIVIClimateZone::Zone zone) const +{ + if (!m_zoneMap.contains(zone)) + return -1; + + return m_zoneMap[zone].seatHeater; +} + +QtIVIClimateControl::AirflowDirection ClimateControlBackend::airflowDirection() const +{ + return m_flowDirection; +} + +bool ClimateControlBackend::airConditioningEnabled() const +{ + return m_airCondition; +} + +bool ClimateControlBackend::heaterEnabled() const +{ + return m_heater; +} + +bool ClimateControlBackend::airRecirculationEnabled() const +{ + return m_airRecirculation; +} + +int ClimateControlBackend::steeringWheelHeater() const +{ + return m_steeringWheelHeater; +} + +int ClimateControlBackend::fanSpeedLevel() const +{ + return m_fanSpeed; +} diff --git a/src/plugins/ivivehiclefunctions/climate_simulator/climatecontrolbackend.h b/src/plugins/ivivehiclefunctions/climate_simulator/climatecontrolbackend.h new file mode 100644 index 0000000..5e0fe98 --- /dev/null +++ b/src/plugins/ivivehiclefunctions/climate_simulator/climatecontrolbackend.h @@ -0,0 +1,69 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#ifndef CLIMATECONTROLBACKEND_H +#define CLIMATECONTROLBACKEND_H + +#include +#include + +class ClimateControlBackend : public QtIVIClimateControlBackendInterface +{ +public: + ClimateControlBackend(QObject* parent = 0); + ~ClimateControlBackend(); + + // QtIVIClimateControlBackendInterface interface +public: + bool hasTargetTemperature(QtIVIClimateZone::Zone zone); + bool hasSeatCooler(QtIVIClimateZone::Zone zone); + bool hasSeatHeater(QtIVIClimateZone::Zone zone); + void setTargetTemperature(QtIVIClimateZone::Zone zone, int val); + void setSeatCooler(QtIVIClimateZone::Zone zone, int val); + void setSeatHeater(QtIVIClimateZone::Zone zone, int val); + QtIVIClimateZone::Zone driverZone() const; + void setAirflowDirection(QtIVIClimateControl::AirflowDirection direction); + void setAirConditioningEnabled(bool val); + void setHeaterEnabled(bool val); + void setAirRecirculationEnabled(bool val); + void setSteeringWheelHeater(int val); + void setFanSpeedLevel(int); + int targetTemperature(QtIVIClimateZone::Zone zone) const; + int seatCooler(QtIVIClimateZone::Zone zone) const; + int seatHeater(QtIVIClimateZone::Zone zone) const; + QtIVIClimateControl::AirflowDirection airflowDirection() const; + bool airConditioningEnabled() const; + bool heaterEnabled() const; + bool airRecirculationEnabled() const; + int steeringWheelHeater() const; + int fanSpeedLevel() const; + +private: + + QtIVIClimateControl::AirflowDirection m_flowDirection; + bool m_airCondition; + bool m_heater; + bool m_airRecirculation; + int m_steeringWheelHeater; + int m_fanSpeed; + + struct ZoneBackend{ + bool hasTargetTemperature; + int targetTemperature; + bool hasSeatCooler; + int seattCooler; + bool hasSeatHeater; + int seatHeater; + }; + + QMap m_zoneMap; +}; + +#endif // CLIMATECONTROLBACKEND_H diff --git a/src/plugins/ivivehiclefunctions/climate_simulator/climateplugin.cpp b/src/plugins/ivivehiclefunctions/climate_simulator/climateplugin.cpp new file mode 100644 index 0000000..c97c02a --- /dev/null +++ b/src/plugins/ivivehiclefunctions/climate_simulator/climateplugin.cpp @@ -0,0 +1,36 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#include "climateplugin.h" +#include "climatecontrolbackend.h" + +#include +#include + +ClimatePlugin::ClimatePlugin(QObject *parent) : + QObject(parent), + m_climate(new ClimateControlBackend(this)) +{ +} + +QStringList ClimatePlugin::interfaces() const +{ + QStringList list; + list << QtIVIClimateControlBackendInterface::interfaceName; + return list; +} + +QObject *ClimatePlugin::interfaceInstance(const QString &interface) const +{ + if (interface != QtIVIClimateControlBackendInterface::interfaceName) + return 0; + + return m_climate; +} diff --git a/src/plugins/ivivehiclefunctions/climate_simulator/climateplugin.h b/src/plugins/ivivehiclefunctions/climate_simulator/climateplugin.h new file mode 100644 index 0000000..58b0e04 --- /dev/null +++ b/src/plugins/ivivehiclefunctions/climate_simulator/climateplugin.h @@ -0,0 +1,34 @@ +/************************************************************************************************ + * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. + * + * This software, including documentation, is protected by copyright controlled by Pelagicore AG. + * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or + * all of this material requires prior written consent of Pelagicore AG Corporation. This material + * also contains confidential information which may not be disclosed to others without the prior + * written consent of Pelagicore AG. + ************************************************************************************************/ + +#ifndef CLIMATEPLUGIN_H +#define CLIMATEPLUGIN_H + +#include + +class ClimateControlBackend; + +class ClimatePlugin : public QObject, QtIVIServiceInterface +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "com.pelagicore.QtIVIServiceInterface" FILE "climate_simulator.json") + Q_INTERFACES(QtIVIServiceInterface) + +public: + ClimatePlugin(QObject *parent = 0); + + QStringList interfaces() const; + QObject* interfaceInstance(const QString& interface) const; + +private: + ClimateControlBackend* m_climate; +}; + +#endif // CLIMATEPLUGIN_H diff --git a/src/plugins/ivivehiclefunctions/ivivehiclefunctions.pro b/src/plugins/ivivehiclefunctions/ivivehiclefunctions.pro new file mode 100644 index 0000000..33efe89 --- /dev/null +++ b/src/plugins/ivivehiclefunctions/ivivehiclefunctions.pro @@ -0,0 +1,13 @@ +################################################################################################## +# Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. +# +# This software, including documentation, is protected by copyright controlled by Pelagicore AG. +# All rights reserved. Copying, including reproducing, storing, adapting or translating, any or +# all of this material requires prior written consent of Pelagicore AG Corporation. This material +# also contains confidential information which may not be disclosed to others without the prior +# written consent of Pelagicore AG. +################################################################################################## + +TEMPLATE = subdirs +SUBDIRS = climate_simulator + diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index d02f230..7049bb6 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -9,5 +9,5 @@ ################################################################################################## TEMPLATE = subdirs -SUBDIRS = vehiclefunctions +SUBDIRS = ivivehiclefunctions diff --git a/src/plugins/vehiclefunctions/climate_simulator/climate_simulator.json b/src/plugins/vehiclefunctions/climate_simulator/climate_simulator.json deleted file mode 100644 index 048376a..0000000 --- a/src/plugins/vehiclefunctions/climate_simulator/climate_simulator.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "interfaces" : [ "com.pelagicore.ClimateControl" ] -} diff --git a/src/plugins/vehiclefunctions/climate_simulator/climate_simulator.pro b/src/plugins/vehiclefunctions/climate_simulator/climate_simulator.pro deleted file mode 100644 index f8b1137..0000000 --- a/src/plugins/vehiclefunctions/climate_simulator/climate_simulator.pro +++ /dev/null @@ -1,28 +0,0 @@ -################################################################################################## -# Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. -# -# This software, including documentation, is protected by copyright controlled by Pelagicore AG. -# All rights reserved. Copying, including reproducing, storing, adapting or translating, any or -# all of this material requires prior written consent of Pelagicore AG Corporation. This material -# also contains confidential information which may not be disclosed to others without the prior -# written consent of Pelagicore AG. -################################################################################################## - -TARGET = climate_simulator - -PLUGIN_TYPE = qtivi -PLUGIN_EXTENDS = qtivi -PLUGIN_CLASS_NAME = QtIVIClimateControlBackendInterface - -QT += core QtIVICore QtIVIVehicleFunctions - -load(qt_plugin) - - -SOURCES += climateplugin.cpp \ - climatecontrolbackend.cpp - -HEADERS += climateplugin.h \ - climatecontrolbackend.h - -DISTFILES += climate_simulator.json diff --git a/src/plugins/vehiclefunctions/climate_simulator/climatecontrolbackend.cpp b/src/plugins/vehiclefunctions/climate_simulator/climatecontrolbackend.cpp deleted file mode 100644 index aab13a1..0000000 --- a/src/plugins/vehiclefunctions/climate_simulator/climatecontrolbackend.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#include "climatecontrolbackend.h" - -#include - -ClimateControlBackend::ClimateControlBackend(QObject *parent) : - QtIVIClimateControlBackendInterface(parent), - m_flowDirection(QtIVIClimateControl::BiLevel), - m_airCondition(true), - m_heater(true), - m_airRecirculation(false), - m_steeringWheelHeater(0), - m_fanSpeed(10) -{ - ZoneBackend leftZone; - leftZone.hasSeatCooler = true; - leftZone.seattCooler = 10; - leftZone.hasSeatHeater = true; - leftZone.seatHeater = 10; - leftZone.targetTemperature = 20; - - m_zoneMap.insert(QtIVIClimateZone::FrontLeft,leftZone); - - ZoneBackend rightZone; - rightZone.hasSeatCooler = false; - rightZone.seattCooler = 5; - rightZone.hasSeatHeater = false; - rightZone.seatHeater = 0; - rightZone.targetTemperature = 10; - - m_zoneMap.insert(QtIVIClimateZone::FrontRight,rightZone); -} - -ClimateControlBackend::~ClimateControlBackend() -{ -} - -bool ClimateControlBackend::hasTargetTemperature(QtIVIClimateZone::Zone zone) -{ - if (!m_zoneMap.contains(zone)) - return false; - - return m_zoneMap[zone].hasTargetTemperature; -} - -bool ClimateControlBackend::hasSeatCooler(QtIVIClimateZone::Zone zone) -{ - if (!m_zoneMap.contains(zone)) - return false; - - return m_zoneMap[zone].hasSeatCooler; -} - -bool ClimateControlBackend::hasSeatHeater(QtIVIClimateZone::Zone zone) -{ - if (!m_zoneMap.contains(zone)) - return false; - - return m_zoneMap[zone].hasSeatHeater; -} - -void ClimateControlBackend::setTargetTemperature(QtIVIClimateZone::Zone zone, int val) -{ - if (!m_zoneMap.contains(zone)) - return; - - if (m_zoneMap[zone].targetTemperature == val) - return; - - qWarning() << "SIMULATION TargetTemperature for Zone" << zone << "changed to" << val; - - m_zoneMap[zone].targetTemperature = val; - emit targetTemperatureChanged(zone, val); -} - -void ClimateControlBackend::setSeatCooler(QtIVIClimateZone::Zone zone, int val) -{ - if (!m_zoneMap.contains(zone)) - return; - - if (m_zoneMap[zone].seattCooler == val) - return; - - qWarning() << "SIMULATION SeatCooler for Zone" << zone << "changed to" << val; - - m_zoneMap[zone].seattCooler = val; - emit seatCoolerChanged(zone, val); -} - -void ClimateControlBackend::setSeatHeater(QtIVIClimateZone::Zone zone, int val) -{ - if (!m_zoneMap.contains(zone)) - return; - - if (m_zoneMap[zone].seatHeater == val) - return; - - qWarning() << "SIMULATION SeatHeater for Zone" << zone << "changed to" << val; - - m_zoneMap[zone].seatHeater = val; - emit seatHeaterChanged(zone, val); -} - -QtIVIClimateZone::Zone ClimateControlBackend::driverZone() const -{ - return QtIVIClimateZone::FrontLeft; -} - -void ClimateControlBackend::setAirflowDirection(QtIVIClimateControl::AirflowDirection direction) -{ - if (m_flowDirection == direction) - return; - - qWarning() << "SIMULATION AirflowDirection changed to" << direction; - - m_flowDirection = direction; - emit airflowDirectionChanged(direction); -} - -void ClimateControlBackend::setAirConditioningEnabled(bool val) -{ - if (m_airCondition == val) - return; - - qWarning() << "SIMULATION AirConditionEnabled changed to" << val; - - m_airCondition = val; - emit airConditioningEnabledChanged(val); -} - -void ClimateControlBackend::setHeaterEnabled(bool val) -{ - if (m_heater == val) - return; - - qWarning() << "SIMULATION HeaterEnabled changed to" << val; - - m_heater = val; - emit heaterEnabledChanged(val); -} - -void ClimateControlBackend::setAirRecirculationEnabled(bool val) -{ - if (m_heater == val) - return; - - qWarning() << "SIMULATION AirRecirculationEnabled changed to" << val; - - m_heater = val; - emit airRecirculationEnabledChanged(val); -} - -void ClimateControlBackend::setSteeringWheelHeater(int val) -{ - if (val < 0 || val > 10) { - qWarning() << "SIMULATION SteeringWheelHeater change out of range (0-10)" << val; - emit steeringWheelHeaterChanged(m_steeringWheelHeater); - return; - } - - if (m_steeringWheelHeater == val) - return; - - qWarning() << "SIMULATION SteeringWheelHeater changed to" << val; - - m_steeringWheelHeater = val; - emit steeringWheelHeaterChanged(val); -} - -void ClimateControlBackend::setFanSpeedLevel(int speed) -{ - if (m_fanSpeed == speed) - return; - - qWarning() << "SIMULATION FanSpeedLevel changed to" << speed; - - m_fanSpeed = speed; - emit fanSpeedLevelChanged(speed); -} - -int ClimateControlBackend::targetTemperature(QtIVIClimateZone::Zone zone) const -{ - if (!m_zoneMap.contains(zone)) - return -1; - - return m_zoneMap[zone].targetTemperature; -} - -int ClimateControlBackend::seatCooler(QtIVIClimateZone::Zone zone) const -{ - if (!m_zoneMap.contains(zone)) - return -1; - - return m_zoneMap[zone].seattCooler; -} - -int ClimateControlBackend::seatHeater(QtIVIClimateZone::Zone zone) const -{ - if (!m_zoneMap.contains(zone)) - return -1; - - return m_zoneMap[zone].seatHeater; -} - -QtIVIClimateControl::AirflowDirection ClimateControlBackend::airflowDirection() const -{ - return m_flowDirection; -} - -bool ClimateControlBackend::airConditioningEnabled() const -{ - return m_airCondition; -} - -bool ClimateControlBackend::heaterEnabled() const -{ - return m_heater; -} - -bool ClimateControlBackend::airRecirculationEnabled() const -{ - return m_airRecirculation; -} - -int ClimateControlBackend::steeringWheelHeater() const -{ - return m_steeringWheelHeater; -} - -int ClimateControlBackend::fanSpeedLevel() const -{ - return m_fanSpeed; -} diff --git a/src/plugins/vehiclefunctions/climate_simulator/climatecontrolbackend.h b/src/plugins/vehiclefunctions/climate_simulator/climatecontrolbackend.h deleted file mode 100644 index 5e0fe98..0000000 --- a/src/plugins/vehiclefunctions/climate_simulator/climatecontrolbackend.h +++ /dev/null @@ -1,69 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#ifndef CLIMATECONTROLBACKEND_H -#define CLIMATECONTROLBACKEND_H - -#include -#include - -class ClimateControlBackend : public QtIVIClimateControlBackendInterface -{ -public: - ClimateControlBackend(QObject* parent = 0); - ~ClimateControlBackend(); - - // QtIVIClimateControlBackendInterface interface -public: - bool hasTargetTemperature(QtIVIClimateZone::Zone zone); - bool hasSeatCooler(QtIVIClimateZone::Zone zone); - bool hasSeatHeater(QtIVIClimateZone::Zone zone); - void setTargetTemperature(QtIVIClimateZone::Zone zone, int val); - void setSeatCooler(QtIVIClimateZone::Zone zone, int val); - void setSeatHeater(QtIVIClimateZone::Zone zone, int val); - QtIVIClimateZone::Zone driverZone() const; - void setAirflowDirection(QtIVIClimateControl::AirflowDirection direction); - void setAirConditioningEnabled(bool val); - void setHeaterEnabled(bool val); - void setAirRecirculationEnabled(bool val); - void setSteeringWheelHeater(int val); - void setFanSpeedLevel(int); - int targetTemperature(QtIVIClimateZone::Zone zone) const; - int seatCooler(QtIVIClimateZone::Zone zone) const; - int seatHeater(QtIVIClimateZone::Zone zone) const; - QtIVIClimateControl::AirflowDirection airflowDirection() const; - bool airConditioningEnabled() const; - bool heaterEnabled() const; - bool airRecirculationEnabled() const; - int steeringWheelHeater() const; - int fanSpeedLevel() const; - -private: - - QtIVIClimateControl::AirflowDirection m_flowDirection; - bool m_airCondition; - bool m_heater; - bool m_airRecirculation; - int m_steeringWheelHeater; - int m_fanSpeed; - - struct ZoneBackend{ - bool hasTargetTemperature; - int targetTemperature; - bool hasSeatCooler; - int seattCooler; - bool hasSeatHeater; - int seatHeater; - }; - - QMap m_zoneMap; -}; - -#endif // CLIMATECONTROLBACKEND_H diff --git a/src/plugins/vehiclefunctions/climate_simulator/climateplugin.cpp b/src/plugins/vehiclefunctions/climate_simulator/climateplugin.cpp deleted file mode 100644 index c97c02a..0000000 --- a/src/plugins/vehiclefunctions/climate_simulator/climateplugin.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#include "climateplugin.h" -#include "climatecontrolbackend.h" - -#include -#include - -ClimatePlugin::ClimatePlugin(QObject *parent) : - QObject(parent), - m_climate(new ClimateControlBackend(this)) -{ -} - -QStringList ClimatePlugin::interfaces() const -{ - QStringList list; - list << QtIVIClimateControlBackendInterface::interfaceName; - return list; -} - -QObject *ClimatePlugin::interfaceInstance(const QString &interface) const -{ - if (interface != QtIVIClimateControlBackendInterface::interfaceName) - return 0; - - return m_climate; -} diff --git a/src/plugins/vehiclefunctions/climate_simulator/climateplugin.h b/src/plugins/vehiclefunctions/climate_simulator/climateplugin.h deleted file mode 100644 index 58b0e04..0000000 --- a/src/plugins/vehiclefunctions/climate_simulator/climateplugin.h +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#ifndef CLIMATEPLUGIN_H -#define CLIMATEPLUGIN_H - -#include - -class ClimateControlBackend; - -class ClimatePlugin : public QObject, QtIVIServiceInterface -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "com.pelagicore.QtIVIServiceInterface" FILE "climate_simulator.json") - Q_INTERFACES(QtIVIServiceInterface) - -public: - ClimatePlugin(QObject *parent = 0); - - QStringList interfaces() const; - QObject* interfaceInstance(const QString& interface) const; - -private: - ClimateControlBackend* m_climate; -}; - -#endif // CLIMATEPLUGIN_H diff --git a/src/plugins/vehiclefunctions/vehiclefunctions.pro b/src/plugins/vehiclefunctions/vehiclefunctions.pro deleted file mode 100644 index 33efe89..0000000 --- a/src/plugins/vehiclefunctions/vehiclefunctions.pro +++ /dev/null @@ -1,13 +0,0 @@ -################################################################################################## -# Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. -# -# This software, including documentation, is protected by copyright controlled by Pelagicore AG. -# All rights reserved. Copying, including reproducing, storing, adapting or translating, any or -# all of this material requires prior written consent of Pelagicore AG Corporation. This material -# also contains confidential information which may not be disclosed to others without the prior -# written consent of Pelagicore AG. -################################################################################################## - -TEMPLATE = subdirs -SUBDIRS = climate_simulator - diff --git a/src/src.pro b/src/src.pro index ce92584..e6435f8 100644 --- a/src/src.pro +++ b/src/src.pro @@ -9,8 +9,8 @@ ################################################################################################## TEMPLATE = subdirs -SUBDIRS = core \ - vehiclefunctions \ +SUBDIRS = ivicore \ + ivivehiclefunctions \ plugins \ imports diff --git a/src/vehiclefunctions/qtiviclimatecontrol.cpp b/src/vehiclefunctions/qtiviclimatecontrol.cpp deleted file mode 100644 index 6bb1ff3..0000000 --- a/src/vehiclefunctions/qtiviclimatecontrol.cpp +++ /dev/null @@ -1,425 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#include "qtiviclimatecontrol.h" - -#include "qtiviclimatecontrolbackendinterface.h" - - - - -QString QtIVIClimateControlBackendInterface::interfaceName = QLatin1String("com.pelagicore.ClimateControl"); - - - - -QtIVIClimateZone::QtIVIClimateZone(Zone zone, QtIVIClimateControl *parent) - : QObject(parent) - , m_zone(zone) - , m_hasTargetTemperature(false) - , m_hasSeatCooler(false) - , m_hasSeatHeater(false) - , m_targetTemperature(0) - , m_seatCooler(0) - , m_seatHeater(0) -{ - -} - -QtIVIClimateZone::Zone QtIVIClimateZone::zone() const -{ - return m_zone; -} - -bool QtIVIClimateZone::hasTargetTemperature() const -{ - return m_hasTargetTemperature; -} - -int QtIVIClimateZone::targetTemperature() const -{ - if (m_hasTargetTemperature) - return m_targetTemperature; - else - return 0; -} - -void QtIVIClimateZone::setTargetTemperature(int t) -{ - if (m_hasTargetTemperature) - qobject_cast(parent())->backend()->setTargetTemperature(m_zone, t); - else - qWarning() << "Trying to set ClimateZone::targetTemperature in an unsupported zone or without a backend."; -} - -bool QtIVIClimateZone::hasSeatCooler() const -{ - return m_hasSeatCooler; -} - -int QtIVIClimateZone::seatCooler() const -{ - if (m_hasSeatCooler) - return m_seatCooler; - else - return 0; -} - -void QtIVIClimateZone::setSeatCooler(int t) -{ - if (t < 0 || t > 10) { - qWarning() << "Trying to set ClimateZone::seatCooler to " << t << " which is out of range (0-10)."; - return; - } - - if (m_hasSeatCooler) - qobject_cast(parent())->backend()->setSeatCooler(m_zone, t); - else - qWarning() << "Trying to set ClimateZone::seatCooler in an unsupported zone or without a backend."; -} - -bool QtIVIClimateZone::hasSeatHeater() const -{ - return m_hasSeatHeater; -} - -int QtIVIClimateZone::seatHeater() const -{ - if (m_hasSeatHeater) - return m_seatHeater; - else - return 0; -} - -void QtIVIClimateZone::setSeatHeater(int t) -{ - if (t < 0 || t > 10) { - qWarning() << "Trying to set ClimateZone::seatHeater to " << t << " which is out of range (0-10)."; - return; - } - - if (m_hasSeatHeater) - qobject_cast(parent())->backend()->setSeatHeater(m_zone, t); - else - qWarning() << "Trying to set ClimateZone::seatHeater in an unsupported zone or without a backend."; -} - -void QtIVIClimateZone::onTargetTemperatureChanged(QtIVIClimateZone::Zone z, int t) -{ - if (z == m_zone) { - m_targetTemperature = t; - if (m_hasTargetTemperature) - emit targetTemperatureChanged(m_targetTemperature); - } -} - -void QtIVIClimateZone::onSeatCoolerChanged(QtIVIClimateZone::Zone z, int t) -{ - if (z == m_zone) { - m_seatCooler = t; - if (m_hasSeatCooler) - emit seatCoolerChanged(m_seatCooler); - } -} - -void QtIVIClimateZone::onSeatHeaterChanged(QtIVIClimateZone::Zone z, int t) -{ - if (z == m_zone) { - m_seatHeater = t; - if (m_hasSeatHeater) - emit seatHeaterChanged(m_seatHeater); - } -} - -void QtIVIClimateZone::setHasTargetTemperature(bool e) -{ - if(e != m_hasTargetTemperature) { - m_hasTargetTemperature = e; - emit hasTargetTemperatureChanged(m_hasTargetTemperature); - - onTargetTemperatureChanged(m_zone, targetTemperature()); - } -} - -void QtIVIClimateZone::setHasSeatCooler(bool e) -{ - if(e != m_hasSeatCooler) { - m_hasSeatCooler = e; - emit hasSeatCoolerChanged(m_hasSeatCooler); - - onSeatCoolerChanged(m_zone, seatCooler()); - } -} - -void QtIVIClimateZone::setHasSeatHeater(bool e) -{ - if(e != m_hasSeatHeater) { - m_hasSeatHeater = e; - emit hasSeatHeaterChanged(m_hasSeatHeater); - - onSeatHeaterChanged(m_zone, seatHeater()); - } -} - - - - - -QtIVIClimateControl::QtIVIClimateControl(QObject *parent) - : QtIVIAbstractFeature(QtIVIClimateControlBackendInterface::interfaceName, true, parent) - , m_airflowDirection(QtIVIClimateControl::BiLevel) - , m_airConditioning(false) - , m_heater(false) - , m_airRecirculation(false) - , m_steeringWheelHeater(0) - , m_fanSpeedLevel(0) -{ - QList zones; - zones << QtIVIClimateZone::FrontLeft << QtIVIClimateZone::FrontCenter << QtIVIClimateZone::FrontRight - << QtIVIClimateZone::RearLeft << QtIVIClimateZone::RearCenter << QtIVIClimateZone::RearRight; - foreach(QtIVIClimateZone::Zone z, zones) - m_zones[z] = new QtIVIClimateZone(z, this); -} - -QtIVIClimateControl::AirflowDirection QtIVIClimateControl::airflowDirection() const -{ - return m_airflowDirection; -} - -bool QtIVIClimateControl::isAirConditioningEnabled() const -{ - return m_airConditioning; -} - -bool QtIVIClimateControl::isHeaterEnabled() const -{ - return m_heater; -} - -bool QtIVIClimateControl::isAirRecirculationEnabled() const -{ - return m_airRecirculation; -} - -int QtIVIClimateControl::steeringWheelHeater() const -{ - return m_steeringWheelHeater; -} - -int QtIVIClimateControl::fanSpeedLevel() const -{ - return m_fanSpeedLevel; -} - -QtIVIClimateZone *QtIVIClimateControl::climateZone(QtIVIClimateZone::Zone z) const -{ - return m_zones[z]; -} - -QtIVIClimateZone *QtIVIClimateControl::driver() const -{ - if (backend()) - return m_zones[backend()->driverZone()]; - else { - qWarning() << "Returning driver zone without a backend, using default driver zone."; - return m_zones[QtIVIClimateZone::FrontLeft]; - } -} - -QtIVIClimateZone *QtIVIClimateControl::frontLeftZone() const -{ - return m_zones[QtIVIClimateZone::FrontLeft]; -} - -QtIVIClimateZone *QtIVIClimateControl::frontCenterZone() const -{ - return m_zones[QtIVIClimateZone::FrontCenter]; -} - -QtIVIClimateZone *QtIVIClimateControl::frontRightZone() const -{ - return m_zones[QtIVIClimateZone::FrontRight]; -} - -QtIVIClimateZone *QtIVIClimateControl::rearLeftZone() const -{ - return m_zones[QtIVIClimateZone::RearLeft]; -} - -QtIVIClimateZone *QtIVIClimateControl::rearCenterZone() const -{ - return m_zones[QtIVIClimateZone::RearCenter]; -} - -QtIVIClimateZone *QtIVIClimateControl::rearRightZone() const -{ - return m_zones[QtIVIClimateZone::RearRight]; -} - -void QtIVIClimateControl::setAirflowDirection(QtIVIClimateControl::AirflowDirection ad) -{ - if(backend()) - backend()->setAirflowDirection(ad); -} - -void QtIVIClimateControl::setAirConditioningEnabled(bool e) -{ - if(backend()) - backend()->setAirConditioningEnabled(e); -} - -void QtIVIClimateControl::setHeaterEnabled(bool e) -{ - if(backend()) - backend()->setHeaterEnabled(e); -} - -void QtIVIClimateControl::setAirRecirculationEnabled(bool e) -{ - if(backend()) - backend()->setAirRecirculationEnabled(e); -} - -void QtIVIClimateControl::setSteeringWheelHeater(int t) -{ - if(backend()) - backend()->setSteeringWheelHeater(t); -} - -void QtIVIClimateControl::setFanSpeedLevel(int fsl) -{ - if(backend()) - backend()->setFanSpeedLevel(fsl); -} - -bool QtIVIClimateControl::acceptServiceObject(QtIVIServiceObject *so) -{ - return (qobject_cast(so->interfaceInstance(QtIVIClimateControlBackendInterface::interfaceName)) != NULL); -} - -void QtIVIClimateControl::connectToServiceObject(QtIVIServiceObject *so) -{ - QtIVIClimateControlBackendInterface *backend = qobject_cast(so->interfaceInstance(QtIVIClimateControlBackendInterface::interfaceName)); - - QList zones; - zones << QtIVIClimateZone::FrontLeft << QtIVIClimateZone::FrontCenter << QtIVIClimateZone::FrontRight - << QtIVIClimateZone::RearLeft << QtIVIClimateZone::RearCenter << QtIVIClimateZone::RearRight; - foreach(QtIVIClimateZone::Zone z, zones) { - connect(backend, &QtIVIClimateControlBackendInterface::targetTemperatureChanged, m_zones[z], &QtIVIClimateZone::onTargetTemperatureChanged); - connect(backend, &QtIVIClimateControlBackendInterface::seatCoolerChanged, m_zones[z], &QtIVIClimateZone::onSeatCoolerChanged); - connect(backend, &QtIVIClimateControlBackendInterface::seatHeaterChanged, m_zones[z], &QtIVIClimateZone::onSeatHeaterChanged); - m_zones[z]->onTargetTemperatureChanged(z, backend->targetTemperature(z)); - m_zones[z]->onSeatCoolerChanged(z, backend->seatCooler(z)); - m_zones[z]->onSeatHeaterChanged(z, backend->seatHeater(z)); - /* Set the has properties last to ensure that the value is available when signalling */ - m_zones[z]->setHasTargetTemperature(backend->hasTargetTemperature(z)); - m_zones[z]->setHasSeatCooler(backend->hasSeatCooler(z)); - m_zones[z]->setHasSeatHeater(backend->hasSeatHeater(z)); - } - - connect(backend, &QtIVIClimateControlBackendInterface::airflowDirectionChanged, this, &QtIVIClimateControl::onAirflowDirectionChanged); - connect(backend, &QtIVIClimateControlBackendInterface::airConditioningEnabledChanged, this, &QtIVIClimateControl::onAirConditioningEnabledChanged); - connect(backend, &QtIVIClimateControlBackendInterface::heaterEnabledChanged, this, &QtIVIClimateControl::onHeaterEnabledChanged); - connect(backend, &QtIVIClimateControlBackendInterface::airRecirculationEnabledChanged, this, &QtIVIClimateControl::onAirRecirculationEnabledChanged); - connect(backend, &QtIVIClimateControlBackendInterface::steeringWheelHeaterChanged, this, &QtIVIClimateControl::onSteeringWheelHeaterChanged); - connect(backend, &QtIVIClimateControlBackendInterface::fanSpeedLevelChanged, this, &QtIVIClimateControl::onFanSpeedLevelChanged); - - onAirflowDirectionChanged(backend->airflowDirection()); - onAirConditioningEnabledChanged(backend->airConditioningEnabled()); - onHeaterEnabledChanged(backend->heaterEnabled()); - onAirRecirculationEnabledChanged(backend->airRecirculationEnabled()); - onSteeringWheelHeaterChanged(backend->steeringWheelHeater()); - onFanSpeedLevelChanged(backend->fanSpeedLevel()); -} - -void QtIVIClimateControl::disconnectFromServiceObject(QtIVIServiceObject *so) -{ - QtIVIClimateControlBackendInterface *backend = qobject_cast(so->interfaceInstance(QtIVIClimateControlBackendInterface::interfaceName)); - - QList zones; - zones << QtIVIClimateZone::FrontLeft << QtIVIClimateZone::FrontCenter << QtIVIClimateZone::FrontRight - << QtIVIClimateZone::RearLeft << QtIVIClimateZone::RearCenter << QtIVIClimateZone::RearRight; - foreach(QtIVIClimateZone::Zone z, zones) { - disconnect(backend, &QtIVIClimateControlBackendInterface::targetTemperatureChanged, m_zones[z], &QtIVIClimateZone::onTargetTemperatureChanged); - disconnect(backend, &QtIVIClimateControlBackendInterface::seatCoolerChanged, m_zones[z], &QtIVIClimateZone::onSeatCoolerChanged); - disconnect(backend, &QtIVIClimateControlBackendInterface::seatHeaterChanged, m_zones[z], &QtIVIClimateZone::onSeatHeaterChanged); - } - - disconnect(backend, &QtIVIClimateControlBackendInterface::airflowDirectionChanged, this, &QtIVIClimateControl::onAirflowDirectionChanged); - disconnect(backend, &QtIVIClimateControlBackendInterface::airConditioningEnabledChanged, this, &QtIVIClimateControl::onAirConditioningEnabledChanged); - disconnect(backend, &QtIVIClimateControlBackendInterface::heaterEnabledChanged, this, &QtIVIClimateControl::onHeaterEnabledChanged); - disconnect(backend, &QtIVIClimateControlBackendInterface::airRecirculationEnabledChanged, this, &QtIVIClimateControl::onAirRecirculationEnabledChanged); - disconnect(backend, &QtIVIClimateControlBackendInterface::steeringWheelHeaterChanged, this, &QtIVIClimateControl::onSteeringWheelHeaterChanged); - disconnect(backend, &QtIVIClimateControlBackendInterface::fanSpeedLevelChanged, this, &QtIVIClimateControl::onFanSpeedLevelChanged); -} - -void QtIVIClimateControl::clearServiceObject() -{ - /* Safe defaults */ - onAirflowDirectionChanged(QtIVIClimateControl::BiLevel); - onAirConditioningEnabledChanged(false); - onHeaterEnabledChanged(false); - onAirRecirculationEnabledChanged(false); - onSteeringWheelHeaterChanged(0); - onFanSpeedLevelChanged(0); - - QList zones; - zones << QtIVIClimateZone::FrontLeft << QtIVIClimateZone::FrontCenter << QtIVIClimateZone::FrontRight - << QtIVIClimateZone::RearLeft << QtIVIClimateZone::RearCenter << QtIVIClimateZone::RearRight; - foreach(QtIVIClimateZone::Zone z, zones) { - m_zones[z]->setHasTargetTemperature(false); - m_zones[z]->setHasSeatCooler(false); - m_zones[z]->setHasSeatHeater(false); - } -} - -void QtIVIClimateControl::onAirflowDirectionChanged(QtIVIClimateControl::AirflowDirection airflowDirection) -{ - m_airflowDirection = airflowDirection; - emit airflowDirectionChanged(m_airflowDirection); -} - -void QtIVIClimateControl::onAirConditioningEnabledChanged(bool airConditioning) -{ - m_airConditioning = airConditioning; - emit airConditioningEnabledChanged(m_airConditioning); -} - -void QtIVIClimateControl::onHeaterEnabledChanged(bool heater) -{ - m_heater = heater; - emit heaterEnabledChanged(m_heater); -} - -void QtIVIClimateControl::onAirRecirculationEnabledChanged(bool airRecirculation) -{ - m_airRecirculation = airRecirculation; - emit airRecirculationEnabledChanged(m_airRecirculation); -} - -void QtIVIClimateControl::onSteeringWheelHeaterChanged(int steeringWheelHeater) -{ - m_steeringWheelHeater = steeringWheelHeater; - emit steeringWheelHeaterChanged(m_steeringWheelHeater); -} - -void QtIVIClimateControl::onFanSpeedLevelChanged(int fanSpeedLevel) -{ - m_fanSpeedLevel = fanSpeedLevel; - emit fanSpeedLevelChanged(m_fanSpeedLevel); -} - -QtIVIClimateControlBackendInterface *QtIVIClimateControl::backend() const -{ - if (serviceObject()) - return qobject_cast(serviceObject()->interfaceInstance(QtIVIClimateControlBackendInterface::interfaceName)); - else - return 0; -} diff --git a/src/vehiclefunctions/qtiviclimatecontrol.h b/src/vehiclefunctions/qtiviclimatecontrol.h deleted file mode 100644 index cce6c07..0000000 --- a/src/vehiclefunctions/qtiviclimatecontrol.h +++ /dev/null @@ -1,208 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#ifndef CLIMATECONTROL_H -#define CLIMATECONTROL_H - -#include - -#include -#include -#include - -class QtIVIClimateControl; -class QtIVIClimateControlBackendInterface; - -/* Properties based on http://www.w3.org/2014/automotive/data_spec.html#idl-def-ClimateControl - * This list contains properties per zone. - */ -class Q_QTIVIVEHICLEFUNCTIONS_EXPORT QtIVIClimateZone : public QObject -{ - Q_OBJECT - - Q_PROPERTY(Zone zone READ zone CONSTANT) - Q_PROPERTY(bool hasTargetTemperature READ hasTargetTemperature NOTIFY hasTargetTemperatureChanged) - Q_PROPERTY(bool hasSeatCooler READ hasSeatCooler NOTIFY hasSeatCoolerChanged) - Q_PROPERTY(bool hasSeatHeater READ hasSeatHeater NOTIFY hasSeatHeaterChanged) - /* current setting of the desired temperature (Unit: celsius) */ - Q_PROPERTY(int targetTemperature READ targetTemperature WRITE setTargetTemperature NOTIFY targetTemperatureChanged) - /* current status of the seat ventilation ( 0: off, 1: least warm, 10: warmest ) */ - Q_PROPERTY(int seatCooler READ seatCooler WRITE setSeatCooler NOTIFY seatCoolerChanged) - /* current status of the seat warmer ( 0: off, 1: least warm, 10: warmest ) */ - Q_PROPERTY(int seatHeater READ seatHeater WRITE setSeatHeater NOTIFY seatHeaterChanged) - - Q_ENUMS(Zone) - -public: - /* Based on http://www.w3.org/2014/automotive/vehicle_spec.html#idl-def-Zone */ - enum Zone { - FrontLeft, - FrontCenter, - FrontRight, - RearLeft, - RearCenter, - RearRight - }; - - QtIVIClimateZone(Zone zone, QtIVIClimateControl *parent); - - Zone zone() const; - - bool hasTargetTemperature() const; - bool hasSeatCooler() const; - bool hasSeatHeater() const; - - int targetTemperature() const; - int seatCooler() const; - int seatHeater() const; - -public slots: - void setTargetTemperature(int); - void setSeatCooler(int); - void setSeatHeater(int); - -signals: - void hasTargetTemperatureChanged(bool hasTargetTemperature); - void hasSeatCoolerChanged(bool hasSeatCooler); - void hasSeatHeaterChanged(bool hasSeatHeater); - - void targetTemperatureChanged(int targetTemperature); - void seatCoolerChanged(int seatCooler); - void seatHeaterChanged(int seatHeater); - -private slots: - void onTargetTemperatureChanged(QtIVIClimateZone::Zone z, int t); - void onSeatCoolerChanged(QtIVIClimateZone::Zone z, int t); - void onSeatHeaterChanged(QtIVIClimateZone::Zone z, int t); - -private: - friend class QtIVIClimateControl; - - void setHasTargetTemperature(bool); - void setHasSeatCooler(bool); - void setHasSeatHeater(bool); - - Zone m_zone; - - bool m_hasTargetTemperature; - bool m_hasSeatCooler; - bool m_hasSeatHeater; - - int m_targetTemperature; - int m_seatCooler; - int m_seatHeater; -}; - - -/* Properties based on http://www.w3.org/2014/automotive/data_spec.html#idl-def-ClimateControl - * This list contains the properties for the whole car. - */ -class Q_QTIVIVEHICLEFUNCTIONS_EXPORT QtIVIClimateControl : public QtIVIAbstractFeature -{ - Q_OBJECT - - Q_PROPERTY(AirflowDirection airflowDirection READ airflowDirection WRITE setAirflowDirection NOTIFY airflowDirectionChanged) - /* current status of the air conditioning system: on (true) or off (false) */ - Q_PROPERTY(bool airConditioning READ isAirConditioningEnabled WRITE setAirConditioningEnabled NOTIFY airConditioningEnabledChanged) - /* current status of the heating system: on (true) or off (false) */ - Q_PROPERTY(bool heater READ isHeaterEnabled WRITE setHeaterEnabled NOTIFY heaterEnabledChanged) - /* current setting of air recirculation: on (true) or pulling in outside air (false) */ - Q_PROPERTY(bool airRecirculation READ isAirRecirculationEnabled WRITE setAirRecirculationEnabled NOTIFY airRecirculationEnabledChanged) - /* current status of steering wheel heater ( 0: off, 1: least warm, 10: warmest ) */ - Q_PROPERTY(int steeringWheelHeater READ steeringWheelHeater WRITE setSteeringWheelHeater NOTIFY steeringWheelHeaterChanged) - /* current status of the fan speed of the air flowing (0: off, 1: weakest, 10: strongest ) */ - Q_PROPERTY(int fanSpeedLevel READ fanSpeedLevel WRITE setFanSpeedLevel NOTIFY fanSpeedLevelChanged) - - Q_PROPERTY(QtIVIClimateZone* frontLeftZone READ frontLeftZone CONSTANT) - Q_PROPERTY(QtIVIClimateZone* frontCenterZone READ frontCenterZone CONSTANT) - Q_PROPERTY(QtIVIClimateZone* frontRightZone READ frontRightZone CONSTANT) - Q_PROPERTY(QtIVIClimateZone* rearLeftZone READ rearLeftZone CONSTANT) - Q_PROPERTY(QtIVIClimateZone* rearCenterZone READ rearCenterZone CONSTANT) - Q_PROPERTY(QtIVIClimateZone* rearRightZone READ rearRightZone CONSTANT) - - Q_PROPERTY(QtIVIClimateZone* driver READ driver CONSTANT) - - Q_ENUMS(AirflowDirection) - -public: - QtIVIClimateControl(QObject *parent=0); - - /* Based on http://www.w3.org/2014/automotive/data_spec.html#idl-def-AirflowDirection */ - enum AirflowDirection { - FloorPanel, - FloorDuct, - BiLevel, - DefrostFloor - }; - - AirflowDirection airflowDirection() const; - - bool isAirConditioningEnabled() const; - bool isHeaterEnabled() const; - bool isAirRecirculationEnabled() const; - int steeringWheelHeater() const; - int fanSpeedLevel() const; - - QtIVIClimateZone *climateZone(QtIVIClimateZone::Zone) const; - QtIVIClimateZone *driver() const; - - QtIVIClimateZone *frontLeftZone() const; - QtIVIClimateZone *frontCenterZone() const; - QtIVIClimateZone *frontRightZone() const; - QtIVIClimateZone *rearLeftZone() const; - QtIVIClimateZone *rearCenterZone() const; - QtIVIClimateZone *rearRightZone() const; - -public slots: - void setAirflowDirection(QtIVIClimateControl::AirflowDirection); - void setAirConditioningEnabled(bool); - void setHeaterEnabled(bool); - void setAirRecirculationEnabled(bool); - void setSteeringWheelHeater(int); - void setFanSpeedLevel(int); - -signals: - void airflowDirectionChanged(QtIVIClimateControl::AirflowDirection airflowDirection); - void airConditioningEnabledChanged(bool airConditioning); - void heaterEnabledChanged(bool heaterEnabled); - void airRecirculationEnabledChanged(bool airRecirculation); - void steeringWheelHeaterChanged(int steeringWheelHeater); - void fanSpeedLevelChanged(int fanSpeedLevel); - -protected: - virtual bool acceptServiceObject(QtIVIServiceObject *so); - virtual void connectToServiceObject(QtIVIServiceObject *so); - virtual void disconnectFromServiceObject(QtIVIServiceObject *so); - virtual void clearServiceObject(); - -private slots: - void onAirflowDirectionChanged(QtIVIClimateControl::AirflowDirection airflowDirection); - void onAirConditioningEnabledChanged(bool airConditioning); - void onHeaterEnabledChanged(bool heater); - void onAirRecirculationEnabledChanged(bool airRecirculation); - void onSteeringWheelHeaterChanged(int steeringWheelHeater); - void onFanSpeedLevelChanged(int fanSpeedLevel); - -private: - friend class QtIVIClimateZone; - - QtIVIClimateControlBackendInterface *backend() const; - - AirflowDirection m_airflowDirection; - bool m_airConditioning; - bool m_heater; - bool m_airRecirculation; - int m_steeringWheelHeater; - int m_fanSpeedLevel; - - QMap m_zones; -}; - -#endif // CLIMATECONTROL_H diff --git a/src/vehiclefunctions/qtiviclimatecontrolbackendinterface.h b/src/vehiclefunctions/qtiviclimatecontrolbackendinterface.h deleted file mode 100644 index e4e046c..0000000 --- a/src/vehiclefunctions/qtiviclimatecontrolbackendinterface.h +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#ifndef QTIVICLIMATECONTROLBACKENDINTERFACE_H -#define QTIVICLIMATECONTROLBACKENDINTERFACE_H - -#include - -#include "qtiviclimatecontrol.h" - -class Q_QTIVIVEHICLEFUNCTIONS_EXPORT QtIVIClimateControlBackendInterface : public QObject -{ - Q_OBJECT - -public: - QtIVIClimateControlBackendInterface(QObject *parent=0) : QObject(parent) {} - - static QString interfaceName; - - virtual bool hasTargetTemperature(QtIVIClimateZone::Zone) = 0; - virtual bool hasSeatCooler(QtIVIClimateZone::Zone) = 0; - virtual bool hasSeatHeater(QtIVIClimateZone::Zone) = 0; - virtual void setTargetTemperature(QtIVIClimateZone::Zone, int) = 0; - virtual void setSeatCooler(QtIVIClimateZone::Zone, int) = 0; - virtual void setSeatHeater(QtIVIClimateZone::Zone, int) = 0; - - virtual QtIVIClimateZone::Zone driverZone() const = 0; - - virtual void setAirflowDirection(QtIVIClimateControl::AirflowDirection) = 0; - virtual void setAirConditioningEnabled(bool) = 0; - virtual void setHeaterEnabled(bool) = 0; - virtual void setAirRecirculationEnabled(bool) = 0; - virtual void setSteeringWheelHeater(int) = 0; - virtual void setFanSpeedLevel(int) = 0; - - virtual int targetTemperature(QtIVIClimateZone::Zone) const = 0; - virtual int seatCooler(QtIVIClimateZone::Zone) const = 0; - virtual int seatHeater(QtIVIClimateZone::Zone) const = 0; - - virtual QtIVIClimateControl::AirflowDirection airflowDirection() const = 0; - virtual bool airConditioningEnabled() const = 0; - virtual bool heaterEnabled() const = 0; - virtual bool airRecirculationEnabled() const = 0; - virtual int steeringWheelHeater() const = 0; - virtual int fanSpeedLevel() const = 0; - -signals: - void targetTemperatureChanged(QtIVIClimateZone::Zone, int); - void seatCoolerChanged(QtIVIClimateZone::Zone, int); - void seatHeaterChanged(QtIVIClimateZone::Zone, int); - - void airflowDirectionChanged(QtIVIClimateControl::AirflowDirection); - void airConditioningEnabledChanged(bool); - void heaterEnabledChanged(bool); - void airRecirculationEnabledChanged(bool); - void steeringWheelHeaterChanged(int); - void fanSpeedLevelChanged(int); -}; - -#endif // QTIVICLIMATECONTROLBACKENDINTERFACE_H - diff --git a/src/vehiclefunctions/qtivivehiclefunctionsglobal.h b/src/vehiclefunctions/qtivivehiclefunctionsglobal.h deleted file mode 100644 index dc6a21a..0000000 --- a/src/vehiclefunctions/qtivivehiclefunctionsglobal.h +++ /dev/null @@ -1,31 +0,0 @@ -/************************************************************************************************ - * Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. - * - * This software, including documentation, is protected by copyright controlled by Pelagicore AG. - * All rights reserved. Copying, including reproducing, storing, adapting or translating, any or - * all of this material requires prior written consent of Pelagicore AG Corporation. This material - * also contains confidential information which may not be disclosed to others without the prior - * written consent of Pelagicore AG. - ************************************************************************************************/ - -#ifndef QTIVIVEHICLEFUNCTIONSGLOBAL_H -#define QTIVIVEHICLEFUNCTIONSGLOBAL_H - -#include - -QT_BEGIN_NAMESPACE - -#ifndef QT_STATIC -# if defined(QT_BUILD_QTIVIVEHICLEFUNCTIONS_LIB) -# define Q_QTIVIVEHICLEFUNCTIONS_EXPORT Q_DECL_EXPORT -# else -# define Q_QTIVIVEHICLEFUNCTIONS_EXPORT Q_DECL_IMPORT -# endif -#else -# define Q_QTIVICORE_EXPORT -#endif - -QT_END_NAMESPACE - -#endif // QTIVIVEHICLEFUNCTIONSGLOBAL_H - diff --git a/src/vehiclefunctions/vehiclefunctions.pro b/src/vehiclefunctions/vehiclefunctions.pro deleted file mode 100644 index 5af37f1..0000000 --- a/src/vehiclefunctions/vehiclefunctions.pro +++ /dev/null @@ -1,27 +0,0 @@ -################################################################################################## -# Copyright (c) 2012-2015 Pelagicore AG. All rights reserved. -# -# This software, including documentation, is protected by copyright controlled by Pelagicore AG. -# All rights reserved. Copying, including reproducing, storing, adapting or translating, any or -# all of this material requires prior written consent of Pelagicore AG Corporation. This material -# also contains confidential information which may not be disclosed to others without the prior -# written consent of Pelagicore AG. -################################################################################################## - -MODULE = QtIVIVehicleFunctions -TARGET = $$MODULE -QT = core qml QtIVICore -CONFIG += c++11 -VERSION = 1.0.0 - -CMAKE_MODULE_TESTS = '-' - -HEADERS += \ - qtiviclimatecontrol.h \ - qtiviclimatecontrolbackendinterface.h \ - qtivivehiclefunctionsglobal.h - -SOURCES += \ - qtiviclimatecontrol.cpp - -load(qt_module) diff --git a/sync.profile b/sync.profile index 50b6d05..4c7c02e 100644 --- a/sync.profile +++ b/sync.profile @@ -1,6 +1,6 @@ %modules = ( # path to module name map - "QtIVICore" => "$basedir/src/core", - "QtIVIVehicleFunctions" => "$basedir/src/vehiclefunctions", + "QtIVICore" => "$basedir/src/ivicore", + "QtIVIVehicleFunctions" => "$basedir/src/ivivehiclefunctions", ); %moduleheaders = ( # restrict the module headers to those found in relative path ); diff --git a/tests/auto/core/servicemanagertest/servicemanagertest.pro b/tests/auto/core/servicemanagertest/servicemanagertest.pro index c2300b9..4c157ee 100644 --- a/tests/auto/core/servicemanagertest/servicemanagertest.pro +++ b/tests/auto/core/servicemanagertest/servicemanagertest.pro @@ -8,7 +8,7 @@ # written consent of Pelagicore AG. ################################################################################################## -QT += testlib QtIVICore +QT += testlib ivicore TARGET = tst_servicemanagertest CONFIG += testcase diff --git a/tests/auto/vehiclefunctions/climatecontroltest/climatecontroltest.pro b/tests/auto/vehiclefunctions/climatecontroltest/climatecontroltest.pro index 804df98..e89f1e4 100644 --- a/tests/auto/vehiclefunctions/climatecontroltest/climatecontroltest.pro +++ b/tests/auto/vehiclefunctions/climatecontroltest/climatecontroltest.pro @@ -8,7 +8,7 @@ # written consent of Pelagicore AG. ################################################################################################## -QT += testlib QtIVICore QtIVIVehicleFunctions +QT += testlib ivicore ivivehiclefunctions TARGET = tst_climatecontroltest CONFIG += testcase -- cgit v1.2.1