From efba3d85875b20bd40e93bc6d94aca1531f25aae Mon Sep 17 00:00:00 2001 From: Karsten Heimrich Date: Mon, 23 Apr 2018 09:03:28 +0200 Subject: Add Qt KNX tradeshow demo application Move from: http://code.qt.io/cgit/qt/qtknx.git/ Change-Id: I92de81ebb1505fe8c8349300321606ec7b2ea120 Reviewed-by: Maurice Kalinowski --- tradeshow/knx-demo/demo.pro | 53 ++++ tradeshow/knx-demo/demodatapoint.cpp | 247 ++++++++++++++++ tradeshow/knx-demo/demodatapoint.h | 162 +++++++++++ tradeshow/knx-demo/etsdevelopmentboard.cpp | 136 +++++++++ tradeshow/knx-demo/etsdevelopmentboard.h | 100 +++++++ tradeshow/knx-demo/images/ArrowDown.png | Bin 0 -> 1944 bytes tradeshow/knx-demo/images/ArrowUp.png | Bin 0 -> 1955 bytes tradeshow/knx-demo/images/Qt-logo-medium.png | Bin 0 -> 2710 bytes tradeshow/knx-demo/images/blind.png | Bin 0 -> 2511 bytes tradeshow/knx-demo/images/blindCover.png | Bin 0 -> 700 bytes tradeshow/knx-demo/images/clock.png | Bin 0 -> 12589 bytes tradeshow/knx-demo/images/e10View.png | Bin 0 -> 4747 bytes tradeshow/knx-demo/images/e1View.png | Bin 0 -> 9036 bytes tradeshow/knx-demo/images/e2View.png | Bin 0 -> 6394 bytes tradeshow/knx-demo/images/e3e4View.png | Bin 0 -> 12311 bytes tradeshow/knx-demo/images/e5e6View.png | Bin 0 -> 2758 bytes tradeshow/knx-demo/images/icon_light.png | Bin 0 -> 8745 bytes tradeshow/knx-demo/images/off.png | Bin 0 -> 10088 bytes tradeshow/knx-demo/images/on_green.png | Bin 0 -> 13368 bytes tradeshow/knx-demo/images/on_orange.png | Bin 0 -> 12787 bytes tradeshow/knx-demo/images/quit_icon.png | Bin 0 -> 2417 bytes tradeshow/knx-demo/images/rainbow.png | Bin 0 -> 1267 bytes tradeshow/knx-demo/images/settings_icon.png | Bin 0 -> 3002 bytes tradeshow/knx-demo/images/stop_orange.png | Bin 0 -> 16042 bytes tradeshow/knx-demo/images/temperature_symbol.png | Bin 0 -> 6750 bytes tradeshow/knx-demo/images/topBar.png | Bin 0 -> 357 bytes tradeshow/knx-demo/main.cpp | 70 +++++ tradeshow/knx-demo/qml.qrc | 43 +++ tradeshow/knx-demo/qmlknxdemo.cpp | 311 +++++++++++++++++++++ tradeshow/knx-demo/qmlknxdemo.h | 137 +++++++++ tradeshow/knx-demo/qtquickcontrols2.conf | 15 + tradeshow/knx-demo/ui/KnxBoardLayout.qml | 141 ++++++++++ .../knx-demo/ui/components/BlindSimulationView.qml | 102 +++++++ tradeshow/knx-demo/ui/components/ColorSlider.qml | 80 ++++++ tradeshow/knx-demo/ui/components/E10LedView.qml | 75 +++++ tradeshow/knx-demo/ui/components/E11LedView.qml | 82 ++++++ tradeshow/knx-demo/ui/components/E12LedView.qml | 80 ++++++ tradeshow/knx-demo/ui/components/E13LedView.qml | 77 +++++ tradeshow/knx-demo/ui/components/E14LedView.qml | 77 +++++ tradeshow/knx-demo/ui/components/E1LedView.qml | 79 ++++++ tradeshow/knx-demo/ui/components/E2LedView.qml | 80 ++++++ tradeshow/knx-demo/ui/components/E3E4LedView.qml | 90 ++++++ tradeshow/knx-demo/ui/components/E5E6LedView.qml | 93 ++++++ tradeshow/knx-demo/ui/components/E7E8LedView.qml | 112 ++++++++ tradeshow/knx-demo/ui/components/E9LedView.qml | 82 ++++++ tradeshow/knx-demo/ui/components/KnxSwitch.qml | 84 ++++++ tradeshow/knx-demo/ui/main.qml | 118 ++++++++ tradeshow/knx-demo/utils.h | 112 ++++++++ 48 files changed, 2838 insertions(+) create mode 100644 tradeshow/knx-demo/demo.pro create mode 100644 tradeshow/knx-demo/demodatapoint.cpp create mode 100644 tradeshow/knx-demo/demodatapoint.h create mode 100644 tradeshow/knx-demo/etsdevelopmentboard.cpp create mode 100644 tradeshow/knx-demo/etsdevelopmentboard.h create mode 100644 tradeshow/knx-demo/images/ArrowDown.png create mode 100644 tradeshow/knx-demo/images/ArrowUp.png create mode 100644 tradeshow/knx-demo/images/Qt-logo-medium.png create mode 100644 tradeshow/knx-demo/images/blind.png create mode 100644 tradeshow/knx-demo/images/blindCover.png create mode 100644 tradeshow/knx-demo/images/clock.png create mode 100644 tradeshow/knx-demo/images/e10View.png create mode 100644 tradeshow/knx-demo/images/e1View.png create mode 100644 tradeshow/knx-demo/images/e2View.png create mode 100644 tradeshow/knx-demo/images/e3e4View.png create mode 100644 tradeshow/knx-demo/images/e5e6View.png create mode 100644 tradeshow/knx-demo/images/icon_light.png create mode 100644 tradeshow/knx-demo/images/off.png create mode 100644 tradeshow/knx-demo/images/on_green.png create mode 100644 tradeshow/knx-demo/images/on_orange.png create mode 100644 tradeshow/knx-demo/images/quit_icon.png create mode 100644 tradeshow/knx-demo/images/rainbow.png create mode 100644 tradeshow/knx-demo/images/settings_icon.png create mode 100644 tradeshow/knx-demo/images/stop_orange.png create mode 100644 tradeshow/knx-demo/images/temperature_symbol.png create mode 100644 tradeshow/knx-demo/images/topBar.png create mode 100644 tradeshow/knx-demo/main.cpp create mode 100644 tradeshow/knx-demo/qml.qrc create mode 100644 tradeshow/knx-demo/qmlknxdemo.cpp create mode 100644 tradeshow/knx-demo/qmlknxdemo.h create mode 100644 tradeshow/knx-demo/qtquickcontrols2.conf create mode 100644 tradeshow/knx-demo/ui/KnxBoardLayout.qml create mode 100644 tradeshow/knx-demo/ui/components/BlindSimulationView.qml create mode 100644 tradeshow/knx-demo/ui/components/ColorSlider.qml create mode 100644 tradeshow/knx-demo/ui/components/E10LedView.qml create mode 100644 tradeshow/knx-demo/ui/components/E11LedView.qml create mode 100644 tradeshow/knx-demo/ui/components/E12LedView.qml create mode 100644 tradeshow/knx-demo/ui/components/E13LedView.qml create mode 100644 tradeshow/knx-demo/ui/components/E14LedView.qml create mode 100644 tradeshow/knx-demo/ui/components/E1LedView.qml create mode 100644 tradeshow/knx-demo/ui/components/E2LedView.qml create mode 100644 tradeshow/knx-demo/ui/components/E3E4LedView.qml create mode 100644 tradeshow/knx-demo/ui/components/E5E6LedView.qml create mode 100644 tradeshow/knx-demo/ui/components/E7E8LedView.qml create mode 100644 tradeshow/knx-demo/ui/components/E9LedView.qml create mode 100644 tradeshow/knx-demo/ui/components/KnxSwitch.qml create mode 100644 tradeshow/knx-demo/ui/main.qml create mode 100644 tradeshow/knx-demo/utils.h diff --git a/tradeshow/knx-demo/demo.pro b/tradeshow/knx-demo/demo.pro new file mode 100644 index 0000000..f5473de --- /dev/null +++ b/tradeshow/knx-demo/demo.pro @@ -0,0 +1,53 @@ +TEMPLATE = app + +!qtHaveModule(quick) { + error("Missing module Qt Quick. Cannot build the Qt KNX demo.") +} + +QT += qml quick knx knx-private +CONFIG += c++11 + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which as been marked deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += main.cpp \ + qmlknxdemo.cpp \ + etsdevelopmentboard.cpp \ + demodatapoint.cpp + +RESOURCES += qml.qrc + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = + +# Additional import path used to resolve QML modules just for Qt Quick Designer +QML_DESIGNER_IMPORT_PATH = + +target.path = $$[QT_INSTALL_EXAMPLES]/knx/demo +INSTALLS += target + +android { + DISTFILES += \ + android/AndroidManifest.xml \ + android/gradle/wrapper/gradle-wrapper.jar \ + android/gradlew \ + android/res/values/libs.xml \ + android/build.gradle \ + android/gradle/wrapper/gradle-wrapper.properties \ + android/gradlew.bat \ + boardModel.qml +} + +HEADERS += \ + qmlknxdemo.h \ + demodatapoint.h \ + utils.h \ + etsdevelopmentboard.h diff --git a/tradeshow/knx-demo/demodatapoint.cpp b/tradeshow/knx-demo/demodatapoint.cpp new file mode 100644 index 0000000..710a6e0 --- /dev/null +++ b/tradeshow/knx-demo/demodatapoint.cpp @@ -0,0 +1,247 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "demodatapoint.h" + +#include +#include +#include +#include +#include + +const QKnxByteArray DemoDataPoint::BytesOn { 0x01 }; +const QKnxByteArray DemoDataPoint::BytesOff { 0x00 }; + +bool DemoSwitchDataPoint::updateDataPointState(const QKnxLinkLayerFrame &frame) +{ + m_switch.setBytes(frame.tpdu().data(), 0, 1); + return true; +} + +void DemoSwitchDataPoint::uiToggle() +{ + if (isOn()) + m_switch.setValue(QKnxSwitch::State::Off); + else + m_switch.setValue(QKnxSwitch::State::On); +} + +bool DemoSwitchDataPoint::isOn() const +{ + return m_switch.value() == QKnxSwitch::State::On; +} + +QKnxByteArray DemoSwitchDataPoint::bytes() const +{ + if (isOn()) + return DemoDataPoint::BytesOn; + return DemoDataPoint::BytesOff; +} + +bool DemoColorLed::updateDataPointState(const QKnxLinkLayerFrame &frame) +{ + bool notifyUI = false; + numMsgConfirmation++; + if (frame.messageCode() == QKnxLinkLayerFrame::MessageCode::DataConfirmation) { + // response to request from UI + // wait for three color confirmation to signal UI + if (numMsgConfirmation == 3) + notifyUI = true; + } else if (frame.messageCode() == QKnxLinkLayerFrame::MessageCode::DataIndication) { + // response to request from Board + notifyUI = true; + } + + QKnxSwitch dpt; + dpt.setBytes(frame.tpdu().data(), 0, 1); + int value = (dpt.value() == QKnxSwitch::State::On ? 255 : 0); + + auto dstAddress = frame.destinationAddress(); + if (dstAddress == QKnxAddress::createGroup(0, 0, 12)) + m_stateColor.setRed(value); + + else if (dstAddress == QKnxAddress::createGroup(0, 0, 13)) + m_stateColor.setGreen(value); + + else if (dstAddress == QKnxAddress::createGroup(0, 0, 14)) + m_stateColor.setBlue(value); + + if (notifyUI) { + numMsgConfirmation = 0; + emit colorChange(m_stateColor); + } + return false; +} + +QKnxByteArray DemoColorLed::redBytes() const +{ + if (m_stateColor.red() > 0) + return DemoDataPoint::BytesOn; + return DemoDataPoint::BytesOff; +} + +QKnxByteArray DemoColorLed::greenBytes() const +{ + if (m_stateColor.green() > 0) + return DemoDataPoint::BytesOn; + return DemoDataPoint::BytesOff; +} + +QKnxByteArray DemoColorLed::blueBytes() const +{ + if (m_stateColor.blue() > 0) + return DemoDataPoint::BytesOn; + return DemoDataPoint::BytesOff; +} + +QColor DemoColorLed::currentColor() const +{ + return m_stateColor; +} + +void DemoColorLed::setCurrentColor(QColor color) +{ + m_stateColor = color; +} + +bool DemoColorLed::isOn() const +{ + return (m_stateColor != Qt::black); +} + +bool DemoRockerDataPoint::updateDataPointState(const QKnxLinkLayerFrame &frame) +{ + auto bytes = frame.serviceInformation(); + QString s = QByteArray((const char *) bytes.constData(), bytes.size()).mid(20, 4); + bool ok; + setPosition(s.toInt(&ok, 16)); + emit rockerChange(m_position); + return false; +} + +void DemoBlindDataPoint::chooseTimeoutHandle(bool blindUp) +{ + if (blindUp) { + disconnect(&m_timer, &QTimer::timeout, this, &DemoBlindDataPoint::moveBlindDown); + connect(&m_timer, &QTimer::timeout, this, &DemoBlindDataPoint::moveBlindUp); + } else { + disconnect(&m_timer, &QTimer::timeout, this, &DemoBlindDataPoint::moveBlindUp); + connect(&m_timer, &QTimer::timeout, this, &DemoBlindDataPoint::moveBlindDown); + } +} + +bool DemoBlindDataPoint::updateDataPointState(const QKnxLinkLayerFrame &frame) +{ + auto tpdu = frame.tpdu(); + if (frame.destinationAddress().toString() == "1/0/0") { + stopBlind(); + + QKnx1Bit dpt; + dpt.setBytes(frame.tpdu().data(), 0, 1); + + chooseTimeoutHandle(dpt.bit()); + reenableTimer(); + } else if (frame.destinationAddress().toString() == "1/1/0") { + stopBlind(); + } + return false; +} + +void DemoBlindDataPoint::reenableTimer() +{ + if (!m_timer.isActive()) + m_timer.start(50); +} + +void DemoBlindDataPoint::moveBlindUp() +{ + if (m_position == 70) { + stopBlind(); + emit blindFullyUp(); + return; + } + ++m_position; + emit blindChange(m_position); +} + +void DemoBlindDataPoint::moveBlindDown() +{ + if (m_position > 0) { + --m_position; + emit blindChange(m_position); + return; + } + stopBlind(); + emit blindFullyDown(); +} + +void DemoBlindDataPoint::stopBlind() +{ + if (m_timer.isActive()) + m_timer.stop(); +} + +QKnxByteArray DemoBlindDataPoint::moveUpBytes() const +{ + // send a 0 to move up + return DemoDataPoint::BytesOff; +} + +QKnxByteArray DemoBlindDataPoint::moveDownBytes() const +{ + // send a 1 to move down + return DemoDataPoint::BytesOn; +} + +QKnxByteArray DemoBlindDataPoint::stopBytes() const +{ + // send a 1 to stop + return DemoDataPoint::BytesOn; +} diff --git a/tradeshow/knx-demo/demodatapoint.h b/tradeshow/knx-demo/demodatapoint.h new file mode 100644 index 0000000..1810203 --- /dev/null +++ b/tradeshow/knx-demo/demodatapoint.h @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DEMODATAPOINT_H +#define DEMODATAPOINT_H + +#include +#include +#include +#include + +class DemoDataPoint +{ +public: + virtual ~DemoDataPoint() = default; + + virtual QKnxByteArray bytes() const { return {}; } + virtual bool updateDataPointState(const QKnxLinkLayerFrame &frame) = 0; + + int position() const { return m_position; } + void setPosition(int pos) { m_position = pos; } + +protected: + int m_position { 0 }; + + static const QKnxByteArray BytesOn; + static const QKnxByteArray BytesOff; +}; + +class DemoSwitchDataPoint : public DemoDataPoint +{ +public: + DemoSwitchDataPoint() = default; + ~DemoSwitchDataPoint() override = default; + + QKnxByteArray bytes() const override; + bool updateDataPointState(const QKnxLinkLayerFrame &frame) override; + + void uiToggle(); + bool isOn() const; + +private: + QKnxSwitch m_switch; +}; + +class DemoColorLed : public QObject, public DemoDataPoint +{ + Q_OBJECT + +public: + DemoColorLed() = default; + ~DemoColorLed() override = default; + + bool updateDataPointState(const QKnxLinkLayerFrame &frame) override; + + QColor currentColor() const; + void setCurrentColor(QColor color); + + QKnxByteArray redBytes() const; + QKnxByteArray greenBytes() const; + QKnxByteArray blueBytes() const; + + bool isOn() const; + +Q_SIGNALS: + void colorChange(QColor color); + +private: + QColor m_stateColor; + quint8 numMsgConfirmation { 0 }; +}; + +class DemoRockerDataPoint : public QObject, public DemoDataPoint +{ + Q_OBJECT +public: + DemoRockerDataPoint() = default; + virtual ~DemoRockerDataPoint() override = default; + + bool updateDataPointState(const QKnxLinkLayerFrame &frame) override; + +Q_SIGNALS: + void rockerChange(int position); +}; + +class DemoBlindDataPoint : public QObject, public DemoDataPoint +{ + Q_OBJECT +public: + DemoBlindDataPoint() = default; + ~DemoBlindDataPoint() override = default; + + bool updateDataPointState(const QKnxLinkLayerFrame &frame) override; + + QKnxByteArray moveUpBytes() const; + QKnxByteArray moveDownBytes() const; + QKnxByteArray stopBytes() const; + +public slots: + void moveBlindUp(); + void moveBlindDown(); + void stopBlind(); + +Q_SIGNALS: + void blindChange(int position); + void blindFullyUp(); + void blindFullyDown(); + +private: + void chooseTimeoutHandle(bool blindUp); + void reenableTimer(); + QTimer m_timer; +}; + +#endif // DEMODATAPOINT_H diff --git a/tradeshow/knx-demo/etsdevelopmentboard.cpp b/tradeshow/knx-demo/etsdevelopmentboard.cpp new file mode 100644 index 0000000..c8a3ccb --- /dev/null +++ b/tradeshow/knx-demo/etsdevelopmentboard.cpp @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "etsdevelopmentboard.h" +#include "demodatapoint.h" + +EtsDevelopmentBoard::EtsDevelopmentBoard() +{ + //e1-e6 + quint8 indexMapKey = 1; + for (quint8 i = 1; i < 7 ; ++i) // small white leds + addDevice(indexMapKey++, 0, 0, i, QSharedPointer::create()); + //e7-e8 + auto blindDataPoint = QSharedPointer::create(); + addDevice(7, 1, 0, 0, blindDataPoint); // blind up/down + //skip e8 (because e7 and e8 are the same) + addDevice(8, 1, 0, 0, blindDataPoint); // blind up/down + //indexMapKey++; + //e9 red led + addDevice(9, 0, 0, 7, QSharedPointer::create()); + //e10 red led + addDevice(10, 0, 0, 8, QSharedPointer::create()); + //e11 red led + addDevice(11, 0, 0, 9, QSharedPointer::create()); + //e12 red led + addDevice(12, 0, 0, 10, QSharedPointer::create()); + // e13 + auto colorLed = QSharedPointer::create(); + addDevice(13, 0, 0, 12, colorLed); // left Red + addDevice(13, 0, 0, 13, colorLed); // left Green + addDevice(13, 0, 0, 14, colorLed); // left Blue + // e14 + addDevice(14, 0, 0, 11, QSharedPointer::create()); // right white + addDevice(15, 2, 0, 0, QSharedPointer::create()); // Rocker + // e16 turn off blind up/down + addDevice(16, 1, 1, 0, blindDataPoint); +} + +DemoDataPoint *EtsDevelopmentBoard::getGroupObject(int idx) const +{ + return m_dataPoints.value(idx).dpt.data(); +} + +DemoDataPoint *EtsDevelopmentBoard::getGroupObject(const QKnxAddress &address) const +{ + return getGroupObject(getIndex(address)); +} + +int EtsDevelopmentBoard::getIndex(const QKnxAddress &address) const +{ + return m_addressToDataPoints.value(address); +} + +QKnxAddress EtsDevelopmentBoard::getAddress(int idx) const +{ + return m_dataPoints.value(idx).address; +} + +bool EtsDevelopmentBoard::exists(const QKnxAddress &address) const +{ + return m_addressToDataPoints.contains(address); +} + +DemoRockerDataPoint *EtsDevelopmentBoard::getRocker() const +{ + return static_cast(getGroupObject(DeviceNumbers::ROCKER)); +} + +DemoBlindDataPoint *EtsDevelopmentBoard::getBlind() const +{ + return static_cast(getGroupObject(DeviceNumbers::E7)); +} + +DemoColorLed *EtsDevelopmentBoard::getColorLed() const +{ + return static_cast(getGroupObject(DeviceNumbers::COLORLED)); +} + +void EtsDevelopmentBoard::addDevice(quint8 key, quint8 mainGroup, quint16 middleGroup, + quint8 subGroup, const QSharedPointer &dpt) +{ + auto address = QKnxAddress::createGroup(mainGroup, middleGroup, subGroup); + + if (!m_dataPoints.contains(key)) + m_dataPoints.insert(key, { address, dpt }); + + if (!m_addressToDataPoints.contains(address)) + m_addressToDataPoints.insert(address, key); +} diff --git a/tradeshow/knx-demo/etsdevelopmentboard.h b/tradeshow/knx-demo/etsdevelopmentboard.h new file mode 100644 index 0000000..e95c701 --- /dev/null +++ b/tradeshow/knx-demo/etsdevelopmentboard.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ETSDEVELOPMENTBOARD_H +#define ETSDEVELOPMENTBOARD_H + +#include "demodatapoint.h" + +#include +#include +#include + +class EtsDevelopmentBoard +{ +public: + enum DeviceNumbers + { + E7 = 7, // blind control up + E8 = 8, // blind control down + COLORLED = 13, + MIDDLE_RIGHT = 14, + ROCKER = 15, + E16 = 16, // blind control down + }; + EtsDevelopmentBoard(); + + DemoDataPoint *getGroupObject(int idx) const; + DemoDataPoint *getGroupObject(const QKnxAddress &address) const; + + int getIndex(const QKnxAddress &address) const; + QKnxAddress getAddress(int idx) const; + + bool exists(const QKnxAddress &address) const; + + inline int size() const { return m_dataPoints.size(); }; + + DemoRockerDataPoint *getRocker() const; + DemoBlindDataPoint *getBlind() const; + DemoColorLed *getColorLed() const; + +private: + void addDevice(quint8 key, quint8 mainGroup, quint16 middleGroup, quint8 subGroup, + const QSharedPointer &dpt); + + struct HashNode { + QKnxAddress address; + QSharedPointer dpt; + }; + QHash m_dataPoints; + QHash m_addressToDataPoints; +}; + +#endif diff --git a/tradeshow/knx-demo/images/ArrowDown.png b/tradeshow/knx-demo/images/ArrowDown.png new file mode 100644 index 0000000..0606ccc Binary files /dev/null and b/tradeshow/knx-demo/images/ArrowDown.png differ diff --git a/tradeshow/knx-demo/images/ArrowUp.png b/tradeshow/knx-demo/images/ArrowUp.png new file mode 100644 index 0000000..ad4fb59 Binary files /dev/null and b/tradeshow/knx-demo/images/ArrowUp.png differ diff --git a/tradeshow/knx-demo/images/Qt-logo-medium.png b/tradeshow/knx-demo/images/Qt-logo-medium.png new file mode 100644 index 0000000..7d42da6 Binary files /dev/null and b/tradeshow/knx-demo/images/Qt-logo-medium.png differ diff --git a/tradeshow/knx-demo/images/blind.png b/tradeshow/knx-demo/images/blind.png new file mode 100644 index 0000000..fc78346 Binary files /dev/null and b/tradeshow/knx-demo/images/blind.png differ diff --git a/tradeshow/knx-demo/images/blindCover.png b/tradeshow/knx-demo/images/blindCover.png new file mode 100644 index 0000000..ae7c752 Binary files /dev/null and b/tradeshow/knx-demo/images/blindCover.png differ diff --git a/tradeshow/knx-demo/images/clock.png b/tradeshow/knx-demo/images/clock.png new file mode 100644 index 0000000..f5fb2af Binary files /dev/null and b/tradeshow/knx-demo/images/clock.png differ diff --git a/tradeshow/knx-demo/images/e10View.png b/tradeshow/knx-demo/images/e10View.png new file mode 100644 index 0000000..b3df098 Binary files /dev/null and b/tradeshow/knx-demo/images/e10View.png differ diff --git a/tradeshow/knx-demo/images/e1View.png b/tradeshow/knx-demo/images/e1View.png new file mode 100644 index 0000000..99b8804 Binary files /dev/null and b/tradeshow/knx-demo/images/e1View.png differ diff --git a/tradeshow/knx-demo/images/e2View.png b/tradeshow/knx-demo/images/e2View.png new file mode 100644 index 0000000..578a2a1 Binary files /dev/null and b/tradeshow/knx-demo/images/e2View.png differ diff --git a/tradeshow/knx-demo/images/e3e4View.png b/tradeshow/knx-demo/images/e3e4View.png new file mode 100644 index 0000000..d8e97b9 Binary files /dev/null and b/tradeshow/knx-demo/images/e3e4View.png differ diff --git a/tradeshow/knx-demo/images/e5e6View.png b/tradeshow/knx-demo/images/e5e6View.png new file mode 100644 index 0000000..e2e81fd Binary files /dev/null and b/tradeshow/knx-demo/images/e5e6View.png differ diff --git a/tradeshow/knx-demo/images/icon_light.png b/tradeshow/knx-demo/images/icon_light.png new file mode 100644 index 0000000..e59ef79 Binary files /dev/null and b/tradeshow/knx-demo/images/icon_light.png differ diff --git a/tradeshow/knx-demo/images/off.png b/tradeshow/knx-demo/images/off.png new file mode 100644 index 0000000..ee01cf7 Binary files /dev/null and b/tradeshow/knx-demo/images/off.png differ diff --git a/tradeshow/knx-demo/images/on_green.png b/tradeshow/knx-demo/images/on_green.png new file mode 100644 index 0000000..3b7e47e Binary files /dev/null and b/tradeshow/knx-demo/images/on_green.png differ diff --git a/tradeshow/knx-demo/images/on_orange.png b/tradeshow/knx-demo/images/on_orange.png new file mode 100644 index 0000000..ebc0044 Binary files /dev/null and b/tradeshow/knx-demo/images/on_orange.png differ diff --git a/tradeshow/knx-demo/images/quit_icon.png b/tradeshow/knx-demo/images/quit_icon.png new file mode 100644 index 0000000..7b022a3 Binary files /dev/null and b/tradeshow/knx-demo/images/quit_icon.png differ diff --git a/tradeshow/knx-demo/images/rainbow.png b/tradeshow/knx-demo/images/rainbow.png new file mode 100644 index 0000000..b426d37 Binary files /dev/null and b/tradeshow/knx-demo/images/rainbow.png differ diff --git a/tradeshow/knx-demo/images/settings_icon.png b/tradeshow/knx-demo/images/settings_icon.png new file mode 100644 index 0000000..c0ccb48 Binary files /dev/null and b/tradeshow/knx-demo/images/settings_icon.png differ diff --git a/tradeshow/knx-demo/images/stop_orange.png b/tradeshow/knx-demo/images/stop_orange.png new file mode 100644 index 0000000..aea256b Binary files /dev/null and b/tradeshow/knx-demo/images/stop_orange.png differ diff --git a/tradeshow/knx-demo/images/temperature_symbol.png b/tradeshow/knx-demo/images/temperature_symbol.png new file mode 100644 index 0000000..cad112f Binary files /dev/null and b/tradeshow/knx-demo/images/temperature_symbol.png differ diff --git a/tradeshow/knx-demo/images/topBar.png b/tradeshow/knx-demo/images/topBar.png new file mode 100644 index 0000000..ba4cb1c Binary files /dev/null and b/tradeshow/knx-demo/images/topBar.png differ diff --git a/tradeshow/knx-demo/main.cpp b/tradeshow/knx-demo/main.cpp new file mode 100644 index 0000000..f1c5fc5 --- /dev/null +++ b/tradeshow/knx-demo/main.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qmlknxdemo.h" + +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + + qmlRegisterType("QmlKnxDemo", 1, 0, "QmlKnxDemo"); + engine.load(QUrl(QLatin1String("qrc:/ui/main.qml"))); + if (engine.rootObjects().isEmpty()) + return -1; + QString namingScheme = QStringLiteral("qrc://"); + engine.rootContext()->setContextProperty("pathPrefix", namingScheme + "/"); + return app.exec(); +} diff --git a/tradeshow/knx-demo/qml.qrc b/tradeshow/knx-demo/qml.qrc new file mode 100644 index 0000000..850bc0d --- /dev/null +++ b/tradeshow/knx-demo/qml.qrc @@ -0,0 +1,43 @@ + + + qtquickcontrols2.conf + ui/main.qml + ui/KnxBoardLayout.qml + ui/components/KnxSwitch.qml + ui/components/BlindSimulationView.qml + ui/components/ColorSlider.qml + ui/components/E1LedView.qml + ui/components/E2LedView.qml + ui/components/E3E4LedView.qml + ui/components/E5E6LedView.qml + ui/components/E7E8LedView.qml + ui/components/E9LedView.qml + ui/components/E10LedView.qml + ui/components/E11LedView.qml + ui/components/E12LedView.qml + ui/components/E13LedView.qml + ui/components/E14LedView.qml + images/ArrowDown.png + images/ArrowUp.png + images/icon_light.png + images/topBar.png + images/settings_icon.png + images/quit_icon.png + images/e1View.png + images/e2View.png + images/e3e4View.png + images/e5e6View.png + images/e10View.png + images/temperature_symbol.png + images/clock.png + images/Qt-logo-medium.png + images/rainbow.png + images/on_green.png + images/off.png + images/blind.png + images/blindCover.png + images/on_orange.png + images/stop_orange.png + + + diff --git a/tradeshow/knx-demo/qmlknxdemo.cpp b/tradeshow/knx-demo/qmlknxdemo.cpp new file mode 100644 index 0000000..4215246 --- /dev/null +++ b/tradeshow/knx-demo/qmlknxdemo.cpp @@ -0,0 +1,311 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "demodatapoint.h" +#include "qmlknxdemo.h" +#include "utils.h" + +#include +#include +#include + +namespace { + const double sliderSectionSize = 1 / 7.0; + using DeviceNumbers = EtsDevelopmentBoard::DeviceNumbers; +} + +QmlKnxDemo::QmlKnxDemo() + : m_tunnel(this) +{ + checkLightStatusOn(); + + if (auto blind = m_etsBoard.getBlind()) { + connect(blind, &DemoBlindDataPoint::blindChange, this, &QmlKnxDemo::blindPositionChange); + connect(blind, &DemoBlindDataPoint::blindFullyUp, this, &QmlKnxDemo::blindFullyUp); + connect(blind, &DemoBlindDataPoint::blindFullyDown, this, &QmlKnxDemo::blindFullyDown); + } + + if (auto rocker = m_etsBoard.getRocker()) + connect(rocker, &DemoRockerDataPoint::rockerChange, this, &QmlKnxDemo::rockerChange); + + if (auto colorLed = m_etsBoard.getColorLed()) + connect(colorLed, &DemoColorLed::colorChange, this, &QmlKnxDemo::colorLedChange); +} + +void QmlKnxDemo::toggleLight(int light) +{ + if (auto dpt = static_cast(m_etsBoard.getGroupObject(light))) { + dpt->uiToggle(); + sendGroupValueWrite(m_tunnel, m_etsBoard.getAddress(light), dpt->bytes()); + } +} + +void QmlKnxDemo::colorSwitch(double value) +{ + QColor colorAtStart = colorState; + if (value < (sliderSectionSize / 2) && colorState != Qt::black) { + colorState = Qt::black; + } else if ((value > (sliderSectionSize / 2)) + && value < (3 * sliderSectionSize / 2) + && (colorState != Qt::white)) { + colorState = Qt::white; + } else if ((value > (3 * sliderSectionSize / 2)) + && value < (5 * sliderSectionSize / 2) + && (colorState != Qt::red)) { + colorState = Qt::red; + } else if ((value > (5 * sliderSectionSize / 2)) + && value < (7 * sliderSectionSize / 2) + && (colorState != Qt::magenta)) { + colorState = Qt::magenta; + } else if ((value > (7 * sliderSectionSize / 2)) + && value < (9 * sliderSectionSize / 2) + && (colorState != Qt::blue)) { + colorState = Qt::blue; + } else if ((value > (9 * sliderSectionSize / 2)) + && value < (11 * sliderSectionSize / 2) + && (colorState != Qt::cyan)) { + colorState = Qt::cyan; + } else if (value > (11 * sliderSectionSize / 2) + && value < (13 * sliderSectionSize / 2) + && (colorState != Qt::green)) { + colorState = Qt::green; + } else if (value > ((6 * sliderSectionSize) + (sliderSectionSize / 2)) + && (colorState != Qt::yellow)) { + colorState = Qt::yellow; + } + + if (colorAtStart != colorState) { + if (auto led = m_etsBoard.getColorLed()) { + led->setCurrentColor(colorState); + sendColorLedGroupValueWriteFrames(m_tunnel, led); + } + } +} + +void QmlKnxDemo::toggleMiddleRight() +{ + auto light = DeviceNumbers::MIDDLE_RIGHT; + if (auto dpt = static_cast(m_etsBoard.getGroupObject(light))) { + dpt->uiToggle(); + sendGroupValueWrite(m_tunnel, m_etsBoard.getAddress(light), dpt->bytes()); + } +} + +void QmlKnxDemo::toggleMiddleLeft() +{ + if (auto led = m_etsBoard.getColorLed()) { + // set green color in dpt by default... + led->setCurrentColor(QColor(0, (!led->isOn() ? 255 : 0), 0)); + sendColorLedGroupValueWriteFrames(m_tunnel, led); + } +} + +QString QmlKnxDemo::getColor() const +{ + if (auto obj = m_etsBoard.getColorLed()) + return obj->currentColor().name(); + return {}; +} + +int QmlKnxDemo::getRockerPosition() const +{ + if (auto rocker = m_etsBoard.getRocker()) + return rocker->position(); + return 0; +} + +bool QmlKnxDemo::getLightState(int lightNum) const +{ + if (auto dpt = static_cast(m_etsBoard.getGroupObject(lightNum))) + return dpt->isOn(); + return false; +} + +int QmlKnxDemo::getBlindPosition() const +{ + if (auto blind = m_etsBoard.getBlind()) + return blind->position(); + return 0; +} + +void QmlKnxDemo::moveBlindUp() +{ + if (auto dpt = m_etsBoard.getBlind()) { + sendGroupValueWrite(m_tunnel, m_etsBoard.getAddress(DeviceNumbers::E7), dpt->moveUpBytes(), + 0xac); + } +} + +void QmlKnxDemo::moveBlindDown() +{ + if (auto dpt = m_etsBoard.getBlind()) { + sendGroupValueWrite(m_tunnel, m_etsBoard.getAddress(DeviceNumbers::E7), dpt->moveDownBytes(), + 0xac); + } +} + +void QmlKnxDemo::stopBlind() +{ + auto index = DeviceNumbers::E16; + if (auto dpt = static_cast(m_etsBoard.getGroupObject(index))) + sendGroupValueWrite(m_tunnel, m_etsBoard.getAddress(index), dpt->stopBytes(), 0xac); +} + +void QmlKnxDemo::handleFrame(const QKnxLinkLayerFrame &frame) +{ + auto dstAdd = frame.destinationAddress().toString(); + + if (QKnxLinkLayerFrame::MessageCode::DataConfirmation == frame.messageCode() + || QKnxLinkLayerFrame::MessageCode::DataIndication == frame.messageCode()) { + // data indication come from pushing buttons on the Board + // data confirmation are responses to App UI requests + bool boardStateChanged = false; + const QKnxAddress dstAddress = frame.destinationAddress(); + if (m_etsBoard.exists(dstAddress)) + boardStateChanged = m_etsBoard.getGroupObject(dstAddress)->updateDataPointState(frame); + + if (boardStateChanged) + emit boardUpdate(m_etsBoard.getIndex(dstAddress)); + } +} + +static QHostAddress obtainLocalAddress() +{ + auto addresses = QNetworkInterface::allAddresses(); + for (auto address : qAsConst(addresses)) { + if (address.isLoopback() || address.protocol() != QAbstractSocket::IPv4Protocol) + continue; + return address; + } + return QHostAddress::LocalHost; // no local address found! +} + +QmlKnxTunnel::QmlKnxTunnel(QmlKnxDemo *demo) +{ + connect(&m_connection, &QKnxNetIpTunnel::stateChanged, + this, &QmlKnxTunnel::handleConnection); + connect(&m_connection, &QKnxNetIpTunnel::frameReceived, + demo, &QmlKnxDemo::handleFrame); + connect(&m_timer, &QTimer::timeout, this, &QmlKnxTunnel::send); + + auto newAddress = obtainLocalAddress(); + m_connection.setLocalAddress(newAddress); + m_discoveryAgent.setLocalAddress(newAddress); + + // Automatic KNXnet/Ip router discovery. Connects to first router found + static auto handleDiscoveredServer = [&](const QKnxNetIpServerInfo &info) { + if (!m_connected) { + m_ip = info.controlEndpointAddress(); + m_port = info.controlEndpointPort(); + // establish the knx tunnel + reconnect(); + m_connected = true; + } + }; + connect(&m_discoveryAgent, &QKnxNetIpServerDiscoveryAgent::deviceDiscovered, this, + handleDiscoveredServer); + autoDiscoverKnxServers(); +} + +void QmlKnxTunnel::sendFrame(const QKnxLinkLayerFrame &frame) +{ + if (frame.size() == 0) + return; + + if (m_frames.size() == 0) + m_timer.start(200); + m_frames.enqueue(frame); +} + +void QmlKnxTunnel::reconnect() +{ + m_connection.connectToHost(m_ip, m_port); +} + +void QmlKnxTunnel::autoDiscoverKnxServers() +{ + m_discoveryAgent.stop(); + m_discoveryAgent.start(); +} + +void QmlKnxTunnel::changeIp(const QString &ip, quint16 port) +{ + m_ip = QHostAddress(ip); + m_port = port; + m_connection.disconnectFromHost(); +} + +void QmlKnxTunnel::send() +{ + m_connection.sendFrame(m_frames.dequeue()); + if (m_frames.size() == 0) + m_timer.stop(); +} + +void QmlKnxTunnel::handleConnection(QKnxNetIpEndpointConnection::State state) +{ + switch (state) { + case QKnxNetIpEndpointConnection::State::Disconnected: + autoDiscoverKnxServers(); + break; + default: + break; + } +} + +void QmlKnxDemo::changeTunnelIp(const QString &ipStr, quint16 port) +{ + m_tunnel.changeIp(ipStr, port); +} + +void QmlKnxDemo::checkLightStatusOn() +{ + initBoard(m_etsBoard, m_tunnel); +} diff --git a/tradeshow/knx-demo/qmlknxdemo.h b/tradeshow/knx-demo/qmlknxdemo.h new file mode 100644 index 0000000..dd9b037 --- /dev/null +++ b/tradeshow/knx-demo/qmlknxdemo.h @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLKNXDEMO_H +#define QMLKNXDEMO_H + +#include "etsdevelopmentboard.h" + +#include +#include +#include +#include +#include +#include + +class QmlKnxDemo; +class QmlKnxTunnel : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(QmlKnxTunnel) + +public: + QmlKnxTunnel(QmlKnxDemo *demo); + void sendFrame(const QKnxLinkLayerFrame &frame); + void changeIp(const QString &ip, quint16 port = 3671); + +public slots: + void handleConnection(QKnxNetIpEndpointConnection::State state); + void send(); + +private: + void reconnect(); + void autoDiscoverKnxServers(); + +private: + QQueue m_frames; + QKnxNetIpTunnel m_connection; + QKnxNetIpServerDiscoveryAgent m_discoveryAgent; + + QTimer m_timer; + QHostAddress m_ip; + quint16 m_port { 3671 }; + bool m_connected { false }; +}; + +class QmlKnxDemo : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(QmlKnxDemo) + +public: + QmlKnxDemo(); + + Q_INVOKABLE void toggleMiddleRight(); + Q_INVOKABLE void toggleMiddleLeft(); + Q_INVOKABLE QString getColor() const; + Q_INVOKABLE int getRockerPosition() const; + Q_INVOKABLE int getBlindPosition() const; + Q_INVOKABLE bool getLightState(int lightNum) const; + + Q_INVOKABLE void moveBlindUp(); + Q_INVOKABLE void moveBlindDown(); + Q_INVOKABLE void stopBlind(); + + Q_INVOKABLE void colorSwitch(double value); + Q_INVOKABLE void toggleLight(int light); + + Q_INVOKABLE void changeTunnelIp(const QString &ipStr, quint16 port = 3671); + +Q_SIGNALS: + void boardUpdate(quint32 lightNum); + void blindPositionChange(int position); + void blindFullyDown(); + void blindFullyUp(); + void rockerChange(int position); + void colorLedChange(QColor color); + +public slots: + void handleFrame(const QKnxLinkLayerFrame &frame); + +private: + void checkLightStatusOn(); + +private: + QColor colorState; + QmlKnxTunnel m_tunnel; + EtsDevelopmentBoard m_etsBoard; +}; + +#endif diff --git a/tradeshow/knx-demo/qtquickcontrols2.conf b/tradeshow/knx-demo/qtquickcontrols2.conf new file mode 100644 index 0000000..1764b16 --- /dev/null +++ b/tradeshow/knx-demo/qtquickcontrols2.conf @@ -0,0 +1,15 @@ +; This file can be edited to change the style of the application +; See Styling Qt Quick Controls 2 in the documentation for details: +; http://doc.qt.io/qt-5/qtquickcontrols2-styles.html + +[Controls] +Style=Default + +[Universal] +Theme=Light +;Accent=Steel + +[Material] +Theme=Light +;Accent=BlueGrey +;Primary=BlueGray diff --git a/tradeshow/knx-demo/ui/KnxBoardLayout.qml b/tradeshow/knx-demo/ui/KnxBoardLayout.qml new file mode 100644 index 0000000..5fd5d3a --- /dev/null +++ b/tradeshow/knx-demo/ui/KnxBoardLayout.qml @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 +import QtQuick.Window 2.2 +import "components" + +Rectangle { + property real xScaleFactor: (width / Screen.width).toFixed(2) + + function toggleLight(num) + { + knxDemo.toggleLight(num); + } + + function enableBox(num, checked) + { + if (num == 1) + e1LedView.lightE1.on = checked; + else if (num == 2) + e2LedView.lightE2.on = checked; + else if (num == 3) + e3e4LedView.lightE3.on = checked; + else if (num == 4) + e3e4LedView.lightE4.on = checked; + else if (num == 5) + e5e6LedView.lightE5.on = checked; + else if (num == 6) + e5e6LedView.lightE6.on = checked; + else if (num == 7) + e7e8LedView.lightE7.on = checked; + else if (num == 8) + e7e8LedView.lightE8.on = checked; + else if (num == 9) + e9LedView.lightE9.on = checked; + else if (num == 10) + e10LedView.lightE10.on = checked; + else if (num == 11) + e11LedView.lightE11.on = checked; + else if (num == 12) + e12LedView.lightE12.on = checked; + else if (num == 14) + changeLedColor(middleRightLed.led, checked ? "Yellow" : "#394251"); + return; + } + + function changeColorLeftLed(color) + { + changeLedColor(middleLeftLed.led, color); + } + + function changeLedColor(led, color) + { + if (Qt.colorEqual(color, "black")) + led.color = "#394251"; + else + led.color = color; + } + + function rotateLogo(rocker) + { + logo.rotation = (rocker - 1000) * 360 / 1000; + } + + ColumnLayout { + anchors.fill: parent + spacing: 0 + RowLayout { + spacing: 0 + E1LedView { id: e1LedView } + E2LedView { id: e2LedView } + E3E4LedView { id: e3e4LedView } + } + RowLayout { + spacing: 0 + E5E6LedView { id: e5e6LedView } + E13LedView { id: middleLeftLed } + E12LedView { id: e12LedView } + E14LedView { id: middleRightLed } + E7E8LedView { id: e7e8LedView } + } + RowLayout { + spacing: 0 + E9LedView { id: e9LedView } + ColumnLayout { + spacing: 0 + ColorSlider {} + E10LedView { id: e10LedView } + } + E11LedView { id: e11LedView } + } + } +} diff --git a/tradeshow/knx-demo/ui/components/BlindSimulationView.qml b/tradeshow/knx-demo/ui/components/BlindSimulationView.qml new file mode 100644 index 0000000..11a0fbd --- /dev/null +++ b/tradeshow/knx-demo/ui/components/BlindSimulationView.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtGraphicalEffects 1.0 + +Item { + signal endSimulation(); + + function goUp() + { + animUp.start(); + } + function goDown() + { + animDown.start(); + } + function pause() + { + if (animUp.running) + animUp.stop(); + if (animDown.running) + animDown.stop(); + } + + Rectangle { + anchors.left: parent.left + anchors.right: parent.right + color: "#272a33" + Image { + id: blind + width: 84 + source: pathPrefix + "images/blind.png" + anchors.top: parent.bottom + } + SequentialAnimation { + id: animUp + running: false + NumberAnimation { target: blind; property: "height"; from: blind.height; to: 30; duration: 4000 } + onRunningChanged: { + if (!running) + endSimulation() + } + } + SequentialAnimation { + id: animDown + running: false + NumberAnimation { target: blind; property: "height"; from: blind.height; to: blind.sourceSize.height; duration: 4000 } + onRunningChanged: { + if (!running) + endSimulation() + } + } + } +} diff --git a/tradeshow/knx-demo/ui/components/ColorSlider.qml b/tradeshow/knx-demo/ui/components/ColorSlider.qml new file mode 100644 index 0000000..cf507c7 --- /dev/null +++ b/tradeshow/knx-demo/ui/components/ColorSlider.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +Rectangle { + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredWidth: 100 + color: "#272a33" + border.width: 4 + border.color: "#686a75" + Slider { + anchors.fill: parent + anchors.margins: 17 + onPressedChanged: knxDemo.colorSwitch(value) + handle: Rectangle { + x: parent.leftPadding + parent.visualPosition * (parent.availableWidth - width) + y: parent.topPadding + parent.availableHeight / 2 - height / 2 + color: hovered ? "#272a33" : "#686a75" + border.color: "gray" + border.width: 1 + implicitWidth: 24 + implicitHeight: 24 + radius: width * 0.2 + } + background: Image { + source: pathPrefix + "images/rainbow.png" + } + } +} + diff --git a/tradeshow/knx-demo/ui/components/E10LedView.qml b/tradeshow/knx-demo/ui/components/E10LedView.qml new file mode 100644 index 0000000..79345df --- /dev/null +++ b/tradeshow/knx-demo/ui/components/E10LedView.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +Rectangle { + property alias lightE10: lightE10 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredWidth: 100 + color: "#272a33" + border.width: 4 + border.color: "#686a75" + KnxSwitch { + id: lightE10 + lightNumber: 10 + anchors.centerIn: parent + z: 1 + scale: xScaleFactor + } + Image { + anchors.fill: parent + anchors.margins: 10 + fillMode: Image.PreserveAspectFit + source: pathPrefix + "images/e10View.png" + } +} diff --git a/tradeshow/knx-demo/ui/components/E11LedView.qml b/tradeshow/knx-demo/ui/components/E11LedView.qml new file mode 100644 index 0000000..fd0eee7 --- /dev/null +++ b/tradeshow/knx-demo/ui/components/E11LedView.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +Rectangle { + property alias lightE11: lightE11 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredWidth: 50 + Layout.preferredHeight: 100 + color: "#272a33" + border.width: 4 + border.color: "#686a75" + RowLayout { + anchors.fill: parent + anchors.margins: 20 + Image { + id: clockSymbol + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: lightE11.left + fillMode: Image.PreserveAspectFit + source: pathPrefix + "images/clock.png" + } + KnxSwitch { + id: lightE11 + lightNumber: 11 + anchors.centerIn: parent + scale: xScaleFactor + } + } +} diff --git a/tradeshow/knx-demo/ui/components/E12LedView.qml b/tradeshow/knx-demo/ui/components/E12LedView.qml new file mode 100644 index 0000000..4b91eab --- /dev/null +++ b/tradeshow/knx-demo/ui/components/E12LedView.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +Rectangle { + property alias lightE12: lightE12 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredWidth: 70 + color: "#272a33" + border.width: 4 + border.color: "#686a75" + ColumnLayout { + anchors.bottomMargin: height / 2 + anchors.topMargin: height / 2 + anchors.centerIn: parent + Image { + Layout.preferredWidth: 70 + Layout.preferredHeight: 70 + fillMode: Image.PreserveAspectFit + anchors.horizontalCenter: lightE12.horizontalCenter + source: pathPrefix + "images/icon_light.png" + } + KnxSwitch { + id: lightE12 + lightNumber: 12 + anchors.horizontalCenter: parent.horizontalCenter + scale: xScaleFactor + } + } +} diff --git a/tradeshow/knx-demo/ui/components/E13LedView.qml b/tradeshow/knx-demo/ui/components/E13LedView.qml new file mode 100644 index 0000000..9d0e937 --- /dev/null +++ b/tradeshow/knx-demo/ui/components/E13LedView.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +Rectangle { + property alias led: leftLed + color: "#272a33" + Layout.fillWidth: true + Layout.fillHeight: true + Layout.minimumWidth: 100 + Layout.minimumHeight: 220 + border.width: 4 + border.color: "#686a75" + Rectangle { + id: leftLed + height: parent.height / 2 + width: parent.height / 2 + color: "#394251" + radius: 0.5 * width + border.color: "#686a75" + border.width: 2 + anchors.centerIn: parent + MouseArea { + anchors.fill: parent + onClicked: knxDemo.toggleMiddleLeft() + } + } +} diff --git a/tradeshow/knx-demo/ui/components/E14LedView.qml b/tradeshow/knx-demo/ui/components/E14LedView.qml new file mode 100644 index 0000000..85987d8 --- /dev/null +++ b/tradeshow/knx-demo/ui/components/E14LedView.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +Rectangle { + property alias led: rightLed + color: "#272a33" + Layout.fillWidth: true + Layout.fillHeight: true + Layout.minimumWidth: 100 + Layout.minimumHeight: 220 + border.width: 4 + border.color: "#686a75" + Rectangle { + id: rightLed + height: parent.height / 2 + width: parent.height / 2 + color: "#394251" + radius: 0.5 * width + border.color: "#686a75" + border.width: 2 + anchors.centerIn: parent + MouseArea { + anchors.fill: parent + onClicked: toggleLight(14) + } + } +} diff --git a/tradeshow/knx-demo/ui/components/E1LedView.qml b/tradeshow/knx-demo/ui/components/E1LedView.qml new file mode 100644 index 0000000..6b676c2 --- /dev/null +++ b/tradeshow/knx-demo/ui/components/E1LedView.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +Rectangle { + color: "#272a33" + property alias lightE1: lightE1 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredWidth: 400 + Layout.preferredHeight: 220 + border.width: 4 + border.color: "#686a75" + Image { + id: e1SchemeImg + source: pathPrefix + "images/e1View.png" + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: lightE1.left + fillMode: Image.PreserveAspectFit + } + KnxSwitch { + id: lightE1 + lightNumber:1 + anchors.verticalCenter: e1SchemeImg.verticalCenter + anchors.right: parent.right + scale: xScaleFactor + } +} diff --git a/tradeshow/knx-demo/ui/components/E2LedView.qml b/tradeshow/knx-demo/ui/components/E2LedView.qml new file mode 100644 index 0000000..f844141 --- /dev/null +++ b/tradeshow/knx-demo/ui/components/E2LedView.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +Rectangle { + id: e2Scheme + property alias lightE2: lightE2 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredWidth: 300 + Layout.preferredHeight: 220 + color: "#272a33" + border.width: 4 + border.color: "#686a75" + Image { + id: e2SchemeImg + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: lightE2.left + fillMode: Image.PreserveAspectFit + source: pathPrefix + "images/e2View.png" + } + KnxSwitch { + id: lightE2 + lightNumber:2 + anchors.right: parent.right + anchors.verticalCenter: e2SchemeImg.verticalCenter + scale: xScaleFactor + } +} diff --git a/tradeshow/knx-demo/ui/components/E3E4LedView.qml b/tradeshow/knx-demo/ui/components/E3E4LedView.qml new file mode 100644 index 0000000..cc0f4f8 --- /dev/null +++ b/tradeshow/knx-demo/ui/components/E3E4LedView.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +Rectangle { + id: e3e4Scheme + property alias lightE3: lightE3 + property alias lightE4: lightE4 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredWidth: 400 + Layout.preferredHeight: 220 + color: "#272a33" + border.width: 4 + border.color: "#686a75" + KnxSwitch { + id: lightE3 + lightNumber: 3 + anchors.left: parent.left + anchors.right: e3e4SchemeImg.left + anchors.verticalCenter: e3e4SchemeImg.verticalCenter + scale: xScaleFactor + } + Image { + id: e3e4SchemeImg + anchors.left: lightE3.right + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: lightE4.left + fillMode: Image.PreserveAspectFit + source: pathPrefix + "images/e3e4View.png" + } + KnxSwitch { + id: lightE4 + lightNumber: 4 + width: 88 + anchors.right: parent.right + anchors.verticalCenter: e3e4SchemeImg.verticalCenter + scale: xScaleFactor + } +} diff --git a/tradeshow/knx-demo/ui/components/E5E6LedView.qml b/tradeshow/knx-demo/ui/components/E5E6LedView.qml new file mode 100644 index 0000000..564c050 --- /dev/null +++ b/tradeshow/knx-demo/ui/components/E5E6LedView.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +Rectangle { + id: e5e6Scheme + color: "#272a33" + property alias lightE5: lightE5 + property alias lightE6: lightE6 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredWidth: 130 + Layout.preferredHeight: 220 + border.width: 4 + border.color: "#686a75" + Image { + id: e5e6SchemeImg + anchors.right: parent.righ + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.left: colSwitches.right + fillMode: Image.PreserveAspectFit + source: pathPrefix + "images/e5e6View.png" + } + ColumnLayout { + id: colSwitches + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.margins: 4 + KnxSwitch { + id: lightE5 + lightNumber: 5 + anchors.top: parent.top + scale: xScaleFactor + } + KnxSwitch { + id: lightE6 + lightNumber: 6 + anchors.bottom: parent.bottom + scale: xScaleFactor + } + } +} diff --git a/tradeshow/knx-demo/ui/components/E7E8LedView.qml b/tradeshow/knx-demo/ui/components/E7E8LedView.qml new file mode 100644 index 0000000..92be92f --- /dev/null +++ b/tradeshow/knx-demo/ui/components/E7E8LedView.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +Rectangle { + color: "#272a33" + property alias lightE7: lightE7 + property alias lightE8: lightE8 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.minimumWidth: 120 + Layout.minimumHeight: 220 + border.width: 4 + border.color: "#686a75" + BlindSimulationView { + id: simulation + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.topMargin: 20 + anchors.leftMargin: 10 + onEndSimulation: { + lightE7.on = false; + lightE8.on = false; + knxDemo.stopBlind(); + } + } + ColumnLayout { + id: blindControls + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: parent.right + spacing: 0 + KnxSwitch { + id: lightE7 + lightNumber: 7 + scale: xScaleFactor + customSwitchAction: true + onUiClicked: { + lightE8.on = false; + simulation.pause(); + if (lightE7.on) { + simulation.goUp(); + knxDemo.moveBlindUp(); + } + } + } + KnxSwitch { + id: lightE8 + lightNumber: 8 + scale: xScaleFactor + customSwitchAction: true + onUiClicked: { + lightE7.on = false; + simulation.pause(); + if (lightE8.on) { + simulation.goDown(); + knxDemo.moveBlindDown(); + } + } + } + } +} diff --git a/tradeshow/knx-demo/ui/components/E9LedView.qml b/tradeshow/knx-demo/ui/components/E9LedView.qml new file mode 100644 index 0000000..e384ea7 --- /dev/null +++ b/tradeshow/knx-demo/ui/components/E9LedView.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +Rectangle { + property alias lightE9: lightE9 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredWidth: 50 + Layout.preferredHeight: 100 + color: "#272a33" + border.width: 4 + border.color: "#686a75" + RowLayout { + anchors.fill: parent + anchors.margins: 20 + Image { + id: tempSymbol + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: lightE9.left + fillMode: Image.PreserveAspectFit + source: pathPrefix + "images/temperature_symbol.png" + } + KnxSwitch { + id: lightE9 + lightNumber: 9 + anchors.centerIn: parent + scale: xScaleFactor + } + } +} diff --git a/tradeshow/knx-demo/ui/components/KnxSwitch.qml b/tradeshow/knx-demo/ui/components/KnxSwitch.qml new file mode 100644 index 0000000..f56bec8 --- /dev/null +++ b/tradeshow/knx-demo/ui/components/KnxSwitch.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +Item { + width: 88 + height: 48 + property bool on: false + property int lightNumber: 0 + property bool customSwitchAction: false + + signal uiClicked(); + MouseArea { + anchors.fill: parent + onClicked: { + if (!customSwitchAction) + toggleLight(lightNumber); + on = !on; + uiClicked(); + } + } + Image { + id: imageOff + anchors.fill: parent + visible: on + fillMode: Image.PreserveAspectFit + source: pathPrefix + "images/on_green.png" + } + Image { + anchors.fill: parent + visible: !on + fillMode: Image.PreserveAspectFit + source: pathPrefix + "images/off.png" + } +} diff --git a/tradeshow/knx-demo/ui/main.qml b/tradeshow/knx-demo/ui/main.qml new file mode 100644 index 0000000..92399a8 --- /dev/null +++ b/tradeshow/knx-demo/ui/main.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 +import QmlKnxDemo 1.0 + +ApplicationWindow { + id: mainWindow + visibility: "FullScreen" + width: 1280 + height: 800 + title: qsTr("KNX Demo") + + QmlKnxDemo { + id: knxDemo + onBoardUpdate: { + console.log("signal onBoardUpdate lightNum: " + lightNum) + knxBoard.enableBox(lightNum, getLightState(lightNum)); + } + onColorLedChange: knxBoard.changeColorLeftLed(color) + onRockerChange: { + logo.rotation = (position - 1000) * 360 / 1000; + } + } + + header: ToolBar { + height: mainWindow.height / 12 + width: parent.width + Layout.fillWidth: true + background: Image { + anchors.fill: parent + source: pathPrefix + "images/topBar.png" + } + Image { + id: logo + antialiasing: true + anchors.verticalCenter: title.verticalCenter + width: 45 + height: 33 + source: pathPrefix + "images/Qt-logo-medium.png" + } + Label { + id: title + color: "grey" + text: qsTr("Qt for automation KNX demo") + anchors.left: logo.right + anchors.verticalCenter: parent.verticalCenter + Layout.maximumWidth: mainWindow.width / 3 + } + ToolButton { + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + width: logo.width * 0.8 + height: logo.width * 0.8 + contentItem: Image { + fillMode: Image.PreserveAspectFit + source: pathPrefix + "images/quit_icon.png" + MouseArea { + anchors.fill: parent + onClicked: Qt.quit(); + } + } + } + } + + KnxBoardLayout { + id: knxBoard + anchors.fill: parent + } +} diff --git a/tradeshow/knx-demo/utils.h b/tradeshow/knx-demo/utils.h new file mode 100644 index 0000000..16c0877 --- /dev/null +++ b/tradeshow/knx-demo/utils.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef UTILS_H +#define UTILS_H + +#include "demodatapoint.h" + +#include +#include + +QKnxLinkLayerFrame createRequestFrame(const QKnxAddress &address, const QKnxTpdu &tpdu, + quint8 ctrl = 0xac, quint8 extCtrl = 0xe0) +{ + QKnxLinkLayerFrame frame(QKnxLinkLayerFrame::MessageCode::DataRequest); + frame.setMediumType(QKnx::MediumType::NetIP); + frame.setControlField(QKnxControlField(ctrl)); + frame.setExtendedControlField(QKnxExtendedControlField(extCtrl)); + frame.setSourceAddress({ QKnxAddress::Type::Group, 0 }); + frame.setDestinationAddress(address); + frame.setTpdu(tpdu); + return frame; +} + +void sendGroupValueWrite(QmlKnxTunnel &tunnel, const QKnxAddress &address, + const QKnxByteArray &data, quint8 ctrl = 0xa4, quint8 extCtrl = 0xe0) +{ + tunnel.sendFrame(createRequestFrame(address, + QKnxTpduFactory::Multicast::createGroupValueWriteTpdu(data), ctrl, extCtrl)); +} + +void sendColorLedGroupValueWriteFrames(QmlKnxTunnel &tunnel, const DemoColorLed *const dpt) +{ + if (dpt) { + tunnel.sendFrame(createRequestFrame(QKnxAddress::createGroup(0, 0, 12), + QKnxTpduFactory::Multicast::createGroupValueWriteTpdu(dpt->redBytes()))); + + tunnel.sendFrame(createRequestFrame(QKnxAddress::createGroup(0, 0, 13), + QKnxTpduFactory::Multicast::createGroupValueWriteTpdu(dpt->greenBytes()))); + + tunnel.sendFrame(createRequestFrame(QKnxAddress::createGroup(0, 0, 14), + QKnxTpduFactory::Multicast::createGroupValueWriteTpdu(dpt->blueBytes()))); + } +} + +void initBoard(EtsDevelopmentBoard &board, QmlKnxTunnel &tunnel) +{ + auto tpdu = QKnxTpduFactory::Multicast::createGroupValueReadTpdu(); + for (int i = 1; i <= board.size(); ++i) { + if (i >= 9 && i <= 12) + continue; // skip red leds readings because they are not indicating the state! + if ((i == 7) || (i == 8) || (i == 16)) + continue; // skip checking blinds state + + if (QKnxAddress::createGroup(0, 0, 12) == board.getAddress(i)) { + tunnel.sendFrame(createRequestFrame(QKnxAddress::createGroup(0, 0, 12), tpdu)); + tunnel.sendFrame(createRequestFrame(QKnxAddress::createGroup(0, 0, 13), tpdu)); + tunnel.sendFrame(createRequestFrame(QKnxAddress::createGroup(0, 0, 14), tpdu)); + } else { + tunnel.sendFrame(createRequestFrame(board.getAddress(i), tpdu, 0xa4)); + } + } +} + +#endif -- cgit v1.2.3