diff --git a/CuteHMI.qbs b/CuteHMI.qbs index e1ab19f6..86f17198 100644 --- a/CuteHMI.qbs +++ b/CuteHMI.qbs @@ -1,60 +1,58 @@ import qbs Project { - property bool buildExamples: true - property bool buildExtensions: true property bool buildTests: false property bool buildTools: true property bool staticExtensions: false property bool buildApk: false property bool buildBinaries: true qbsSearchPaths: ["qbs"] references: [ "tools/tools.qbs", "extensions/extensions.qbs" ] AutotestRunner { environment: { var env = base; env.push("QML2_IMPORT_PATH=" + cutehmi.dirs.installDir + "/" + cutehmi.dirs.extensionsInstallSubdir); env.push("QBS_INSTALL_ROOT=" + qbs.installRoot); if (qbs.hostOS.contains("windows") && qbs.targetOS.contains("windows")) { var path = ""; for (var i = 0; i < env.length; ++i) { if (env[i].startsWith("PATH=")) { path = env[i].substring(5); break; } } path = Qt.core.binPath + ";" + path; var arrayElem = "PATH=" + path; if (i < env.length) env[i] = arrayElem; else env.push(arrayElem); } if (qbs.hostOS.contains("darwin") && qbs.targetOS.contains("darwin")) { env.push("DYLD_FRAMEWORK_PATH=" + Qt.core.libPath); env.push("DYLD_LIBRARY_PATH=" + Qt.core.libPath); } return env; } Depends { name: "Qt.core" } Depends { name: "cutehmi.dirs" } } } diff --git a/README.md b/README.md index 3263f2a7..1c2973e9 100644 --- a/README.md +++ b/README.md @@ -1,158 +1,155 @@ # CuteHMI
[//]: # (\htmlonly) [![License: LGPL 3.0](https://img.shields.io/badge/license-LGPL%203.0-blue.svg)](https://opensource.org/licenses/LGPL-3.0) [![Build Status](https://invent.kde.org/sdk/cutehmi/badges/4/pipeline.svg)](https://invent.kde.org/sdk/cutehmi/pipelines) [![Coverity Scan Build Status](https://scan.coverity.com/projects/20988/badge.svg)](https://scan.coverity.com/projects/cutehmi) [//]: # (\endhtmlonly)
CuteHMI is an open-source HMI (Human Machine Interface) software written in C++ and QML, using Qt libraries as a framework. CuteHMI is essentially a collection of libraries, plugins and executables, referred to as "extensions" and "tools", glued together by Qbs components. To create custom project one creates his own first-class extension, which may depend on any number of other extensions and uses specific tool to load its components. This makes CuteHMI very flexible framework with many use cases. ![Qt Designer](doc/images/design_mode.png) ![Sample application built with CuteHMI](doc/images/demo.png) Note: While most of the project uses GNU Lesser General Public License version 3, some files are distributed under different licenses. ## Branches Consecutive branch numbers denote successive iterations of the project. Iteration of the project is related to build framework (repository layout and Qbs items). Extensions and tools are versioned independently and they have their own development status. Branch "master" is a development branch. Development branch may contain source code that is undergoing deep changes, rendering it unusable. Branch "master" is merged frequently into a branch, which has "alpha" status. This branch may also -undergo deep modifications, but at least it is guaranteed to build successfuly. -Most stable branches are denoted by "perpetual beta" status. No backward -incompatible changes shall be made to them. +undergo deep modifications, but it should be usable. Branches with +"perpetual beta" status are stable in a sense that no backward incompatible +changes shall be made to them.
[//]: # (\htmlonly) | Branch | Build status | Development status | |-------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|--------------------| | [master](https://invent.kde.org/sdk/cutehmi) | [![Build Status](https://invent.kde.org/sdk/cutehmi/badges/master/pipeline.svg)](https://invent.kde.org/sdk/cutehmi/pipelines) | pre-alpha | | [4](https://invent.kde.org/sdk/cutehmi/-/tree/4)| [![Build Status](https://invent.kde.org/sdk/cutehmi/badges/4/pipeline.svg)](https://invent.kde.org/sdk/cutehmi/pipelines) | alpha | | [3](https://invent.kde.org/sdk/cutehmi/-/tree/3)| [![Build Status](https://invent.kde.org/sdk/cutehmi/badges/3/pipeline.svg)](https://invent.kde.org/sdk/cutehmi/pipelines) | perpetual beta | -| [2](https://invent.kde.org/sdk/cutehmi/-/tree/2)| [![Build Status](https://invent.kde.org/sdk/cutehmi/badges/2/pipeline.svg)](https://invent.kde.org/sdk/cutehmi/pipelines) | perpetual beta | -| [1](https://invent.kde.org/sdk/cutehmi/tree/1) | [![Build Status](https://travis-ci.org/michpolicht/CuteHMI.svg?branch=1)](https://travis-ci.org/michpolicht/CuteHMI/branches) | perpetual beta | [//]: # (\endhtmlonly)
## Compiling 1. Get the Qt toolkit. Open-source and commercial editions can be obtained from https://www.qt.io/. Qt can also be shipped with Linux distribution. 2. Open `CuteHMI.qbs` file with QtCreator and simply build it. 3. All extensions dependent on external libraries will be disabled, if these libraries could not be found. To make the process of finding the libraries and installing them under Windows easier, a set of Makefiles is provided, which allows the libraries to be build from sources. Check out [external](external/) libraries for more details. Each extension may provide individual documentation on how to build it. Remember that Qbs caches [Probe](http://doc.qt.io/qbs/qml-qbslanguageitems-probe.html) items' results, so if the library is installed after the project has been configured with Qbs, it will not show up. You can use `--force-probe-execution` option to force Qbs to not use cached results. ### Building only specified products By default Qbs will compile all the products (tools and extension), even if they are not needed for a project. To build only specific product use `--products | -p` [build option](https://doc.qt.io/qbs/cli-build.html#op-op-op-op-products-op-op-op-op-p-op-lt-op-name-op-gt-op-op-op-op-op-op-lt-op-name-op-gt-op-op-op-op-op-op-op-op-op). For example following command will build only `CuteHMI.Examples.SimpleView.1` extension and its dependencies, using default configuration. ``` qbs -f CuteHMI.qbs -p CuteHMI.Examples.SimpleView.1 ``` Find out more about build options on [Qbs documentation website](https://doc.qt.io/qbs/index.html). ## Getting started For an introduction you may want to run one of the existing examples. In CuteHMI everything is either a tool or an extension, therefore examples are also provided as extensions. Their names start with "CuteHMI.Examples" prefix. The most basic -example `CuteHMI.Examples.SimpleView.1` can be run with `cutehmi.view.3` tool by +example `CuteHMI.Examples.SimpleView.2` can be run with `cutehmi.view.4` tool by issuing following command. ``` -cutehmi.view.3 --extension="CuteHMI.Examples.SimpleView.1" +cutehmi.view.4 CuteHMI.Examples.SimpleView.2 ``` To create your own project you can simply copy one of the examples to your own -subdirectory in `extensions` directory (e.g. `Me/MyExtension.0`), rename `qbs` file -accordingly to match extension name (e.g. `MyExtension.0.qbs`), then edit `qbs` -file and change `name` property to match extension name -(e.g. `name: "Me.MyExtension.0"`) +subdirectory in `extensions` directory (e.g. `Me/MyExtension.0`) and edit +`project.qbs` file. Change `name` property to match extension name (e.g. `name: +"Me.MyExtension.0"`) After that you can use `--force-probe-execution` Qbs option or delete build directory and rebuild whole project. Your extension should be installed and it -can be run with `cutehmi.view.3` tool. +can be run with `cutehmi.view.4` tool. ``` -cutehmi.view.3 --extension="Me.MyExtension.0" +cutehmi.view.4 Me.MyExtension.0 ``` More methodical approach is to use one of the templates. The process of creating custom extensions is described in more detail [here](extensions/). Examples are listed in the documentation along with other extensions. ## Internals Directory structure of the project is organized as follows. - *_sass*, *_layouts* - directories used by GitHub Pages. - *awkgward* - code maintanance scripts (don't bother). - *dev* - development notes (irrelevant). - [doc](doc/) - a place where documentation shall be. - [extensions](extensions/) - libraries and QML extensions. - [external](external/) - directory containing "external" libraries. - *extra* - various stuff related to the project, such as T-shirts. - *qbs* - Qbs modules and imports. - [tools](tools/) - executable programs. ![Dependencies between tools, extensions and external libraries](doc/images/general_dependencies.svg) Two most important directories are [extensions](extensions/) and [tools](tools/). Extensions combine functionality of QML extensions and standard libraries. They can be utilized by end-user applications, but they can be also linked with each other. Some extensions may depend on [external](external/) libraries. ## Quick links - [Repository](https://invent.kde.org/sdk/cutehmi) - [Website](https://cutehmi.kde.org/) - [Documentation](https://cutehmi.kde.org/docs/) diff --git a/extensions/CuteHMI.2/CuteHMI.2.qbs b/extensions/CuteHMI.2/project.qbs similarity index 95% rename from extensions/CuteHMI.2/CuteHMI.2.qbs rename to extensions/CuteHMI.2/project.qbs index 8139ccdc..a0de1306 100644 --- a/extensions/CuteHMI.2/CuteHMI.2.qbs +++ b/extensions/CuteHMI.2/project.qbs @@ -1,107 +1,107 @@ import qbs import cutehmi Project { name: "CuteHMI.2" references: [ "tests/tests.qbs" ] cutehmi.CppExtension { name: parent.name vendor: "CuteHMI" domain: "cutehmi.kde.org" friendlyName: "CuteHMI" description: "Provides core functionality to other modules." files: [ "README.md", "LICENSE", "include/cutehmi/Init.hpp", "include/cutehmi/Initializer.hpp", "include/cutehmi/InplaceError.hpp", "include/cutehmi/Message.hpp", "include/cutehmi/Messenger.hpp", "include/cutehmi/Notifier.hpp", "include/cutehmi/constants.hpp", "include/cutehmi/functions.hpp", "include/cutehmi/macros.hpp", "include/cutehmi/wrappers.hpp", "include/cutehmi/Error.hpp", "include/cutehmi/ErrorException.hpp", "include/cutehmi/ErrorInfo.hpp", "include/cutehmi/Exception.hpp", "include/cutehmi/ExceptionMixin.hpp", "include/cutehmi/MPtr.hpp", "include/cutehmi/NonCopyable.hpp", "include/cutehmi/NonMovable.hpp", "include/cutehmi/Notification.hpp", "include/cutehmi/NotificationListModel.hpp", "include/cutehmi/Singleton.hpp", "include/cutehmi/Worker.hpp", "include/cutehmi/internal/common.hpp", "include/cutehmi/internal/platform.hpp", "include/cutehmi/internal/singleton.hpp", "include/cutehmi/logging.hpp", "include/cutehmi/loggingMacros.hpp", "include/cutehmi/metadata.hpp", "src/cutehmi/Error.cpp", "src/cutehmi/ErrorException.cpp", "src/cutehmi/ErrorInfo.cpp", "src/cutehmi/Exception.cpp", "src/cutehmi/Init.cpp", "src/cutehmi/InplaceError.cpp", "src/cutehmi/Message.cpp", "src/cutehmi/Messenger.cpp", "src/cutehmi/Notification.cpp", "src/cutehmi/NotificationListModel.cpp", "src/cutehmi/Notifier.cpp", "src/cutehmi/Singleton.cpp", "src/cutehmi/Worker.cpp", "src/cutehmi/internal/singleton.cpp", "src/cutehmi/logging.cpp", "src/cutehmi/internal/QMLPlugin.cpp", "src/cutehmi/internal/QMLPlugin.hpp", ] Depends { name: "Qt.core" } Depends { name: "Qt.qml" } Depends { name: "cutehmi.doxygen" } cutehmi.doxygen.warnIfUndocumented: false cutehmi.doxygen.useDoxyqml: true cutehmi.doxygen.exclude: ['dev', 'tests'] Depends { name: "cutehmi.init" } Depends { name: "cutehmi.metadata" } Depends { name: "cutehmi.qmldir" } cutehmi.qmldir.singletons: ["Palette"] Depends { name: "cutehmi.qmltypes" } Export { Depends { name: "Qt.core" } Depends { name: "Qt.qml" } } } cutehmi.AndroidQMLPlugin { extensionName: parent.name } } -//(c)C: Copyright © 2018-2020, Michał Policht , Wojtek Zygmuntowicz . All rights reserved. +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/BitcoinCash.0/CuteHMI.BitcoinCash.0.qbs b/extensions/CuteHMI/BitcoinCash.0/project.qbs similarity index 97% rename from extensions/CuteHMI/BitcoinCash.0/CuteHMI.BitcoinCash.0.qbs rename to extensions/CuteHMI/BitcoinCash.0/project.qbs index b5b3fdc3..4e20072a 100644 --- a/extensions/CuteHMI/BitcoinCash.0/CuteHMI.BitcoinCash.0.qbs +++ b/extensions/CuteHMI/BitcoinCash.0/project.qbs @@ -1,71 +1,71 @@ import qbs import cutehmi Project { condition: false // This extension no longer works, because Bitcoin.com REST API v1 became unavailable. name: "CuteHMI.BitcoinCash.0" references: [ "tests/tests.qbs" ] cutehmi.CppExtension { name: parent.name minor: 0 micro: 0 friendlyName: "Bitcoin Cash" vendor: "CuteHMI" domain: "cutehmi.kde.org" description: "Wraps Bitcoin.com REST API to provide Bitcoin Cash operations." author: "Michal Policht" copyright: "Michal Policht" license: "GNU Lesser General Public License, v. 3.0" files: [ "README.md", "include/cutehmi/bitcoincash/Address.hpp", "include/cutehmi/bitcoincash/internal/common.hpp", "include/cutehmi/bitcoincash/internal/platform.hpp", "include/cutehmi/bitcoincash/logging.hpp", "include/cutehmi/bitcoincash/metadata.hpp", "src/cutehmi/bitcoincash/Address.cpp", "src/cutehmi/bitcoincash/internal/QMLPlugin.cpp", "src/cutehmi/bitcoincash/internal/QMLPlugin.hpp", "src/cutehmi/bitcoincash/logging.cpp", ] Depends { name: "Qt.network" } Depends { name: "CuteHMI.2" } // Depends { name: "cutehmi.doxygen" } // cutehmi.doxygen.warnIfUndocumented: false // cutehmi.doxygen.useDoxyqml: true // cutehmi.doxygen.exclude: ['tests'] Depends { name: "cutehmi.qmldir" } Depends { name: "cutehmi.qmltypes" } Export { Depends { name: "CuteHMI.2" } } } } -//(c)C: Copyright © 2019, Michał Policht . All rights reserved. +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/DataAcquisition.0/DataAcquisition.0.qbs b/extensions/CuteHMI/DataAcquisition.0/project.qbs similarity index 100% rename from extensions/CuteHMI/DataAcquisition.0/DataAcquisition.0.qbs rename to extensions/CuteHMI/DataAcquisition.0/project.qbs diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/CountDaemon.3/Daemon.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/CountDaemon.3/Daemon.qml index fd3e8aa1..e1a7c658 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/CountDaemon.3/Daemon.qml @@ -1,54 +1,28 @@ -import qbs +import QtQuick 2.0 -import cutehmi - -Project { - name: "CuteHMI.Symbols.Pipes.1" - - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] +QtObject { + Component.onCompleted: { + console.log("Hello from counting daemon!") + } - Depends { name: "cutehmi.qmldir" } + property Timer timer: Timer { + interval: 1000 + running: true + repeat: true - Depends { name: "cutehmi.qmltypes" } + property int ctr: 0 - Export { - Depends { name: "CuteHMI.GUI.1" } + onTriggered: { + ctr++; + console.log("I can count to", ctr) + if (ctr === 10) + Qt.quit() } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/CountDaemon.3/LICENSE b/extensions/CuteHMI/Examples/CountDaemon.3/LICENSE new file mode 100644 index 00000000..0a041280 --- /dev/null +++ b/extensions/CuteHMI/Examples/CountDaemon.3/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/extensions/CuteHMI/Examples/CountDaemon.3/LICENSE.C.dslash.inc b/extensions/CuteHMI/Examples/CountDaemon.3/LICENSE.C.dslash.inc new file mode 100644 index 00000000..3604b204 --- /dev/null +++ b/extensions/CuteHMI/Examples/CountDaemon.3/LICENSE.C.dslash.inc @@ -0,0 +1,6 @@ + +//(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/CountDaemon.3/LICENSE.C.hash.inc b/extensions/CuteHMI/Examples/CountDaemon.3/LICENSE.C.hash.inc new file mode 100644 index 00000000..daa303be --- /dev/null +++ b/extensions/CuteHMI/Examples/CountDaemon.3/LICENSE.C.hash.inc @@ -0,0 +1,6 @@ + +#(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +#(c)C: This file is a part of CuteHMI. +#(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +#(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +#(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/CountDaemon.3/README.md b/extensions/CuteHMI/Examples/CountDaemon.3/README.md new file mode 100644 index 00000000..aaae1e02 --- /dev/null +++ b/extensions/CuteHMI/Examples/CountDaemon.3/README.md @@ -0,0 +1,26 @@ +# Count Daemon + +Counting daemon example. Daemon counts to 10 and then quits. + +To run the example use [cutehmi.daemon.3](../../../../tools/cutehmi.daemon.3/) tool. +``` +cutehmi.daemon.3 CuteHMI.Examples.CountDaemon.3 +``` + +Running this example should result in printing following lines. +``` +qml: Hello from counting daemon! +qml: I can count to 1 +qml: I can count to 2 +qml: I can count to 3 +qml: I can count to 4 +qml: I can count to 5 +qml: I can count to 6 +qml: I can count to 7 +qml: I can count to 8 +qml: I can count to 9 +qml: I can count to 10 +``` + +\example Daemon.qml +Here is a complete listing of the example source file. diff --git a/extensions/CuteHMI/Examples/CountDaemon.3/doc/project_logo.png b/extensions/CuteHMI/Examples/CountDaemon.3/doc/project_logo.png new file mode 100644 index 00000000..c5bc24be Binary files /dev/null and b/extensions/CuteHMI/Examples/CountDaemon.3/doc/project_logo.png differ diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/CountDaemon.3/project.qbs similarity index 70% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/CountDaemon.3/project.qbs index fd3e8aa1..a194e95f 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/CountDaemon.3/project.qbs @@ -1,54 +1,40 @@ import qbs import cutehmi Project { - name: "CuteHMI.Symbols.Pipes.1" + name: "CuteHMI.Examples.CountDaemon.3" cutehmi.Extension { name: parent.name - friendlyName: "Pipes" - vendor: "CuteHMI" domain: "cutehmi.kde.org" - description: "Pipe drawing components." + friendlyName: "Count Daemon" + + description: "Counting daemon example." files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", + "LICENSE", "README.md", - "Tee.qml", - "functions.js", + "Daemon.qml" ] - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] - Depends { name: "cutehmi.qmldir" } Depends { name: "cutehmi.qmltypes" } - Export { - Depends { name: "CuteHMI.GUI.1" } - } + Depends { name: "cutehmi.daemon.3" } + + Depends { name: "cutehmi.doxygen" } + cutehmi.doxygen.useDoxyqml: true } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/DataAcquisition.0/DataAcquisition.0.qbs similarity index 65% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/DataAcquisition.0/DataAcquisition.0.qbs index fd3e8aa1..dd800bed 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/DataAcquisition.0/DataAcquisition.0.qbs @@ -1,54 +1,39 @@ import qbs import cutehmi Project { - name: "CuteHMI.Symbols.Pipes.1" + name: "CuteHMI.Examples.DataAcquisition.0" cutehmi.Extension { name: parent.name - friendlyName: "Pipes" - vendor: "CuteHMI" domain: "cutehmi.kde.org" - description: "Pipe drawing components." + friendlyName: "Data Acquisition Example" + + description: "Basic data acquisition example." files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", + "LICENSE", "README.md", - "Tee.qml", - "functions.js", + "Main.qml", ] - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + Depends { name: "CuteHMI.DataAcquisition.0" } Depends { name: "cutehmi.qmldir" } Depends { name: "cutehmi.qmltypes" } - Export { - Depends { name: "CuteHMI.GUI.1" } - } + Depends { name: "cutehmi.view.3" } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/DataAcquisition.0/LICENSE b/extensions/CuteHMI/Examples/DataAcquisition.0/LICENSE new file mode 100644 index 00000000..0a041280 --- /dev/null +++ b/extensions/CuteHMI/Examples/DataAcquisition.0/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/extensions/CuteHMI/Examples/DataAcquisition.0/LICENSE.C.dslash.inc b/extensions/CuteHMI/Examples/DataAcquisition.0/LICENSE.C.dslash.inc new file mode 100644 index 00000000..3604b204 --- /dev/null +++ b/extensions/CuteHMI/Examples/DataAcquisition.0/LICENSE.C.dslash.inc @@ -0,0 +1,6 @@ + +//(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/DataAcquisition.0/LICENSE.C.hash.inc b/extensions/CuteHMI/Examples/DataAcquisition.0/LICENSE.C.hash.inc new file mode 100644 index 00000000..daa303be --- /dev/null +++ b/extensions/CuteHMI/Examples/DataAcquisition.0/LICENSE.C.hash.inc @@ -0,0 +1,6 @@ + +#(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +#(c)C: This file is a part of CuteHMI. +#(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +#(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +#(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/DataAcquisition.0/Main.qml b/extensions/CuteHMI/Examples/DataAcquisition.0/Main.qml new file mode 100644 index 00000000..69bfd88b --- /dev/null +++ b/extensions/CuteHMI/Examples/DataAcquisition.0/Main.qml @@ -0,0 +1,363 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.14 + +import CuteHMI.Services 2.0 +import CuteHMI.SharedDatabase 0.0 +import CuteHMI.DataAcquisition 0.0 + +ColumnLayout { + anchors.fill: parent + + BusyIndicator { + anchors.centerIn: parent + parent: Overlay.overlay + running: schema.busy + } + + Service { + id: dbService + + name: "Database Service" + + Database { + connectionName: "myConnection" + type: "QPSQL" +// type: "QSQLITE" + host: "localhost" + port: 5432 + name: "test" + user: "postgres" + password: "postgres" + +// threaded: false +// onConnected: historyService.start() + } + +// onStarted: historyService.start() + } + + Schema { + id: schema + + name: "my" + + connectionName: "myConnection" + } + + ColumnLayout { + Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter + + Row { + spacing: 5 + + Label { + text: dbService.name + ":" + } + + Label { + text: dbService.status + } + } + + Row { + spacing: 5 + + Label { + text: historyService.name + ":" + } + + Label { + text: historyService.status + } + } + + Row { + spacing: 5 + + Label { + text: recencyService.name + ":" + } + + Label { + text: recencyService.status + } + } + + Row { + spacing: 5 + + Label { + text: eventService.name + ":" + } + + Label { + text: eventService.status + } + } + + Row { + spacing: 5 + + Button { + text: qsTr("Start DB") + onClicked: dbService.start() + } + + Button { + text: qsTr("Stop DB") + onClicked: dbService.stop() + } + + } + + Row { + spacing: 5 + + Button { + text: qsTr("Start All") + onClicked: { + ServiceManager.start() + } + } + + Button { + text: qsTr("Stop All") + onClicked: { + ServiceManager.stop() + } + } + + Button { + text: qsTr("Start History") + onClicked: historyService.start() + } + + Button { + text: qsTr("Stop History") + onClicked: historyService.stop() + } + + Button { + text: qsTr("Start Recency") + onClicked: recencyService.start() + } + + Button { + text: qsTr("Stop Recency") + onClicked: recencyService.stop() + } + + Button { + text: qsTr("Start Event") + onClicked: eventService.start() + } + + Button { + text: qsTr("Stop Event") + onClicked: eventService.stop() + } + } + + Row { + spacing: 5 + + Button { + text: qsTr("Create schema") + onClicked: schema.create() + } + + Button { + text: qsTr("Drop schema") + onClicked: schema.drop() + } + } + +// Tag { +// id: tag + +// schema: schema + +// name: "testTag" +// } + + Service { + id: eventService + + name: "Event Service" + + EventWriter { + schema: schema + + TagValue { + name: "aa1.bool" + value: dupaCheckbox.checked + } + + TagValue { + name: "fp5.aa" + value: dupaSlider.intValue + 2 + } + + TagValue { + name: "fp5.real" + value: dupaSlider.value + } + + TagValue { + name: "fp6.real" + value: dupaSlider.value + 0.1 + } + } + } + + Service { + id: recencyService + + name: "Recency Service" + + RecencyWriter { + schema: schema +// interval: 10000 + + TagValue { + name: "aa1.bool" + value: dupaCheckbox.checked + } + + TagValue { + name: "fp5.aa" + value: dupaSlider.intValue + 2 + } + + TagValue { + name: "fp5.bb" + value: dupaSlider.intValue + } + + TagValue { + name: "fp5.real" + value: dupaSlider.value + } + } + } + + Service { + id: historyService + + name: "History Service" + + HistoryWriter { + id: history + + schema: schema + interval: 250 + samples: 25 + +// onStopped: { +// console.log("STTTTTTTTTTTTTTTTTOPPPPPPPPPPPPPPPEDDDDDDDD") +// } + +// onStopped: dbService.stop() + +// Component.onCompleted: console.log(values) +// values: [ + TagValue { + name: "fp1.fill" + property bool k: true + value: k + } + + TagValue { + name: "fp2.fill" + value: true + } + + TagValue { + name: "fp4.duspa" + value: dupaSlider.intValue + } + + TagValue { + name: "fp5.aa" + value: dupaSlider.intValue + 2 + } + + TagValue { + name: "aa1.real" + value: dupaSlider.value * 0.5 + 10 + } + + TagValue { + name: "aa2.real" + value: dupaSlider.value + } + + TagValue { + name: "aa1.bool" + value: dupaCheckbox.checked + } + + TagValue { + name: "aa2.bool" + value: dupaCheckbox.checked + } + +// ] + } + } + + RecencyModel { + id: recencyModel + + schema: schema + } + + Button { + text: "Recency Update" + onClicked: recencyModel.requestUpdate() + } + + Button { + text: "Push" + onClicked: history.pushValues() + } + + Button { + text: "Validate schema test" + onClicked: schema.validate() + } + + Slider { + id: dupaSlider + from: 0 + to: 100 + property int intValue: value + } + + CheckBox { + id: dupaCheckbox + } + + Row { + spacing: 5 + + Button { + text: qsTr("Create tag") + onClicked: tag.create() + } + + Button { + text: qsTr("Drop tag") + onClicked: tag.drop() + } + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/DataAcquisition.0/README.md b/extensions/CuteHMI/Examples/DataAcquisition.0/README.md new file mode 100644 index 00000000..9698d040 --- /dev/null +++ b/extensions/CuteHMI/Examples/DataAcquisition.0/README.md @@ -0,0 +1,10 @@ +# Shared Database Example + +To run the example use [cutehmi.view.3](../../../../tools/cutehmi.view.3/) tool. +``` +cutehmi.view.3 --extension="CuteHMI.Examples.SharedDatabase.0" +``` + +\example Main.qml +Here is a complete listing of the example source file. + diff --git a/extensions/CuteHMI/Examples/DataAcquisition.0/doc/project_logo.png b/extensions/CuteHMI/Examples/DataAcquisition.0/doc/project_logo.png new file mode 100644 index 00000000..c5bc24be Binary files /dev/null and b/extensions/CuteHMI/Examples/DataAcquisition.0/doc/project_logo.png differ diff --git a/extensions/CuteHMI/Examples/Modbus/Basic.1/LICENSE b/extensions/CuteHMI/Examples/Modbus/Basic.1/LICENSE new file mode 100644 index 00000000..0a041280 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Basic.1/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/extensions/CuteHMI/Examples/Modbus/Basic.1/LICENSE.C.dslash.inc b/extensions/CuteHMI/Examples/Modbus/Basic.1/LICENSE.C.dslash.inc new file mode 100644 index 00000000..3604b204 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Basic.1/LICENSE.C.dslash.inc @@ -0,0 +1,6 @@ + +//(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Basic.1/LICENSE.C.hash.inc b/extensions/CuteHMI/Examples/Modbus/Basic.1/LICENSE.C.hash.inc new file mode 100644 index 00000000..daa303be --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Basic.1/LICENSE.C.hash.inc @@ -0,0 +1,6 @@ + +#(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +#(c)C: This file is a part of CuteHMI. +#(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +#(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +#(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Basic.1/README.md b/extensions/CuteHMI/Examples/Modbus/Basic.1/README.md new file mode 100644 index 00000000..2168ed84 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Basic.1/README.md @@ -0,0 +1,72 @@ +# Basic Modbus Example + +Baisc Modbus example. Example demonstrates basic usage of QML components provided by [CuteHMI.Modbus.2](../../../Modbus.2/) +extension. + +To run the example use [cutehmi.view.4](../../../../../tools/cutehmi.view.4/) tool. +``` +cutehmi.view.4 CuteHMI.Examples.Modbus.Basic.0 +``` + +Let's make a quick tour over `View.qml` file. + +First thing to notice are CuteHMI imports. + +\snippet View.qml Import statements + +Example uses [CuteHMI.Modbus.2](../../../Modbus.2/) and [CuteHMI.Services.2](../../../Services.2/) extensions. + +Next thing to notice is a configuration of a Modbus server. The server is given an IP address, a port and a slave address. + +\snippet View.qml Configuring a server + +Similarly we configure Modbus client. + +\snippet View.qml Configuring a client + +We want our server to be managed by CuteHMI.Services.ServiceManager, so that we don't need to worry about its connection status. +This is simply done by embedding it inside CuteHMI.Services.Service component. + +\snippet View.qml Setting up server service + +Similarly we want the client to be turned into a service. Outside a service client would not perform polling, handle connection +errors and so on. + +\snippet View.qml Setting up client service + +As the client and the server are configured we can move on to establishing some interaction between them. Let's create a button that +will tell the client to send a request to turn on a coil. + +\snippet View.qml Client set coil button + +Once the button is clicked it will send a request to write coil value at address 10. This may look suspicious on a localhost, but +the whole communication is done over TCP/IP protocol. Now let's reset coil value to off on the server side. + +\snippet View.qml Server reset coil button + +Now let's introduce CuteHMI.Modbus.CoilController. Controllers typically are a better mean of control as they allow for property +binding. + +\snippet View.qml Coil controller + +We assign a device using \a id of of the client. We also set up the same address as used by buttons. We use `onValueChanged` signal +handler to update value of a corresponding switch once the value in the controller changes. The switch itself updates the value of +a controller once the user changes its value. + +\snippet View.qml Switch onCheckedChanged handler + +Value of the coil can be binded to other properties as it is done with `active` property of status indicator. + +\snippet View.qml Status indicator binding + +The same procedure is repeated for a holding register, of course using different set of controls - adequate to holding register 16 +bit integer capacity. + +\snippet View.qml Holding register controls + +Last, but not least. We start the services by calling CuteHMI.Services.ServiceManager.start() slot. + +\snippet View.qml Start services + +\example View.qml +Here is a complete listing of the example source file. diff --git a/extensions/CuteHMI/Examples/Modbus/Basic.1/View.qml b/extensions/CuteHMI/Examples/Modbus/Basic.1/View.qml new file mode 100644 index 00000000..c802ac84 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Basic.1/View.qml @@ -0,0 +1,152 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Controls 2.1 +import QtQuick.Extras 1.4 + +//! [Import statements] +import CuteHMI.Modbus 2.0 +import CuteHMI.Services 2.0 +//! [Import statements] + +/** + %View component. +*/ +Item { + width: 800 + height: 600 + + //! [Setting up server service] + Service { + id: serverService + + name: "TCP Server" + + //! [Configuring a server] + TCPServer { + id: server + + host: "127.0.0.1" + port: 50002 + slaveAddress: 1 + } + //! [Configuring a server] + } + //! [Setting up server service] + + //! [Setting up client service] + Service { + id: clientService + + name: "TCP Client" + + //! [Configuring a client] + TCPClient { + id: client + + host: "127.0.0.1" + port: 50002 + slaveAddress: 1 + } + //! [Configuring a client] + } + //! [Setting up client service] + + Row { + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + + spacing: 10 + + Column { + spacing: 10 + + //! [Client set coil button] + Button { + text: "Client set coil" + onClicked: client.requestWriteCoil(10, true) + } + //! [Client set coil button] + + //! [Server reset coil button] + Button { + text: "Server reset coil" + onClicked: server.requestWriteCoil(10, false) + } + //! [Server reset coil button] + + Switch { + id: coilSwitch + + checked: coilController.value + + //! [Switch onCheckedChanged handler] + onCheckedChanged: coilController.value = checked + //! [Switch onCheckedChanged handler] + + //! [Coil controller] + CoilController { + id: coilController + + device: client + address: 10 + onValueChanged: coilSwitch.checked = value + } + //! [Coil controller] + } + + StatusIndicator { + //! [Status indicator binding] + active: coilController.value + //! [Status indicator binding] + } + } + + Column { + spacing: 10 + + //! [Holding register controls] + Button { + text: "Client set holding register" + onClicked: client.requestWriteHoldingRegister(10, 2020) + } + + Button { + text: "Server reset holding register" + onClicked: server.requestWriteHoldingRegister(10, 0) + } + + SpinBox { + id: holdingRegisterSpinBox + + from: 0 + to: 10000 + value: holdingRegisterController.value + + onValueChanged: holdingRegisterController.value = value + + HoldingRegisterController { + id: holdingRegisterController + + device: client + address: 10 + onValueChanged: holdingRegisterSpinBox.value = value + } + } + + Label { + text: holdingRegisterController.value + } + //! [Holding register controls] + } + } + + //! [Start services] + Component.onCompleted: ServiceManager.start() + //! [Start services] +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Basic.1/doc/project_logo.png b/extensions/CuteHMI/Examples/Modbus/Basic.1/doc/project_logo.png new file mode 100644 index 00000000..c5bc24be Binary files /dev/null and b/extensions/CuteHMI/Examples/Modbus/Basic.1/doc/project_logo.png differ diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Basic.1/project.qbs similarity index 70% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Basic.1/project.qbs index fd3e8aa1..8c0d5e0b 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Basic.1/project.qbs @@ -1,54 +1,42 @@ import qbs import cutehmi Project { - name: "CuteHMI.Symbols.Pipes.1" + name: "CuteHMI.Examples.Modbus.Basic.1" cutehmi.Extension { name: parent.name - friendlyName: "Pipes" - vendor: "CuteHMI" domain: "cutehmi.kde.org" - description: "Pipe drawing components." + friendlyName: "Basic Modbus Example" + + description: "Example demonstrates basic usage of QML components provided by CuteHMI.Modbus.2 extension." files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", + "LICENSE", + "View.qml", "README.md", - "Tee.qml", - "functions.js", ] - Depends { name: "CuteHMI.GUI.1" } - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] Depends { name: "cutehmi.qmldir" } Depends { name: "cutehmi.qmltypes" } - Export { - Depends { name: "CuteHMI.GUI.1" } - } + Depends { name: "cutehmi.view.4" } + + Depends { name: "CuteHMI.Modbus.2" } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/CoilControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/ClientServer.1/CoilControl.qml index fd3e8aa1..5e7dc308 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/CoilControl.qml @@ -1,54 +1,54 @@ -import qbs +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 +import QtQml.Models 2.1 -import cutehmi +import CuteHMI.Modbus 2.0 +import CuteHMI.Services 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +GridLayoutModel { + id: root - cutehmi.Extension { - name: parent.name + property CoilController controller + property alias text: label.text - friendlyName: "Pipes" + Label { + id: label - vendor: "CuteHMI" + Layout.alignment: Qt.AlignCenter - domain: "cutehmi.kde.org" + text: qsTr("Coil") + } + + SpinBox { + id: addressSpinBox - description: "Pipe drawing components." + Layout.alignment: Qt.AlignCenter - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + value: controller.address + editable: true + + onValueChanged: controller.address = value + } - Depends { name: "CuteHMI.GUI.1" } + Switch { + id: valueSpinBox - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + checked: controller.value - Depends { name: "cutehmi.qmldir" } + onCheckedChanged: controller.value = checked - Depends { name: "cutehmi.qmltypes" } + BusyIndicator { + anchors.centerIn: parent - Export { - Depends { name: "CuteHMI.GUI.1" } + running: controller.busy } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/ClientServer.1/DeviceControl.qml b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/DeviceControl.qml new file mode 100644 index 00000000..e4e2191c --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/DeviceControl.qml @@ -0,0 +1,63 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 + +import CuteHMI.Modbus 2.0 +import CuteHMI.Services 2.0 + +ColumnLayout { + id: root + + property AbstractDevice device + property Item configurationItem + + RowLayout { + Label { + text: qsTr("Device state:") + } + + Label { + text: { + switch (device.state) { + case AbstractDevice.OPENING: + return qsTr("Opening") + case AbstractDevice.OPENED: + return qsTr("Opened") + case AbstractDevice.CLOSING: + return qsTr("Closing") + case AbstractDevice.CLOSED: + return qsTr("Closed") + default: + return qsTr("Unrecognized state") + } + } + } + } + + GroupBox { + contentItem: configurationItem + } + + Row { + Layout.alignment: Qt.AlignRight + + spacing: 5 + + Button { + text: qsTr("Open") + onClicked: device.open() + } + + Button { + text: qsTr("Close") + onClicked: device.close() + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/DiscreteInputControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/ClientServer.1/DiscreteInputControl.qml index fd3e8aa1..521215b9 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/DiscreteInputControl.qml @@ -1,54 +1,54 @@ -import qbs +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 +import QtQml.Models 2.1 -import cutehmi +import CuteHMI.Modbus 2.0 +import CuteHMI.Services 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +GridLayoutModel { + id: root - cutehmi.Extension { - name: parent.name + property DiscreteInputController controller + property alias text: label.text - friendlyName: "Pipes" + Label { + id: label - vendor: "CuteHMI" + Layout.alignment: Qt.AlignCenter - domain: "cutehmi.kde.org" + text: qsTr("Discrete input") + } + + SpinBox { + id: addressSpinBox - description: "Pipe drawing components." + Layout.alignment: Qt.AlignCenter - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + value: controller.address + editable: true + + onValueChanged: controller.address = value + } - Depends { name: "CuteHMI.GUI.1" } + Switch { + id: valueSpinBox - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + checked: controller.value - Depends { name: "cutehmi.qmldir" } + onCheckedChanged: controller.value = checked - Depends { name: "cutehmi.qmltypes" } + BusyIndicator { + anchors.centerIn: parent - Export { - Depends { name: "CuteHMI.GUI.1" } + running: controller.busy } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/ClientServer.1/GridLayoutModel.qml b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/GridLayoutModel.qml new file mode 100644 index 00000000..b443b6fe --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/GridLayoutModel.qml @@ -0,0 +1,20 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 +import QtQml.Models 2.1 + +ObjectModel { + property GridLayout layout + + Component.onCompleted: { + for (var i = 0; i < root.count; i++) + layout.children.push(root.get(i)) + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/HoldingRegisterControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/ClientServer.1/HoldingRegisterControl.qml index fd3e8aa1..c1aba3e5 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/HoldingRegisterControl.qml @@ -1,54 +1,54 @@ -import qbs +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 +import QtQml.Models 2.1 -import cutehmi +import CuteHMI.Modbus 2.0 +import CuteHMI.Services 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +GridLayoutModel { + id: root - cutehmi.Extension { - name: parent.name + property HoldingRegisterController controller + property alias text: label.text - friendlyName: "Pipes" + Label { + id: label - vendor: "CuteHMI" + Layout.alignment: Qt.AlignCenter - domain: "cutehmi.kde.org" + text: qsTr("Holding register") + } + + SpinBox { + id: addressSpinBox - description: "Pipe drawing components." + Layout.alignment: Qt.AlignCenter - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + value: controller.address + editable: true + + onValueChanged: controller.address = value + } - Depends { name: "CuteHMI.GUI.1" } + SpinBox { + id: valueSpinBox - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + value: controller.value - Depends { name: "cutehmi.qmldir" } + onValueChanged: controller.value = value - Depends { name: "cutehmi.qmltypes" } + BusyIndicator { + anchors.centerIn: parent - Export { - Depends { name: "CuteHMI.GUI.1" } + running: controller.busy } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/InputRegisterControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/ClientServer.1/InputRegisterControl.qml index fd3e8aa1..04fcc8c8 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/InputRegisterControl.qml @@ -1,54 +1,54 @@ -import qbs +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 +import QtQml.Models 2.1 -import cutehmi +import CuteHMI.Modbus 2.0 +import CuteHMI.Services 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +GridLayoutModel { + id: root - cutehmi.Extension { - name: parent.name + property InputRegisterController controller + property alias text: label.text - friendlyName: "Pipes" + Label { + id: label - vendor: "CuteHMI" + Layout.alignment: Qt.AlignCenter - domain: "cutehmi.kde.org" + text: qsTr("Input register") + } + + SpinBox { + id: addressSpinBox - description: "Pipe drawing components." + Layout.alignment: Qt.AlignCenter - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + value: controller.address + editable: true + + onValueChanged: controller.address = value + } - Depends { name: "CuteHMI.GUI.1" } + SpinBox { + id: valueSpinBox - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + value: controller.value - Depends { name: "cutehmi.qmldir" } + onValueChanged: controller.value = value - Depends { name: "cutehmi.qmltypes" } + BusyIndicator { + anchors.centerIn: parent - Export { - Depends { name: "CuteHMI.GUI.1" } + running: controller.busy } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/ClientServer.1/LICENSE b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/LICENSE new file mode 100644 index 00000000..0a041280 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/extensions/CuteHMI/Examples/Modbus/ClientServer.1/LICENSE.C.dslash.inc b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/LICENSE.C.dslash.inc new file mode 100644 index 00000000..3604b204 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/LICENSE.C.dslash.inc @@ -0,0 +1,6 @@ + +//(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/ClientServer.1/LICENSE.C.hash.inc b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/LICENSE.C.hash.inc new file mode 100644 index 00000000..daa303be --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/LICENSE.C.hash.inc @@ -0,0 +1,6 @@ + +#(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +#(c)C: This file is a part of CuteHMI. +#(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +#(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +#(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/ClientServer.1/README.md b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/README.md new file mode 100644 index 00000000..738d277e --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/README.md @@ -0,0 +1,38 @@ +# Modbus Client and Server Example + +Example allowing one to interact with Modbus client and server over Modbus TCP protocol. + +To run the example use [cutehmi.view.4](../../../../../tools/cutehmi.view.4/) tool. +``` +cutehmi.view.4 CuteHMI.Examples.Modbus.ClientServer.1 +``` + +\example CoilControl.qml +Here is a complete listing of the example source file + +\example DeviceControl.qml +Here is a complete listing of the example source file + +\example DiscreteInputControl.qml +Here is a complete listing of the example source file + +\example GridLayoutModel.qml +Here is a complete listing of the example source file + +\example HoldingRegisterControl.qml +Here is a complete listing of the example source file + +\example InputRegisterControl.qml +Here is a complete listing of the example source file + +\example View.qml +Here is a complete listing of the example source file + +\example ServiceControl.qml +Here is a complete listing of the example source file + +\example TCPClientConfiguration.qml +Here is a complete listing of the example source file + +\example TCPServerConfiguration.qml +Here is a complete listing of the example source file diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/ServiceControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/ClientServer.1/ServiceControl.qml index fd3e8aa1..b56917fd 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/ServiceControl.qml @@ -1,54 +1,42 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Controls 2.5 +import QtQuick.Layouts 1.3 -import cutehmi +import CuteHMI.Modbus 2.0 +import CuteHMI.Services 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +ColumnLayout { + property Service service - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + RowLayout { + Label { + text: qsTr("%1 status:").arg(service.name) + } - Depends { name: "CuteHMI.GUI.1" } + Label { + text: service.status + } + } - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + Row { + Layout.alignment: Qt.AlignRight - Depends { name: "cutehmi.qmldir" } + spacing: 5 - Depends { name: "cutehmi.qmltypes" } + Button { + text: qsTr("Start") + onClicked: service.start() + } - Export { - Depends { name: "CuteHMI.GUI.1" } + Button { + text: qsTr("Stop") + onClicked: service.stop() } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/TCPClientConfiguration.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/ClientServer.1/TCPClientConfiguration.qml index fd3e8aa1..5dbbb39f 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/TCPClientConfiguration.qml @@ -1,54 +1,54 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 -import cutehmi +import CuteHMI.Modbus 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +GridLayout { + columns: 2 - cutehmi.Extension { - name: parent.name + property TCPClient client - friendlyName: "Pipes" + Label { + Layout.alignment: Qt.AlignRight - vendor: "CuteHMI" + text: qsTr("Host:") + } - domain: "cutehmi.kde.org" + TextField { + text: client.host + onEditingFinished: client.host = text + } - description: "Pipe drawing components." + Label { + Layout.alignment: Qt.AlignRight - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + text: qsTr("Port:") + } - Depends { name: "CuteHMI.GUI.1" } + TextField { + text: client.port + onEditingFinished: client.port = text + } - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + Label { + Layout.alignment: Qt.AlignRight - Depends { name: "cutehmi.qmldir" } + text: qsTr("Slave address:") + } - Depends { name: "cutehmi.qmltypes" } + SpinBox { + from: 1 + to: 247 + value: client.slaveAddress + editable: true - Export { - Depends { name: "CuteHMI.GUI.1" } - } + onValueChanged: client.slaveAddress = value } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/ClientServer.1/TCPServerConfiguration.qml b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/TCPServerConfiguration.qml new file mode 100644 index 00000000..baa24025 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/TCPServerConfiguration.qml @@ -0,0 +1,66 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 + +import CuteHMI.Modbus 2.0 + +GridLayout { + columns: 2 + + property TCPServer server + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Host:") + } + + TextField { + text: server.host + onEditingFinished: server.host = text + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Port:") + } + + TextField { + text: server.port + onEditingFinished: server.port = text + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Slave address:") + } + + SpinBox { + from: 1 + to: 247 + value: server.slaveAddress + editable: true + + onValueChanged: server.slaveAddress = value + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Busy:") + } + + Switch { + checked: server.busy + + onCheckedChanged: server.busy = checked + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/ClientServer.1/View.qml b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/View.qml new file mode 100644 index 00000000..a2a7ab86 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/View.qml @@ -0,0 +1,202 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 + +import CuteHMI.Modbus 2.0 +import CuteHMI.Services 2.0 + +Item { + Service { + id: serverService + + name: "TCP Server" + + TCPServer { + id: server + } + } + + Service { + id: clientService + + name: "TCP Client" + + TCPClient { + id: client + } + } + + ColumnLayout { + anchors.centerIn: parent + spacing: 20 + + Label { + text: "Reminder: you may need to change default ports to higher numbers." + } + + RowLayout { + id: serverLayout + + spacing: 20 + + ColumnLayout { + spacing: 20 + + ServiceControl { + service: serverService + } + + DeviceControl { + device: server + configurationItem: TCPServerConfiguration { + server: server + } + } + } + + GridLayout { + id: serverControllersLayout + + rows: 3 + flow: GridLayout.TopToBottom + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Register type:") + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Address:") + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Value:") + } + + CoilControl { + layout: serverControllersLayout + + controller: CoilController { + device: server + } + } + + DiscreteInputControl { + layout: serverControllersLayout + + controller: DiscreteInputController { + device: server + } + } + + HoldingRegisterControl { + layout: serverControllersLayout + + controller: HoldingRegisterController { + device: server + } + } + + InputRegisterControl { + layout: serverControllersLayout + + controller: InputRegisterController { + device: server + } + } + } + } + + RowLayout { + id: clientLayout + + spacing: 20 + + ColumnLayout { + spacing: 20 + + ServiceControl { + service: clientService + } + + DeviceControl { + device: client + configurationItem: TCPClientConfiguration { + client: client + } + } + } + + GridLayout { + id: clientControllersLayout + + rows: 3 + flow: GridLayout.TopToBottom + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Register type:") + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Address:") + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Value:") + } + + CoilControl { + layout: clientControllersLayout + + controller: CoilController { + device: client + } + } + + DiscreteInputControl { + layout: clientControllersLayout + text: qsTr("Discrete input (read-only)") + + controller: DiscreteInputController { + device: client + } + } + + HoldingRegisterControl { + layout: clientControllersLayout + + controller: HoldingRegisterController { + device: client + } + } + + InputRegisterControl { + layout: clientControllersLayout + text: qsTr("Input register (read-only)") + + controller: InputRegisterController { + device: client + } + } + } + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/ClientServer.1/doc/project_logo.png b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/doc/project_logo.png new file mode 100644 index 00000000..c5bc24be Binary files /dev/null and b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/doc/project_logo.png differ diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/project.qbs similarity index 61% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/ClientServer.1/project.qbs index fd3e8aa1..bfd2e9ed 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/ClientServer.1/project.qbs @@ -1,54 +1,51 @@ import qbs import cutehmi Project { - name: "CuteHMI.Symbols.Pipes.1" + name: "CuteHMI.Examples.Modbus.ClientServer.1" cutehmi.Extension { name: parent.name - friendlyName: "Pipes" - vendor: "CuteHMI" domain: "cutehmi.kde.org" - description: "Pipe drawing components." + friendlyName: "Modbus Client and Server Example" + + description: "Example allowing one to interact with Modbus client and server over Modbus TCP protocol." files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } + "CoilControl.qml", + "DeviceControl.qml", + "DiscreteInputControl.qml", + "GridLayoutModel.qml", + "HoldingRegisterControl.qml", + "InputRegisterControl.qml", + "LICENSE", + "View.qml", + "README.md", + "ServiceControl.qml", + "TCPClientConfiguration.qml", + "TCPServerConfiguration.qml", + ] Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] Depends { name: "cutehmi.qmldir" } Depends { name: "cutehmi.qmltypes" } - Export { - Depends { name: "CuteHMI.GUI.1" } - } + Depends { name: "cutehmi.view.4" } + + Depends { name: "CuteHMI.Modbus.2" } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/LICENSE b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/LICENSE new file mode 100644 index 00000000..0a041280 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/LICENSE.C.dslash.inc b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/LICENSE.C.dslash.inc new file mode 100644 index 00000000..3604b204 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/LICENSE.C.dslash.inc @@ -0,0 +1,6 @@ + +//(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/LICENSE.C.hash.inc b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/LICENSE.C.hash.inc new file mode 100644 index 00000000..daa303be --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/LICENSE.C.hash.inc @@ -0,0 +1,6 @@ + +#(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +#(c)C: This file is a part of CuteHMI. +#(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +#(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +#(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/README.md b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/README.md new file mode 100644 index 00000000..20fc22e4 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/README.md @@ -0,0 +1,26 @@ +# Modbus Controller Items + +The purpose of this example is to demonstrate the use of controller items, which are especially useful, when dealing with Qt Creator +"Design" mode. + +Read a documentation on \ref using-qt-creator-in-design-mode.md "Using Qt Creator in Design mode" to see how to set up environment +for this example. + +In this example component \ref Screen.ui.qml "Screen" is intended to be edited in "Design" mode. This should look similar to the +screenshot below. + +![Design mode](doc/design_mode.png) + +As one can observe CuteHMI.Modbus.CoilItem and CuteHMI.Modbus.HoldingRegisterItem are created as child items of respective Qt +Quick controls, which they use as their delegates. Binding is established between controller and specified delegate property. + +The example can be run with [cutehmi.view.4](../../../../../tools/cutehmi.view.4/) tool. +``` +cutehmi.view.4 CuteHMI.Examples.Modbus.ControllerItems.1 +``` + +\example View.qml +Here is a complete listing of the example source file. + +\example Screen.ui.qml +Here is a complete listing of the example source file. diff --git a/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/Screen.ui.qml b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/Screen.ui.qml new file mode 100644 index 00000000..0821c565 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/Screen.ui.qml @@ -0,0 +1,78 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 + +import CuteHMI.Modbus 2.0 + +Item { + Switch { + id: element + x: 10 + y: 10 + text: qsTr("Switch") + + CoilItem { + id: coilItem + device: client + address: 10 + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + } + } + + CheckBox { + id: checkBox + x: 10 + y: 80 + text: qsTr("Check Box") + + CoilItem { + id: coilItem1 + device: client + address: 10 + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + } + } + + Label { + id: label + x: 227 + y: 94 + text: qsTr("Label") + + HoldingRegisterItem { + id: holdingRegisterItem1 + device: client + delegateProperty: "text" + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + address: 10 + } + } + + SpinBox { + id: spinBox + x: 160 + y: 10 + + HoldingRegisterItem { + id: holdingRegisterItem + device: client + address: 10 + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + } + } +} + +/*##^## +Designer { + D{i:0;autoSize:true;height:480;width:640} +} +##^##*/ + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/View.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/ControllerItems.1/View.qml index fd3e8aa1..f00a10e8 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/View.qml @@ -1,54 +1,41 @@ -import qbs +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Controls 2.1 +import QtQuick.Extras 1.4 -import cutehmi +import CuteHMI.Modbus 2.0 +import CuteHMI.Services 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +/** + %View component. +*/ +Item { + width: 640 + height: 480 - cutehmi.Extension { - name: parent.name + Service { + id: clientService - friendlyName: "Pipes" + name: "Dummy Client" - vendor: "CuteHMI" + DummyClient { + id: client - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] - - Depends { name: "cutehmi.qmldir" } - - Depends { name: "cutehmi.qmltypes" } - - Export { - Depends { name: "CuteHMI.GUI.1" } + latency: 250 + connectLatency: 0 + disconnectLatency: 0 } } + + Screen { + anchors.fill: parent + } + + Component.onCompleted: ServiceManager.start() } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/doc/design_mode.png b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/doc/design_mode.png new file mode 100644 index 00000000..e6919985 Binary files /dev/null and b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/doc/design_mode.png differ diff --git a/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/doc/project_logo.png b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/doc/project_logo.png new file mode 100644 index 00000000..c5bc24be Binary files /dev/null and b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/doc/project_logo.png differ diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/project.qbs similarity index 70% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/ControllerItems.1/project.qbs index fd3e8aa1..548e927f 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/ControllerItems.1/project.qbs @@ -1,54 +1,43 @@ import qbs import cutehmi Project { - name: "CuteHMI.Symbols.Pipes.1" + name: "CuteHMI.Examples.Modbus.ControllerItems.1" cutehmi.Extension { name: parent.name - friendlyName: "Pipes" - vendor: "CuteHMI" domain: "cutehmi.kde.org" - description: "Pipe drawing components." + friendlyName: "Modbus Controller Items" + + description: "Example demonstrates the use of controller items, useful when dealing with Qt Creator Design mode." files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", + "LICENSE", + "View.qml", "README.md", - "Tee.qml", - "functions.js", + "Screen.ui.qml", ] - Depends { name: "CuteHMI.GUI.1" } - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] Depends { name: "cutehmi.qmldir" } Depends { name: "cutehmi.qmltypes" } - Export { - Depends { name: "CuteHMI.GUI.1" } - } + Depends { name: "cutehmi.view.4" } + + Depends { name: "CuteHMI.Modbus.2" } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Controllers.1/CoilControl.qml b/extensions/CuteHMI/Examples/Modbus/Controllers.1/CoilControl.qml new file mode 100644 index 00000000..2ca7ebbd --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Controllers.1/CoilControl.qml @@ -0,0 +1,129 @@ +import QtQuick 2.0 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 + +import CuteHMI.Modbus 2.0 + +ColumnLayout { + id: root + + property string title: qsTr("Coil") + + property AbstractDevice device + + property Item delegate + + property alias controller: controller + + CoilController { + id: controller + + device: root.device + address: addressBox.value + readOnWrite: readOnWriteBox.checked + writeDelay: writeDelayBox.value + writeMode: writeModeBox.value + enabled: enabledBox.checked + + onValueUpdated: delegate.checked = value + } + + Connections { + target: delegate + onCheckedChanged: controller.value = delegate.checked + } + + Label { + text: root.title + } + + GroupBox { + GridLayout { + columns: 2 + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Address:") + } + + SpinBox { + id: addressBox + + from: 0 + to: 65536 + editable: true + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Write mode:") + } + + ComboBox { + id: writeModeBox + + textRole: "key" + model: ListModel { + ListElement { key: "Delayed"; value: CoilController.WRITE_DELAYED } + ListElement { key: "Postponed"; value: CoilController.WRITE_POSTPONED } + ListElement { key: "Immediate"; value: CoilController.WRITE_IMMEDIATE } + ListElement { key: "Explicit"; value: CoilController.WRITE_EXPLICIT } + } + + property int value: model.get(currentIndex).value + + onActivated: value = model.get(index).value + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Write delay:") + } + + SpinBox { + id: writeDelayBox + + enabled: controller.writeMode == CoilController.WRITE_DELAYED + + from: 0 + to: 1000 + stepSize: 100 + + value: 500 + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Read on write:") + } + + CheckBox { + id: readOnWriteBox + + checked: true + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Enabled:") + } + + CheckBox { + id: enabledBox + + checked: true + } + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Controllers.1/DeviceControl.qml b/extensions/CuteHMI/Examples/Modbus/Controllers.1/DeviceControl.qml new file mode 100644 index 00000000..e4e2191c --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Controllers.1/DeviceControl.qml @@ -0,0 +1,63 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 + +import CuteHMI.Modbus 2.0 +import CuteHMI.Services 2.0 + +ColumnLayout { + id: root + + property AbstractDevice device + property Item configurationItem + + RowLayout { + Label { + text: qsTr("Device state:") + } + + Label { + text: { + switch (device.state) { + case AbstractDevice.OPENING: + return qsTr("Opening") + case AbstractDevice.OPENED: + return qsTr("Opened") + case AbstractDevice.CLOSING: + return qsTr("Closing") + case AbstractDevice.CLOSED: + return qsTr("Closed") + default: + return qsTr("Unrecognized state") + } + } + } + } + + GroupBox { + contentItem: configurationItem + } + + Row { + Layout.alignment: Qt.AlignRight + + spacing: 5 + + Button { + text: qsTr("Open") + onClicked: device.open() + } + + Button { + text: qsTr("Close") + onClicked: device.close() + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Controllers.1/DeviceLoader.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Controllers.1/DeviceLoader.qml index fd3e8aa1..856eea29 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Controllers.1/DeviceLoader.qml @@ -1,54 +1,44 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.4 -import cutehmi +import CuteHMI.Modbus 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +Control { + padding: 20 + contentItem: ColumnLayout { + spacing: 10 - cutehmi.Extension { - name: parent.name + RowLayout { + Layout.alignment: Qt.AlignLeft - friendlyName: "Pipes" + Label { + text: qsTr("Device type:") + } - vendor: "CuteHMI" + ComboBox { + textRole: "name" - domain: "cutehmi.kde.org" + model: ListModel { + ListElement { name: "DummyClient"; source: "DummyClientComposite.qml"} + } - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] - - Depends { name: "cutehmi.qmldir" } + onActivated: loader.source = model.get(currentIndex).source + } + } - Depends { name: "cutehmi.qmltypes" } + Loader { + id: loader - Export { - Depends { name: "CuteHMI.GUI.1" } + source: "DummyClientComposite.qml" } } + + property alias source: loader.source } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Controllers.1/DummyClientConfiguration.qml b/extensions/CuteHMI/Examples/Modbus/Controllers.1/DummyClientConfiguration.qml new file mode 100644 index 00000000..e29f8cb8 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Controllers.1/DummyClientConfiguration.qml @@ -0,0 +1,63 @@ +import QtQuick 2.0 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 + +import CuteHMI.Modbus 2.0 + +GridLayout { + columns: 2 + + property DummyClient client + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Connect latency:") + } + + SpinBox { + from: 0 + to: 10 + value: client.connectLatency / 1000 + editable: true + + onValueChanged: client.connectLatency = value * 1000 + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Disconnect latency:") + } + + SpinBox { + from: 0 + to: 10 + value: client.disconnectLatency / 1000 + editable: true + + onValueChanged: client.disconnectLatency = value * 1000 + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Latency (requests):") + } + + SpinBox { + from: 0 + to: 10 + value: client.latency / 1000 + editable: true + + onValueChanged: client.latency = value * 1000 + } + +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Controllers.1/HoldingRegisterControl.qml b/extensions/CuteHMI/Examples/Modbus/Controllers.1/HoldingRegisterControl.qml new file mode 100644 index 00000000..e9110a56 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Controllers.1/HoldingRegisterControl.qml @@ -0,0 +1,170 @@ +import QtQuick 2.0 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 + +import CuteHMI.Modbus 2.0 + +ColumnLayout { + id: root + + property string title: qsTr("Holding register") + + property AbstractDevice device + + property Item delegate + + property alias controller: controller + + HoldingRegisterController { + id: controller + + device: root.device + address: addressBox.value + valueScale: valueScaleBox.realValue + encoding: encodingBox.value + readOnWrite: readOnWriteBox.checked + writeDelay: writeDelayBox.value + writeMode: writeModeBox.value + enabled: enabledBox.checked + + onValueUpdated: delegate.value = value + } + + Connections { + target: delegate + onValueChanged: controller.value = delegate.value + } + + Label { + text: root.title + } + + GroupBox { + GridLayout { + columns: 2 + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Address:") + } + + SpinBox { + id: addressBox + + from: 0 + to: 65536 + editable: true + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Value scale:") + } + + SpinBox { + id: valueScaleBox + + from: -3 + to: 3 + + property real realValue: Math.pow(10, value) + + textFromValue: function(value, locale) { + return Number(Math.pow(10, value)).toLocaleString(locale, 'f', -from) + } + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Encoding:") + } + + ComboBox { + id: encodingBox + + textRole: "key" + model: ListModel { + ListElement { key: "16 bit integer"; value: HoldingRegisterController.INT16 } + ListElement { key: "16 bit unsigned integer"; value: HoldingRegisterController.UINT16 } + } + + property int value: model.get(currentIndex).value + + onActivated: value = model.get(index).value + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Write mode:") + } + + ComboBox { + id: writeModeBox + + textRole: "key" + model: ListModel { + ListElement { key: "Delayed"; value: HoldingRegisterController.WRITE_DELAYED } + ListElement { key: "Postponed"; value: HoldingRegisterController.WRITE_POSTPONED } + ListElement { key: "Immediate"; value: HoldingRegisterController.WRITE_IMMEDIATE } + ListElement { key: "Explicit"; value: HoldingRegisterController.WRITE_EXPLICIT } + } + + property int value: model.get(currentIndex).value + + onActivated: value = model.get(index).value + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Write delay:") + } + + SpinBox { + id: writeDelayBox + + enabled: controller.writeMode == HoldingRegisterController.WRITE_DELAYED + + from: 0 + to: 1000 + stepSize: 100 + + value: 500 + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Read on write:") + } + + CheckBox { + id: readOnWriteBox + + checked: true + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Enabled:") + } + + CheckBox { + id: enabledBox + + checked: true + } + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Controllers.1/LICENSE b/extensions/CuteHMI/Examples/Modbus/Controllers.1/LICENSE new file mode 100644 index 00000000..0a041280 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Controllers.1/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/extensions/CuteHMI/Examples/Modbus/Controllers.1/LICENSE.C.dslash.inc b/extensions/CuteHMI/Examples/Modbus/Controllers.1/LICENSE.C.dslash.inc new file mode 100644 index 00000000..3604b204 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Controllers.1/LICENSE.C.dslash.inc @@ -0,0 +1,6 @@ + +//(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Controllers.1/LICENSE.C.hash.inc b/extensions/CuteHMI/Examples/Modbus/Controllers.1/LICENSE.C.hash.inc new file mode 100644 index 00000000..daa303be --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Controllers.1/LICENSE.C.hash.inc @@ -0,0 +1,6 @@ + +#(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +#(c)C: This file is a part of CuteHMI. +#(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +#(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +#(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Controllers.1/README.md b/extensions/CuteHMI/Examples/Modbus/Controllers.1/README.md new file mode 100644 index 00000000..b0a5d37f --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Controllers.1/README.md @@ -0,0 +1,30 @@ +# Modbus Controllers Example + +Example featuring register controllers. Example uses cutehmi::modbus::DummyDevice to simulate latencies and show various properties +of controllers. + +To run the example use [cutehmi.view.4](../../../../../tools/cutehmi.view.4/) tool. +``` +cutehmi.view.4 CuteHMI.Examples.Modbus.Controllers.1 +``` + +\example CoilControl.qml +Here is a complete listing of the example source file. + +\example DeviceControl.qml +Here is a complete listing of the example source file. + +\example DeviceLoader.qml +Here is a complete listing of the example source file. + +\example DummyClientConfiguration.qml +Here is a complete listing of the example source file. + +\example HoldingRegisterControl.qml +Here is a complete listing of the example source file. + +\example View.qml +Here is a complete listing of the example source file. + +\example ServiceControl.qml +Here is a complete listing of the example source file. diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Controllers.1/ServiceControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Controllers.1/ServiceControl.qml index fd3e8aa1..bf74820d 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Controllers.1/ServiceControl.qml @@ -1,54 +1,47 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 -import cutehmi +import CuteHMI.Services 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +RowLayout { + spacing: 20 - cutehmi.Extension { - name: parent.name + property Service service - friendlyName: "Pipes" + ColumnLayout { + GridLayout { + columns: 2 - vendor: "CuteHMI" + Label { + text: qsTr("%1 status:").arg(service.name) + } - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } + Label { + text: service.status + } + } - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + Row { + Layout.alignment: Qt.AlignRight - Depends { name: "cutehmi.qmldir" } + spacing: 5 - Depends { name: "cutehmi.qmltypes" } + Button { + text: qsTr("Start") + onClicked: service.start() + } - Export { - Depends { name: "CuteHMI.GUI.1" } + Button { + text: qsTr("Stop") + onClicked: service.stop() + } } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Controllers.1/View.qml b/extensions/CuteHMI/Examples/Modbus/Controllers.1/View.qml new file mode 100644 index 00000000..e6c6b238 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Controllers.1/View.qml @@ -0,0 +1,178 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 +import QtQml.Models 2.11 + +import CuteHMI.Modbus 2.0 +import CuteHMI.Services 2.0 + +ColumnLayout { + + Component.onCompleted: ServiceManager.start() + + Service { + id: clientService + + name: "Dummy" + + DummyClient { + id: client + + pollingTimer.interval: 2000 + pollingTimer.subtimer.interval: 1000 + } + } + + RowLayout { + Layout.alignment: Qt.AlignCenter + + spacing: 40 + + ColumnLayout { + spacing: 40 + Layout.alignment: Qt.AlignTop + + ServiceControl { + service: clientService + } + + DeviceControl { + device: client + configurationItem: DummyClientConfiguration { + client: client + } + } + } + + ColumnLayout { + spacing: 40 + + RowLayout { + HoldingRegisterControl { + id: spinBoxControl + + title: qsTr("Holding register spin box") + + delegate: spinBox + device: client + + RowLayout { + Layout.alignment: Qt.AlignRight + + SpinBox { + id: spinBox + + from: -32767 + to: 65535 + editable: true + + BusyIndicator { + anchors.centerIn: parent + running: spinBoxControl.controller.busy + } + } + + RoundButton { + text: "\u2713" + + onClicked: spinBoxControl.controller.writeValue() + } + } + } + + HoldingRegisterControl { + title: qsTr("Holding register text field") + + delegate: textFiled + device: client + + TextField { + id: textFiled + + Layout.alignment: Qt.AlignRight + + text: Number(value).toLocaleString(locale, 'f', 3) + validator: DoubleValidator { + decimals: 3 + } + + property real value + + onAccepted: value = Number.fromLocaleString(locale, text) + + BusyIndicator { + anchors.centerIn: parent + running: parent.parent.controller.busy + } + } + } + + } + + RowLayout { + CoilControl { + id: checkBoxControl + + title: qsTr("Coil check box") + + delegate: checkBox + device: client + + RowLayout { + Layout.alignment: Qt.AlignRight + + CheckBox { + id: checkBox + + BusyIndicator { + anchors.centerIn: parent + running: checkBoxControl.controller.busy + } + } + + RoundButton { + text: "\u2713" + + onClicked: checkBoxControl.controller.writeValue() + } + } + } + + CoilControl { + id: switchControl + + title: qsTr("Coil switch") + + delegate: switchItem + device: client + + RowLayout { + Layout.alignment: Qt.AlignRight + + Switch { + id: switchItem + + BusyIndicator { + anchors.centerIn: parent + running: switchControl.controller.busy + } + } + + RoundButton { + text: "\u2713" + + onClicked: switchControl.controller.writeValue() + } + } + } + } + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Controllers.1/doc/project_logo.png b/extensions/CuteHMI/Examples/Modbus/Controllers.1/doc/project_logo.png new file mode 100644 index 00000000..c5bc24be Binary files /dev/null and b/extensions/CuteHMI/Examples/Modbus/Controllers.1/doc/project_logo.png differ diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Controllers.1/project.qbs similarity index 70% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Controllers.1/project.qbs index fd3e8aa1..deba342c 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Controllers.1/project.qbs @@ -1,54 +1,48 @@ import qbs import cutehmi Project { - name: "CuteHMI.Symbols.Pipes.1" + name: "CuteHMI.Examples.Modbus.Controllers.1" cutehmi.Extension { name: parent.name - friendlyName: "Pipes" - vendor: "CuteHMI" domain: "cutehmi.kde.org" - description: "Pipe drawing components." + friendlyName: "Modbus Controllers Example" + + description: "Example featuring register controllers." files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", + "CoilControl.qml", + "DeviceControl.qml", + "DeviceLoader.qml", + "DummyClientConfiguration.qml", + "HoldingRegisterControl.qml", + "LICENSE", + "View.qml", "README.md", - "Tee.qml", - "functions.js", + "ServiceControl.qml", ] - Depends { name: "CuteHMI.GUI.1" } - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] Depends { name: "cutehmi.qmldir" } Depends { name: "cutehmi.qmltypes" } - Export { - Depends { name: "CuteHMI.GUI.1" } - } + Depends { name: "cutehmi.view.4" } + + Depends { name: "CuteHMI.Modbus.2" } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/DeviceControl.qml b/extensions/CuteHMI/Examples/Modbus/Requests.1/DeviceControl.qml new file mode 100644 index 00000000..25d4e628 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/DeviceControl.qml @@ -0,0 +1,66 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 + +import CuteHMI.Modbus 2.0 +import CuteHMI.Services 2.0 + +ColumnLayout { + id: root + + property AbstractDevice device + property Item configurationItem + property alias text: label.text + + RowLayout { + Label { + id: label + + text: qsTr("Device state:") + } + + Label { + text: { + switch (device.state) { + case AbstractDevice.OPENING: + return qsTr("Opening") + case AbstractDevice.OPENED: + return qsTr("Opened") + case AbstractDevice.CLOSING: + return qsTr("Closing") + case AbstractDevice.CLOSED: + return qsTr("Closed") + default: + return qsTr("Unrecognized state") + } + } + } + } + + GroupBox { + contentItem: configurationItem + } + + Row { + Layout.alignment: Qt.AlignRight + + spacing: 5 + + Button { + text: qsTr("Open") + onClicked: device.open() + } + + Button { + text: qsTr("Close") + onClicked: device.close() + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/DiagnosticsControl.qml b/extensions/CuteHMI/Examples/Modbus/Requests.1/DiagnosticsControl.qml new file mode 100644 index 00000000..275b6de7 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/DiagnosticsControl.qml @@ -0,0 +1,83 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 + +import CuteHMI.Modbus 2.0 + +RowLayout { + property AbstractDevice device + + property int diagnosticsData + + Button { + text: "Diagnostics" + onClicked: device.requestDiagnostics(subfunctionBox.value, parent.diagnosticsData) + } + + Label { + text: qsTr("Subfunction:") + } + + ComboBox { + id: subfunctionBox + + implicitWidth: 250 + textRole: "key" + model: ListModel { + ListElement { key: qsTr("Return query data"); value: AbstractDevice.DIAGNOSTICS_RETURN_QUERY_DATA } + ListElement { key: qsTr("Restart communications option"); value: AbstractDevice.DIAGNOSTICS_RESTART_COMM_OPTION } + ListElement { key: qsTr("Return diagnostics register"); value: AbstractDevice.DIAGNOSTICS_RETURN_DIAGNOSTICS_REGISTER } + ListElement { key: qsTr("Change ASCII input delimiter"); value: AbstractDevice.DIAGNOSTICS_CHANGE_ASCII_INPUT_DELIMITER } + ListElement { key: qsTr("Force listen only mode"); value: AbstractDevice.DIAGNOSTICS_FORCE_LISTEN_ONLY_MODE } + ListElement { key: qsTr("Clear counters and diagnostic register"); value: AbstractDevice.DIAGNOSTICS_CLEAR_COUNTERS_AND_DIAGNOSTICS_REGISTER } + ListElement { key: qsTr("Return bus message count"); value: AbstractDevice.DIAGNOSTICS_RETURN_BUS_MESSAGE_COUNT } + ListElement { key: qsTr("Return bus communication error count"); value: AbstractDevice.DIAGNOSTICS_RETURN_BUS_COMM_ERROR_COUNT } + ListElement { key: qsTr("Return bus exception error count"); value: AbstractDevice.DIAGNOSTICS_RETURN_BUS_EXCEPTION_ERROR_COUNT } + ListElement { key: qsTr("Return slave message count"); value: AbstractDevice.DIAGNOSTICS_RETURN_SLAVE_MESSAGE_COUNT } + ListElement { key: qsTr("Return slave no response count"); value: AbstractDevice.DIAGNOSTICS_RETURN_SLAVE_NO_RESPONSE_COUNT } + ListElement { key: qsTr("Return slave NAK count"); value: AbstractDevice.DIAGNOSTICS_RETURN_SLAVE_NAK_COUNT } + ListElement { key: qsTr("Return slave busy count"); value: AbstractDevice.DIAGNOSTICS_RETURN_SLAVE_BUSY_COUNT } + ListElement { key: qsTr("Return bus character overrun count"); value: AbstractDevice.DIAGNOSTICS_RETURN_BUS_CHARACTER_OVERRUN_COUNT } + ListElement { key: qsTr("Return IOP overrun count"); value: AbstractDevice.DIAGNOSTICS_RETURN_IOP_OVERRUN_COUNT } + ListElement { key: qsTr("Clear overrun counter and flag"); value: AbstractDevice.DIAGNOSTICS_CLEAR_OVERRUN_COUNTER_AND_FLAG } + ListElement { key: qsTr("Get/Clear modbus plus statistics"); value: AbstractDevice.DIAGNOSTICS_GET_CLEAR_MODBUS_PLUS_STATISTICS } + } + + property int value: model.get(currentIndex).value + + onActivated: value = model.get(index).value + } + + Label { + text: qsTr("Data:") + } + + TextField { + text: parent.diagnosticsData + validator: IntValidator { + bottom: 0 + top: 65535 + } + + onAccepted: parent.diagnosticsData = Number.fromLocaleString(locale, text) + } + + Label { + text: qsTr("Data (hex):") + } + + TextField { + text: "0x" + parent.diagnosticsData.toString(16) + validator: RegExpValidator { + regExp: /0x[0-9A-Fa-f]{1,4}/ + } + + onAccepted: parent.diagnosticsData = parseInt(text) + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/FetchCommEventCounterControl.qml b/extensions/CuteHMI/Examples/Modbus/Requests.1/FetchCommEventCounterControl.qml new file mode 100644 index 00000000..2315c62b --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/FetchCommEventCounterControl.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 + +import CuteHMI.Modbus 2.0 + +RowLayout { + property AbstractDevice device + + Button { + text: "Fetch comm event counter" + onClicked: device.requestFetchCommEventCounter() + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/FetchCommEventLogControl.qml b/extensions/CuteHMI/Examples/Modbus/Requests.1/FetchCommEventLogControl.qml new file mode 100644 index 00000000..3840da12 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/FetchCommEventLogControl.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 + +import CuteHMI.Modbus 2.0 + +RowLayout { + property AbstractDevice device + + Button { + text: "Fetch comm event log" + onClicked: device.requestFetchCommEventLog() + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/LICENSE b/extensions/CuteHMI/Examples/Modbus/Requests.1/LICENSE new file mode 100644 index 00000000..0a041280 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/LICENSE.C.dslash.inc b/extensions/CuteHMI/Examples/Modbus/Requests.1/LICENSE.C.dslash.inc new file mode 100644 index 00000000..3604b204 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/LICENSE.C.dslash.inc @@ -0,0 +1,6 @@ + +//(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/LICENSE.C.hash.inc b/extensions/CuteHMI/Examples/Modbus/Requests.1/LICENSE.C.hash.inc new file mode 100644 index 00000000..daa303be --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/LICENSE.C.hash.inc @@ -0,0 +1,6 @@ + +#(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +#(c)C: This file is a part of CuteHMI. +#(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +#(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +#(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/MaskWrite4xRegisterControl.qml b/extensions/CuteHMI/Examples/Modbus/Requests.1/MaskWrite4xRegisterControl.qml new file mode 100644 index 00000000..7c3ce737 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/MaskWrite4xRegisterControl.qml @@ -0,0 +1,61 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 + +import CuteHMI.Modbus 2.0 + +RowLayout { + property AbstractDevice device + + property int andMask: 0 + property int orMask: 0 + + Button { + text: "Mask write 4X register" + onClicked: device.requestMaskWriteHoldingRegister(addressBox.value, parent.andMask, parent.orMask) + } + + Label { + text: qsTr("Address:") + } + + SpinBox { + id: addressBox + + editable: true + from: 0 + to: 65535 + } + + Label { + text: qsTr("And mask (hex):") + } + + TextField { + text: "0x" + parent.andMask.toString(16) + validator: RegExpValidator { + regExp: /0x[0-9A-Fa-f]{1,4}/ + } + + onAccepted: parent.andMask = parseInt(text) + } + + Label { + text: qsTr("Or mask (hex):") + } + + TextField { + text: "0x" + parent.orMask.toString(16) + validator: RegExpValidator { + regExp: /0x[0-9A-Fa-f]{1,4}/ + } + + onAccepted: parent.orMask = parseInt(text) + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/README.md b/extensions/CuteHMI/Examples/Modbus/Requests.1/README.md new file mode 100644 index 00000000..dcf0b53c --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/README.md @@ -0,0 +1,8 @@ +# Modbus Requests Example + +Example demonstrating a variety of Modbus requests. + +To run the example use [cutehmi.view.4](../../../../../tools/cutehmi.view.4/) tool. +``` +cutehmi.view.4 CuteHMI.Examples.Modbus.Requests.1 +``` diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadCoilsControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Requests.1/ReadCoilsControl.qml index fd3e8aa1..10fe8e5c 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadCoilsControl.qml @@ -1,54 +1,45 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 -import cutehmi +import CuteHMI.Modbus 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +RowLayout { + property AbstractDevice device - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." + Button { + text: "Read coils" + onClicked: device.requestReadCoils(addressBox.value, amountBox.value) + } - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + Label { + text: qsTr("Address:") + } - Depends { name: "CuteHMI.GUI.1" } + SpinBox { + id: addressBox - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + editable: true + from: 0 + to: 65535 + } - Depends { name: "cutehmi.qmldir" } + Label { + text: qsTr("Amount:") + } - Depends { name: "cutehmi.qmltypes" } + SpinBox { + id: amountBox - Export { - Depends { name: "CuteHMI.GUI.1" } - } + editable: true + from: 0 + to: device.maxReadCoils + value: 1 } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadDiscreteInputsControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Requests.1/ReadDiscreteInputsControl.qml index fd3e8aa1..7b1471e5 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadDiscreteInputsControl.qml @@ -1,54 +1,45 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 -import cutehmi +import CuteHMI.Modbus 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +RowLayout { + property AbstractDevice device - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." + Button { + text: "Read discrete inputs" + onClicked: device.requestReadDiscreteInputs(addressBox.value, amountBox.value) + } - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + Label { + text: qsTr("Address:") + } - Depends { name: "CuteHMI.GUI.1" } + SpinBox { + id: addressBox - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + editable: true + from: 0 + to: 65535 + } - Depends { name: "cutehmi.qmldir" } + Label { + text: qsTr("Amount:") + } - Depends { name: "cutehmi.qmltypes" } + SpinBox { + id: amountBox - Export { - Depends { name: "CuteHMI.GUI.1" } - } + editable: true + from: 0 + to: device.maxReadDiscreteInputs + value: 1 } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadExceptionStatusControl.qml b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadExceptionStatusControl.qml new file mode 100644 index 00000000..71bf1c8c --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadExceptionStatusControl.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 + +import CuteHMI.Modbus 2.0 + +RowLayout { + property AbstractDevice device + + Button { + text: "Read exception status" + onClicked: device.requestReadExceptionStatus() + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadFIFOQueueControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Requests.1/ReadFIFOQueueControl.qml index fd3e8aa1..a0407898 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadFIFOQueueControl.qml @@ -1,54 +1,32 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 -import cutehmi +import CuteHMI.Modbus 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +RowLayout { + property AbstractDevice device - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + Button { + text: "Read FIFO queue" + onClicked: device.requestReadFIFOQueue(addressBox.value) + } - Depends { name: "cutehmi.qmldir" } + Label { + text: qsTr("FIFO pointer address:") + } - Depends { name: "cutehmi.qmltypes" } + SpinBox { + id: addressBox - Export { - Depends { name: "CuteHMI.GUI.1" } - } + editable: true + from: 0 + to: 65535 } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadFileRecordControl.qml b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadFileRecordControl.qml new file mode 100644 index 00000000..195c1640 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadFileRecordControl.qml @@ -0,0 +1,95 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 + +import CuteHMI.Modbus 2.0 + +RowLayout { + property AbstractDevice device + + Button { + Layout.alignment: Qt.AlignTop + + text: "Read file record" + onClicked: { + var subrequests = [] + for (var i = 0; i < repeater.count; i++) { + var item = repeater.itemAt(i) + subrequests.push(device.readFileRecordSubrequest(item.file, item.address, item.amount)) + } + device.requestReadFileRecord(subrequests) + } + } + + RowLayout { + Layout.alignment: Qt.AlignTop + + Label { + text: qsTr("Subrequests:") + } + + SpinBox { + id: subrequestsBox + + editable: true + from: 1 + to: 10 + } + } + + ColumnLayout { + Repeater { + id: repeater + + model: subrequestsBox.value + + RowLayout { + property int file: fileBox.value + property int address: addressBox.value + property int amount: amountBox.value + + Label { + text: qsTr("File:") + } + + SpinBox { + id: fileBox + + editable: true + from: 1 + to: 65535 + } + + Label { + text: qsTr("Address:") + } + + SpinBox { + id: addressBox + + editable: true + from: 0 + to: 0x270F + } + + Label { + text: qsTr("Amount:") + } + + SpinBox { + id: amountBox + + editable: true + from: 1 + to: 65535 + } + } + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadHoldingRegistersControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Requests.1/ReadHoldingRegistersControl.qml index fd3e8aa1..05dde892 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadHoldingRegistersControl.qml @@ -1,54 +1,45 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 -import cutehmi +import CuteHMI.Modbus 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +RowLayout { + property AbstractDevice device - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." + Button { + text: "Read holding registers" + onClicked: device.requestReadHoldingRegisters(addressBox.value, amountBox.value) + } - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + Label { + text: qsTr("Address:") + } - Depends { name: "CuteHMI.GUI.1" } + SpinBox { + id: addressBox - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + editable: true + from: 0 + to: 65535 + } - Depends { name: "cutehmi.qmldir" } + Label { + text: qsTr("Amount:") + } - Depends { name: "cutehmi.qmltypes" } + SpinBox { + id: amountBox - Export { - Depends { name: "CuteHMI.GUI.1" } - } + editable: true + from: 0 + to: device.maxReadHoldingRegisters + value: 1 } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadInputRegistersControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Requests.1/ReadInputRegistersControl.qml index fd3e8aa1..b4073a9e 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadInputRegistersControl.qml @@ -1,54 +1,47 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 -import cutehmi +import CuteHMI.Modbus 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +RowLayout { + property AbstractDevice device - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." + Button { + text: "Read input registers" + onClicked: device.requestReadInputRegisters(addressBox.value, amountBox.value) + } - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + RowLayout { + Label { + text: qsTr("Address:") + } - Depends { name: "CuteHMI.GUI.1" } + SpinBox { + id: addressBox - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + editable: true + from: 0 + to: 65535 + } - Depends { name: "cutehmi.qmldir" } + Label { + text: qsTr("Amount:") + } - Depends { name: "cutehmi.qmltypes" } + SpinBox { + id: amountBox - Export { - Depends { name: "CuteHMI.GUI.1" } + editable: true + from: 0 + to: device.maxReadInputRegisters + value: 1 } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadWriteMultipleHoldingRegistersControl.qml b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadWriteMultipleHoldingRegistersControl.qml new file mode 100644 index 00000000..5650c428 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReadWriteMultipleHoldingRegistersControl.qml @@ -0,0 +1,91 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 + +import CuteHMI.Modbus 2.0 + +RowLayout { + property AbstractDevice device + + Button { + text: "Read/write multiple holding registers" + onClicked: { + var values = [] + for (var i = 0; i < repeater.count; i++) + values.push(repeater.itemAt(i).value) + device.requestReadWriteMultipleHoldingRegisters(readAddressBox.value, readAmountBox.value, writeAddressBox.value, values) + } + } + + Label { + text: qsTr("Read address:") + } + + SpinBox { + id: readAddressBox + + editable: true + from: 0 + to: 65535 + } + + Label { + text: qsTr("Read amount:") + } + + SpinBox { + id: readAmountBox + + editable: true + from: 0 + to: device.maxReadHoldingRegisters + value: 1 + } + + Label { + text: qsTr("Write address:") + } + + SpinBox { + id: writeAddressBox + + editable: true + from: 0 + to: 65535 + } + + Label { + text: qsTr("Write amount:") + } + + SpinBox { + id: writeAmountBox + + editable: true + from: 0 + to: device.maxWriteHoldingRegisters + value: 1 + } + + Label { + text: qsTr("Values:") + } + + Repeater { + id: repeater + + model: writeAmountBox.value + + SpinBox { + editable: true + from: 0 + to: 65535 + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/ReportSlaveIdControl.qml b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReportSlaveIdControl.qml new file mode 100644 index 00000000..13a7d4f5 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/ReportSlaveIdControl.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 + +import CuteHMI.Modbus 2.0 + +RowLayout { + property AbstractDevice device + + Button { + text: "Report slave id" + onClicked: device.requestReportSlaveId() + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Requests.1/TCPClientConfiguration.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Requests.1/TCPClientConfiguration.qml index fd3e8aa1..5dbbb39f 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/TCPClientConfiguration.qml @@ -1,54 +1,54 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 -import cutehmi +import CuteHMI.Modbus 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +GridLayout { + columns: 2 - cutehmi.Extension { - name: parent.name + property TCPClient client - friendlyName: "Pipes" + Label { + Layout.alignment: Qt.AlignRight - vendor: "CuteHMI" + text: qsTr("Host:") + } - domain: "cutehmi.kde.org" + TextField { + text: client.host + onEditingFinished: client.host = text + } - description: "Pipe drawing components." + Label { + Layout.alignment: Qt.AlignRight - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + text: qsTr("Port:") + } - Depends { name: "CuteHMI.GUI.1" } + TextField { + text: client.port + onEditingFinished: client.port = text + } - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + Label { + Layout.alignment: Qt.AlignRight - Depends { name: "cutehmi.qmldir" } + text: qsTr("Slave address:") + } - Depends { name: "cutehmi.qmltypes" } + SpinBox { + from: 1 + to: 247 + value: client.slaveAddress + editable: true - Export { - Depends { name: "CuteHMI.GUI.1" } - } + onValueChanged: client.slaveAddress = value } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/TCPServerConfiguration.qml b/extensions/CuteHMI/Examples/Modbus/Requests.1/TCPServerConfiguration.qml new file mode 100644 index 00000000..baa24025 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/TCPServerConfiguration.qml @@ -0,0 +1,66 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 + +import CuteHMI.Modbus 2.0 + +GridLayout { + columns: 2 + + property TCPServer server + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Host:") + } + + TextField { + text: server.host + onEditingFinished: server.host = text + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Port:") + } + + TextField { + text: server.port + onEditingFinished: server.port = text + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Slave address:") + } + + SpinBox { + from: 1 + to: 247 + value: server.slaveAddress + editable: true + + onValueChanged: server.slaveAddress = value + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Busy:") + } + + Switch { + checked: server.busy + + onCheckedChanged: server.busy = checked + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/View.qml b/extensions/CuteHMI/Examples/Modbus/Requests.1/View.qml new file mode 100644 index 00000000..826085ba --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/View.qml @@ -0,0 +1,193 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 + +import CuteHMI.Modbus 2.0 +import CuteHMI.Services 2.0 + +Item { + anchors.fill: parent + + TCPServer { + id: server + } + + TCPClient { + id: client + } + + RowLayout { + anchors.fill: parent + anchors.margins: 40 + spacing: 40 + + + ColumnLayout { + spacing: 40 + + DeviceControl { + text: qsTr("Server state:") + device: server + configurationItem: TCPServerConfiguration { + server: server + } + } + + DeviceControl { + text: qsTr("Client state:") + device: client + configurationItem: TCPClientConfiguration { + client: client + } + } + } + + ColumnLayout { + Layout.fillHeight: true + Layout.fillWidth: true + + ComboBox { + id: deviceBox + + model: ["Server", "Client"] + currentIndex: 1 + + property AbstractDevice device: client + + onActivated: { + if (currentText === "Server") + device = server + else if (currentText === "Client") + device = client + } + + onDeviceChanged: { + device.requestCompleted.disconnect(deviceRquestReplyArea.onRequestCompleted) + device.requestCompleted.connect(deviceRquestReplyArea.onRequestCompleted) + } + } + + Flickable { + Layout.fillHeight: true + Layout.fillWidth: true + + ScrollBar.vertical: ScrollBar {} + ScrollBar.horizontal: ScrollBar {} + + clip: true + contentWidth: requestsLayout.implicitWidth + contentHeight: requestsLayout.implicitHeight + + ColumnLayout { + id: requestsLayout + + ReadCoilsControl { + device: deviceBox.device + } + + WriteCoilControl { + device: deviceBox.device + } + + WriteMultipleCoilsControl { + device: deviceBox.device + } + + ReadDiscreteInputsControl { + device: deviceBox.device + } + + WriteDiscreteInputControl { + device: deviceBox.device + } + + WriteMultipleDiscreteInputsControl { + device: deviceBox.device + } + + ReadHoldingRegistersControl { + device: deviceBox.device + } + + WriteHoldingRegisterControl { + device: deviceBox.device + } + + WriteMultipleHoldingRegistersControl { + device: deviceBox.device + } + + ReadInputRegistersControl { + device: deviceBox.device + } + + WriteInputRegisterControl { + device: deviceBox.device + } + + WriteMultipleInputRegistersControl { + device: deviceBox.device + } + + ReadExceptionStatusControl { + device: deviceBox.device + } + + DiagnosticsControl { + device: deviceBox.device + } + + ReportSlaveIdControl { + device: deviceBox.device + } + + FetchCommEventCounterControl { + device: deviceBox.device + } + + FetchCommEventLogControl { + device: deviceBox.device + } + + ReadFIFOQueueControl { + device: deviceBox.device + } + + MaskWrite4xRegisterControl { + device: deviceBox.device + } + + ReadWriteMultipleHoldingRegistersControl { + device: deviceBox.device + } + + ReadFileRecordControl { + device: deviceBox.device + } + + WriteFileRecordControl { + device: deviceBox.device + } + } + } + + TextArea { + id: deviceRquestReplyArea + + readOnly: true + + function onRequestCompleted(request, reply) { + text = "Request: " + JSON.stringify(request) + "\nReply: " + JSON.stringify(reply) + } + } + + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteCoilControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Requests.1/WriteCoilControl.qml index fd3e8aa1..00640270 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteCoilControl.qml @@ -1,54 +1,40 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 -import cutehmi +import CuteHMI.Modbus 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +RowLayout { + property AbstractDevice device - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + Button { + text: "Write coil" + onClicked: device.requestWriteCoil(addressBox.value, valueBox.checked) + } - Depends { name: "CuteHMI.GUI.1" } + Label { + text: qsTr("Address:") + } - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + SpinBox { + id: addressBox - Depends { name: "cutehmi.qmldir" } + editable: true + from: 0 + to: 65535 + } - Depends { name: "cutehmi.qmltypes" } + Label { + text: qsTr("Value:") + } - Export { - Depends { name: "CuteHMI.GUI.1" } - } + CheckBox { + id: valueBox } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteDiscreteInputControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Requests.1/WriteDiscreteInputControl.qml index fd3e8aa1..80f64657 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteDiscreteInputControl.qml @@ -1,54 +1,40 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 -import cutehmi +import CuteHMI.Modbus 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +RowLayout { + property AbstractDevice device - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + Button { + text: "Write discrete input" + onClicked: device.requestWriteDiscreteInput(addressBox.value, valueBox.checked) + } - Depends { name: "CuteHMI.GUI.1" } + Label { + text: qsTr("Address:") + } - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + SpinBox { + id: addressBox - Depends { name: "cutehmi.qmldir" } + editable: true + from: 0 + to: 65535 + } - Depends { name: "cutehmi.qmltypes" } + Label { + text: qsTr("Value:") + } - Export { - Depends { name: "CuteHMI.GUI.1" } - } + CheckBox { + id: valueBox } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteFileRecordControl.qml b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteFileRecordControl.qml new file mode 100644 index 00000000..7fe02228 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteFileRecordControl.qml @@ -0,0 +1,116 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 + +import CuteHMI.Modbus 2.0 + +RowLayout { + property AbstractDevice device + + Button { + Layout.alignment: Qt.AlignTop + + text: "Write file record" + onClicked: { + var subrequests = [] + for (var i = 0; i < repeater.count; i++) { + var item = repeater.itemAt(i) + var values = [] + for (var j = 0; j < item.valuesRepeater.count; j++) + values.push(item.valuesRepeater.itemAt(j).value) + subrequests.push(device.writeFileRecordSubrequest(item.file, item.address, values)) + } + device.requestWriteFileRecord(subrequests) + } + } + + RowLayout { + Layout.alignment: Qt.AlignTop + + Label { + text: qsTr("Subrequests:") + } + + SpinBox { + id: subrequestsBox + + editable: true + from: 1 + to: 10 + } + } + + ColumnLayout { + Repeater { + id: repeater + + model: subrequestsBox.value + + RowLayout { + property int file: fileBox.value + property int address: addressBox.value + property int amount: amountBox.value + property var valuesRepeater: valuesRepeater + + Label { + text: qsTr("File:") + } + + SpinBox { + id: fileBox + + editable: true + from: 1 + to: 65535 + } + + Label { + text: qsTr("Address:") + } + + SpinBox { + id: addressBox + + editable: true + from: 0 + to: 0x270F + } + + Label { + text: qsTr("Amount:") + } + + SpinBox { + id: amountBox + + editable: true + from: 1 + to: 65535 + } + + Label { + text: qsTr("Values:") + } + + Repeater { + id: valuesRepeater + + model: amountBox.value + + SpinBox { + editable: true + from: 0 + to: 65535 + } + } + } + } + } + +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteHoldingRegisterControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Requests.1/WriteHoldingRegisterControl.qml index fd3e8aa1..74531914 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteHoldingRegisterControl.qml @@ -1,54 +1,44 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 -import cutehmi +import CuteHMI.Modbus 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +RowLayout { + property AbstractDevice device - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." + Button { + text: "Write holding register" + onClicked: device.requestWriteHoldingRegister(addressBox.value, valueBox.value) + } - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + Label { + text: qsTr("Address:") + } - Depends { name: "CuteHMI.GUI.1" } + SpinBox { + id: addressBox - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + editable: true + from: 0 + to: 65535 + } - Depends { name: "cutehmi.qmldir" } + Label { + text: qsTr("Value:") + } - Depends { name: "cutehmi.qmltypes" } + SpinBox { + id: valueBox - Export { - Depends { name: "CuteHMI.GUI.1" } - } + editable: true + from: 0 + to: 65535 } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteInputRegisterControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Requests.1/WriteInputRegisterControl.qml index fd3e8aa1..7741b1e7 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteInputRegisterControl.qml @@ -1,54 +1,44 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 -import cutehmi +import CuteHMI.Modbus 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +RowLayout { + property AbstractDevice device - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." + Button { + text: "Write input register" + onClicked: device.requestWriteInputRegister(addressBox.value, valueBox.value) + } - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + Label { + text: qsTr("Address:") + } - Depends { name: "CuteHMI.GUI.1" } + SpinBox { + id: addressBox - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + editable: true + from: 0 + to: 65535 + } - Depends { name: "cutehmi.qmldir" } + Label { + text: qsTr("Value:") + } - Depends { name: "cutehmi.qmltypes" } + SpinBox { + id: valueBox - Export { - Depends { name: "CuteHMI.GUI.1" } - } + editable: true + from: 0 + to: 65535 } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteMultipleCoilsControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Requests.1/WriteMultipleCoilsControl.qml index fd3e8aa1..a90a4131 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteMultipleCoilsControl.qml @@ -1,54 +1,63 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 -import cutehmi +import CuteHMI.Modbus 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +RowLayout { + property AbstractDevice device - cutehmi.Extension { - name: parent.name + Button { + text: "Write multiple coils" - friendlyName: "Pipes" + onClicked: { + var values = [] + for (var i = 0; i < repeater.count; i++) + values.push(repeater.itemAt(i).checked) + device.requestWriteMultipleCoils(addressBox.value, values) + } + } - vendor: "CuteHMI" + Label { + text: qsTr("Address:") + } - domain: "cutehmi.kde.org" + SpinBox { + id: addressBox - description: "Pipe drawing components." + editable: true + from: 0 + to: 65535 + } - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + Label { + text: qsTr("Amount:") + } - Depends { name: "CuteHMI.GUI.1" } + SpinBox { + id: amountBox - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + editable: true + from: 0 + to: device.maxWriteCoils + value: 1 + } + + Label { + text: qsTr("Values:") + } - Depends { name: "cutehmi.qmldir" } + Repeater { + id: repeater - Depends { name: "cutehmi.qmltypes" } + model: amountBox.value - Export { - Depends { name: "CuteHMI.GUI.1" } - } + CheckBox {} } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteMultipleDiscreteInputsControl.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Modbus/Requests.1/WriteMultipleDiscreteInputsControl.qml index fd3e8aa1..20a3a5bb 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteMultipleDiscreteInputsControl.qml @@ -1,54 +1,63 @@ -import qbs +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 -import cutehmi +import CuteHMI.Modbus 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +RowLayout { + property AbstractDevice device - cutehmi.Extension { - name: parent.name + Button { + text: "Write multiple discrete inputs" - friendlyName: "Pipes" + onClicked: { + var values = [] + for (var i = 0; i < repeater.count; i++) + values.push(repeater.itemAt(i).checked) + device.requestWriteMultipleDiscreteInputs(addressBox.value, values) + } + } - vendor: "CuteHMI" + Label { + text: qsTr("Address:") + } - domain: "cutehmi.kde.org" + SpinBox { + id: addressBox - description: "Pipe drawing components." + editable: true + from: 0 + to: 65535 + } - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + Label { + text: qsTr("Amount:") + } - Depends { name: "CuteHMI.GUI.1" } + SpinBox { + id: amountBox - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + editable: true + from: 0 + to: device.maxWriteDiscreteInputs + value: 1 + } + + Label { + text: qsTr("Values:") + } - Depends { name: "cutehmi.qmldir" } + Repeater { + id: repeater - Depends { name: "cutehmi.qmltypes" } + model: amountBox.value - Export { - Depends { name: "CuteHMI.GUI.1" } - } + CheckBox {} } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteMultipleHoldingRegistersControl.qml b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteMultipleHoldingRegistersControl.qml new file mode 100644 index 00000000..a4567d78 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteMultipleHoldingRegistersControl.qml @@ -0,0 +1,69 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 + +import CuteHMI.Modbus 2.0 + +RowLayout { + property AbstractDevice device + + Button { + text: "Write multiple holding registers" + + onClicked: { + var values = [] + for (var i = 0; i < repeater.count; i++) + values.push(repeater.itemAt(i).value) + device.requestWriteMultipleHoldingRegisters(addressBox.value, values) + } + } + + RowLayout { + Label { + text: qsTr("Address:") + } + + SpinBox { + id: addressBox + + editable: true + from: 0 + to: 65535 + } + + Label { + text: qsTr("Amount:") + } + + SpinBox { + id: amountBox + + editable: true + from: 0 + to: device.maxWriteHoldingRegisters + value: 1 + } + + Label { + text: qsTr("Values:") + } + + Repeater { + id: repeater + + model: amountBox.value + + SpinBox { + editable: true + from: 0 + to: 65535 + } + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteMultipleInputRegistersControl.qml b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteMultipleInputRegistersControl.qml new file mode 100644 index 00000000..8c08fa78 --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/WriteMultipleInputRegistersControl.qml @@ -0,0 +1,70 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 + +import CuteHMI.Modbus 2.0 + +RowLayout { + property AbstractDevice device + + Button { + text: "Write multiple input registers" + + onClicked: { + var values = [] + for (var i = 0; i < repeater.count; i++) + values.push(repeater.itemAt(i).value) + device.requestWriteMultipleInputRegisters(addressBox.value, values) + } + } + + RowLayout { + Label { + text: qsTr("Address:") + } + + SpinBox { + id: addressBox + + editable: true + from: 0 + to: 65535 + } + + Label { + text: qsTr("Amount:") + } + + SpinBox { + id: amountBox + + editable: true + from: 0 + to: device.maxWriteInputRegisters + value: 1 + } + + Label { + text: qsTr("Values:") + } + + Repeater { + id: repeater + + model: amountBox.value + + SpinBox { + editable: true + from: 0 + to: 65535 + } + } + } + +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/doc/project_logo.png b/extensions/CuteHMI/Examples/Modbus/Requests.1/doc/project_logo.png new file mode 100644 index 00000000..c5bc24be Binary files /dev/null and b/extensions/CuteHMI/Examples/Modbus/Requests.1/doc/project_logo.png differ diff --git a/extensions/CuteHMI/Examples/Modbus/Requests.1/project.qbs b/extensions/CuteHMI/Examples/Modbus/Requests.1/project.qbs new file mode 100644 index 00000000..e4fd947b --- /dev/null +++ b/extensions/CuteHMI/Examples/Modbus/Requests.1/project.qbs @@ -0,0 +1,67 @@ +import qbs + +import cutehmi + +Project { + name: "CuteHMI.Examples.Modbus.Requests.1" + + cutehmi.Extension { + name: parent.name + + vendor: "CuteHMI" + + domain: "cutehmi.kde.org" + + friendlyName: "Modbus Requests Example" + + description: "Example demonstrating a variety of Modbus requests." + + files: [ + "DeviceControl.qml", + "DiagnosticsControl.qml", + "FetchCommEventCounterControl.qml", + "FetchCommEventLogControl.qml", + "LICENSE", + "View.qml", + "MaskWrite4xRegisterControl.qml", + "README.md", + "ReadCoilsControl.qml", + "ReadDiscreteInputsControl.qml", + "ReadExceptionStatusControl.qml", + "ReadFIFOQueueControl.qml", + "ReadFileRecordControl.qml", + "ReadHoldingRegistersControl.qml", + "ReadInputRegistersControl.qml", + "ReadWriteMultipleHoldingRegistersControl.qml", + "ReportSlaveIdControl.qml", + "TCPClientConfiguration.qml", + "TCPServerConfiguration.qml", + "WriteCoilControl.qml", + "WriteDiscreteInputControl.qml", + "WriteFileRecordControl.qml", + "WriteHoldingRegisterControl.qml", + "WriteInputRegisterControl.qml", + "WriteMultipleCoilsControl.qml", + "WriteMultipleDiscreteInputsControl.qml", + "WriteMultipleHoldingRegistersControl.qml", + "WriteMultipleInputRegistersControl.qml", + ] + + Depends { name: "cutehmi.doxygen" } + cutehmi.doxygen.useDoxyqml: true + + Depends { name: "cutehmi.qmldir" } + + Depends { name: "cutehmi.qmltypes" } + + Depends { name: "cutehmi.view.4" } + + Depends { name: "CuteHMI.Modbus.2" } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/SharedDatabase.1/LICENSE b/extensions/CuteHMI/Examples/SharedDatabase.1/LICENSE new file mode 100644 index 00000000..0a041280 --- /dev/null +++ b/extensions/CuteHMI/Examples/SharedDatabase.1/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/extensions/CuteHMI/Examples/SharedDatabase.1/LICENSE.C.dslash.inc b/extensions/CuteHMI/Examples/SharedDatabase.1/LICENSE.C.dslash.inc new file mode 100644 index 00000000..3604b204 --- /dev/null +++ b/extensions/CuteHMI/Examples/SharedDatabase.1/LICENSE.C.dslash.inc @@ -0,0 +1,6 @@ + +//(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/SharedDatabase.1/LICENSE.C.hash.inc b/extensions/CuteHMI/Examples/SharedDatabase.1/LICENSE.C.hash.inc new file mode 100644 index 00000000..daa303be --- /dev/null +++ b/extensions/CuteHMI/Examples/SharedDatabase.1/LICENSE.C.hash.inc @@ -0,0 +1,6 @@ + +#(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +#(c)C: This file is a part of CuteHMI. +#(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +#(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +#(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/SharedDatabase.1/README.md b/extensions/CuteHMI/Examples/SharedDatabase.1/README.md new file mode 100644 index 00000000..0ad92c85 --- /dev/null +++ b/extensions/CuteHMI/Examples/SharedDatabase.1/README.md @@ -0,0 +1,9 @@ +# Shared Database Example + +To run the example use [cutehmi.view.4](../../../../tools/cutehmi.view.4/) tool. +``` +cutehmi.view.4 CuteHMI.Examples.SharedDatabase.1 +``` + +\example View.qml +Here is a complete listing of the example source file. diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/SharedDatabase.1/View.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/SharedDatabase.1/View.qml index fd3e8aa1..7bb82293 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/SharedDatabase.1/View.qml @@ -1,54 +1,63 @@ -import qbs - -import cutehmi - -Project { - name: "CuteHMI.Symbols.Pipes.1" - - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 + +import CuteHMI.Services 2.0 +import CuteHMI.SharedDatabase 0.0 + +ColumnLayout { + anchors.fill: parent + + Service { + id: service + + name: "Database Service" + + Database { + connectionName: "exampleConnection" + type: "QSQLITE" + host: "localhost" + port: 5432 + name: "test" + user: "bill" + password: "windows" + } + } - description: "Pipe drawing components." + ColumnLayout { + Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + Row { + spacing: 5 - Depends { name: "CuteHMI.GUI.1" } + Label { + text: service.name + ":" + } - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + Label { + text: service.status + } + } - Depends { name: "cutehmi.qmldir" } + Row { + spacing: 5 - Depends { name: "cutehmi.qmltypes" } + Button { + text: qsTr("Start") + onClicked: service.start() + } - Export { - Depends { name: "CuteHMI.GUI.1" } + Button { + text: qsTr("Stop") + onClicked: service.stop() + } } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/SharedDatabase.1/doc/project_logo.png b/extensions/CuteHMI/Examples/SharedDatabase.1/doc/project_logo.png new file mode 100644 index 00000000..c5bc24be Binary files /dev/null and b/extensions/CuteHMI/Examples/SharedDatabase.1/doc/project_logo.png differ diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/SharedDatabase.1/project.qbs similarity index 70% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/SharedDatabase.1/project.qbs index fd3e8aa1..9597120f 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/SharedDatabase.1/project.qbs @@ -1,54 +1,42 @@ import qbs import cutehmi Project { - name: "CuteHMI.Symbols.Pipes.1" + name: "CuteHMI.Examples.SharedDatabase.1" cutehmi.Extension { name: parent.name - friendlyName: "Pipes" - vendor: "CuteHMI" domain: "cutehmi.kde.org" - description: "Pipe drawing components." + friendlyName: "Shared Database Example" + + description: "Example showing how to establish database connection with CuteHMI.SharedDatabase extension." files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", + "LICENSE", "README.md", - "Tee.qml", - "functions.js", + "View.qml", ] - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + Depends { name: "CuteHMI.SharedDatabase.0" } Depends { name: "cutehmi.qmldir" } Depends { name: "cutehmi.qmltypes" } - Export { - Depends { name: "CuteHMI.GUI.1" } - } + Depends { name: "cutehmi.view.4" } + + Depends { name: "cutehmi.doxygen" } + cutehmi.doxygen.useDoxyqml: true } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/SimpleView.2/LICENSE b/extensions/CuteHMI/Examples/SimpleView.2/LICENSE new file mode 100644 index 00000000..0a041280 --- /dev/null +++ b/extensions/CuteHMI/Examples/SimpleView.2/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/extensions/CuteHMI/Examples/SimpleView.2/LICENSE.C.dslash.inc b/extensions/CuteHMI/Examples/SimpleView.2/LICENSE.C.dslash.inc new file mode 100644 index 00000000..3604b204 --- /dev/null +++ b/extensions/CuteHMI/Examples/SimpleView.2/LICENSE.C.dslash.inc @@ -0,0 +1,6 @@ + +//(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/SimpleView.2/LICENSE.C.hash.inc b/extensions/CuteHMI/Examples/SimpleView.2/LICENSE.C.hash.inc new file mode 100644 index 00000000..daa303be --- /dev/null +++ b/extensions/CuteHMI/Examples/SimpleView.2/LICENSE.C.hash.inc @@ -0,0 +1,6 @@ + +#(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +#(c)C: This file is a part of CuteHMI. +#(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +#(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +#(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/SimpleView.2/README.md b/extensions/CuteHMI/Examples/SimpleView.2/README.md new file mode 100644 index 00000000..34ca8491 --- /dev/null +++ b/extensions/CuteHMI/Examples/SimpleView.2/README.md @@ -0,0 +1,14 @@ +# Simple View + +Simple example demonstrating how to provide visual indication of device operational status with CuteHMI.GUI components. + +To run the example use [cutehmi.view.4](../../../../tools/cutehmi.view.4/) tool. +``` +cutehmi.view.4 CuteHMI.Examples.SimpleView.2 +``` + +\example View.qml +Here is a complete listing of the example source file. + +\example RectangularElement.qml +Here is a complete listing of the example source file. diff --git a/extensions/CuteHMI/Examples/SimpleView.2/RectangularElement.qml b/extensions/CuteHMI/Examples/SimpleView.2/RectangularElement.qml new file mode 100644 index 00000000..819b4202 --- /dev/null +++ b/extensions/CuteHMI/Examples/SimpleView.2/RectangularElement.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +import CuteHMI.GUI 1.0 + +Element { + Rectangle { + width: parent.width + height: parent.height + color: parent.color.fill + border.color: parent.color.stroke + border.width: parent.units.strokeWidth + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/SimpleView.2/View.qml b/extensions/CuteHMI/Examples/SimpleView.2/View.qml new file mode 100644 index 00000000..e281533c --- /dev/null +++ b/extensions/CuteHMI/Examples/SimpleView.2/View.qml @@ -0,0 +1,99 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 + +import CuteHMI.GUI 1.0 + +ColumnLayout { + anchors.fill: parent + + property real quadrat: Theme.units.quadrat + + Column { + Layout.alignment: Qt.AlignCenter + + Slider { + id: slider + + from: 0 + to: 100 + } + + Item { + width: quadrat * 2.5 + height: quadrat * 3.75 + + PropItem { + id: sidePropNumberDisplay + + anchors.horizontalCenter: parent.horizontalCenter + + leftPadding: quadrat * 0.25 + rightPadding: quadrat * 0.25 + bottomPadding: quadrat * 0.5 + + NumberDisplay { + value: slider.value * 10 + integralWidth: 4 + fractionalWidth: 0 + unit: "kWh" + + warning: value > 500 + alarm: value > 800 + } + } + + RectangularElement { + id: element + + anchors.top: sidePropNumberDisplay.bottom + width: parent.width + height: parent.height - sidePropNumberDisplay.height - propNumberDisplay.height + + active: slider.value > 0 + warning: slider.value > 80 + alarm: slider.value > 90 + + NumberDisplay { + id: numberDisplay + + anchors.centerIn: parent + + value: slider.value + + warning: value > 30 + alarm: value > 70 + } + } + + PropItem { + id: propNumberDisplay + + anchors.top: element.bottom + anchors.horizontalCenter: parent.horizontalCenter + + topPadding: quadrat * 0.25 + + NumberDisplay { + value: slider.value + fractionalWidth: 2 + unit: "Pa" + + warning: value > 60 + alarm: value > 90 + } + } + } + } + + Component.onCompleted: { + Theme.units.quadrat = 80 + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/SimpleView.2/doc/project_logo.png b/extensions/CuteHMI/Examples/SimpleView.2/doc/project_logo.png new file mode 100644 index 00000000..c5bc24be Binary files /dev/null and b/extensions/CuteHMI/Examples/SimpleView.2/doc/project_logo.png differ diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/SimpleView.2/project.qbs similarity index 70% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/SimpleView.2/project.qbs index fd3e8aa1..6e8ddaac 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/SimpleView.2/project.qbs @@ -1,54 +1,41 @@ import qbs import cutehmi Project { - name: "CuteHMI.Symbols.Pipes.1" + name: "CuteHMI.Examples.SimpleView.2" cutehmi.Extension { name: parent.name - friendlyName: "Pipes" - vendor: "CuteHMI" domain: "cutehmi.kde.org" - description: "Pipe drawing components." + friendlyName: "Simple View" + + description: "Simple example demonstrating how to provide visual indication of device operational status with CuteHMI.GUI components." files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", + "LICENSE", "README.md", - "Tee.qml", - "functions.js", + "RectangularElement.qml", + "View.qml", ] - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] - Depends { name: "cutehmi.qmldir" } Depends { name: "cutehmi.qmltypes" } - Export { - Depends { name: "CuteHMI.GUI.1" } - } + Depends { name: "cutehmi.view.4" } + + Depends { name: "cutehmi.doxygen" } + cutehmi.doxygen.useDoxyqml: true } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/AirFilterSettings.qml b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/AirFilterSettings.qml new file mode 100644 index 00000000..d9d0b312 --- /dev/null +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/AirFilterSettings.qml @@ -0,0 +1,69 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.3 + +import CuteHMI.Symbols.HVAC 1.0 + +ElementSettings { + element: filter + + property AirFilter filter + + GroupBox { + title: qsTr("Custom properties") + + Layout.fillWidth: true + + GridLayout { + columns: 2 + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Mirror:") + } + + CheckBox { + checked: filter.mirror + + onCheckedChanged: filter.mirror = checked + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Pockets:") + } + + SpinBox { + from: 1 + to: 10 + value: filter.pockets + + onValueChanged: filter.pockets = value + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Fill:") + } + + Slider { + id: fillSlider + + from: 0 + to: 100 + + onValueChanged: filter.fill = value / 100 + } + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/BasicDiscreteInstrumentSettings.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/BasicDiscreteInstrumentSettings.qml index fd3e8aa1..2827a282 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/BasicDiscreteInstrumentSettings.qml @@ -1,54 +1,38 @@ -import qbs +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.3 -import cutehmi +import CuteHMI.Symbols.HVAC 1.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +ElementSettings { + element: instrument - cutehmi.Extension { - name: parent.name + property BasicDiscreteInstrument instrument - friendlyName: "Pipes" - vendor: "CuteHMI" + GroupBox { + title: qsTr("Custom properties") - domain: "cutehmi.kde.org" + Layout.fillWidth: true - description: "Pipe drawing components." + GridLayout { + columns: 2 + Label { + text: qsTr("Symbol:") + } - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + TextField { + text: instrument.symbol - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] - - Depends { name: "cutehmi.qmldir" } - - Depends { name: "cutehmi.qmltypes" } - - Export { - Depends { name: "CuteHMI.GUI.1" } + onTextChanged: instrument.symbol = text + } } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/BladeDamperSettings.qml b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/BladeDamperSettings.qml new file mode 100644 index 00000000..7cebf41d --- /dev/null +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/BladeDamperSettings.qml @@ -0,0 +1,95 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.3 + +import CuteHMI.Symbols.HVAC 1.0 + +ElementSettings { + element: damper + + property BladeDamper damper + + GroupBox { + title: qsTr("Custom properties") + + Layout.fillWidth: true + + GridLayout { + columns: 2 + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Mirror:") + } + + CheckBox { + checked: damper.mirror + + onCheckedChanged: damper.mirror = checked + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Horizontal:") + } + + CheckBox { + checked: damper.horizontal + + onCheckedChanged: damper.horizontal = checked + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Blades:") + } + + SpinBox { + from: 1 + to: 10 + value: damper.blades + + onValueChanged: damper.blades = value + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Value:") + } + + Slider { + id: valueSlider + + from: 0 + to: 100 + + value: damper.value * 100 + + onValueChanged: damper.value = value / 100 + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Opposed blade:") + } + + CheckBox { + checked: damper.opposedBlade + + onCheckedChanged: damper.opposedBlade = checked + } + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/CentrifugalFanSettings.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/CentrifugalFanSettings.qml index fd3e8aa1..f01f67dd 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/CentrifugalFanSettings.qml @@ -1,54 +1,52 @@ -import qbs +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.3 -import cutehmi +import CuteHMI.Symbols.HVAC 1.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +ElementSettings { + element: fan - cutehmi.Extension { - name: parent.name + property CentrifugalFan fan - friendlyName: "Pipes" - vendor: "CuteHMI" + GroupBox { + title: qsTr("Custom properties") - domain: "cutehmi.kde.org" + Layout.fillWidth: true - description: "Pipe drawing components." + GridLayout { + columns: 2 - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + Label { + text: qsTr("Mirror:") + } - Depends { name: "CuteHMI.GUI.1" } + CheckBox { + checked: fan.mirror - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + onCheckedChanged: fan.mirror = checked + } - Depends { name: "cutehmi.qmldir" } + Label { + text: qsTr("RPM:") + } - Depends { name: "cutehmi.qmltypes" } + Slider { + from: 0 + to: 120 - Export { - Depends { name: "CuteHMI.GUI.1" } + value: fan.implicitRpm + + onValueChanged: fan.implicitRpm = value + } } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/ElementSettings.qml b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/ElementSettings.qml new file mode 100644 index 00000000..767c2bc4 --- /dev/null +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/ElementSettings.qml @@ -0,0 +1,71 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.5 +import QtQuick.Layouts 1.3 + +import CuteHMI.GUI 1.0 + +ColumnLayout { + Layout.fillWidth: true + + property Element element + + GroupBox { + Layout.fillWidth: true + + title: qsTr("Common properties") + + ColumnLayout { + CheckBox { + text: qsTr("Neutral") + + onCheckedChanged: checked ? element.colorSet = Theme.palette.neutral : element.colorSet = Qt.binding(element.currentStateColorSet) + } + + CheckBox { + text: qsTr("Active") + + checked: element.active + + onCheckedChanged: element.active = checked + } + + CheckBox { + text: qsTr("Warning") + + checked: element.warning + + onCheckedChanged: element.warning = checked + } + + CheckBox { + text: qsTr("Alarm") + + checked: element.alarm + + onCheckedChanged: element.alarm = checked + } + + CheckBox { + text: qsTr("Indirect warning") + + checked: element.indirectWarning + + onCheckedChanged: element.indirectWarning = checked + } + + CheckBox { + text: qsTr("Indirect alarm") + + checked: element.indirectAlarm + + onCheckedChanged: element.indirectAlarm = checked + } + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/HeatRecoveryWheelSettings.qml b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/HeatRecoveryWheelSettings.qml new file mode 100644 index 00000000..f1765c00 --- /dev/null +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/HeatRecoveryWheelSettings.qml @@ -0,0 +1,67 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.3 + +import CuteHMI.Symbols.HVAC 1.0 + +ElementSettings { + element: wheel + + property HeatRecoveryWheel wheel + + GroupBox { + title: qsTr("Custom properties") + + Layout.fillWidth: true + + GridLayout { + columns: 2 + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Segments:") + } + + SpinBox { + from: 1 + to: 100 + value: wheel.segments + + onValueChanged: wheel.segments = value + } + + Label { + text: qsTr("RPM:") + } + + Slider { + from: 0 + to: 20 + + value: wheel.implicitRpm + + onValueChanged: wheel.implicitRpm = value + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Clockwise:") + } + + CheckBox { + checked: wheel.clockwise + + onCheckedChanged: wheel.clockwise = checked + } + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/LICENSE b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/LICENSE new file mode 100644 index 00000000..0a041280 --- /dev/null +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/LICENSE.C.dslash.inc b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/LICENSE.C.dslash.inc new file mode 100644 index 00000000..3604b204 --- /dev/null +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/LICENSE.C.dslash.inc @@ -0,0 +1,6 @@ + +//(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/LICENSE.C.hash.inc b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/LICENSE.C.hash.inc new file mode 100644 index 00000000..daa303be --- /dev/null +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/LICENSE.C.hash.inc @@ -0,0 +1,6 @@ + +#(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +#(c)C: This file is a part of CuteHMI. +#(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +#(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +#(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/MotorActuatorSettings.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/MotorActuatorSettings.qml index fd3e8aa1..fd1b4227 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/MotorActuatorSettings.qml @@ -1,54 +1,65 @@ -import qbs +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.3 -import cutehmi +import CuteHMI.Symbols.HVAC 1.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +ElementSettings { + element: actuator - cutehmi.Extension { - name: parent.name + property MotorActuator actuator - friendlyName: "Pipes" - vendor: "CuteHMI" + GroupBox { + title: qsTr("Custom properties") - domain: "cutehmi.kde.org" + Layout.fillWidth: true - description: "Pipe drawing components." + GridLayout { + columns: 2 - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + Label { + text: qsTr("Symbol:") + } - Depends { name: "CuteHMI.GUI.1" } + TextField { + text: actuator.symbol - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + onTextChanged: actuator.symbol = text + } - Depends { name: "cutehmi.qmldir" } + Label { + text: qsTr("Start angle:") + } - Depends { name: "cutehmi.qmltypes" } + Slider { + from: 0 + to: 100 - Export { - Depends { name: "CuteHMI.GUI.1" } + value: actuator.start * 100 + + onValueChanged: actuator.start = value / 100 + } + + Label { + text: qsTr("Value:") + } + + Slider { + from: 0 + to: 100 + + value: actuator.value * 100 + + onValueChanged: actuator.value = value / 100 + } } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/PumpSettings.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/PumpSettings.qml index fd3e8aa1..cd46cff0 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/PumpSettings.qml @@ -1,54 +1,42 @@ -import qbs +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.3 -import cutehmi +import CuteHMI.Symbols.HVAC 1.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +ElementSettings { + element: pump - cutehmi.Extension { - name: parent.name + property Pump pump - friendlyName: "Pipes" - vendor: "CuteHMI" + GroupBox { + title: qsTr("Custom properties") - domain: "cutehmi.kde.org" + Layout.fillWidth: true - description: "Pipe drawing components." + GridLayout { + columns: 2 - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + Label { + text: qsTr("RPM:") + } - Depends { name: "CuteHMI.GUI.1" } + Slider { + from: 0 + to: 120 - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + value: pump.implicitRpm - Depends { name: "cutehmi.qmldir" } - - Depends { name: "cutehmi.qmltypes" } - - Export { - Depends { name: "CuteHMI.GUI.1" } + onValueChanged: pump.implicitRpm = value + } } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/README.md b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/README.md new file mode 100644 index 00000000..1f5f1443 --- /dev/null +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/README.md @@ -0,0 +1,31 @@ +# HVAC Symbols Gallery Example + +Gallery of HVAC symbols provided by [CuteHMI.Symbols.HVAC.1](../../../../Symbols/HVAC.1/) extension. + +![View component](doc/View.png) + +To run the example use [cutehmi.view.4](../../../../../../tools/cutehmi.view.4/) tool. +``` +cutehmi.view.4 CuteHMI.Examples.Symbols.HVAC.Gallery.2 +``` + +\example AirFilterSettings.qml +Here is a complete listing of the example source file. + +\example BasicDiscreteInstrumentSettings.qml +Here is a complete listing of the example source file. + +\example CentrifugalFanSettings.qml +Here is a complete listing of the example source file. + +\example ElementSettings.qml +Here is a complete listing of the example source file. + +\example View.qml +Here is a complete listing of the example source file. + +\example MotorActuatorSettings.qml +Here is a complete listing of the example source file. + +\example PumpSettings.qml +Here is a complete listing of the example source file. diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/TankSettings.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/TankSettings.qml index fd3e8aa1..221ff248 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/TankSettings.qml @@ -1,54 +1,56 @@ -import qbs +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.3 -import cutehmi +import CuteHMI.Symbols.HVAC 1.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +ElementSettings { + element: tank - cutehmi.Extension { - name: parent.name + property Tank tank - friendlyName: "Pipes" + GroupBox { + title: qsTr("Custom properties") - vendor: "CuteHMI" + Layout.fillWidth: true - domain: "cutehmi.kde.org" + GridLayout { + columns: 2 - description: "Pipe drawing components." + Label { + Layout.alignment: Qt.AlignRight - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + text: qsTr("Head ratio:") + } - Depends { name: "CuteHMI.GUI.1" } + Slider { + from: 0 + to: 50 + value: tank.headRatio * 100 - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + onValueChanged: tank.headRatio = value / 100 + } - Depends { name: "cutehmi.qmldir" } + Label { + Layout.alignment: Qt.AlignRight - Depends { name: "cutehmi.qmltypes" } + text: qsTr("Level:") + } - Export { - Depends { name: "CuteHMI.GUI.1" } + Slider { + from: 0 + to: 100 + value: tank.level * 100 + + onValueChanged: tank.level = value / 100 + } } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/ValveSettings.qml b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/ValveSettings.qml new file mode 100644 index 00000000..abd23657 --- /dev/null +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/ValveSettings.qml @@ -0,0 +1,125 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.3 + +import CuteHMI.Symbols.HVAC 1.0 + +ElementSettings { + element: valve + + property Valve valve + + GroupBox { + title: qsTr("Custom properties") + + Layout.fillWidth: true + + GridLayout { + columns: 2 + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Left way:") + } + + CheckBox { + checked: valve.leftWay + + onCheckedChanged: valve.leftWay = checked + } + + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Right way:") + } + + CheckBox { + checked: valve.rightWay + + onCheckedChanged: valve.rightWay = checked + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Top way:") + } + + CheckBox { + checked: valve.topWay + + onCheckedChanged: valve.topWay = checked + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Bottom way:") + } + + CheckBox { + checked: valve.bottomWay + + onCheckedChanged: valve.bottomWay = checked + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Left closed:") + } + + CheckBox { + checked: valve.leftClosed + + onCheckedChanged: valve.leftClosed = checked + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Right closed:") + } + + CheckBox { + checked: valve.rightClosed + + onCheckedChanged: valve.rightClosed = checked + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Top closed:") + } + + CheckBox { + checked: valve.topClosed + + onCheckedChanged: valve.topClosed = checked + } + + Label { + Layout.alignment: Qt.AlignRight + + text: qsTr("Bottom closed:") + } + + CheckBox { + checked: valve.bottomClosed + + onCheckedChanged: valve.bottomClosed = checked + } + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/View.qml b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/View.qml new file mode 100644 index 00000000..aeeae128 --- /dev/null +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/View.qml @@ -0,0 +1,316 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Controls 2.4 +import QtQuick.Layouts 1.3 + +import CuteHMI.GUI 1.0 +import CuteHMI.Symbols.HVAC 1.0 + +/** + %View component. +*/ +Rectangle { + anchors.fill: parent + + color: Theme.palette.background + + ColumnLayout { + anchors.fill: parent + anchors.margins: 10 + + spacing: 20 + + RowLayout { + Label { + text: qsTr("Size:") + } + + Slider { + from: 10 + to: 240 + + value: Theme.units.quadrat + + onValueChanged: Theme.units.quadrat = value + } + } + + Flickable { + Layout.fillHeight: true + Layout.fillWidth: true + + ScrollBar.vertical: ScrollBar {} + ScrollBar.horizontal: ScrollBar {} + + contentWidth: row.width + contentHeight: row.height + + Row { + id: row + + GridLayout { + rows: 3 + flow: GridLayout.TopToBottom + + Label { + Layout.alignment: Qt.AlignCenter + + text: qsTr("Air filter") + } + + AirFilter { + id: filter + + Layout.alignment: Qt.AlignCenter + } + + AirFilterSettings { + Layout.alignment: Qt.AlignTop + + filter: filter + } + + Label { + Layout.alignment: Qt.AlignCenter + + text: qsTr("Basic cooler") + } + + BasicCooler { + id: basicCooler + + Layout.alignment: Qt.AlignCenter + } + + ElementSettings { + Layout.alignment: Qt.AlignTop + + element: basicCooler + } + + Label { + Layout.alignment: Qt.AlignCenter + + text: qsTr("Basic discrete instrument") + } + + BasicDiscreteInstrument { + id: basicDiscreteInstrument + + Layout.alignment: Qt.AlignCenter + } + + BasicDiscreteInstrumentSettings { + Layout.alignment: Qt.AlignTop + + instrument: basicDiscreteInstrument + } + + Label { + Layout.alignment: Qt.AlignCenter + + text: qsTr("Basic heater") + } + + BasicHeater { + id: basicHeater + + Layout.alignment: Qt.AlignCenter + } + + ElementSettings { + Layout.alignment: Qt.AlignTop + + element: basicHeater + } + + Label { + Layout.alignment: Qt.AlignCenter + + text: qsTr("Blade damper") + } + + BladeDamper { + id: bladeDamper + + Layout.alignment: Qt.AlignCenter + } + + BladeDamperSettings { + Layout.alignment: Qt.AlignTop + + damper: bladeDamper + } + + Label { + Layout.alignment: Qt.AlignCenter + + text: qsTr("Centrifugal fan") + } + + CentrifugalFan { + id: centrifugalFan + + Layout.alignment: Qt.AlignCenter + } + + CentrifugalFanSettings { + Layout.alignment: Qt.AlignTop + + fan: centrifugalFan + } + + Label { + Layout.alignment: Qt.AlignCenter + + text: qsTr("Cooler") + } + + Cooler { + id: cooler + + Layout.alignment: Qt.AlignCenter + } + + ElementSettings { + Layout.alignment: Qt.AlignTop + + element: cooler + } + + Label { + Layout.alignment: Qt.AlignCenter + + text: qsTr("Heater") + } + + Heater { + id: heater + + Layout.alignment: Qt.AlignCenter + } + + ElementSettings { + Layout.alignment: Qt.AlignTop + + element: heater + } + + Label { + Layout.alignment: Qt.AlignCenter + + text: qsTr("Heat exchanger") + } + + HeatExchanger { + id: heatExchanger + + Layout.alignment: Qt.AlignCenter + } + + ElementSettings { + Layout.alignment: Qt.AlignTop + + element: heatExchanger + } + + Label { + Layout.alignment: Qt.AlignCenter + + text: qsTr("Heat recovery wheel") + } + + HeatRecoveryWheel { + id: wheel + + Layout.alignment: Qt.AlignCenter + } + + HeatRecoveryWheelSettings { + Layout.alignment: Qt.AlignTop + + wheel: wheel + } + + Label { + Layout.alignment: Qt.AlignCenter + + text: qsTr("Motor actuator") + } + + MotorActuator { + id: motorActuator + + Layout.alignment: Qt.AlignCenter + } + + MotorActuatorSettings { + Layout.alignment: Qt.AlignTop + + actuator: motorActuator + } + + Label { + Layout.alignment: Qt.AlignCenter + + text: qsTr("Pump") + } + + Pump { + id: pump + + Layout.alignment: Qt.AlignCenter + } + + PumpSettings { + Layout.alignment: Qt.AlignTop + + pump: pump + } + + Label { + Layout.alignment: Qt.AlignCenter + + text: qsTr("Tank") + } + + Tank { + id: tank + + Layout.alignment: Qt.AlignCenter + } + + TankSettings { + Layout.alignment: Qt.AlignTop + + tank: tank + } + + Label { + Layout.alignment: Qt.AlignCenter + + text: qsTr("Valve") + } + + Valve { + id: valve + + Layout.alignment: Qt.AlignCenter + } + + ValveSettings { + Layout.alignment: Qt.AlignTop + + valve: valve + } + } + } + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/doc/View.png b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/doc/View.png new file mode 100644 index 00000000..c81dc19c Binary files /dev/null and b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/doc/View.png differ diff --git a/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/doc/project_logo.png b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/doc/project_logo.png new file mode 100644 index 00000000..c5bc24be Binary files /dev/null and b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/doc/project_logo.png differ diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/project.qbs similarity index 59% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/project.qbs index fd3e8aa1..d1175bfd 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/project.qbs @@ -1,54 +1,56 @@ import qbs import cutehmi Project { - name: "CuteHMI.Symbols.Pipes.1" + name: "CuteHMI.Examples.Symbols.HVAC.Gallery.2" + + references: [ + "tests/tests.qbs" + ] cutehmi.Extension { name: parent.name - friendlyName: "Pipes" - vendor: "CuteHMI" domain: "cutehmi.kde.org" - description: "Pipe drawing components." + friendlyName: "HVAC Symbols Gallery Example" + + description: "Gallery of HVAC symbols provided by CuteHMI.Symbols.HVAC.1 extension." files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } + "AirFilterSettings.qml", + "BasicDiscreteInstrumentSettings.qml", + "BladeDamperSettings.qml", + "CentrifugalFanSettings.qml", + "ElementSettings.qml", + "HeatRecoveryWheelSettings.qml", + "LICENSE", + "View.qml", + "MotorActuatorSettings.qml", + "PumpSettings.qml", + "README.md", + "TankSettings.qml", + "ValveSettings.qml", + ] Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] Depends { name: "cutehmi.qmldir" } Depends { name: "cutehmi.qmltypes" } - Export { - Depends { name: "CuteHMI.GUI.1" } - } + Depends { name: "cutehmi.view.4" } + + Depends { name: "CuteHMI.Symbols.HVAC.1" } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/tests/Test.qbs similarity index 51% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/tests/Test.qbs index fd3e8aa1..3a03b17d 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/tests/Test.qbs @@ -1,54 +1,18 @@ import qbs import cutehmi -Project { - name: "CuteHMI.Symbols.Pipes.1" +cutehmi.Test +{ + testNamePrefix: parent.parent.name - cutehmi.Extension { - name: parent.name + Depends { name: "CuteHMI.Examples.Symbols.HVAC.Gallery.2" } - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] - - Depends { name: "cutehmi.qmldir" } - - Depends { name: "cutehmi.qmltypes" } - - Export { - Depends { name: "CuteHMI.GUI.1" } - } - } + Depends { name: "CuteHMI.Test.0" } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/tests/test_QML.cpp similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/tests/test_QML.cpp index fd3e8aa1..44cc5198 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/tests/test_QML.cpp @@ -1,54 +1,31 @@ -import qbs +#include "cutehmi.dirs.hpp" -import cutehmi +#include -Project { - name: "CuteHMI.Symbols.Pipes.1" +#include - cutehmi.Extension { - name: parent.name +class test_QML: + public QObject +{ + Q_OBJECT - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + public slots: + void qmlEngineAvailable(QQmlEngine * engine) + { + cutehmi::test::setupScreenshotDirs(CUTEHMI_DIRS_PROJECT_RELATIVE_PATH, engine); + } - Depends { name: "cutehmi.qmldir" } + void cleanupTestCase() + { + } +}; - Depends { name: "cutehmi.qmltypes" } - Export { - Depends { name: "CuteHMI.GUI.1" } - } - } -} +QUICK_TEST_MAIN_WITH_SETUP(CuteHMI.Examples.Symbols.HVAC.Gallery.1, test_QML) +#include "test_QML.moc" //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/tests/tests.qbs similarity index 51% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/tests/tests.qbs index fd3e8aa1..b2a41408 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/tests/tests.qbs @@ -1,54 +1,22 @@ import qbs -import cutehmi +import "Test.qbs" as Test Project { - name: "CuteHMI.Symbols.Pipes.1" - - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." + Test { + testName: "test_QML" files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] - - Depends { name: "cutehmi.qmldir" } - - Depends { name: "cutehmi.qmltypes" } + "test_QML.cpp", + "tst_View.qml", + ] - Export { - Depends { name: "CuteHMI.GUI.1" } - } + cutehmi.dirs.artifacts: true } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/tests/tst_View.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/tests/tst_View.qml index fd3e8aa1..f6467bed 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Symbols/HVAC/Gallery.2/tests/tst_View.qml @@ -1,54 +1,36 @@ -import qbs +import QtQuick 2.12 +import QtQuick.Controls 2.5 +import QtTest 1.2 -import cutehmi +import CuteHMI.Examples.Symbols.HVAC.Gallery 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +Item { + id: root - cutehmi.Extension { - name: parent.name + width: 1600 + height: 1024 - friendlyName: "Pipes" + View { + id: main - vendor: "CuteHMI" + TestCase { + name: "View" + when: windowShown - domain: "cutehmi.kde.org" + function initTestCase() { + } - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] - - Depends { name: "cutehmi.qmldir" } - - Depends { name: "cutehmi.qmltypes" } - - Export { - Depends { name: "CuteHMI.GUI.1" } + function test_main() { + waitForRendering(root) + var image = grabImage(main); + image.save(docScreenshotsDir + "/View.png") + } } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/LICENSE b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/LICENSE new file mode 100644 index 00000000..0a041280 --- /dev/null +++ b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/LICENSE.C.dslash.inc b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/LICENSE.C.dslash.inc new file mode 100644 index 00000000..3604b204 --- /dev/null +++ b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/LICENSE.C.dslash.inc @@ -0,0 +1,6 @@ + +//(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/LICENSE.C.hash.inc b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/LICENSE.C.hash.inc new file mode 100644 index 00000000..daa303be --- /dev/null +++ b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/LICENSE.C.hash.inc @@ -0,0 +1,6 @@ + +#(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +#(c)C: This file is a part of CuteHMI. +#(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +#(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +#(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/README.md b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/README.md new file mode 100644 index 00000000..f701421e --- /dev/null +++ b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/README.md @@ -0,0 +1,27 @@ +# Piping example + +This example shows how to use piping components provided by [CuteHMI.Symbols.Pipes.1](../../../../Symbols/Pipes.1/) extension. + +To run the example use [cutehmi.view.4](../../../../../../tools/cutehmi.view.4/) tool. +``` +cutehmi.view.4 CuteHMI.Examples.Symbols.Pipes.Piping.2 +``` + +A remark on Qt Creator. + +\snippet View.qml Red-blue pipe + +Qt Creator may refuse to render this pipe in "Design" mode. PipeConnector objects are created within named properties of red and +blue rectangles. + +\snippet View.qml Red rectangle outlet property + +It comes out Qt Creator has troubles with such bindings if component is defined inplace. It would render pipe correctly however, if +rectangles were defined in separate QML files. Thus if one wants to use PipeConnector objects as item properties with Qt Creator in +"Design" mode, he has to pack such code into custom QML component. For example red rectangle code below could be moved to +`RedRectangle.qml` file. + +\snippet View.qml Red rectangle + +\example View.qml +Here is a complete listing of the example source file. diff --git a/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/View.qml b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/View.qml new file mode 100644 index 00000000..07472da4 --- /dev/null +++ b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/View.qml @@ -0,0 +1,402 @@ +import QtQml 2.2 +import QtQuick 2.11 +import QtQuick.Controls 2.4 +import QtQuick.Layouts 1.3 + +import CuteHMI.GUI 1.0 +import CuteHMI.Symbols.Pipes 1.0 + +/** + %View component. +*/ +Rectangle { + id: root + + anchors.fill: parent + + color: Theme.palette.background + + Pipe { + from: PipeConnector { + x: 20 + y: 20 + } + + to: PipeConnector { + x: 200 + y: 20 + } + } + + PipeConnector { + id: verticalA + + x: 300 + y: 20 + } + + PipeConnector { + id: verticalB + x: 300 + y: 200 + } + + Pipe { + from: verticalA + to: verticalB + } + + //! [Red rectangle] + Rectangle { + id: red + + x: 400 + y: 20 + + width: 40 + height: 40 + color: "red" + border.width: 1 + + //! [Red rectangle outlet property] + property PipeConnector outlet: PipeConnector { + x: 40 + y: 20 + parent: red + } + //! [Red rectangle outlet property] + } + //! [Red rectangle] + + Rectangle { + id: blue + + x: 600 + y: 20 + + width: 40 + height: 40 + color: "blue" + border.width: 1 + + property PipeConnector inlet: PipeConnector { + x: 0 + y: 20 + parent: blue + } + } + + //! [Red-blue pipe] + Pipe { + from: red.outlet + to: blue.inlet + + color.interior: ["red", "blue"] + } + //! [Red-blue pipe] + + Rectangle { + id: green + + x: 700 + y: 20 + + width: 40 + height: 40 + color: "green" + border.width: 1 + + rotation: 90 + + property PipeConnector outlet: PipeConnector { + x: 40 + y: 20 + parent: green + } + } + + Rectangle { + id: orange + + x: 700 + y: 200 + + width: 40 + height: 40 + color: "orange" + border.width: 1 + + rotation: 90 + + property PipeConnector inlet: PipeConnector { + x: 0 + y: 20 + parent: orange + } + } + + Pipe { + from: green.outlet + to: orange.inlet + + color.interior: ["green", "orange"] + } + + // Pipe elments example + Tee { + id: tee + + x: 100 + y: 300 + + color.interior: "yellow" + } + + Tee { + id: teeFlip + + x: 200 + y: 300 + + rotation: 180 + + color.interior: "yellow" + } + + Elbow { + id: elbow + + x: 300 + y: 300 + + color.interior: "yellow" + } + + Elbow { + id: elbow90 + + x: 300 + y: 400 + rotation: 90 + + color.interior: "yellow" + } + + Elbow { + id: elbow180 + + x: 100 + y: 400 + rotation: 180 + + color.interior: "yellow" + } + + PipeEnd { + id: leftEnd + + x: 20 + y: 300 + + color.interior: "yellow" + } + + PipeEnd { + id: topEnd + + x: 200 + y: 250 + rotation: 90 + + color.interior: "yellow" + } + + Pipe { + from: leftEnd.connector.sideB + to: tee.connector.sideA + + color.interior: "orange" + } + + Pipe { + from: tee.connector.sideB + to: teeFlip.connector.sideB + + color.interior: "orange" + } + + Pipe { + from: teeFlip.connector.sideA + to: elbow.connector.sideA + + color.interior: "orange" + } + + Pipe { + from: elbow.connector.sideB + to: elbow90.connector.sideA + + color.interior: "orange" + } + + Pipe { + from: elbow90.connector.sideB + to: elbow180.connector.sideA + + color.interior: "orange" + } + + Pipe { + from: elbow180.connector.sideB + to: tee.connector.middle + + color.interior: "orange" + } + + Pipe { + from: teeFlip.connector.middle + to: topEnd.connector.sideB + + color.interior: "orange" + } + + Tee { + id: tee_2 + + x: 400 + y: 300 + + color.interior: "pink" + } + + Tee { + id: teeFlip_2 + + x: 500 + y: 300 + + rotation: 180 + + color.interior: "pink" + } + + Elbow { + id: elbow_2 + + x: 600 + y: 300 + + color.interior: "pink" + } + + Elbow { + id: elbow90_2 + + x: 600 + y: 400 + rotation: 90 + + color.interior: "pink" + } + + Elbow { + id: elbow180_2 + + x: 400 + y: 400 + rotation: 180 + + color.interior: "pink" + } + + PipeEnd { + id: leftEnd_2 + + x: 320 + y: 300 + + color.interior: "pink" + } + + PipeEnd { + id: topEnd_2 + + x: 500 + y: 250 + rotation: 90 + + color.interior: "pink" + } + + Cap { + id: topCap_2 + + x: 500 + y: 200 + + color.interior: "pink" + rotation: -90 + } + + Pipe { + from: leftEnd_2.connector + to: tee_2.connector + + color.interior: "violet" + } + + Pipe { + from: tee_2.connector + to: teeFlip_2.connector + + color.interior: "violet" + } + + Pipe { + from: teeFlip_2.connector + to: elbow_2.connector + + color.interior: "violet" + } + + Pipe { + from: elbow_2.connector + to: elbow90_2.connector + + color.interior: "violet" + } + + Pipe { + from: elbow90_2.connector + to: elbow180_2.connector + + color.interior: "violet" + } + + Pipe { + from: elbow180_2.connector + to: tee_2.connector + + color.interior: "violet" + } + + Pipe { + from: teeFlip_2.connector + to: topEnd_2.connector + + color.interior: "violet" + } + + Pipe { + from: topEnd_2.connector + to: topCap_2.connector + + color.interior: "violet" + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/doc/View.png b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/doc/View.png new file mode 100644 index 00000000..f0bfaf96 Binary files /dev/null and b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/doc/View.png differ diff --git a/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/doc/project_logo.png b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/doc/project_logo.png new file mode 100644 index 00000000..c5bc24be Binary files /dev/null and b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/doc/project_logo.png differ diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/project.qbs similarity index 70% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/project.qbs index fd3e8aa1..ed1d9bb7 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/project.qbs @@ -1,54 +1,46 @@ import qbs import cutehmi Project { - name: "CuteHMI.Symbols.Pipes.1" + name: "CuteHMI.Examples.Symbols.Pipes.Piping.2" + + references: [ + "tests/tests.qbs" + ] cutehmi.Extension { name: parent.name - friendlyName: "Pipes" - vendor: "CuteHMI" domain: "cutehmi.kde.org" - description: "Pipe drawing components." + friendlyName: "Piping Example" + + description: "Piping example using CuteHMI.Symbols.Pipes.1 extension." files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", + "LICENSE", + "View.qml", "README.md", - "Tee.qml", - "functions.js", ] - Depends { name: "CuteHMI.GUI.1" } - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] Depends { name: "cutehmi.qmldir" } Depends { name: "cutehmi.qmltypes" } - Export { - Depends { name: "CuteHMI.GUI.1" } - } + Depends { name: "cutehmi.view.4" } + + Depends { name: "CuteHMI.Symbols.Pipes.1" } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/tests/Test.qbs similarity index 51% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/tests/Test.qbs index fd3e8aa1..0c9666ee 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/tests/Test.qbs @@ -1,54 +1,18 @@ import qbs import cutehmi -Project { - name: "CuteHMI.Symbols.Pipes.1" +cutehmi.Test +{ + testNamePrefix: parent.parent.name - cutehmi.Extension { - name: parent.name + Depends { name: "CuteHMI.Examples.Symbols.Pipes.Piping.2" } - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] - - Depends { name: "cutehmi.qmldir" } - - Depends { name: "cutehmi.qmltypes" } - - Export { - Depends { name: "CuteHMI.GUI.1" } - } - } + Depends { name: "CuteHMI.Test.0" } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/tests/test_QML.cpp similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/tests/test_QML.cpp index fd3e8aa1..55934dcf 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/tests/test_QML.cpp @@ -1,54 +1,33 @@ -import qbs +#include "cutehmi.dirs.hpp" -import cutehmi +#include -Project { - name: "CuteHMI.Symbols.Pipes.1" +#include - cutehmi.Extension { - name: parent.name +#include - friendlyName: "Pipes" +class test_QML: + public QObject +{ + Q_OBJECT - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + public slots: + void qmlEngineAvailable(QQmlEngine * engine) + { + cutehmi::test::setupScreenshotDirs(CUTEHMI_DIRS_PROJECT_RELATIVE_PATH, engine); + } - Depends { name: "cutehmi.qmldir" } + void cleanupTestCase() + { + } +}; - Depends { name: "cutehmi.qmltypes" } - Export { - Depends { name: "CuteHMI.GUI.1" } - } - } -} +QUICK_TEST_MAIN_WITH_SETUP(CuteHMI.Examples.Symbols.Pipes.Piping.2, test_QML) +#include "test_QML.moc" //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/tests/tests.qbs similarity index 51% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/tests/tests.qbs index fd3e8aa1..f377e3ae 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/tests/tests.qbs @@ -1,54 +1,22 @@ import qbs -import cutehmi +import "Test.qbs" as Test Project { - name: "CuteHMI.Symbols.Pipes.1" - - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." + Test { + testName: "test_QML" files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] - - Depends { name: "cutehmi.qmldir" } - - Depends { name: "cutehmi.qmltypes" } + "test_QML.cpp", + "tst_View.qml", + ] - Export { - Depends { name: "CuteHMI.GUI.1" } - } + cutehmi.dirs.artifacts: true } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/tests/tst_View.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/tests/tst_View.qml index fd3e8aa1..5a820e14 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/extensions/CuteHMI/Examples/Symbols/Pipes/Piping.2/tests/tst_View.qml @@ -1,54 +1,37 @@ -import qbs +import QtQuick 2.12 +import QtQuick.Controls 2.5 +import QtTest 1.2 -import cutehmi +import CuteHMI.Examples.Symbols.Pipes.Piping 2.0 -Project { - name: "CuteHMI.Symbols.Pipes.1" +Item { + id: root - cutehmi.Extension { - name: parent.name + width: 800 + height: 600 - friendlyName: "Pipes" + View { + id: main - vendor: "CuteHMI" + TestCase { + name: "View" + when: windowShown - domain: "cutehmi.kde.org" + function initTestCase() { + } - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] - - Depends { name: "cutehmi.qmldir" } - - Depends { name: "cutehmi.qmltypes" } - - Export { - Depends { name: "CuteHMI.GUI.1" } + function test_main() { + waitForRendering(root) + wait(1000); + var image = grabImage(main); + image.save(docScreenshotsDir + "/View.png") + } } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/FileSystem.0/CuteHMI.FileSystem.0.qbs b/extensions/CuteHMI/FileSystem.0/project.qbs similarity index 91% rename from extensions/CuteHMI/FileSystem.0/CuteHMI.FileSystem.0.qbs rename to extensions/CuteHMI/FileSystem.0/project.qbs index 1152a073..88a71b76 100644 --- a/extensions/CuteHMI/FileSystem.0/CuteHMI.FileSystem.0.qbs +++ b/extensions/CuteHMI/FileSystem.0/project.qbs @@ -1,53 +1,53 @@ import qbs import cutehmi Project { name: "CuteHMI.FileSystem.0" // references: [ // "tests/tests.qbs" // ] cutehmi.CppExtension { name: parent.name vendor: "CuteHMI" domain: "cutehmi.kde.org" friendlyName: "File System" description: "Wraps QT file system manipulation classes into QML API." files: [ "README.md", "include/cutehmi/filesystem/internal/platform.hpp", "include/cutehmi/filesystem/internal/common.hpp", "include/cutehmi/filesystem/logging.hpp", "include/cutehmi/filesystem/metadata.hpp", "src/cutehmi/filesystem/internal/QMLPlugin.cpp", "src/cutehmi/filesystem/internal/QMLPlugin.hpp", "src/cutehmi/filesystem/logging.cpp", ] Depends { name: "cutehmi.metadata" } Depends { name: "CuteHMI.2" } // Depends { name: "cutehmi.doxygen" } // cutehmi.doxygen.warnIfUndocumented: false // cutehmi.doxygen.useDoxyqml: true // cutehmi.doxygen.exclude: ['tests'] Export { Depends { name: "CuteHMI.2" } } } } -//(c)C: Copyright © 2019-2020, Michał Policht , Wojtek Zygmuntowicz . All rights reserved. +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/GPIO.0/CuteHMI.GPIO.0.qbs b/extensions/CuteHMI/GPIO.0/project.qbs similarity index 96% rename from extensions/CuteHMI/GPIO.0/CuteHMI.GPIO.0.qbs rename to extensions/CuteHMI/GPIO.0/project.qbs index 4c1f97da..dbd6e829 100644 --- a/extensions/CuteHMI/GPIO.0/CuteHMI.GPIO.0.qbs +++ b/extensions/CuteHMI/GPIO.0/project.qbs @@ -1,73 +1,73 @@ import qbs import cutehmi Project { name: "CuteHMI.GPIO.0" references: [ "tests/tests.qbs" ] cutehmi.CppExtension { name: parent.name cutehmi.product.enabled: cutehmi.libs.libgpiod.found friendlyName: "General-purpose Input/Output" vendor: "CuteHMI" domain: "cutehmi.kde.org" description: "An extension built on top of 'libgpiod' library to deal with GPIO chips." files: [ "README.md", "include/cutehmi/gpio/Chip.hpp", "include/cutehmi/gpio/ChipEnumerator.hpp", "include/cutehmi/gpio/Line.hpp", "include/cutehmi/gpio/LineConfig.hpp", "include/cutehmi/gpio/internal/LineEventMonitorThread.hpp", "include/cutehmi/gpio/internal/common.hpp", "include/cutehmi/gpio/internal/platform.hpp", "include/cutehmi/gpio/logging.hpp", "include/cutehmi/gpio/metadata.hpp", "src/cutehmi/gpio/Chip.cpp", "src/cutehmi/gpio/ChipEnumerator.cpp", "src/cutehmi/gpio/Line.cpp", "src/cutehmi/gpio/LineConfig.cpp", "src/cutehmi/gpio/internal/LineEventMonitorThread.cpp", "src/cutehmi/gpio/internal/QMLPlugin.cpp", "src/cutehmi/gpio/internal/QMLPlugin.hpp", "src/cutehmi/gpio/logging.cpp", ] Depends { name: "CuteHMI.2" } Depends { name: "cutehmi.libs.libgpiod" } // Depends { name: "cutehmi.doxygen" } // cutehmi.doxygen.warnIfUndocumented: false // cutehmi.doxygen.useDoxyqml: true // cutehmi.doxygen.exclude: ['tests'] Depends { name: "cutehmi.metadata" } Depends { name: "cutehmi.qmldir" } Depends { name: "cutehmi.qmltypes" } Export { Depends { name: "cutehmi.libs.libgpiod" } Depends { name: "CuteHMI.2" } } } } -//(c)C: Copyright © 2019-2020, Michał Policht . All rights reserved. +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/GUI.1/CuteHMI.GUI.1.qbs b/extensions/CuteHMI/GUI.1/project.qbs similarity index 100% rename from extensions/CuteHMI/GUI.1/CuteHMI.GUI.1.qbs rename to extensions/CuteHMI/GUI.1/project.qbs diff --git a/extensions/CuteHMI/Modbus.2/README.md b/extensions/CuteHMI/Modbus.2/README.md index 735afafd..e1d16dee 100644 --- a/extensions/CuteHMI/Modbus.2/README.md +++ b/extensions/CuteHMI/Modbus.2/README.md @@ -1,86 +1,86 @@ # Modbus This extension provides support for Modbus protocol. Its main purpose is to allow for configuring and interacting with Modbus devices from QML. Modbus is an industrial communcation protocol originally designed by Modicon to be used with a series of their PLCs (Programmable Logic Controllers). It is still one of the most popular protocols used in automation and many devices support Modbus as their communication interface. ## Device classes Modbus devices can be divided into two basic categories: servers and clients. In Modbus nomenclature clients are often called masters and servers are called slaves. Modbus is a higher level protocol [[1]][National Instruments - The Modbus Protocol In-Depth] [[2]][Acromag - Introdution To Modbus TCP/IP], hence each server or client can perform communication over arbitrary lower level protocol stack. Two most common solutions are TCP/IP and RTU (Remote Terminal Unit, which again is a sort of abstraction, but typically means serial port communcation). cutehmi::modbus::AbstractDevice is a base class for all Modbus devices. It defines common features of all Modbus devices. cutehmi::modbus::AbstractClient and cutehmi::modbus::AbstractServer are abstract classes for clients and servers respectively. cutehmi::modbus::RTUClient and cutehmi::modbus::RTUServer implement client and server functionalities using serial port communication. cutehmi::modbus::TCPClient and cutehmi::modbus::TCPServer implement client and server functionalities using TCP/IP to communicate. cutehmi::modbus::DummyClient is a special client that does not need a server to communicate with and it can be used to test UI for example. Device classes are lowest level API of the extension. They are centered around an idea of JSON requests and replies, inspired by web REST interfaces. Additionaly classes have various properties allowing one to configure devices or check their statuses from QML. Device classes are intended to be used with [CuteHMI.Services](../Services.2/). Notably device object will not perform polling on its own. For this purpose device classes implement cutehmi::services::Serviceable interface. Device object must be embedded in cutehmi::services::Service object to perform polling (after services are started by cutehmi::services::ServiceManager). In return its state is managed by the state machine, which will handle start/stop requests, try to repair broken connections etc. ## Register controllers Modbus protocol is oriented around four classes of registers, which can be viewed as four contiguous memory regions. These are: holding registers, input registers, coils and discrete inputs. Clients can read and write to holding registers and coils; input registers and discrete inputs provide read-only access for clients. Holding registers and input registers are addressed with 16 bit byte, while byte is 1 bit wide for discrete inputs and coils (byte is smallest addressable unit of memory). While registers can be accessed with device classes, in most cases imperative function calls do not fit well into QML declarative syntax. Typically it is better to access a register from QML using one of the controller classes. There is one class registered as QML component for each of the Modbus register types: CuteHMI.Modbus.CoilController, CuteHMI.Modbus.DiscreteInputController, CuteHMI.Modbus.InputRegisterController and CuteHMI.Modbus.HoldingRegisterController, but they share most of the code, because there is not much of the difference between them. Controllers are better suited for accessing registers from QML, because they reveal various register aspects through a set of properties. They allow one to easily control how reads and writes are performed. They track requests, interpret responses and translate the sequence of events in between into convenient signals. Their properties can be binded with other QML components. ## Register items Register items are convenient components, which are composed of a controller and visual indicator item. They are particularly useful in "Design" mode. For each register controller there is corresponding register item, that is: CuteHMI.Modbus.CoilItem, CuteHMI.Modbus.DiscreteInputItem, CuteHMI.Modbus.HoldingRegisterItem and CuteHMI.Modbus.InputRegisterItem. ## Relationship between classes Structural relationship between extension classes is conceptually shown on the following quasi-UML diagram. ![Relationship between extension classes](doc/quasi_uml.svg) [National Instruments - The Modbus Protocol In-Depth]: https://www.ni.com/pl-pl/innovations/white-papers/14/the-modbus-protocol-in-depth.html [Acromag - Introdution To Modbus TCP/IP]: https://www.prosoft-technology.com/kb/assets/intro_modbustcp.pdf ## QML components Classes exposed as QML components are listed within CuteHMI.Modbus namespace. ## Examples The extension is supplemented by following examples. -- [CuteHMI.Examples.Modbus.Basic.0](../Examples/Modbus/Basic.0/) -- [CuteHMI.Examples.Modbus.ClientServer.0](../Examples/Modbus/ClientServer.0/) -- [CuteHMI.Examples.Modbus.ControllerItems.0](../Examples/Modbus/ControllerItems.0/) -- [CuteHMI.Examples.Modbus.Controllers.0](../Examples/Modbus/Controllers.0/) -- [CuteHMI.Examples.Modbus.Requests.0](../Examples/Modbus/Requests.0/) - -The one to get started with is [CuteHMI.Examples.Modbus.Basic.0](../Examples/Modbus/Basic.0/). This example shows basic usage of QML -components. Another simple example [CuteHMI.Examples.Modbus.ControllerItems.0](../Examples/Modbus/ControllerItems.0/) is provided to +- [CuteHMI.Examples.Modbus.Basic.1](../Examples/Modbus/Basic.1/) +- [CuteHMI.Examples.Modbus.ClientServer.1](../Examples/Modbus/ClientServer.1/) +- [CuteHMI.Examples.Modbus.ControllerItems.1](../Examples/Modbus/ControllerItems.1/) +- [CuteHMI.Examples.Modbus.Controllers.1](../Examples/Modbus/Controllers.1/) +- [CuteHMI.Examples.Modbus.Requests.1](../Examples/Modbus/Requests.1/) + +The one to get started with is [CuteHMI.Examples.Modbus.Basic.1](../Examples/Modbus/Basic.1/). This example shows basic usage of QML +components. Another simple example [CuteHMI.Examples.Modbus.ControllerItems.1](../Examples/Modbus/ControllerItems.1/) is provided to work with Qt Creator in "Design" mode. The other examples are provided to demonstrate more advanced features. diff --git a/extensions/CuteHMI/Modbus.2/Modbus.2.qbs b/extensions/CuteHMI/Modbus.2/project.qbs similarity index 98% rename from extensions/CuteHMI/Modbus.2/Modbus.2.qbs rename to extensions/CuteHMI/Modbus.2/project.qbs index 1c4cdf61..9686b3af 100644 --- a/extensions/CuteHMI/Modbus.2/Modbus.2.qbs +++ b/extensions/CuteHMI/Modbus.2/project.qbs @@ -1,207 +1,207 @@ import qbs import cutehmi Project { name: "CuteHMI.Modbus.2" references: [ "tests/tests.qbs" ] cutehmi.PuppetExtension { originalExtension: parent.name files: [ "puppet/designer/CoilItemSpecifics.qml", "puppet/designer/DiscreteInputItemSpecifics.qml", "puppet/designer/HoldingRegisterItemSpecifics.qml", "puppet/designer/InputRegisterItemSpecifics.qml", "puppet/designer/Modbus.metainfo" ] } cutehmi.CppExtension { name: parent.name vendor: "CuteHMI" domain: "cutehmi.kde.org" friendlyName: "Modbus" description: "Modbus protocol support." files: [ "CoilItem.qml", "DiscreteInputItem.qml", "HoldingRegisterItem.qml", "InputRegisterItem.qml", "LICENSE", "README.md", "RegisterItem.js", "dev/CuteHMI.Modbus-1.solved.Qt.design.txt", "dev/CuteHMI.Modbus-2.workaround.Qt.design.txt", "dev/CuteHMI.Modbus-3.workaround.Qt.design.txt", "dev/CuteHMI.Modbus-4.unsolved.Qt.design.txt", "dev/CuteHMI.Modbus-5.unsolved.Qt.design.txt", "dev/CuteHMI.Modbus-6.unsolved.Qt.design.txt", "dev/CuteHMI.Modbus-7.workaround.Qt.design.txt", "dev/CuteHMI.Modbus-8.workaround.Qt.design.txt", "dev/CuteHMI.Modbus-9.workaround.Qt.design.txt", "dev/rationale.txt", "include/cutehmi/modbus/AbstractClient.hpp", "include/cutehmi/modbus/AbstractDevice.hpp", "include/cutehmi/modbus/AbstractRegisterController.hpp", "include/cutehmi/modbus/AbstractServer.hpp", "include/cutehmi/modbus/Coil.hpp", "include/cutehmi/modbus/CoilController.hpp", "include/cutehmi/modbus/DiscreteInput.hpp", "include/cutehmi/modbus/DiscreteInputController.hpp", "include/cutehmi/modbus/DummyClient.hpp", "include/cutehmi/modbus/Exception.hpp", "include/cutehmi/modbus/HoldingRegister.hpp", "include/cutehmi/modbus/HoldingRegisterController.hpp", "include/cutehmi/modbus/Init.hpp", "include/cutehmi/modbus/InputRegister.hpp", "include/cutehmi/modbus/InputRegisterController.hpp", "include/cutehmi/modbus/RTUClient.hpp", "include/cutehmi/modbus/RTUServer.hpp", "include/cutehmi/modbus/Register1.hpp", "include/cutehmi/modbus/Register16.hpp", "include/cutehmi/modbus/Register16Controller.hpp", "include/cutehmi/modbus/Register1Controller.hpp", "include/cutehmi/modbus/TCPClient.hpp", "include/cutehmi/modbus/TCPServer.hpp", "include/cutehmi/modbus/internal/AbstractClientBackend.hpp", "include/cutehmi/modbus/internal/AbstractDeviceBackend.hpp", "include/cutehmi/modbus/internal/AbstractServerBackend.hpp", "include/cutehmi/modbus/internal/Coil.hpp", "include/cutehmi/modbus/internal/CoilPolling.hpp", "include/cutehmi/modbus/internal/Config.hpp", "include/cutehmi/modbus/internal/DataContainer.hpp", "include/cutehmi/modbus/internal/DataContainerPolling.hpp", "include/cutehmi/modbus/internal/DiscreteInput.hpp", "include/cutehmi/modbus/internal/DiscreteInputPolling.hpp", "include/cutehmi/modbus/internal/DummyClientBackend.hpp", "include/cutehmi/modbus/internal/DummyClientConfig.hpp", "include/cutehmi/modbus/internal/HoldingRegister.hpp", "include/cutehmi/modbus/internal/HoldingRegisterPolling.hpp", "include/cutehmi/modbus/internal/InputRegister.hpp", "include/cutehmi/modbus/internal/InputRegisterPolling.hpp", "include/cutehmi/modbus/internal/IterableTasks.hpp", "include/cutehmi/modbus/internal/PollingIterator.hpp", "include/cutehmi/modbus/internal/QtClientBackend.hpp", "include/cutehmi/modbus/internal/QtRTUClientBackend.hpp", "include/cutehmi/modbus/internal/QtRTUServer.hpp", "include/cutehmi/modbus/internal/QtRTUServerBackend.hpp", "include/cutehmi/modbus/internal/QtServerBackend.hpp", "include/cutehmi/modbus/internal/QtServerMixin.hpp", "include/cutehmi/modbus/internal/QtTCPClientBackend.hpp", "include/cutehmi/modbus/internal/QtTCPServer.hpp", "include/cutehmi/modbus/internal/QtTCPServerBackend.hpp", "include/cutehmi/modbus/internal/RTUClientConfig.hpp", "include/cutehmi/modbus/internal/RTUServerConfig.hpp", "include/cutehmi/modbus/internal/RegisterControllerMixin.hpp", "include/cutehmi/modbus/internal/RegisterControllerTraits.hpp", "include/cutehmi/modbus/internal/RegisterTraits.hpp", "include/cutehmi/modbus/internal/TCPClientConfig.hpp", "include/cutehmi/modbus/internal/TCPServerConfig.hpp", "include/cutehmi/modbus/internal/common.hpp", "include/cutehmi/modbus/internal/functions.hpp", "include/cutehmi/modbus/internal/platform.hpp", "include/cutehmi/modbus/logging.hpp", "include/cutehmi/modbus/metadata.hpp", "src/cutehmi/modbus/AbstractClient.cpp", "src/cutehmi/modbus/AbstractDevice.cpp", "src/cutehmi/modbus/AbstractRegisterController.cpp", "src/cutehmi/modbus/AbstractServer.cpp", "src/cutehmi/modbus/CoilController.cpp", "src/cutehmi/modbus/DiscreteInputController.cpp", "src/cutehmi/modbus/DummyClient.cpp", "src/cutehmi/modbus/HoldingRegisterController.cpp", "src/cutehmi/modbus/Init.cpp", "src/cutehmi/modbus/InputRegisterController.cpp", "src/cutehmi/modbus/RTUClient.cpp", "src/cutehmi/modbus/RTUServer.cpp", "src/cutehmi/modbus/Register1.cpp", "src/cutehmi/modbus/Register16.cpp", "src/cutehmi/modbus/Register16Controller.cpp", "src/cutehmi/modbus/Register1Controller.cpp", "src/cutehmi/modbus/TCPClient.cpp", "src/cutehmi/modbus/TCPServer.cpp", "src/cutehmi/modbus/internal/AbstractClientBackend.cpp", "src/cutehmi/modbus/internal/AbstractDeviceBackend.cpp", "src/cutehmi/modbus/internal/AbstractServerBackend.cpp", "src/cutehmi/modbus/internal/Coil.cpp", "src/cutehmi/modbus/internal/CoilPolling.cpp", "src/cutehmi/modbus/internal/Config.cpp", "src/cutehmi/modbus/internal/DiscreteInput.cpp", "src/cutehmi/modbus/internal/DiscreteInputPolling.cpp", "src/cutehmi/modbus/internal/DummyClientBackend.cpp", "src/cutehmi/modbus/internal/DummyClientConfig.cpp", "src/cutehmi/modbus/internal/HoldingRegister.cpp", "src/cutehmi/modbus/internal/HoldingRegisterPolling.cpp", "src/cutehmi/modbus/internal/InputRegister.cpp", "src/cutehmi/modbus/internal/InputRegisterPolling.cpp", "src/cutehmi/modbus/internal/IterableTasks.cpp", "src/cutehmi/modbus/internal/PollingIterator.cpp", "src/cutehmi/modbus/internal/QMLPlugin.cpp", "src/cutehmi/modbus/internal/QMLPlugin.hpp", "src/cutehmi/modbus/internal/QtClientBackend.cpp", "src/cutehmi/modbus/internal/QtRTUClientBackend.cpp", "src/cutehmi/modbus/internal/QtRTUServer.cpp", "src/cutehmi/modbus/internal/QtRTUServerBackend.cpp", "src/cutehmi/modbus/internal/QtServerBackend.cpp", "src/cutehmi/modbus/internal/QtTCPClientBackend.cpp", "src/cutehmi/modbus/internal/QtTCPServer.cpp", "src/cutehmi/modbus/internal/QtTCPServerBackend.cpp", "src/cutehmi/modbus/internal/RTUClientConfig.cpp", "src/cutehmi/modbus/internal/RTUServerConfig.cpp", "src/cutehmi/modbus/internal/TCPClientConfig.cpp", "src/cutehmi/modbus/internal/TCPServerConfig.cpp", "src/cutehmi/modbus/internal/functions.cpp", "src/cutehmi/modbus/logging.cpp", ] Depends { name: "Qt.concurrent" } Depends { name: "Qt.serialbus" } Depends { name: "Qt.serialport" } Depends { name: "CuteHMI.2" } Depends { name: "CuteHMI.Services.2" } Depends { name: "cutehmi.doxygen" } cutehmi.doxygen.warnIfUndocumented: false cutehmi.doxygen.useDoxyqml: true cutehmi.doxygen.exclude: ['dev', 'puppet', 'tests'] Depends { name: "cutehmi.init" } Depends { name: "cutehmi.metadata" } Depends { name: "cutehmi.qmldir" } cutehmi.qmldir.exclude: ["^designer/.*", "\.js$"] Depends { name: "cutehmi.qmltypes" } Export { Depends { name: "Qt.serialbus" } Depends { name: "Qt.serialport" } Depends { name: "CuteHMI.2" } Depends { name: "CuteHMI.Services.2" } } } } -//(c)C: Copyright © 2019-2020, Michał Policht . All rights reserved. +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Services.2/Services.2.qbs b/extensions/CuteHMI/Services.2/project.qbs similarity index 96% rename from extensions/CuteHMI/Services.2/Services.2.qbs rename to extensions/CuteHMI/Services.2/project.qbs index 6b262e4e..4ea6606b 100644 --- a/extensions/CuteHMI/Services.2/Services.2.qbs +++ b/extensions/CuteHMI/Services.2/project.qbs @@ -1,75 +1,75 @@ import qbs import cutehmi Project { name: "CuteHMI.Services.2" references: [ "tests/tests.qbs" ] cutehmi.CppExtension { name: parent.name vendor: "CuteHMI" domain: "cutehmi.kde.org" friendlyName: "Services" description: "Extension that helps creating services." files: [ "README.md", "LICENSE", "dev/CuteHMI.Services-1.workaround.Qml2Puppet.bug.txt", "dev/StandardStates.scxml", "include/cutehmi/services/Init.hpp", "include/cutehmi/services/PollingTimer.hpp", "include/cutehmi/services/Service.hpp", "include/cutehmi/services/ServiceListModel.hpp", "include/cutehmi/services/ServiceManager.hpp", "include/cutehmi/services/Serviceable.hpp", "include/cutehmi/services/internal/StateInterface.hpp", "include/cutehmi/services/internal/platform.hpp", "include/cutehmi/services/internal/common.hpp", "include/cutehmi/services/logging.hpp", "include/cutehmi/services/metadata.hpp", "src/cutehmi/services/Init.cpp", "src/cutehmi/services/PollingTimer.cpp", "src/cutehmi/services/Service.cpp", "src/cutehmi/services/ServiceListModel.cpp", "src/cutehmi/services/ServiceManager.cpp", "src/cutehmi/services/internal/QMLPlugin.cpp", "src/cutehmi/services/internal/QMLPlugin.hpp", "src/cutehmi/services/internal/StateInterface.cpp", "src/cutehmi/services/logging.cpp", ] Depends { name: "CuteHMI.2" } Depends { name: "cutehmi.doxygen" } cutehmi.doxygen.warnIfUndocumented: false cutehmi.doxygen.useDoxyqml: true cutehmi.doxygen.exclude: ['dev', 'tests'] Depends { name: "cutehmi.init" } Depends { name: "cutehmi.metadata" } Depends { name: "cutehmi.qmldir" } Depends { name: "cutehmi.qmltypes" } Export { Depends { name: "CuteHMI.2" } } } } -//(c)C: Copyright © 2019-2020, Michał Policht . All rights reserved. +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/SharedDatabase.0/SharedDatabase.0.qbs b/extensions/CuteHMI/SharedDatabase.0/project.qbs similarity index 100% rename from extensions/CuteHMI/SharedDatabase.0/SharedDatabase.0.qbs rename to extensions/CuteHMI/SharedDatabase.0/project.qbs diff --git a/extensions/CuteHMI/Symbols/HVAC.1/README.md b/extensions/CuteHMI/Symbols/HVAC.1/README.md index 9a098b7f..1ea27697 100644 --- a/extensions/CuteHMI/Symbols/HVAC.1/README.md +++ b/extensions/CuteHMI/Symbols/HVAC.1/README.md @@ -1,6 +1,6 @@ # HVAC Symbols Collection of \ref active-symbols.md "active symbols" used in HVAC(R) industry. Symbols are represented by various QML components provided by this extension. They can be previewed by running -[CuteHMI.Examples.Symbols.HVAC.Gallery.1](../../Examples/Symbols/HVAC/Gallery.1/) example. +[CuteHMI.Examples.Symbols.HVAC.Gallery.2](../../Examples/Symbols/HVAC/Gallery.2/) example. diff --git a/extensions/CuteHMI/Symbols/HVAC.1/HVAC.1.qbs b/extensions/CuteHMI/Symbols/HVAC.1/project.qbs similarity index 100% rename from extensions/CuteHMI/Symbols/HVAC.1/HVAC.1.qbs rename to extensions/CuteHMI/Symbols/HVAC.1/project.qbs diff --git a/extensions/CuteHMI/Symbols/Pipes.1/README.md b/extensions/CuteHMI/Symbols/Pipes.1/README.md index f6ff2186..790f63dd 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/README.md +++ b/extensions/CuteHMI/Symbols/Pipes.1/README.md @@ -1,6 +1,6 @@ # Pipes Pipe drawing components. -Refer to [CuteHMI.Examples.Symbols.Pipes.Piping.1](../../Examples/Symbols/Pipes/Piping.1/) example to get some glimpse of what this +Refer to [CuteHMI.Examples.Symbols.Pipes.Piping.2](../../Examples/Symbols/Pipes/Piping.2/) example to get some glimpse of what this extension does. diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/extensions/CuteHMI/Symbols/Pipes.1/project.qbs similarity index 100% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to extensions/CuteHMI/Symbols/Pipes.1/project.qbs diff --git a/extensions/CuteHMI/Test.0/CuteHMI.Test.0.qbs b/extensions/CuteHMI/Test.0/project.qbs similarity index 91% rename from extensions/CuteHMI/Test.0/CuteHMI.Test.0.qbs rename to extensions/CuteHMI/Test.0/project.qbs index 11784551..b250f5f1 100644 --- a/extensions/CuteHMI/Test.0/CuteHMI.Test.0.qbs +++ b/extensions/CuteHMI/Test.0/project.qbs @@ -1,55 +1,55 @@ import qbs import cutehmi Project { name: "CuteHMI.Test.0" references: [ "tests/tests.qbs" ] cutehmi.CppExtension { name: parent.name friendlyName: "Test" vendor: "CuteHMI" domain: "cutehmi.kde.org" description: "Testing helpers." files: [ "include/cutehmi/test/IsAnyOfTypes.hpp", "include/cutehmi/test/IsIntType.hpp", "include/cutehmi/test/internal/common.hpp", "include/cutehmi/test/internal/platform.hpp", "include/cutehmi/test/logging.hpp", "include/cutehmi/test/metadata.hpp", "include/cutehmi/test/qml.hpp", "include/cutehmi/test/random.hpp", "include/cutehmi/test/tests.hpp", "src/cutehmi/test/logging.cpp", "src/cutehmi/test/qml.cpp", ] cutehmi.dirs.artifacts: true Depends { name: "Qt.testlib" } Depends { name: "cutehmi.metadata" } Depends { name: "CuteHMI.2" } Export { Depends { name: "CuteHMI.2" } } } } -//(c)C: Copyright © 2018-2020, Michał Policht , Wojtek Zygmuntowicz . All rights reserved. +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Workarounds/PuppetBootloader.0/PuppetBootloader.0.qbs b/extensions/CuteHMI/Workarounds/PuppetBootloader.0/project.qbs similarity index 100% rename from extensions/CuteHMI/Workarounds/PuppetBootloader.0/PuppetBootloader.0.qbs rename to extensions/CuteHMI/Workarounds/PuppetBootloader.0/project.qbs diff --git a/extensions/Templates/CppPluginSkeleton.0/CppPluginSkeleton.0.qbs b/extensions/Templates/CppPluginSkeleton.0/project.qbs similarity index 100% rename from extensions/Templates/CppPluginSkeleton.0/CppPluginSkeleton.0.qbs rename to extensions/Templates/CppPluginSkeleton.0/project.qbs diff --git a/extensions/Templates/CppSkeleton.0/CppSkeleton.0.qbs b/extensions/Templates/CppSkeleton.0/project.qbs similarity index 100% rename from extensions/Templates/CppSkeleton.0/CppSkeleton.0.qbs rename to extensions/Templates/CppSkeleton.0/project.qbs diff --git a/extensions/Templates/QMLSkeleton.0/QMLSkeleton.0.qbs b/extensions/Templates/QMLSkeleton.0/project.qbs similarity index 100% rename from extensions/Templates/QMLSkeleton.0/QMLSkeleton.0.qbs rename to extensions/Templates/QMLSkeleton.0/project.qbs diff --git a/extensions/extensions.qbs b/extensions/extensions.qbs index b15ac88d..e824b705 100644 --- a/extensions/extensions.qbs +++ b/extensions/extensions.qbs @@ -1,42 +1,43 @@ import qbs.File Project { minimumQbsVersion: "1.10" references: extensionsProbe.extensionDirs /* This probe performs a recursive search for extension directories. It first scans current directory for its subdirectories. - If subdirectory contains a dot character ('.'), then it is considered to be an extension directory with a major version number - after the dot. If subdirectory does not contain a dot character, then it is recursively scanned for extension directories. - Extension directories are stored in `extensionDirs` property. + Each directory, which contains `project.qbs` file or a `.qbs` file with the same base name as name of the directory, where it + resides is considered to be an extension directory. If subdirectory does not contain any of these files, then it is + recursively scanned for extension directories. Extension directories are stored in `extensionDirs` property. */ Probe { id: extensionsProbe property pathList extensionDirs: [] configure: { /* Recursive function that searches for extension directories. @param rootPath root path, where the search should start. @param dir directory relative to root path, which is going to be scanned for extension directories. Do not add trailing "/" (slash) upon external call. @param result array containing list of extension directories. */ - function findExtensionDirs(rootPath, dir, result) - { + function findExtensionDirs(rootPath, dir, result) { var dirs = File.directoryEntries(rootPath + "/" + dir, File.Dirs | File.NoDotAndDotDot) - for (var i = 0; i < dirs.length; i++) - if (dirs[i].indexOf('.') === -1) - findExtensionDirs(rootPath, dir + dirs[i] + "/", result) // Intrnally trailing slash has to be appended however. - else + for (var i = 0; i < dirs.length; i++) { + var qbsFileDir = rootPath + "/" + dir + dirs[i] + "/" + if (File.exists(qbsFileDir + "project.qbs") || File.exists(qbsFileDir + dirs[i] + ".qbs")) result.push(dir + dirs[i]) + else + findExtensionDirs(rootPath, dir + dirs[i] + "/", result) // Internally trailing slash has to be appended however. + } } var result = [] findExtensionDirs(path, "", result) extensionDirs = result } } } diff --git a/tools/cutehmi.console.0/README.md b/tools/cutehmi.console.0/README.md index 852fb17e..34c4ec6d 100644 --- a/tools/cutehmi.console.0/README.md +++ b/tools/cutehmi.console.0/README.md @@ -1,42 +1,47 @@ # Console Interactive command line interface, which allows one to browse QML object model and evaluate expressions. This tool allows one to execute QML expressions. One specifies an extension and the tool will make an attempt to import that extension and instantiate `Console` component. If the extension does not provide `Console` component an alternative non-GUI -component may be specified with `--component` option. You can use `--help` command line argument to see a list of all possible +component may be specified with next positional argument. You can use `--help` command line argument to see a list of all possible command line options. For example following command imports [Console Example](../../extensions/CuteHMI/Examples/Console.0/) extension, which provides `Console` component allowing for some basic interaction with the tool. ``` cutehmi.console.0 CuteHMI.Examples.Console.0 ``` +Component `Console` could be specified directly. +``` +cutehmi.console.0 CuteHMI.Examples.Console.0 Console +``` + After starting the program, a command prompt is shown. Command line interpreter basically works in two modes: console command mode and QML expression mode. Any string that starts with `\` character is interpreted as console command; everything else is interpreted as QML expression. -For example `\quit` string consists of `quit` command prepended by `\` (which by the implementation is also treated as a command - -the one that enables the console command mode), so it is interpreted as a console command, which quits the console. +For example `\quit` string consists of `quit` command prepended by `\` (which by the way is also treated as a command - the one that +enables the console command mode), so it is interpreted as a console command, which quits the console. ``` # \quit cutehmi.console.0: See you. ``` But the following are QML expressions with the results of evaluation printed below. ``` # 2+2 cutehmi.console.0: QVariant(int, 4) # console.info("huhu") qml: huhu ``` The motiviation behind this tool is to make it possible to conveniently set up or configure an extenision, in situations, when no GUI is available. Creating a schema of a database is an example use case. ## Limitations Except the obvious limitation like inability to represent GUI features or deficiencies of current version, Console may have troubles with extensions that use threads. As it does not provide dedicated output window nor customized input, such extensions may produce glitches in the command line. diff --git a/tools/cutehmi.console.0/src/main.cpp b/tools/cutehmi.console.0/src/main.cpp index 8d69f9e1..3741b1b8 100644 --- a/tools/cutehmi.console.0/src/main.cpp +++ b/tools/cutehmi.console.0/src/main.cpp @@ -1,190 +1,202 @@ #include "../cutehmi.metadata.hpp" #include "../cutehmi.dirs.hpp" #include "cutehmi/console/logging.hpp" #include "cutehmi/console/Exception.hpp" #include "cutehmi/console/Interpreter.hpp" #include "cutehmi/console/InputHandler.hpp" #include #include #include #include #include #include #include #include #include #include using namespace cutehmi::console; /** * Main function. * @param argc number of arguments passed to the program. * @param argv list of arguments passed to the program. * @return return code. */ int main(int argc, char * argv[]) { + static constexpr const char * DEFAULT_COMPONENT = "Console"; + static constexpr const char * DEFAULT_MINOR = "0"; + // Set up application. QCoreApplication::setOrganizationName(CUTEHMI_CONSOLE_VENDOR); QCoreApplication::setOrganizationDomain(CUTEHMI_CONSOLE_DOMAIN); QCoreApplication::setApplicationName(CUTEHMI_CONSOLE_FRIENDLY_NAME); QCoreApplication::setApplicationVersion(QString("%1.%2.%3").arg(CUTEHMI_CONSOLE_MAJOR).arg(CUTEHMI_CONSOLE_MINOR).arg(CUTEHMI_CONSOLE_MICRO)); try { // // "In general, creating QObjects before the QApplication is not supported and can lead to weird crashes on exit, depending on the // platform. This means static instances of QObject are also not supported. A properly structured single or multi-threaded application // should make the QApplication be the first created, and last destroyed QObject." QCoreApplication app(argc, argv); // Translations initial setup. QString language = QLocale::system().name(); #ifdef CUTEHMI_VIEW_DEFAULT_LANGUAGE language = CUTEHMI_VIEW_DEFAULT_LANGUAGE; #endif if (!qgetenv("CUTEHMI_LANGUAGE").isEmpty()) { language = qgetenv("CUTEHMI_LANGUAGE"); CUTEHMI_DEBUG("Language set by 'CUTEHMI_LANGUAGE' environmental variable: " << qgetenv("CUTEHMI_LANGUAGE")); } QTranslator qtTranslator; if (!qtTranslator.load("qt_" + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) CUTEHMI_WARNING("Could not load translations file '" << "qt_" + language << "'."); app.installTranslator(& qtTranslator); QTranslator translator; QString translationsDir = QDir("/" CUTEHMI_DIRS_TOOLS_INSTALL_SUBDIR).relativeFilePath("/" CUTEHMI_DIRS_TRANSLATIONS_INSTALL_SUBDIR); QString translationFilePrefix = QString(CUTEHMI_CONSOLE_NAME).replace('.', '-') + "_"; QString translationFile = translationFilePrefix + language; if (!translator.load(translationFile, translationsDir)) CUTEHMI_WARNING("Could not load translations file '" << translationFile << "'."); app.installTranslator(& translator); // Configure command line parser and process arguments. QCommandLineParser cmd; cmd.setApplicationDescription(CUTEHMI_CONSOLE_TRANSLATED_FRIENDLY_NAME + "\n" + CUTEHMI_CONSOLE_TRANSLATED_DESCRIPTION); cmd.addHelpOption(); cmd.addVersionOption(); QCommandLineOption langOption("lang", QCoreApplication::translate("main", "Choose application ."), QCoreApplication::translate("main", "language")); langOption.setDefaultValue(language); cmd.addOption(langOption); QCommandLineOption basedirOption("basedir", QCoreApplication::translate("main", "Set base directory to ."), QCoreApplication::translate("main", "dir")); cmd.addOption(basedirOption); - QCommandLineOption componentOption("component", QCoreApplication::translate("main", "Extension component ."), QCoreApplication::translate("main", "name")); - componentOption.setDefaultValue("Console"); - cmd.addOption(componentOption); - QCommandLineOption minorOption({"m", "minor"}, QCoreApplication::translate("main", "Use for extension minor version to import."), QCoreApplication::translate("main", "version")); - minorOption.setDefaultValue("0"); + minorOption.setDefaultValue(DEFAULT_MINOR); cmd.addOption(minorOption); cmd.addPositionalArgument("extension", QCoreApplication::translate("main", "Extension to import."), "[extension]"); - cmd.addPositionalArgument("component", QCoreApplication::translate("main", "Component to create."), "[component]"); + cmd.addPositionalArgument("component", QCoreApplication::translate("main", "Component to create. Defaults to '%1'.").arg(DEFAULT_COMPONENT), "[component]"); cmd.process(app); // Finalize setting up translations. CUTEHMI_DEBUG("Default locale: " << QLocale()); CUTEHMI_DEBUG("Language: " << cmd.value(langOption)); if (!qtTranslator.load("qt_" + cmd.value(langOption), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) CUTEHMI_WARNING("Could not load translations file '" << "qt_" + cmd.value(langOption) << "'."); translationFile = translationFilePrefix + cmd.value(langOption); if (!translator.load(translationFile, translationsDir)) CUTEHMI_WARNING("Could not load translations file '" << translationFile << "'."); // Prepare QML engine. QDir baseDir(QCoreApplication::applicationDirPath() + "/.."); if (cmd.isSet(basedirOption)) baseDir.setPath(cmd.value(basedirOption)); QString baseDirPath = baseDir.absolutePath() + "/"; CUTEHMI_DEBUG("Base directory: " << baseDirPath); CUTEHMI_DEBUG("Library paths: " << QCoreApplication::libraryPaths()); std::unique_ptr engine(new QQmlApplicationEngine); engine->addImportPath(baseDirPath + CUTEHMI_DIRS_EXTENSIONS_INSTALL_SUBDIR); CUTEHMI_DEBUG("QML import paths: " << engine->importPathList()); CUTEHMI_INFO(QCoreApplication::translate("main", "Welcome to %1 %2. Type \\help to see the list of commands.").arg(CUTEHMI_CONSOLE_VENDOR).arg(CUTEHMI_CONSOLE_FRIENDLY_NAME)); QStringList positionalArguments = cmd.positionalArguments(); if (positionalArguments.length() > 0) { QString extension = positionalArguments.at(0); QString extensionBaseName = extension.left(extension.lastIndexOf('.')); QString extensionMajor = extension.right(extension.length() - extension.lastIndexOf('.') - 1); + { + bool ok; + extensionMajor.toUInt(& ok); + if (!ok) + throw Exception(QCoreApplication::translate("main", "Command line argument error: please specify extension with major version number after the last dot.")); + } QString extensionMinor = cmd.value(minorOption); if (!extensionMinor.isEmpty()) { bool ok; extensionMinor.toUInt(& ok); if (!ok) throw Exception(QCoreApplication::translate("main", "Command line argument error: value of '%1' option must be a number.").arg(minorOption.names().last())); } - QString extensionComponent = cmd.value(componentOption); + QString extensionComponent; + if (positionalArguments.length() == 2) + extensionComponent = positionalArguments.at(1); + else + extensionComponent = DEFAULT_COMPONENT; QString extensionImportStatement; if (!extension.isEmpty()) { if (!extensionMinor.isEmpty()) extensionImportStatement = QString("import %1 %2.%3").arg(extensionBaseName).arg(extensionMajor).arg(extensionMinor); else extensionImportStatement = QString("import %1 %2").arg(extensionBaseName).arg(extensionMajor); } + CUTEHMI_INFO(QCoreApplication::translate("main", "Extension: '%1 %2.%3'").arg(extensionBaseName).arg(extensionMajor).arg(extensionMinor)); + CUTEHMI_INFO(QCoreApplication::translate("main", "Component: '%1'").arg(extensionComponent)); + engine->loadData((extensionImportStatement + "\n" + extensionComponent + "{}").toLocal8Bit()); } InputHandler inputHandler; Interpreter interpreter(engine.get()); QObject::connect(& inputHandler, & InputHandler::lineRead, & interpreter, & Interpreter::interperetLine, Qt::QueuedConnection); QObject::connect(& interpreter, & Interpreter::lineInterpreted, & inputHandler, & InputHandler::readLine, Qt::QueuedConnection); inputHandler.readLine(); return app.exec(); // } catch (const cutehmi::Messenger::NoAdvertiserException & e) { CUTEHMI_CRITICAL("Dialog message: " << e.message()->text()); if (!e.message()->informativeText().isEmpty()) CUTEHMI_CRITICAL("Informative text: " << e.message()->informativeText()); if (!e.message()->detailedText().isEmpty()) CUTEHMI_CRITICAL("Detailed text: " << e.message()->detailedText()); CUTEHMI_CRITICAL("Available buttons: " << e.message()->buttons()); } catch (const QException & e) { CUTEHMI_CRITICAL(e.what()); } catch (const std::exception & e) { CUTEHMI_CRITICAL(e.what()); } catch (...) { CUTEHMI_CRITICAL("Caught unrecognized exception."); throw; } return EXIT_FAILURE; } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.daemon.2/README.md b/tools/cutehmi.daemon.2/README.md index 4c086203..efef794a 100644 --- a/tools/cutehmi.daemon.2/README.md +++ b/tools/cutehmi.daemon.2/README.md @@ -1,95 +1,97 @@ # Daemon +**Obsolete** - this tool is being replaced by [cutehmi.daemon.3](../cutehmi.daemon.3/). + Console program, which allows one to run QML project in the background. Daemon mode is currently supported only on Linux. On Windows program can be run in application mode only (`--app` option). Any extension that does not provide graphical UI QML component can be loaded as *cutehmi.daemon.2* project. Use `--extension` command line argument to specify an extension. For example to run [Count Daemon](../../extensions/CuteHMI/Examples/CountDaemon.2/) example use following command. ``` cutehmi.daemon.2 --extension="CuteHMI.Examples.CountDaemon.2" ``` Read system logs to investigate whether daemon is running (e.g. `journalctl -n20` on a system with *systemd*). One may use `--app` option to tell the program to work as a foreground process (this can be useful when testing projects). For example following command runs [Count Daemon](../../extensions/CuteHMI/Examples/CountDaemon.2/) in application mode. ``` cutehmi.daemon.2 --extension="CuteHMI.Examples.CountDaemon.2" --app ``` Default loader picks `Main.qml` as default QML component to load. Component can be specified with `--component` option. One can also use `--init` option to replace default loader with custom one. You can use `--help` command line argument to see the list of all possible command line options. Setting empty path for PID file option (`--pidfile=`) disables creation of PID file. Fore debug builds use `cutehmi.daemon.2.debug` instead of `cutehmi.daemon.2`. ## Linux ### Signals Under Unix daemon will respond to signals in a following way. - SIGTERM tells daemon to gracefully quit with exit code set to EXIT_SUCCESS (0 on almost all systems). - SIGINT tells daemon to gracefully quit, but exit code will be set to 128 + signal code. - SIGQUIT causes violent termination and exits via abort. - SIGHUP attempts to reload the project as if daemon has been restarted. ### Forking Daemon is a program, which is supposed to work as a background process. This could be achieved in many ways, but lots of traditional UNIX daemons have been accomplishing it through techniques, which involve forking. Unfortunately this spots a controversy. It comes out there are three conflicting schools on how many forks daemon should perform. According to these daemon should fork once, twice or not fork at all... Detailed description on the topic is out of the scope of this document, but here are some major points. #### Single forking daemon Single fork is performed to exit the parent process and get rid of controlling terminal. After forking, daemon can become a new session leader, so that when user logs out from the session, process is not killed along with processes associated with that session. This is how [daemon()][3] function has been implemented. #### Double forking daemon After first fork process can still acquire controlling terminal if it opens tty according to System V rules [[1]]. Second fork prevents this [[2]]. Unfortunately this approach heavily obscures process hierarchy, because daemon continues as orphaned process. Notably *systemd* has troubles handling double-forking daemons as service units. [Documentation](https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=) of *systemd* is explicit about expected behaviour of daemon for forking service type. ``` If set to forking, it is expected that the process configured with ExecStart= will call fork() as part of its start-up. The parent process is expected to exit when start-up is complete and all communication channels are set up. The child continues to run as the main service process, and the service manager will consider the unit started when the parent process exits. ``` In double-forking approach the child won't continue as main service process, but rather its own child will do. This can deceive *systemd* to think that daemon finished. #### No forking Many people advice to not fork at all, as it is a domain of the user to detrmine the way how the program shall be run. By this view program should not daemonize itself. Instead it can be run as a background process (by putting `&` after the command) and tools such as *screen* and *nohup* can be used to prevent process from being killed when user logs out [[4]]. --- There are some valid points in each of these views, so *cutehmi.daemon.2* allows you to pick number of forks by setting `--nforks={number}` parameter. For *systemd* service pick `--nforks=1` and use `Type=forking` or `--nforks=0` with `Type=simple`. Note that `--nforks=0` is not the same as application mode (`--app` option) - daemon uses system logging facility instead of standard output, responds to signals, unlocks former working directory, creates PID file, closes file descriptors and resets its umask. ## References 1. [Stephen A. Rago, W. Richard Stevens, "Advanced Programming in the UNIX® Environment: Second Edition", Chapter 13. Daemon Processes.][1] 2. [Andries Brouwer, "The Linux kernel".][2] 3. [Linux Programmer's Manual, DAEMON(3)][3] 4. [Department of Health Technology, "Processes; foreground and background, ps, top, kill, screen, nohup and daemons".][4] [1]: https://learning.oreilly.com/library/view/advanced-programming-in/0201433079/ [2]: https://www.win.tue.nl/~aeb/linux/lk/lk-10.html [3]: http://man7.org/linux/man-pages/man3/daemon.3.html [4]: http://teaching.healthtech.dtu.dk/unix/index.php/Processes;_foreground_and_background,_ps,_top,_kill,_screen,_nohup_and_daemons diff --git a/tools/cutehmi.daemon.3/LICENSE b/tools/cutehmi.daemon.3/LICENSE new file mode 100644 index 00000000..0a041280 --- /dev/null +++ b/tools/cutehmi.daemon.3/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/tools/cutehmi.daemon.3/LICENSE.C.dslash.inc b/tools/cutehmi.daemon.3/LICENSE.C.dslash.inc new file mode 100644 index 00000000..3604b204 --- /dev/null +++ b/tools/cutehmi.daemon.3/LICENSE.C.dslash.inc @@ -0,0 +1,6 @@ + +//(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.daemon.3/LICENSE.C.hash.inc b/tools/cutehmi.daemon.3/LICENSE.C.hash.inc new file mode 100644 index 00000000..daa303be --- /dev/null +++ b/tools/cutehmi.daemon.3/LICENSE.C.hash.inc @@ -0,0 +1,6 @@ + +#(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +#(c)C: This file is a part of CuteHMI. +#(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +#(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +#(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.daemon.2/README.md b/tools/cutehmi.daemon.3/README.md similarity index 77% copy from tools/cutehmi.daemon.2/README.md copy to tools/cutehmi.daemon.3/README.md index 4c086203..12f9d897 100644 --- a/tools/cutehmi.daemon.2/README.md +++ b/tools/cutehmi.daemon.3/README.md @@ -1,95 +1,103 @@ # Daemon Console program, which allows one to run QML project in the background. Daemon mode is currently supported only on Linux. On Windows program can be run in application mode only (`--app` option). -Any extension that does not provide graphical UI QML component can be loaded as *cutehmi.daemon.2* project. Use `--extension` -command line argument to specify an extension. For example to run -[Count Daemon](../../extensions/CuteHMI/Examples/CountDaemon.2/) example use following command. - +Any extension that does not provide graphical UI QML component can be loaded as *cutehmi.daemon.3* project. Use positional argument +to specify an extension. For example to run [Count Daemon](../../extensions/CuteHMI/Examples/CountDaemon.3/) example use following +command. ``` -cutehmi.daemon.2 --extension="CuteHMI.Examples.CountDaemon.2" +cutehmi.daemon.3 CuteHMI.Examples.CountDaemon.3 ``` Read system logs to investigate whether daemon is running (e.g. `journalctl -n20` on a system with *systemd*). One may use `--app` option to tell the program to work as a foreground process (this can be useful when testing projects). -For example following command runs [Count Daemon](../../extensions/CuteHMI/Examples/CountDaemon.2/) in application mode. +For example following command runs [Count Daemon](../../extensions/CuteHMI/Examples/CountDaemon.3/) in application mode. ``` -cutehmi.daemon.2 --extension="CuteHMI.Examples.CountDaemon.2" --app +cutehmi.daemon.3 CuteHMI.Examples.CountDaemon.3 --app ``` -Default loader picks `Main.qml` as default QML component to load. Component can be specified with `--component` option. One can also -use `--init` option to replace default loader with custom one. +Default loader picks `Daemon.qml` as default QML component to load. Component can be specified with second positional argument. + +One can also use `--init` option to replace default loader with custom one. You can use `--help` command line argument to see the list of all possible command line options. Setting empty path for PID file option (`--pidfile=`) disables creation of PID file. -Fore debug builds use `cutehmi.daemon.2.debug` instead of `cutehmi.daemon.2`. +Fore debug builds use `cutehmi.daemon.3.debug` instead of `cutehmi.daemon.3`. ## Linux ### Signals Under Unix daemon will respond to signals in a following way. - SIGTERM tells daemon to gracefully quit with exit code set to EXIT_SUCCESS (0 on almost all systems). - SIGINT tells daemon to gracefully quit, but exit code will be set to 128 + signal code. - SIGQUIT causes violent termination and exits via abort. - SIGHUP attempts to reload the project as if daemon has been restarted. ### Forking Daemon is a program, which is supposed to work as a background process. This could be achieved in many ways, but lots of traditional UNIX daemons have been accomplishing it through techniques, which involve forking. Unfortunately this spots a controversy. It comes out there are three conflicting schools on how many forks daemon should perform. According to these daemon should fork once, twice or not fork at all... Detailed description on the topic is out of the scope of this document, but here are some major points. #### Single forking daemon Single fork is performed to exit the parent process and get rid of controlling terminal. After forking, daemon can become a new session leader, so that when user logs out from the session, process is not killed along with processes associated with that session. This is how [daemon()][3] function has been implemented. #### Double forking daemon After first fork process can still acquire controlling terminal if it opens tty according to System V rules [[1]]. Second fork prevents this [[2]]. Unfortunately this approach heavily obscures process hierarchy, because daemon continues as orphaned process. Notably *systemd* has troubles handling double-forking daemons as service units. [Documentation](https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=) of *systemd* is explicit about expected behaviour of daemon for forking service type. ``` If set to forking, it is expected that the process configured with ExecStart= will call fork() as part of its start-up. The parent process is expected to exit when start-up is complete and all communication channels are set up. The child continues to run as the main service process, and the service manager will consider the unit started when the parent process exits. ``` In double-forking approach the child won't continue as main service process, but rather its own child will do. This can deceive *systemd* to think that daemon finished. #### No forking Many people advice to not fork at all, as it is a domain of the user to detrmine the way how the program shall be run. By this view program should not daemonize itself. Instead it can be run as a background process (by putting `&` after the command) and tools such as *screen* and *nohup* can be used to prevent process from being killed when user logs out [[4]]. --- -There are some valid points in each of these views, so *cutehmi.daemon.2* allows you to pick number of forks by setting -`--nforks={number}` parameter. For *systemd* service pick `--nforks=1` and use `Type=forking` or `--nforks=0` with `Type=simple`. -Note that `--nforks=0` is not the same as application mode (`--app` option) - daemon uses system logging facility instead of +There are some valid points in each of these views, so *cutehmi.daemon.3* allows you to pick number of forks by setting +`--forks={number}` parameter. For *systemd* service pick `--forks=1` and use `Type=forking` or `--forks=0` with `Type=simple`. +Note that `--forks=0` is not the same as application mode (`--app` option) - daemon uses system logging facility instead of standard output, responds to signals, unlocks former working directory, creates PID file, closes file descriptors and resets its umask. +## Changes + +Compared to previous major version following changes were made. +- Daemon looks for `Daemon` QML component instead of Main`. +- Extension is specified with first positional argument instead of `--extension` argument. +- Component is specified with second positional argument instead of `--component` argument. +- Option `--nforks` has been renamed to `--forks`. + ## References 1. [Stephen A. Rago, W. Richard Stevens, "Advanced Programming in the UNIX® Environment: Second Edition", Chapter 13. Daemon Processes.][1] 2. [Andries Brouwer, "The Linux kernel".][2] 3. [Linux Programmer's Manual, DAEMON(3)][3] 4. [Department of Health Technology, "Processes; foreground and background, ps, top, kill, screen, nohup and daemons".][4] [1]: https://learning.oreilly.com/library/view/advanced-programming-in/0201433079/ [2]: https://www.win.tue.nl/~aeb/linux/lk/lk-10.html [3]: http://man7.org/linux/man-pages/man3/daemon.3.html [4]: http://teaching.healthtech.dtu.dk/unix/index.php/Processes;_foreground_and_background,_ps,_top,_kill,_screen,_nohup_and_daemons diff --git a/tools/cutehmi.daemon.3/dev/cutehmi.daemon-1.workaround.Qt.QTBUG-73649.txt b/tools/cutehmi.daemon.3/dev/cutehmi.daemon-1.workaround.Qt.QTBUG-73649.txt new file mode 100644 index 00000000..ed4a76a7 --- /dev/null +++ b/tools/cutehmi.daemon.3/dev/cutehmi.daemon-1.workaround.Qt.QTBUG-73649.txt @@ -0,0 +1,28 @@ +Problem: + +Class QQmlApplicationEngine connects Qt.quit() signal to +QCoreApplication::quit() and QQmlApplicationEngine::exit() signal to +QCoreApplication::exit(), but it does so with AutoConnection. This causes in +some circumstances problems, which are described in Qt documentation. + +"It's good practice to always connect signals to this slot using a +QueuedConnection. If a signal connected (non-queued) to this slot is emitted +before control enters the main event loop (such as before "int main" calls +exec()), the slot has no effect and the application never exits. Using a queued +connection ensures that the slot will not be invoked until after control enters +the main event loop." -- Qt documentation on QCoreApplication::exit(). + +Investigation: + +File qtdeclarative/src/qml/qml/qqmlapplicationengine.cpp contains method +QQmlApplicationEnginePrivate::init(), which contains following lines. + +``` +q->connect(q, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit())); +q->connect(q, &QQmlApplicationEngine::exit, QCoreApplication::instance(), &QCoreApplication::exit); +``` + +Workaround: + +Disconnect signals and connect them again with QueuedConnection. + diff --git a/tools/cutehmi.daemon.3/doc/project_logo.png b/tools/cutehmi.daemon.3/doc/project_logo.png new file mode 100644 index 00000000..c5bc24be Binary files /dev/null and b/tools/cutehmi.daemon.3/doc/project_logo.png differ diff --git a/tools/cutehmi.daemon.3/project.qbs b/tools/cutehmi.daemon.3/project.qbs new file mode 100644 index 00000000..16ac1932 --- /dev/null +++ b/tools/cutehmi.daemon.3/project.qbs @@ -0,0 +1,109 @@ +import qbs 1.0 + +import cutehmi + +Project { + name: "cutehmi.daemon.3" + + condition: !qbs.targetOS.contains("android") + + references: [ + "tests/tests.qbs" + ] + + cutehmi.Tool { + name: parent.name + + consoleApplication: true + + vendor: "CuteHMI" + + domain: "cutehmi.kde.org" + + friendlyName: "Daemon" + + description: "Console program, which allows one to run QML project in the background." + + files: [ + "README.md", + "dev/cutehmi.daemon-1.workaround.Qt.QTBUG-73649.txt", + "qml/ExtensionLoader.qml", + "resources.qrc", + "src/cutehmi/daemon/CoreData.hpp", + "src/cutehmi/daemon/Daemon.cpp", + "src/cutehmi/daemon/Daemon.hpp", + "src/cutehmi/daemon/Exception.cpp", + "src/cutehmi/daemon/Exception.hpp", + "src/cutehmi/daemon/logging.cpp", + "src/cutehmi/daemon/logging.hpp", + "src/main.cpp", + ] + + property string defaultExtension + + property string defaultMinor + + property string defaultInit + + property string defaultComponent + +// property string defaultLanguage + + property bool forceDefaultOptions: false + + cpp.defines: { + var result = [] + + if (defaultExtension) + result.push("CUTEHMI_DAEMON_DEFAULT_EXTENSION=\"" + defaultExtension + "\"") + + if (defaultMinor) + result.push("CUTEHMI_DAEMON_DEFAULT_MINOR=\"" + defaultMinor + "\"") + + if (defaultInit) + result.push("CUTEHMI_DAEMON_DEFAULT_INIT=\"" + defaultInit + "\"") + + if (defaultComponent) + result.push("CUTEHMI_DAEMON_DEFAULT_COMPONENT=\"" + defaultComponent + "\"") + + if (forceDefaultOptions) + result.push("CUTEHMI_DAEMON_FORCE_DEFAULT_OPTIONS") + +// if (defaultLanguage) +// result.push("CUTEHMI_DAEMON_DEFAULT_LANGUAGE=\"" + defaultLanguage + "\"") + + return result + } + + Group { + name: "Windows" + condition: qbs.targetOS.contains("windows") + files: [ + "src/cutehmi/daemon/Daemon_win.cpp", + ] + } + Group { + name: "Linux" + condition: qbs.targetOS.contains("linux") + files: [ + "src/cutehmi/daemon/Daemon_unix.cpp", + "src/cutehmi/daemon/Daemon_unix.hpp" + ] + } + + cutehmi.dirs.artifacts: true + + Depends { name: "CuteHMI.2" } + + Depends { name: "cutehmi.doxygen" } + cutehmi.doxygen.exclude: ['dev', 'examples', 'tests'] + + Depends { name: "cutehmi.metadata" } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.daemon.3/qml/ExtensionLoader.qml b/tools/cutehmi.daemon.3/qml/ExtensionLoader.qml new file mode 100644 index 00000000..c1bb79b6 --- /dev/null +++ b/tools/cutehmi.daemon.3/qml/ExtensionLoader.qml @@ -0,0 +1,36 @@ +import QtQuick 2.0 + +import CuteHMI 2.0 as CuteHMI + +QtObject { + id: extensionContainer + + Component.onCompleted: { + if (cutehmi_daemon_extensionBaseName && cutehmi_daemon_extensionMajor && cutehmi_daemon_extensionMinor) { + var qmlData = "import " + cutehmi_daemon_extensionBaseName + " " + cutehmi_daemon_extensionMajor + "." + cutehmi_daemon_extensionMinor + qmlData += "\n" + cutehmi_daemon_extensionComponent + " {}\n" + + try { + Qt.createQmlObject(qmlData, extensionContainer) + } catch(error) { + var informativeText = qsTr("Reasons:") + informativeText += "\n" + error.qmlErrors.map(function (obj) { return "- " + obj.message }).join("\n") + "." + + var extensionName = cutehmi_daemon_extensionBaseName + " " + cutehmi_daemon_extensionMajor + "." + cutehmi_daemon_extensionMinor + console.error(qsTr("Could not load extension '%1'.").arg(extensionName)) + console.error(informativeText) + Qt.exit(1) + } + } else { + console.log("No extension specified.") + console.log("Use --help to see available options.") + Qt.quit() + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.daemon.3/resources.qrc b/tools/cutehmi.daemon.3/resources.qrc new file mode 100644 index 00000000..338e6a40 --- /dev/null +++ b/tools/cutehmi.daemon.3/resources.qrc @@ -0,0 +1,5 @@ + + + qml/ExtensionLoader.qml + + diff --git a/tools/cutehmi.daemon.3/src/cutehmi/daemon/CoreData.hpp b/tools/cutehmi.daemon.3/src/cutehmi/daemon/CoreData.hpp new file mode 100644 index 00000000..19844183 --- /dev/null +++ b/tools/cutehmi.daemon.3/src/cutehmi/daemon/CoreData.hpp @@ -0,0 +1,45 @@ +#ifndef H_TOOLS_CUTEHMI_DAEMON_3_SRC_CUTEHMI_DAEMON_COREDATA_HPP +#define H_TOOLS_CUTEHMI_DAEMON_3_SRC_CUTEHMI_DAEMON_COREDATA_HPP + +#include +#include + +namespace cutehmi { +namespace daemon { + +struct CoreData +{ + QCoreApplication * app; + QCommandLineParser * cmd; + QTranslator * qtTranslator; + QTranslator * daemonTranslator; + QString language; + QStringList failedTranslationsFiles; + QString translationsDir; + QString daemonTranslationFilePrefix; + QString daemonTranslationFile; + + struct Options + { + QStringList extension; + QStringList component; + QCommandLineOption app; + QCommandLineOption basedir; + QCommandLineOption init; + QCommandLineOption minor; + QCommandLineOption lang; + QCommandLineOption pidfile; + QCommandLineOption forks; + } * opt; +}; + +} +} + +#endif + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.daemon.3/src/cutehmi/daemon/Daemon.cpp b/tools/cutehmi.daemon.3/src/cutehmi/daemon/Daemon.cpp new file mode 100644 index 00000000..e9d06cef --- /dev/null +++ b/tools/cutehmi.daemon.3/src/cutehmi/daemon/Daemon.cpp @@ -0,0 +1,52 @@ +#include "Daemon.hpp" + +namespace cutehmi { +namespace daemon { + +Daemon::Daemon(CoreData * data, std::function & core): + m_data(data), + m_core(core), + m_exitCode(EXIT_FAILURE) +{ + // + _init(); + // +} + +Daemon::~Daemon() +{ + _destroy(); +} + +int Daemon::exitCode() const +{ + return m_exitCode; +} + +void Daemon::setExitCode(int exitCode) +{ + m_exitCode = exitCode; +} + +int Daemon::exec() +{ + do { + _exec(); + m_exitCode = m_core(*m_data); + } while (m_exitCode == EXIT_AGAIN); + return m_exitCode; +} + +CoreData * Daemon::data() const +{ + return m_data; +} + +} +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/tools/cutehmi.daemon.3/src/cutehmi/daemon/Daemon.hpp similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to tools/cutehmi.daemon.3/src/cutehmi/daemon/Daemon.hpp index fd3e8aa1..b5f45bdb 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/tools/cutehmi.daemon.3/src/cutehmi/daemon/Daemon.hpp @@ -1,54 +1,53 @@ -import qbs +#ifndef H_TOOLS_CUTEHMI_DAEMON_3_SRC_CUTEHMI_DAEMON_DAEMON_HPP +#define H_TOOLS_CUTEHMI_DAEMON_3_SRC_CUTEHMI_DAEMON_DAEMON_HPP -import cutehmi +#include "CoreData.hpp" -Project { - name: "CuteHMI.Symbols.Pipes.1" +#include - cutehmi.Extension { - name: parent.name +namespace cutehmi { +namespace daemon { - friendlyName: "Pipes" +class _Daemon; - vendor: "CuteHMI" +class Daemon final +{ + public: + static constexpr int EXIT_AGAIN = 129; // 128 + SIGHUP (1). - domain: "cutehmi.kde.org" + Daemon(CoreData * data, std::function & core); - description: "Pipe drawing components." + ~Daemon(); // Non-virtual destructor, but class is final. - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] + int exitCode() const; - Depends { name: "CuteHMI.GUI.1" } + protected: + void setExitCode(int exitCode); - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] + int exec(); - Depends { name: "cutehmi.qmldir" } + CoreData * data() const; - Depends { name: "cutehmi.qmltypes" } + private: + void _init(); + + void _exec(); + + void _destroy(); + + CoreData * m_data; + std::function & m_core; + int m_exitCode; + _Daemon * _daemon; +}; - Export { - Depends { name: "CuteHMI.GUI.1" } - } - } } +} + +#endif //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.daemon.3/src/cutehmi/daemon/Daemon_unix.cpp b/tools/cutehmi.daemon.3/src/cutehmi/daemon/Daemon_unix.cpp new file mode 100644 index 00000000..194a40d4 --- /dev/null +++ b/tools/cutehmi.daemon.3/src/cutehmi/daemon/Daemon_unix.cpp @@ -0,0 +1,338 @@ +#include "Daemon.hpp" +#include "Daemon_unix.hpp" +#include "logging.hpp" +#include "../../../cutehmi.metadata.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + +void syslogMessageHandler(QtMsgType type, const QMessageLogContext & context, const QString & msg) +{ + QByteArray localMsg = msg.toLocal8Bit(); + switch (type) { +#ifndef CUTEHMI_NDEBUG + case QtDebugMsg: + syslog(LOG_DEBUG, "%s: %s [%s:%u, %s]", context.category, localMsg.constData(), context.file, context.line, context.function); + break; + case QtInfoMsg: + syslog(LOG_INFO, "%s: %s [%s:%u, %s]", context.category, localMsg.constData(), context.file, context.line, context.function); + break; + case QtWarningMsg: + syslog(LOG_WARNING, "%s: %s [%s:%u, %s]", context.category, localMsg.constData(), context.file, context.line, context.function); + break; + case QtCriticalMsg: + syslog(LOG_CRIT, "%s: %s [%s:%u, %s]", context.category, localMsg.constData(), context.file, context.line, context.function); + break; + case QtFatalMsg: + syslog(LOG_ALERT, "%s: %s [%s:%u, %s]", context.category, localMsg.constData(), context.file, context.line, context.function); + break; +#else + case QtDebugMsg: + syslog(LOG_DEBUG, "%s: %s", context.category, localMsg.constData()); + break; + case QtInfoMsg: + syslog(LOG_INFO, "%s: %s", context.category, localMsg.constData()); + break; + case QtWarningMsg: + syslog(LOG_WARNING, "%s: %s", context.category, localMsg.constData()); + break; + case QtCriticalMsg: + syslog(LOG_CRIT, "%s: %s", context.category, localMsg.constData()); + break; + case QtFatalMsg: + syslog(LOG_ALERT, "%s: %s", context.category, localMsg.constData()); + break; +#endif + } +} + +} + +namespace cutehmi { +namespace daemon { + +void sigHandler(int signal) +{ + // Reference implementation: http://doc.qt.io/qt-5/unix-signals.html. + + ::write(_Daemon::signalFd[0], & signal, sizeof(signal)); +} + +int _Daemon::signalFd[2]; + +_Daemon::_Daemon(const QString & pidFile): + m_pidFile(pidFile), + m_pidFd(-1) +{ +} + +void _Daemon::initializeSignalHandling() +{ + // Reference implementation: http://doc.qt.io/qt-5/unix-signals.html. + + if (::socketpair(AF_UNIX, SOCK_STREAM, 0, signalFd)) + CUTEHMI_DIE("Could not create socket pair for signal handling."); + m_signalSocketNotifier.reset(new QSocketNotifier(signalFd[1], QSocketNotifier::Read)); + connect(m_signalSocketNotifier.get(), & QSocketNotifier::activated, this, & _Daemon::handleSignal); + +} + +void _Daemon::initializePidFile() +{ + if (!m_pidFile.isEmpty()) { + CUTEHMI_DEBUG("PID file path: '" << m_pidFile << "'."); + m_pidFd = createPidFile(); + lockPidFile(); + writePidFile(); + } else + CUTEHMI_WARNING("PID file disabled."); +} + +void _Daemon::destroyPidFile() +{ + if (!m_pidFile.isEmpty()) + removePidFile(); +} + +void _Daemon::handleSignal() +{ + // Reference implementation: http://doc.qt.io/qt-5/unix-signals.html. + + m_signalSocketNotifier->setEnabled(false); + + int signal; + QByteArray signalArr(sizeof(signal), 0); + std::size_t nRead = 0; + do { + ssize_t n = ::read(signalFd[1], signalArr.data() + nRead, sizeof(signal) - nRead); + if (n == -1) { + CUTEHMI_CRITICAL("Fatal error occurred while reading from local socket: " << strerror(errno)); + break; + } + if (n == 0) { + CUTEHMI_CRITICAL("Unexpected EOF occurred while reading from local socket."); + break; + } + nRead += n; + } while (nRead < sizeof(signal)); + + if (nRead == sizeof(signal)) { + signal = *reinterpret_cast(signalArr.data()); + switch (signal) { + case SIGTERM: + CUTEHMI_INFO("Termination requested by SIGTERM (" << signal << ") signal."); + emit exitRequested(EXIT_SUCCESS); + break; + case SIGINT: + CUTEHMI_INFO("Interrupt requested by SIGINT (" << signal << ") signal."); + emit exitRequested(128 + signal); + break; + case SIGHUP: + CUTEHMI_INFO("Restarting due to SIGHUP (" << signal << ") signal."); + emit exitRequested(Daemon::EXIT_AGAIN); + break; + case SIGQUIT: + CUTEHMI_DIE("Aborting due to SIGQUIT (%d) signal.", signal); + default: + CUTEHMI_WARNING("Captured unhandled signal (" << signal << ")."); + } + } else + CUTEHMI_CRITICAL("Unable to encode signal due to internal errors."); + + m_signalSocketNotifier->setEnabled(true); +} + +int _Daemon::createPidFile() +{ + int fd = open(m_pidFile.toLocal8Bit().constData(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + if (fd == -1) + CUTEHMI_DIE("Could not open PID file '%s'; %s.", m_pidFile.toLocal8Bit().constData(), strerror(errno)); + + // Set close-on-exec flag. + int flags = fcntl(fd, F_GETFD); + if (flags == -1) + CUTEHMI_DIE("Could not access flags of PID file '%s'; %s.", m_pidFile.toLocal8Bit().constData(), strerror(errno)); + flags |= FD_CLOEXEC; + if (fcntl(fd, F_SETFD, flags) == -1) + CUTEHMI_DIE("Could not update flags of PID file '%s'; %s.", m_pidFile.toLocal8Bit().constData(), strerror(errno)); + + return fd; +} + +void _Daemon::lockPidFile() +{ + struct flock fl; + + fl.l_type = F_WRLCK; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + + if (fcntl(m_pidFd, F_SETLK, & fl) == -1) { + if (errno == EAGAIN || errno == EACCES) + CUTEHMI_DIE("PID file '%s' is already locked by another process. Ensure that another instance of '" CUTEHMI_DAEMON_NAME "' with the same 'pidfile' option is not already running.", m_pidFile.toLocal8Bit().constData()); + else + CUTEHMI_DIE("Unable to lock PID file '%s'; %s.", m_pidFile.toLocal8Bit().constData(), strerror(errno)); + } +} + +void _Daemon::writePidFile() +{ + if (ftruncate(m_pidFd, 0) == -1) + CUTEHMI_DIE("Could not truncate PID file '%s'.", m_pidFile.toLocal8Bit().constData()); + + QByteArray buff = QByteArray::number(getpid()); + if (static_cast(write(m_pidFd, buff.constData(), static_cast(buff.size()))) != buff.size()) + CUTEHMI_DIE("Could not store PID in the PID file '%s'.", m_pidFile.toLocal8Bit().constData()); +} + +void _Daemon::removePidFile() +{ + if (close(m_pidFd) == -1) + CUTEHMI_DIE("Could not close descriptor of the PID file '%s'; %s.", m_pidFile.toLocal8Bit().constData(), strerror(errno)); + + if (unlink(m_pidFile.toLocal8Bit().constData()) == -1) + CUTEHMI_WARNING("Could not remove PID file '" << m_pidFile << "'; " << strerror(errno) << "."); +} + + +void Daemon::_init() +{ + // + + // Configure logging. + openlog(CUTEHMI_DAEMON_NAME, LOG_PID | LOG_NDELAY, LOG_USER); + qInstallMessageHandler(::syslogMessageHandler); + + // As logging has been configured daemon can use logging macros. Standard file descriptors still have to be closed. + CUTEHMI_INFO("Starting " << CUTEHMI_DAEMON_NAME << "..."); + + int forks; + { + bool ok; + forks = data()->cmd->value(data()->opt->forks).toInt(& ok); + if (!ok) + CUTEHMI_DIE("Provided value for parameter '%s' is not a number.", data()->opt->forks.names()[0].toLocal8Bit().constData()); + else { + if (forks < 0 || forks > 2) + CUTEHMI_DIE("Value of parameter '%s' is out of range [0, 2].", data()->opt->forks.names()[0].toLocal8Bit().constData()); + CUTEHMI_DEBUG("Daemon set up to fork '" << forks << "' time(s)."); + } + } + + if (forks > 0) { + pid_t pid, sid; + + // Detach from controlling tty (tty is given per session). + // Note: when using std::exit() stack unwinding is not performed, which means destructors won't be called. + + // Fork and exit parent process to become a session leader. + pid = fork(); + if (pid < 0) { + CUTEHMI_WARNING("Daemon could not fork."); + std::exit(EXIT_FAILURE); + } else if (pid > 0) + std::exit(EXIT_SUCCESS); // tty session leader quits. + + // "... the child inherits the process group ID of the parent but gets a new process ID, so we’re guaranteed that the child + // is not a process group leader. This is a prerequisite for the call to setsid that is done next." + // -- Stephen A. Rago, W. Richard Stevens, "Advanced Programming in the UNIX® Environment: Second Edition" [Chapter 13. Daemon Processes]. + // Now process may become a session leader and detach from parent session. + sid = setsid(); + if (sid < 0) + CUTEHMI_DIE("Failed to initialize daemon (could not create session)."); + + if (forks > 1) { + // Second fork to become orphan and ensure that process will not acquire tty (see daemon(3)). + // Additionaly process will not receive modem hang-up signals (see Stephen A. Rago, W. Richard Stevens, "Advanced Programming in the UNIX® Environment: Second Edition" [Chapter 9. Process Relationships - Controlling Terminal]). + pid = fork(); + if (pid < 0) { + CUTEHMI_WARNING("Daemon could not fork."); + std::exit(EXIT_FAILURE); + } else if (pid > 0) + std::exit(EXIT_SUCCESS); // Session leader quits. + + // Orphaned daemon process continues... + } + } + + umask(0); + + // This is mainly to avoid locking former working directory. + if ((chdir("/")) < 0) + CUTEHMI_DIE("Failed to change working directory to '/'."); + + // Close file descriptors. + close(STDIN_FILENO); + close(STDOUT_FILENO); + close(STDERR_FILENO); + + // + + // Create helper class. + QString pidFilePath = data()->cmd->value(data()->opt->pidfile); + if (!pidFilePath.isEmpty()) { + if (QDir::isRelativePath(data()->cmd->value(data()->opt->pidfile))) + pidFilePath.prepend(QDir(data()->cmd->value(data()->opt->basedir)).absolutePath() + "/"); + } + _daemon = new _Daemon(pidFilePath); + + // Create exit point through 'terminateRequested' signal. + QObject::connect(_daemon, & _Daemon::exitRequested, [](int exitCode) { + QCoreApplication::exit(exitCode); + }); + + // Initialize signal handling. + _daemon->initializeSignalHandling(); + + // Initialize PID file. + _daemon->initializePidFile(); + + // Install signal handler. + struct sigaction sigAct; + sigAct.sa_handler = sigHandler; + sigemptyset(& sigAct.sa_mask); + sigAct.sa_flags = 0; + sigaction(SIGTERM, & sigAct, nullptr); + sigaction(SIGINT, & sigAct, nullptr); + sigaction(SIGQUIT, & sigAct, nullptr); + sigaction(SIGHUP, & sigAct, nullptr); + + // Execute core. + exec(); +} + +void Daemon::_exec() +{ +} + +void Daemon::_destroy() +{ + CUTEHMI_INFO("Daemon finished execution with exit code '" << exitCode() << "'."); + + _daemon->destroyPidFile(); + _daemon->deleteLater(); + + closelog(); // "The use of closelog() is optional." -- SYSLOG(3). +} + +} +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.daemon.3/src/cutehmi/daemon/Daemon_unix.hpp b/tools/cutehmi.daemon.3/src/cutehmi/daemon/Daemon_unix.hpp new file mode 100644 index 00000000..2e4445bb --- /dev/null +++ b/tools/cutehmi.daemon.3/src/cutehmi/daemon/Daemon_unix.hpp @@ -0,0 +1,65 @@ +#ifndef H_TOOLS_CUTEHMI_DAEMON_3_SRC_CUTEHMI_DAEMON_DAEMON_u_UNIX_HPP +#define H_TOOLS_CUTEHMI_DAEMON_3_SRC_CUTEHMI_DAEMON_DAEMON_u_UNIX_HPP + +#include +#include + +#include + +namespace cutehmi { +namespace daemon { + +class Daemon; + +/** + * Unix-specific daemon helper. + */ +class _Daemon: + public QObject +{ + Q_OBJECT + + public: + static int signalFd[2]; + + _Daemon(const QString & pidFile); + + void initializeSignalHandling(); + + void initializePidFile(); + + void destroyPidFile(); + + signals: + void exitRequested(int exitCode); + + private slots: + void handleSignal(); + + private: + int createPidFile(); + + void lockPidFile(); + + void writePidFile(); + + void removePidFile(); + + private: + QString m_pidFile; + int m_pidFd; + std::unique_ptr m_signalSocketNotifier; + std::unique_ptr m_unhandledSignalsSocketNotifier; +}; + + +} +} + +#endif + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.daemon.3/src/cutehmi/daemon/Daemon_win.cpp b/tools/cutehmi.daemon.3/src/cutehmi/daemon/Daemon_win.cpp new file mode 100644 index 00000000..4f452f18 --- /dev/null +++ b/tools/cutehmi.daemon.3/src/cutehmi/daemon/Daemon_win.cpp @@ -0,0 +1,29 @@ +#include "Daemon.hpp" +#include "logging.hpp" + +namespace cutehmi { +namespace daemon { + +void Daemon::_init() +{ + CUTEHMI_DIE("Windows daemon is not implemented."); +} + +void Daemon::_exec() +{ + CUTEHMI_DIE("Windows daemon is not implemented."); +} + +void Daemon::_destroy() +{ + CUTEHMI_DIE("Windows daemon is not implemented."); +} + +} +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.daemon.3/src/cutehmi/daemon/Exception.cpp b/tools/cutehmi.daemon.3/src/cutehmi/daemon/Exception.cpp new file mode 100644 index 00000000..71831904 --- /dev/null +++ b/tools/cutehmi.daemon.3/src/cutehmi/daemon/Exception.cpp @@ -0,0 +1,18 @@ +#include "Exception.hpp" + +namespace cutehmi { +namespace daemon { + +Exception::Exception(const QString & what): + Parent(what) +{ +} + +} +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.daemon.3/src/cutehmi/daemon/Exception.hpp b/tools/cutehmi.daemon.3/src/cutehmi/daemon/Exception.hpp new file mode 100644 index 00000000..68ea28cd --- /dev/null +++ b/tools/cutehmi.daemon.3/src/cutehmi/daemon/Exception.hpp @@ -0,0 +1,27 @@ +#ifndef H_TOOLS_CUTEHMI_DAEMON_3_SRC_CUTEHMI_DAEMON_EXCEPTION_HPP +#define H_TOOLS_CUTEHMI_DAEMON_3_SRC_CUTEHMI_DAEMON_EXCEPTION_HPP + +#include + +namespace cutehmi { +namespace daemon { + +class Exception: + public ExceptionMixin +{ + typedef ExceptionMixin Parent; + + public: + Exception(const QString & what); +}; + +} +} + +#endif + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.daemon.3/src/cutehmi/daemon/logging.cpp b/tools/cutehmi.daemon.3/src/cutehmi/daemon/logging.cpp new file mode 100644 index 00000000..490e0ea0 --- /dev/null +++ b/tools/cutehmi.daemon.3/src/cutehmi/daemon/logging.cpp @@ -0,0 +1,10 @@ +#include "logging.hpp" +#include "../../../cutehmi.metadata.hpp" + +Q_LOGGING_CATEGORY(cutehmi_daemon_loggingCategory, CUTEHMI_DAEMON_NAME) + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.daemon.3/src/cutehmi/daemon/logging.hpp b/tools/cutehmi.daemon.3/src/cutehmi/daemon/logging.hpp new file mode 100644 index 00000000..b42b6df3 --- /dev/null +++ b/tools/cutehmi.daemon.3/src/cutehmi/daemon/logging.hpp @@ -0,0 +1,26 @@ +#ifndef H_TOOLS_CUTEHMI_DAEMON_3_SRC_CUTEHMI_DAEMON_LOGGING_HPP +#define H_TOOLS_CUTEHMI_DAEMON_3_SRC_CUTEHMI_DAEMON_LOGGING_HPP + +#include + +Q_DECLARE_LOGGING_CATEGORY(cutehmi_daemon_loggingCategory) + +namespace cutehmi { +namespace daemon { + +inline +const QLoggingCategory & loggingCategory() +{ + return cutehmi_daemon_loggingCategory(); +} + +} +} + +#endif + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.daemon.3/src/main.cpp b/tools/cutehmi.daemon.3/src/main.cpp new file mode 100644 index 00000000..fc314754 --- /dev/null +++ b/tools/cutehmi.daemon.3/src/main.cpp @@ -0,0 +1,329 @@ +#include "../cutehmi.metadata.hpp" +#include "../cutehmi.dirs.hpp" +#include "cutehmi/daemon/logging.hpp" +#include "cutehmi/daemon/Daemon.hpp" +#include "cutehmi/daemon/CoreData.hpp" +#include "cutehmi/daemon/Exception.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace cutehmi::daemon; + +/** + * Main function. + * @param argc number of arguments passed to the program. + * @param argv list of arguments passed to the program. + * @return return code. + */ +int main(int argc, char * argv[]) +{ +#ifdef CUTEHMI_DAEMON_DEFAULT_INIT + static constexpr const char * DEFAULT_INIT = CUTEHMI_DAEMON_DEFAULT_INIT; +#else + static constexpr const char * DEFAULT_INIT = "qrc:/qml/ExtensionLoader.qml"; +#endif + +#ifdef CUTEHMI_DAEMON_DEFAULT_EXTENSION + static constexpr const char * DEFAULT_EXTENSION = CUTEHMI_DAEMON_DEFAULT_EXTENSION; +#else + static constexpr const char * DEFAULT_EXTENSION = ""; +#endif + +#ifdef CUTEHMI_DAEMON_DEFAULT_COMPONENT + static constexpr const char * DEFAULT_COMPONENT = CUTEHMI_DAEMON_DEFAULT_COMPONENT; +#else + static constexpr const char * DEFAULT_COMPONENT = "Daemon"; +#endif + +#ifdef CUTEHMI_DAEMON_DEFAULT_MINOR + static constexpr const char * DEFAULT_MINOR = CUTEHMI_DAEMON_DEFAULT_MINOR; +#else + static constexpr const char * DEFAULT_MINOR = "0"; +#endif + + static constexpr const char * DEFAULT_FORKS = "2"; + + // + // Output shall remain silent until daemon logging is set up. + + // + // "In general, creating QObjects before the QApplication is not supported and can lead to weird crashes on exit, depending on the + // platform. This means static instances of QObject are also not supported. A properly structured single or multi-threaded application + // should make the QApplication be the first created, and last destroyed QObject." + + // Set up application. + + QCoreApplication::setOrganizationName(CUTEHMI_DAEMON_VENDOR); + QCoreApplication::setOrganizationDomain(CUTEHMI_DAEMON_DOMAIN); + QCoreApplication::setApplicationName(CUTEHMI_DAEMON_FRIENDLY_NAME); + QCoreApplication::setApplicationVersion(QString("%1.%2.%3").arg(CUTEHMI_DAEMON_MAJOR).arg(CUTEHMI_DAEMON_MINOR).arg(CUTEHMI_DAEMON_MICRO)); + + QCoreApplication app(argc, argv); + + + // Initial language setup. + + QString language = QLocale::system().name(); + QStringList failedTranslationsFiles; +#ifdef CUTEHMI_VIEW_DEFAULT_LANGUAGE + language = CUTEHMI_VIEW_DEFAULT_LANGUAGE; +#endif + if (!qgetenv("CUTEHMI_LANGUAGE").isEmpty()) + language = qgetenv("CUTEHMI_LANGUAGE"); + + QTranslator qtTranslator; + if (!qtTranslator.load("qt_" + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + failedTranslationsFiles.append("qt_" + language); + app.installTranslator(& qtTranslator); + + QTranslator daemonTranslator; + QString translationsDir = QDir("/" CUTEHMI_DIRS_TOOLS_INSTALL_SUBDIR).relativeFilePath("/" CUTEHMI_DIRS_TRANSLATIONS_INSTALL_SUBDIR); + QString daemonTranslationFilePrefix = QString(CUTEHMI_DAEMON_NAME).replace('.', '-') + "_"; + QString daemonTranslationFile = daemonTranslationFilePrefix + language; + if (!daemonTranslator.load(daemonTranslationFile, translationsDir)) + failedTranslationsFiles.append(daemonTranslationFile); + app.installTranslator(& daemonTranslator); + + + // Configure command line parser and process arguments. + + QCommandLineParser cmd; + cmd.setApplicationDescription(CUTEHMI_DAEMON_TRANSLATED_FRIENDLY_NAME + "\n" + CUTEHMI_DAEMON_TRANSLATED_DESCRIPTION); + cmd.addHelpOption(); + cmd.addVersionOption(); + CoreData::Options opt { + QStringList({"extension", QCoreApplication::translate("main", "Extension to import."), "[extension]"}), + QStringList({"component", QCoreApplication::translate("main", "Component to create. Defaults to '%1'.").arg(DEFAULT_COMPONENT), "[component]"}), + QCommandLineOption("app", QCoreApplication::translate("main", "Run project in application mode.")), + QCommandLineOption("basedir", QCoreApplication::translate("main", "Set base directory to ."), QCoreApplication::translate("main", "dir")), + QCommandLineOption("init", QCoreApplication::translate("main", "Override loader by specifying initial QML to load."), QCoreApplication::translate("main", "file")), + QCommandLineOption({"m", "minor"}, QCoreApplication::translate("main", "Use for extension minor version to import."), QCoreApplication::translate("main", "version")), + QCommandLineOption("lang", QCoreApplication::translate("main", "Choose application ."), QCoreApplication::translate("main", "language")), + QCommandLineOption("pidfile", QCoreApplication::translate("main", "PID file (Unix-specific)."), QCoreApplication::translate("main", "path")), + QCommandLineOption("forks", QCoreApplication::translate("main", "Denotes of forks the daemon should perform (Unix-specific)."), QCoreApplication::translate("main", "number")), + }; + opt.init.setDefaultValue(DEFAULT_INIT); + opt.minor.setDefaultValue(DEFAULT_MINOR); + opt.pidfile.setDefaultValue(QString("/var/run/") + CUTEHMI_DAEMON_NAME ".pid"); + opt.pidfile.setDescription(opt.pidfile.description() + "\nDefault value: '" + opt.pidfile.defaultValues().at(0) + "'."); + opt.basedir.setDefaultValue(QDir(QCoreApplication::applicationDirPath() + "/..").canonicalPath()); + opt.basedir.setDescription(opt.basedir.description() + "\nDefault value: '" + opt.basedir.defaultValues().at(0) + "'."); + opt.forks.setDefaultValue(DEFAULT_FORKS); + opt.forks.setDescription(opt.forks.description() + "\nDefault value: '" + opt.forks.defaultValues().at(0) + "'."); + cmd.addOption(opt.app); + cmd.addOption(opt.basedir); + cmd.addOption(opt.init); + cmd.addOption(opt.minor); + cmd.addOption(opt.lang); + cmd.addOption(opt.pidfile); + cmd.addOption(opt.forks); +#ifdef CUTEHMI_DAEMON_FORCE_DEFAULT_OPTIONS + opt.init.setFlags(QCommandLineOption::HiddenFromHelp); + opt.minor.setFlags(QCommandLineOption::HiddenFromHelp); +#else + cmd.addPositionalArgument(opt.extension.at(0), opt.extension.at(1), opt.extension.at(2)); + cmd.addPositionalArgument(opt.component.at(0), opt.component.at(1), opt.component.at(2)); +#endif + cmd.process(app); + + + // Prepare program core. + + CoreData coreData; + coreData.app = & app; + coreData.cmd = & cmd; + coreData.opt = & opt; + coreData.qtTranslator = & qtTranslator; + coreData.daemonTranslator = & daemonTranslator; + coreData.language = language; + coreData.translationsDir = translationsDir; + coreData.daemonTranslationFilePrefix = daemonTranslationFilePrefix; + coreData.daemonTranslationFile = daemonTranslationFile; + coreData.failedTranslationsFiles = failedTranslationsFiles; + + std::function core = [](CoreData & data) { + try { + // Finish language setup. + + if (!qgetenv("CUTEHMI_LANGUAGE").isEmpty()) + CUTEHMI_DEBUG("Language set by 'CUTEHMI_LANGUAGE' environmental variable: " << qgetenv("CUTEHMI_LANGUAGE")); + + if (!data.failedTranslationsFiles.isEmpty()) + for (auto translationsFile : data.failedTranslationsFiles) + CUTEHMI_WARNING("Could not load translations file '" << translationsFile << "'."); + + if (data.cmd->isSet(data.opt->lang)) + data.language = data.cmd->value(data.opt->lang); + + CUTEHMI_DEBUG("Default locale: " << QLocale()); + CUTEHMI_DEBUG("Language: " << data.language); + + if (!data.qtTranslator->load("qt_" + data.language, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + CUTEHMI_WARNING("Could not load translations file '" << "qt_" + data.language << "'."); + + data.daemonTranslationFilePrefix = QString(CUTEHMI_DAEMON_NAME).replace('.', '-') + "_"; + data.daemonTranslationFile = data.daemonTranslationFilePrefix + data.language; + if (!data.daemonTranslator->load(data.daemonTranslationFile, data.translationsDir)) + CUTEHMI_WARNING("Could not load translations file '" << data.daemonTranslationFile << "'."); + + + QDir baseDir = data.cmd->value(data.opt->basedir); + QString baseDirPath = baseDir.absolutePath() + "/"; + CUTEHMI_DEBUG("Base directory: " << baseDirPath); + + CUTEHMI_DEBUG("Library paths: " << QCoreApplication::libraryPaths()); + + QQmlApplicationEngine engine; + engine.addImportPath(baseDirPath + CUTEHMI_DIRS_EXTENSIONS_INSTALL_SUBDIR); + CUTEHMI_DEBUG("QML import paths: " << engine.importPathList()); + + QStringList positionalArguments = data.cmd->positionalArguments(); +#ifndef CUTEHMI_DAEMON_FORCE_DEFAULT_OPTIONS + QString extension; + if (positionalArguments.length() > 0) + extension = positionalArguments.at(0); + else + extension = DEFAULT_EXTENSION; + + QString extensionMinor = data.cmd->value(data.opt->minor); + QString init = data.cmd->value(data.opt->init); + QString component; + if (positionalArguments.length() > 1) + component = positionalArguments.at(1); + else + component = DEFAULT_COMPONENT; +#else + QString extension = DEFAULT_EXTENSION; + QString component = DEFAULT_COMPONENT; + QString extensionMinor = data.opt->minor.defaultValues().first(); + QString init = data.opt->init.defaultValues().first(); + + if (positionalArguments.length() > 1) + throw Exception(QCoreApplication::translate("main", "You can not use 'component' option, because 'forceDefaultOptions' option has been set during compilation time.").toLocal8Bit().constData()); + if (positionalArguments.length() > 0) + throw Exception(QCoreApplication::translate("main", "You can not use 'extension' option, because 'forceDefaultOptions' option has been set during compilation time.").toLocal8Bit().constData()); + if (data.cmd->value(data.opt->minor) != extensionMinor) + throw Exception(QCoreApplication::translate("main", "You can not use '%1' option, because 'forceDefaultOptions' option has been set during compilation time.").arg(data.opt->minor.names().join(", ")).toLocal8Bit().constData()); + if (data.cmd->value(data.opt->init) != init) + throw Exception(QCoreApplication::translate("main", "You can not use '%1' option, because 'forceDefaultOptions' option has been set during compilation time.").arg(data.opt->init.names().join(", ")).toLocal8Bit().constData()); +#endif + if (!extensionMinor.isEmpty()) { + bool ok; + extensionMinor.toUInt(& ok); + if (!ok) + throw Exception(QCoreApplication::translate("main", "Command line argument error: value of '%1' option must be a number.").arg(data.opt->minor.names().last())); + } + QString extensionBaseName = extension.left(extension.lastIndexOf('.')); + QString extensionMajor = extension.right(extension.length() - extension.lastIndexOf('.') - 1); + { + bool ok; + extensionMajor.toUInt(& ok); + if (!ok) + throw Exception(QCoreApplication::translate("main", "Command line argument error: please specify extension with major version number after the last dot.")); + } + engine.rootContext()->setContextProperty("cutehmi_daemon_extensionBaseName", extensionBaseName); + engine.rootContext()->setContextProperty("cutehmi_daemon_extensionMajor", extensionMajor); + engine.rootContext()->setContextProperty("cutehmi_daemon_extensionMinor", extensionMinor); + engine.rootContext()->setContextProperty("cutehmi_daemon_extensionComponent", component); + + // + // Class QQmlApplicationEngine connects Qt.quit() signal to QCoreApplication::quit() and QQmlApplicationEngine::exit() + // signal to QCoreApplication::exit(), but it does so with AutoConnection. This causes in some circumstances problems, + // which are described in Qt documentation (see QCoreApplication::exit()). Workaround is to disconnect signals and + // connect them again with QueuedConnection. + engine.disconnect(& engine, nullptr, data.app, nullptr); + engine.connect(& engine, SIGNAL(quit()), data.app, SLOT(quit()), Qt::QueuedConnection); + engine.connect(& engine, & QQmlApplicationEngine::exit, data.app, & QCoreApplication::exit, Qt::QueuedConnection); + // + + if (!init.isNull()) { + CUTEHMI_DEBUG("Init: '" << init << "'"); + CUTEHMI_DEBUG("Extension: '" << extension << "'"); + CUTEHMI_DEBUG("Minor: '" << extensionMinor << "'"); + CUTEHMI_DEBUG("Component: '" << component << "'"); + QUrl initUrl(init); + if (initUrl.isValid()) { + // Assure that URL is not mixing relative path with explicitly specified scheme, which is forbidden. QUrl::isValid() doesn't check this out. + if (!initUrl.scheme().isEmpty() && QDir::isRelativePath(initUrl.path())) + throw Exception(QCoreApplication::translate("main", "URL '%1' contains relative path along with URL scheme, which is forbidden.").arg(initUrl.url())); + else { + // If source URL is relative (does not contain scheme), then make absolute URL: file:///baseDirPath/sourceUrl. + if (initUrl.isRelative()) + initUrl = QUrl::fromLocalFile(baseDirPath).resolved(initUrl); + // Check if file exists and eventually set context property. + if (initUrl.isLocalFile() && !QFile::exists(initUrl.toLocalFile())) + throw Exception(QCoreApplication::translate("main", "QML file '%1' does not exist.").arg(initUrl.url())); + else { + engine.load(initUrl.url()); + int result = data.app->exec(); + engine.collectGarbage(); + return result; + } + } + } else + throw Exception(QCoreApplication::translate("main", "Invalid format of QML file URL '%1'.").arg(init)); + } else + throw Exception(QCoreApplication::translate("main", "No initial loader has been specified.")); + + return EXIT_SUCCESS; + + } catch (const Exception & e) { + CUTEHMI_CRITICAL(e.what()); + } catch (const cutehmi::Messenger::NoAdvertiserException & e) { + CUTEHMI_CRITICAL("Dialog message: " << e.message()->text()); + if (!e.message()->informativeText().isEmpty()) + CUTEHMI_CRITICAL("Informative text: " << e.message()->informativeText()); + if (!e.message()->detailedText().isEmpty()) + CUTEHMI_CRITICAL("Detailed text: " << e.message()->detailedText()); + CUTEHMI_CRITICAL("Available buttons: " << e.message()->buttons()); + } catch (const std::exception & e) { + CUTEHMI_CRITICAL(e.what()); + } catch (...) { + CUTEHMI_CRITICAL("Caught unrecognized exception."); + throw; + } + + return EXIT_FAILURE; + }; + + + // Run program core in daemon or application mode. + + int exitCode; + + if (!cmd.isSet(opt.app)) { + Daemon daemon(& coreData, core); + + // At this point logging should be configured and printing facilities silenced. Not much to say anyways... + // + + exitCode = daemon.exitCode(); + } else + exitCode = core(coreData); + + // Destroy singleton instances before QCoreApplication. Ignoring the recommendation to connect clean-up code to the + // aboutToQuit() signal, because for daemon it is always violent termination if QCoreApplication::exec() does not exit. + cutehmi::destroySingletonInstances(); + + return exitCode; + + // +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/tools/cutehmi.daemon.3/tests/Test.qbs similarity index 51% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to tools/cutehmi.daemon.3/tests/Test.qbs index fd3e8aa1..e7f9db64 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/tools/cutehmi.daemon.3/tests/Test.qbs @@ -1,54 +1,18 @@ import qbs import cutehmi -Project { - name: "CuteHMI.Symbols.Pipes.1" +cutehmi.Test +{ + testNamePrefix: parent.parent.name - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] - - Depends { name: "cutehmi.qmldir" } - - Depends { name: "cutehmi.qmltypes" } - - Export { - Depends { name: "CuteHMI.GUI.1" } - } - } + Depends { name: "cutehmi.daemon.3" } + Depends { name: "CuteHMI.2" } + Depends { name: "CuteHMI.Test.0" } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.daemon.3/tests/test_cutehmi_daemon.cpp b/tools/cutehmi.daemon.3/tests/test_cutehmi_daemon.cpp new file mode 100644 index 00000000..24fba961 --- /dev/null +++ b/tools/cutehmi.daemon.3/tests/test_cutehmi_daemon.cpp @@ -0,0 +1,106 @@ +#include +#include + +#include "../cutehmi.dirs.hpp" + +namespace cutehmi { +namespace daemon { + +class test_cutehmi_daemon: + public QObject +{ + Q_OBJECT + + private slots: + void initTestCase(); + + void helpOption(); + + void versionOption(); + + void countDaemonExample(); + + private: + QString m_installDir; + QString m_programPath; +}; + +void test_cutehmi_daemon::initTestCase() +{ + QString m_installDir = qEnvironmentVariable("CUTEHMI_INSTALL_DIR"); + QVERIFY(!m_installDir.isEmpty()); + + QString toolsInstallSubdir = CUTEHMI_DIRS_TOOLS_INSTALL_SUBDIR; + if (!toolsInstallSubdir.isEmpty()) + m_installDir += "/" + toolsInstallSubdir; + + m_programPath = m_installDir + "/cutehmi.daemon.3"; +#ifndef CUTEHMI_NDEBUG + m_programPath += ".debug"; +#endif +} + +void test_cutehmi_daemon::helpOption() +{ + QList argumentsList; + argumentsList << QStringList({"--help"}) + << QStringList({"--h"}); + + for (auto arguments : argumentsList) { + QProcess process; + process.start(m_programPath, arguments); + process.waitForFinished(1000); + QCOMPARE(process.error(), QProcess::UnknownError); + QVERIFY(!process.readAllStandardError().contains("Unknown option")); + QVERIFY(!process.readAllStandardOutput().isEmpty()); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QCOMPARE(process.exitCode(), EXIT_SUCCESS); + } +} + +void test_cutehmi_daemon::versionOption() +{ + QList argumentsList; + argumentsList << QStringList({"--version"}) + << QStringList({"--v"}); + + for (auto arguments : argumentsList) { + QProcess process; + process.start(m_programPath, arguments); + process.waitForFinished(1000); + QCOMPARE(process.error(), QProcess::UnknownError); + QVERIFY(!process.readAllStandardError().contains("Unknown option")); + QVERIFY(!process.readAllStandardOutput().isEmpty()); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QCOMPARE(process.exitCode(), EXIT_SUCCESS); + } +} + +void test_cutehmi_daemon::countDaemonExample() +{ + QProcess process; + QStringList arguments({"--app", "CuteHMI.Examples.CountDaemon.3"}); + process.start(m_programPath, arguments); + QVERIFY(process.waitForFinished()); + + QString stdOut = QString::fromLocal8Bit(process.readAllStandardOutput()); + QString stdErr = QString::fromLocal8Bit(process.readAllStandardError()); + + QVERIFY(stdErr.contains("I can count")); + + QCOMPARE(process.error(), QProcess::UnknownError); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QCOMPARE(process.exitCode(), EXIT_SUCCESS); +} + +} +} + +QTEST_MAIN(cutehmi::daemon::test_cutehmi_daemon) +#include "test_cutehmi_daemon.moc" + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/tools/cutehmi.daemon.3/tests/tests.qbs similarity index 52% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to tools/cutehmi.daemon.3/tests/tests.qbs index fd3e8aa1..e8435cbe 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/tools/cutehmi.daemon.3/tests/tests.qbs @@ -1,54 +1,23 @@ import qbs -import cutehmi +import "Test.qbs" as Test Project { - name: "CuteHMI.Symbols.Pipes.1" + condition: !qbs.targetOS.contains("windows") - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." + Test { + testName: "test_cutehmi_daemon" files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", + "test_cutehmi_daemon.cpp", ] - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] - - Depends { name: "cutehmi.qmldir" } - - Depends { name: "cutehmi.qmltypes" } - - Export { - Depends { name: "CuteHMI.GUI.1" } - } + Depends { name: "CuteHMI.Examples.CountDaemon.3" } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.view.3/README.md b/tools/cutehmi.view.3/README.md index dc7ee197..44104820 100644 --- a/tools/cutehmi.view.3/README.md +++ b/tools/cutehmi.view.3/README.md @@ -1,33 +1,35 @@ # View +**Obsolete** - this tool is being replaced by [cutehmi.view.4](../cutehmi.view.4/). + Client, GUI application, which allows one to run CuteHMI project in a window. By default this tool shows only a simple help screen. ![Default view screenshot](doc/screenshot.png) CuteHMI approach is to treat each project as a first-class QML extension, so the purpose of the tool is to load specified extension and display one of its QML components. Any extension that provides graphical UI QML component can be loaded as *cutehmi.view.3* project. Use `--extension` command line argument to specify an extension. For example to run [Simple View](../../extensions/CuteHMI/Examples/SimpleView.1/) example use following command. ``` cutehmi.view.3 --extension="CuteHMI.Examples.SimpleView.1" ``` To run project from QtCreator click `Projects` -> `Run`. Select `cutehmi.view.3` from `Run configuration`. In the `Command line arguments` box type: `cutehmi.view.3 --extension="CuteHMI.Examples.SimpleView.1"`. The window should look similar to the screenshot below. ![SimpleView screenshot](doc/SimpleView.png) Default loader picks `Main.qml` as default QML component to load. Component can be specified with `--component` option. One can also use `--init` option to replace default loader with custom one. You can use `--help` command line argument to see a list of all possible command line options. For debug builds use `cutehmi.view.3.debug` instead of `cutehmi.view.3`. ## Changes Compared to previous major version, this version uses 'CuteHMI.GUI.1' extension instead of 'CuteHMI.GUI.0'. diff --git a/tools/cutehmi.view.4/LICENSE b/tools/cutehmi.view.4/LICENSE new file mode 100644 index 00000000..0a041280 --- /dev/null +++ b/tools/cutehmi.view.4/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/tools/cutehmi.view.4/LICENSE.C.dslash.inc b/tools/cutehmi.view.4/LICENSE.C.dslash.inc new file mode 100644 index 00000000..3604b204 --- /dev/null +++ b/tools/cutehmi.view.4/LICENSE.C.dslash.inc @@ -0,0 +1,6 @@ + +//(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.view.4/LICENSE.C.hash.inc b/tools/cutehmi.view.4/LICENSE.C.hash.inc new file mode 100644 index 00000000..daa303be --- /dev/null +++ b/tools/cutehmi.view.4/LICENSE.C.hash.inc @@ -0,0 +1,6 @@ + +#(c)C: Copyright © %YEAR%, %AUTHORS%. All rights reserved. +#(c)C: This file is a part of CuteHMI. +#(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +#(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +#(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.view.4/README.md b/tools/cutehmi.view.4/README.md new file mode 100644 index 00000000..0ac06dc5 --- /dev/null +++ b/tools/cutehmi.view.4/README.md @@ -0,0 +1,41 @@ +# View + +Client, GUI application, which allows one to run CuteHMI project in a window. + +By default this tool shows only a simple help screen. + +![Default view screenshot](doc/screenshot.png) + +CuteHMI approach is to treat each project as a first-class QML extension, so the purpose of the tool is to load specified extension +and display one of its QML components. Any extension that provides graphical UI QML component can be loaded as *cutehmi.view.4* +project. Use command line argument to specify an extension. + +For example to run [Simple View](../../extensions/CuteHMI/Examples/SimpleView.2/) example use following command. +``` +cutehmi.view.4 CuteHMI.Examples.SimpleView.2 +``` + +To run project from QtCreator click `Projects` -> `Run`. Select `cutehmi.view.4` from `Run configuration`. In the +`Command line arguments` box type: `CuteHMI.Examples.SimpleView.2`. +The window should look similar to the screenshot below. + +![SimpleView screenshot](doc/SimpleView.png) + +Default loader picks `View` as default QML component to load. Component can be specified with second positional argument. For +example following displays `RectangularElement` component from the previous example. +``` +cutehmi.view.4 CuteHMI.Examples.SimpleView.2 RectangularElement +``` + +One can also use `--init` option to replace default loader with custom one. + +You can use `--help` command line argument to see a list of all possible command line options. + +For debug builds use `cutehmi.view.4.debug` instead of `cutehmi.view.4`. + +## Changes + +Compared to previous major version following changes were made. +- View looks for `View` component instead of `Main`. +- Extension is specified with first positional argument instead of `--extension` argument. +- Component is specified with second positional argument instead of `--component` argument. diff --git a/tools/cutehmi.view.4/dev/cutehmi.view.2-1.solved.Qt.design.txt b/tools/cutehmi.view.4/dev/cutehmi.view.2-1.solved.Qt.design.txt new file mode 100644 index 00000000..3974db15 --- /dev/null +++ b/tools/cutehmi.view.4/dev/cutehmi.view.2-1.solved.Qt.design.txt @@ -0,0 +1,13 @@ +Problem: + +ApplicationWindow does not show up when visibility is set to Window.AutomaticVisibility. + +Workaround: + +Set Window.Maximized as default window visibility value. + +Snippet: + +Solution: + +Window shows up if visible parameter is additionaly set to true. \ No newline at end of file diff --git a/tools/cutehmi.view.4/dev/cutehmi.view.2-2.unsolved.Qt.bug.txt b/tools/cutehmi.view.4/dev/cutehmi.view.2-2.unsolved.Qt.bug.txt new file mode 100644 index 00000000..111d55cc --- /dev/null +++ b/tools/cutehmi.view.4/dev/cutehmi.view.2-2.unsolved.Qt.bug.txt @@ -0,0 +1,10 @@ +Problem: + +When changing window visibility in the following manner: +Window.Windowed -> Window.Maximized -> Window.FullScreen -> Window.Maximized -> Window.Windowed, +window does not return to its original size. + +Investigation: + +Simply restoring settings when going from Window.FullScreen to Window.Maximized does not help, +because explicitly setting x, y, width and height affects the window even if it is maximized. diff --git a/tools/cutehmi.view.4/dev/cutehmi.view.2-3.solved.Qt.bug.txt b/tools/cutehmi.view.4/dev/cutehmi.view.2-3.solved.Qt.bug.txt new file mode 100644 index 00000000..835d8194 --- /dev/null +++ b/tools/cutehmi.view.4/dev/cutehmi.view.2-3.solved.Qt.bug.txt @@ -0,0 +1,35 @@ +Problem: + +ListView topMargin does not work when orientation is set to Qt.Horizontal. + +Workaround: + +Add spacer items to the delegate, which act as a margins. + +Snippet: + +Column +{ + // Spacer item. + Item + { + (..) + } + + // Delegate. + Button + { + (..) + } + + // Spacer item. + Item + { + (..) + } +} + +Solution: + +Not relevant any more. + diff --git a/tools/cutehmi.view.4/dev/cutehmi.view.2-4.workaround.Qt.bug.txt b/tools/cutehmi.view.4/dev/cutehmi.view.2-4.workaround.Qt.bug.txt new file mode 100644 index 00000000..80ec5da9 --- /dev/null +++ b/tools/cutehmi.view.4/dev/cutehmi.view.2-4.workaround.Qt.bug.txt @@ -0,0 +1,18 @@ +Problem: + +MessageDialog (QtQuick.Dialogs 1.2) misbehaves badly. Signal 'onRejected' is not triggered, +if dialog is closed via 'X' button. Additionaly when user presses one of the 'standardButtons' 'onClickedButtonChanged' is emitted after(!) 'onVisibleChanged', so there is no way to determine if +dialog was closed by 'X' button or by one of the 'standardButtons' and 'Prompt' expects only single +call to `acceptResponse`. Attempts to force dialog to stay visible by setting 'visible = true' ended +up with failure... + +Investigation: + +In theory 'Qt.labs.platform 1.0' could replace 'QtQuickDialogs 1.2', but after a bit of testing +it came out that for now implementation is immature and buggy. + +Workaround: + +Using 'QApplication' instead of 'QGuiApplication' made 'onRejected' signal work as expected. +Additionaly QApplication fixed lack of "beep" sound, when dialog shows up. +The price is that application has to be linked against 'widgets' module. \ No newline at end of file diff --git a/tools/cutehmi.view.4/dev/cutehmi.view.2-5.workaround.Qt.bug.txt b/tools/cutehmi.view.4/dev/cutehmi.view.2-5.workaround.Qt.bug.txt new file mode 100644 index 00000000..114f3ca4 --- /dev/null +++ b/tools/cutehmi.view.4/dev/cutehmi.view.2-5.workaround.Qt.bug.txt @@ -0,0 +1,9 @@ +Problem: + +When run on raw Xorg server application does not show up cursor unless some controls are hovered. + +Investigation: + +Workaround: + +Set cursor with QGuiApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)) for non-touch mode. \ No newline at end of file diff --git a/tools/cutehmi.view.4/dev/cutehmi.view.2-6.workaround.Qt.bug.txt b/tools/cutehmi.view.4/dev/cutehmi.view.2-6.workaround.Qt.bug.txt new file mode 100644 index 00000000..19a4d2a8 --- /dev/null +++ b/tools/cutehmi.view.4/dev/cutehmi.view.2-6.workaround.Qt.bug.txt @@ -0,0 +1,12 @@ +Problem: + +On Windows cursor does not refresh properly when using +QGuiApplication::setOverrideCursor(). This is visible when leaving and entering +window. + +Investigation: + +Workaround: + +Do not use QGuiApplication::setOverrideCursor() on Windows. + diff --git a/tools/cutehmi.view.4/doc/SimpleView.png b/tools/cutehmi.view.4/doc/SimpleView.png new file mode 100644 index 00000000..9ac9ec41 Binary files /dev/null and b/tools/cutehmi.view.4/doc/SimpleView.png differ diff --git a/tools/cutehmi.view.4/doc/project_logo.png b/tools/cutehmi.view.4/doc/project_logo.png new file mode 100644 index 00000000..c5bc24be Binary files /dev/null and b/tools/cutehmi.view.4/doc/project_logo.png differ diff --git a/tools/cutehmi.view.4/doc/screenshot.png b/tools/cutehmi.view.4/doc/screenshot.png new file mode 100644 index 00000000..bf02b004 Binary files /dev/null and b/tools/cutehmi.view.4/doc/screenshot.png differ diff --git a/tools/cutehmi.view.4/i18n/cutehmi-view-4_en.ts b/tools/cutehmi.view.4/i18n/cutehmi-view-4_en.ts new file mode 100644 index 00000000..535f7267 --- /dev/null +++ b/tools/cutehmi.view.4/i18n/cutehmi-view-4_en.ts @@ -0,0 +1,133 @@ + + + + + DefaultScreen + + + Start application with --help option to see available options. + + + + + ExtensionLoader + + + Could not load extension '%1'. + + + + + Reasons: + + + + + main + + + Run application in full screen mode. + + + + + file + + + + + Override loader by specifying initial QML <file> to load. + + + + + Load extension specified by QML <import>. + + + + + import + + + + + Extension component <name>. + + + + + name + + + + + Touch screen (hides mouse cursor). + + + + + Set Qt Quick <style>. + + + + + style + + + + + Choose application <language>. + + + + + language + + + + + Set base directory to <dir>. + + + + + dir + + + + + + + You can not use '%1' option, because 'forceDefaultOptions' option has been set during compilation time. + + + + + URL '%1' contains relative path along with URL scheme, which is forbidden. + + + + + QML file '%1' does not exist. + + + + + Invalid format of QML file URL '%1'. + + + + + metadata + + + View + + + + + GUI application, which allows one to run QML project in a window. + + + + diff --git a/tools/cutehmi.view.4/i18n/cutehmi-view-4_pl.ts b/tools/cutehmi.view.4/i18n/cutehmi-view-4_pl.ts new file mode 100644 index 00000000..c7769312 --- /dev/null +++ b/tools/cutehmi.view.4/i18n/cutehmi-view-4_pl.ts @@ -0,0 +1,149 @@ + + + + + DefaultScreen + + + Start application with --help option to see available options. + Uruchom aplikację z opcją --help aby zobaczyć możliwe opcje. + + + + ExtensionLoader + + + Reasons: + Powody: + + + Reason: + Powód: + + + + Could not load extension '%1'. + Nie można załadować rozszerzenia '%1'. + + + Reason(s): + + Powód: + Powody: + Powodów: + + + + + main + + + Run application in full screen mode. + Uruchom aplikację w trybie pełnoekranowym. + + + + file + plik + + + Override loader specifying initial QML <file> to load. + Nadpisz ładowacza określając inicjujący <plik> QML do załadowania. + + + + Override loader by specifying initial QML <file> to load. + Nadpisz ładowacza ustalając inicjujący <plik> QML do załadowania. + + + + Load extension specified by QML <import>. + Załaduj rozszerzenie określone przez QMLowy <import>. + + + + import + import + + + + Extension component <name>. + Komponent rozszerzenia <nazwa>. + + + + name + nazwa + + + + Touch screen (hides mouse cursor). + Ekran dotykowy (ukrywa kursor myszy). + + + + Set Qt Quick <style>. + Ustaw <styl> Qt Quick. + + + + style + styl + + + + Choose application <language>. + Wybierz <język> aplikacji. + + + + language + język + + + + Set base directory to <dir>. + Ustaw bazowy katalog jako <katalog>. + + + + dir + katalog + + + + + + You can not use '%1' option, because 'forceDefaultOptions' option has been set during compilation time. + Nie możesz użyć opcji '%1' ponieważ opcja 'forceDefaultOptions' została aktywowana podczas kompilacji. + + + + URL '%1' contains relative path along with URL scheme, which is forbidden. + URL '%1' zawiera relatywne ścieżki razem ze schematem URL co jest zabronione. + + + + QML file '%1' does not exist. + Plik QML '%1' nie istnieje. + + + + Invalid format of QML file URL '%1'. + Niewłaściwy format URL pliku QML '%1'. + + + + metadata + + + View + Widok + + + + GUI application, which allows one to run QML project in a window. + Aplikacja GUI, która umożliwia uruchomienie projektu QML w oknie. + + + diff --git a/tools/cutehmi.view.4/img/icon.ico b/tools/cutehmi.view.4/img/icon.ico new file mode 100644 index 00000000..1b26486b Binary files /dev/null and b/tools/cutehmi.view.4/img/icon.ico differ diff --git a/tools/cutehmi.view.4/img/icon.png b/tools/cutehmi.view.4/img/icon.png new file mode 100644 index 00000000..e788dd2b Binary files /dev/null and b/tools/cutehmi.view.4/img/icon.png differ diff --git a/tools/cutehmi.view.4/project.qbs b/tools/cutehmi.view.4/project.qbs new file mode 100644 index 00000000..58e8b834 --- /dev/null +++ b/tools/cutehmi.view.4/project.qbs @@ -0,0 +1,108 @@ +import qbs 1.0 + +import cutehmi + +Project { + name: "cutehmi.view.4" + + references: [ + "tests/tests.qbs" + ] + + cutehmi.Tool { + name: parent.name + + vendor: "CuteHMI" + + domain: "cutehmi.kde.org" + + friendlyName: "View" + + description: "GUI application, which allows one to run QML project in a window." + + // Add also QML files from qrc, because for eg. androiddeployqt needs them installed to scan them. + files: [ + "README.md", + "dev/cutehmi.view.2-1.solved.Qt.design.txt", + "dev/cutehmi.view.2-2.unsolved.Qt.bug.txt", + "dev/cutehmi.view.2-3.solved.Qt.bug.txt", + "dev/cutehmi.view.2-4.workaround.Qt.bug.txt", + "dev/cutehmi.view.2-5.workaround.Qt.bug.txt", + "dev/cutehmi.view.2-6.workaround.Qt.bug.txt", + "i18n/cutehmi-view-4_en.ts", + "i18n/cutehmi-view-4_pl.ts", + "resources.qrc", + "resources.rc", + "src/cutehmi/view/logging.cpp", + "src/cutehmi/view/logging.hpp", + "src/main.cpp", + "qml/DefaultScreen.qml", + "qml/ExtensionLoader.qml", + "qml/MainWindow.qml", + "qml/MessageDialog.qml", + "qml/NotificationListView.qml", + ] + + property string defaultExtension + + property string defaultMinor + + property string defaultInit + + property string defaultComponent + + property string defaultLanguage + + property bool forceDefaultOptions: false + + property bool virtualKeyboard: false + + cpp.defines: { + var result = [] + + if (virtualKeyboard) + result.push("CUTEHMI_VIEW_VIRTUAL_KEYBOARD") + + if (defaultExtension) + result.push("CUTEHMI_VIEW_DEFAULT_EXTENSION=\"" + defaultExtension + "\"") + + if (defaultMinor) + result.push("CUTEHMI_VIEW_DEFAULT_MINOR=\"" + defaultMinor + "\"") + + if (defaultInit) + result.push("CUTEHMI_VIEW_DEFAULT_INIT=\"" + defaultInit + "\"") + + if (defaultComponent) + result.push("CUTEHMI_VIEW_DEFAULT_COMPONENT=\"" + defaultComponent + "\"") + + if (forceDefaultOptions) + result.push("CUTEHMI_VIEW_FORCE_DEFAULT_OPTIONS") + + if (defaultLanguage) + result.push("CUTEHMI_VIEW_DEFAULT_LANGUAGE=\"" + defaultLanguage + "\"") + + return result + } + + cutehmi.dirs.artifacts: true + + Depends { name: "CuteHMI.GUI.1" } + + Depends { name: "cutehmi.doxygen" } + cutehmi.doxygen.exclude: ['dev', 'tests'] + + Depends { name: "cutehmi.metadata" } + + Depends { name: "cutehmi.i18n" } + + Export { + Depends { name: "CuteHMI.GUI.1" } + } + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.view.4/qml/DefaultScreen.qml b/tools/cutehmi.view.4/qml/DefaultScreen.qml new file mode 100644 index 00000000..7929bf3f --- /dev/null +++ b/tools/cutehmi.view.4/qml/DefaultScreen.qml @@ -0,0 +1,15 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.4 + +Text +{ + text: qsTr("Start application with --help option to see available options.") + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.view.4/qml/ExtensionLoader.qml b/tools/cutehmi.view.4/qml/ExtensionLoader.qml new file mode 100644 index 00000000..73a86def --- /dev/null +++ b/tools/cutehmi.view.4/qml/ExtensionLoader.qml @@ -0,0 +1,46 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 + +import CuteHMI 2.0 as CuteHMI + +Item { + id: extensionContainer + + CuteHMI.Message { + id: message + + type: CuteHMI.Message.CRITICAL + text: qsTr("Could not load extension '%1'.").arg(cutehmi_view_extensionBaseName + " " + cutehmi_view_extensionMajor + "." + cutehmi_view_extensionMinor) + buttons: CuteHMI.Message.BUTTON_OK + } + + Component.onCompleted: { + if (cutehmi_view_extensionBaseName && cutehmi_view_extensionMajor && cutehmi_view_extensionMinor) { + var qmlData = "import " + cutehmi_view_extensionBaseName + " " + cutehmi_view_extensionMajor + "." + cutehmi_view_extensionMinor + qmlData += "\n" + cutehmi_view_extensionComponent + " { anchors.fill: parent }\n" + + try { + Qt.createQmlObject(qmlData, extensionContainer) + } catch(error) { + showDefaultScreen() + message.informativeText = qsTr("Reasons:") + message.informativeText += "\n" + error.qmlErrors.map(function (obj) { return "- " + obj.message }).join("\n") + "." + createDialog(message) + } + } else { + showDefaultScreen() + } + } + + function showDefaultScreen() { + var defaultScreenComponent = Qt.createComponent("DefaultScreen.qml") + var defaultScreen = defaultScreenComponent.createObject(extensionContainer) + defaultScreen.anchors.centerIn = extensionContainer + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.view.4/qml/MainWindow.qml b/tools/cutehmi.view.4/qml/MainWindow.qml new file mode 100644 index 00000000..1b930d26 --- /dev/null +++ b/tools/cutehmi.view.4/qml/MainWindow.qml @@ -0,0 +1,98 @@ +import QtQuick 2.3 +import QtQuick.Controls 2.1 +import QtQuick.Window 2.2 +import Qt.labs.settings 1.0 + +import CuteHMI 2.0 + +ApplicationWindow { + id: mainWindow + + x: settings.x + y: settings.y + width: settings.width + height: settings.height + visibility: settings.visibility + visible: true // This is required to avoid "Conflicting properties 'visible' and 'visibility' for Window 'root'" warning and to make Window.AutomaticVisibility visibility work. + + FocusScope { + focus: true + + Keys.onPressed: { + // Toggle full screen. + if (event.key === Qt.Key_F11) { + if (mainWindow.visibility != Window.FullScreen) { + // Store visibility. + settings.visibility = mainWindow.visibility + mainWindow.visibility = Window.FullScreen + } else { + // Restore visibility or swap to Window.AutomaticVisibility if application was restored to full screen mode on startup. + // + // When changing window visibility in the following manner: + // Window.Windowed -> Window.Maximized -> Window.FullScreen -> Window.Maximized -> Window.Windowed, + // window does not return to its original size. + if (settings.visibility != Window.FullScreen) + mainWindow.visibility = settings.visibility + else + mainWindow.visibility = Window.AutomaticVisibility + // + } + } + } + } + + Settings { + id: settings + + category: "cutehmi.view.4/MainWindow" + + property int visibility: Window.AutomaticVisibility + property int x: 0 + property int y: 0 + property int width: 1280 + property int height: 720 + + function storeMainWindow() { + if (mainWindow.visibility === Window.Hidden) + settings.visibility = Window.AutomaticVisibility + else + settings.visibility = mainWindow.visibility + if (mainWindow.visibility == Window.Windowed) { + settings.x = mainWindow.x + settings.y = mainWindow.y + settings.width = mainWindow.width + settings.height = mainWindow.height + } + } + } + + Loader { + anchors.fill: parent + source: cutehmi_view_initURL + } + + function createDialog(message) { + var messageDialogComponent = Qt.createComponent("MessageDialog.qml") + var messageDialog = messageDialogComponent.createObject(mainWindow, {"message" : message}) + messageDialog.messageChanged.connect(messageDialog.destroy) + messageDialog.open() + } + + Component.onCompleted: { + for (var i = 1; i < Qt.application.arguments.length; i++) + if (Qt.application.arguments[i] === "--fullscreen") + mainWindow.visibility = Window.FullScreen + + Messenger.resetAdvertiser(mainWindow) + } + + onClosing: { + settings.storeMainWindow() + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs b/tools/cutehmi.view.4/qml/MessageDialog.qml similarity index 50% copy from extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs copy to tools/cutehmi.view.4/qml/MessageDialog.qml index fd3e8aa1..e5ad5f7f 100644 --- a/extensions/CuteHMI/Symbols/Pipes.1/Pipes.1.qbs +++ b/tools/cutehmi.view.4/qml/MessageDialog.qml @@ -1,54 +1,31 @@ -import qbs - -import cutehmi - -Project { - name: "CuteHMI.Symbols.Pipes.1" - - cutehmi.Extension { - name: parent.name - - friendlyName: "Pipes" - - vendor: "CuteHMI" - - domain: "cutehmi.kde.org" - - description: "Pipe drawing components." - - files: [ - "Cap.qml", - "ConnectorSelector.qml", - "Elbow.qml", - "Pipe.qml", - "PipeColor.qml", - "PipeConnector.qml", - "PipeElement.qml", - "PipeEnd.qml", - "README.md", - "Tee.qml", - "functions.js", - ] - - Depends { name: "CuteHMI.GUI.1" } - - Depends { name: "cutehmi.doxygen" } - cutehmi.doxygen.warnIfUndocumented: false - cutehmi.doxygen.useDoxyqml: true - cutehmi.doxygen.exclude: ['dev', 'tests'] +import QtQuick 2.0 +import QtQuick.Dialogs 1.2 + +import CuteHMI 2.0 as CuteHMI + +MessageDialog +{ + property CuteHMI.Message message + + onMessageChanged: { + if (message) { + text = message.text + informativeText = message.informativeText + detailedText = message.detailedText + standardButtons = message.buttons + icon = message.type + } + } - Depends { name: "cutehmi.qmldir" } + onClickedButtonChanged: if (message) { message.acceptResponse(clickedButton); message = null } - Depends { name: "cutehmi.qmltypes" } + onRejected: if (message) { message.acceptResponse(clickedButton); message = null } - Export { - Depends { name: "CuteHMI.GUI.1" } - } - } + Component.onDestruction: if (message) message.deleteLater() } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.view.4/qml/NotificationListView.qml b/tools/cutehmi.view.4/qml/NotificationListView.qml new file mode 100644 index 00000000..7be53de8 --- /dev/null +++ b/tools/cutehmi.view.4/qml/NotificationListView.qml @@ -0,0 +1,13 @@ +import QtQuick 2.7 + +ListView { + delegate: Text { + text: display + } +} + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.view.4/resources.qrc b/tools/cutehmi.view.4/resources.qrc new file mode 100644 index 00000000..2cec8965 --- /dev/null +++ b/tools/cutehmi.view.4/resources.qrc @@ -0,0 +1,10 @@ + + + img/icon.png + qml/MainWindow.qml + qml/DefaultScreen.qml + qml/MessageDialog.qml + qml/NotificationListView.qml + qml/ExtensionLoader.qml + + diff --git a/tools/cutehmi.view.4/resources.rc b/tools/cutehmi.view.4/resources.rc new file mode 100644 index 00000000..8f6122f0 --- /dev/null +++ b/tools/cutehmi.view.4/resources.rc @@ -0,0 +1 @@ +CUTEHMI_VIEW_ICON ICON DISCARDABLE "img/icon.ico" diff --git a/tools/cutehmi.view.4/src/cutehmi/view/logging.cpp b/tools/cutehmi.view.4/src/cutehmi/view/logging.cpp new file mode 100644 index 00000000..c9d56050 --- /dev/null +++ b/tools/cutehmi.view.4/src/cutehmi/view/logging.cpp @@ -0,0 +1,11 @@ +#include "logging.hpp" + +#include "../../../cutehmi.metadata.hpp" + +Q_LOGGING_CATEGORY(cutehmi_view_loggingCategory, CUTEHMI_VIEW_NAME) + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.view.4/src/cutehmi/view/logging.hpp b/tools/cutehmi.view.4/src/cutehmi/view/logging.hpp new file mode 100644 index 00000000..bf4633e4 --- /dev/null +++ b/tools/cutehmi.view.4/src/cutehmi/view/logging.hpp @@ -0,0 +1,26 @@ +#ifndef H_TOOLS_CUTEHMI_VIEW_4_SRC_CUTEHMI_VIEW_LOGGING_HPP +#define H_TOOLS_CUTEHMI_VIEW_4_SRC_CUTEHMI_VIEW_LOGGING_HPP + +#include + +Q_DECLARE_LOGGING_CATEGORY(cutehmi_view_loggingCategory) + +namespace cutehmi { +namespace view { + +inline +const QLoggingCategory & loggingCategory() +{ + return cutehmi_view_loggingCategory(); +} + +} +} + +#endif + +//(c)C: Copyright © 2020, Michał Policht . All rights reserved. +//(c)C: This file is a part of CuteHMI. +//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/tools/cutehmi.view.4/src/main.cpp b/tools/cutehmi.view.4/src/main.cpp new file mode 100644 index 00000000..4ff8c5af --- /dev/null +++ b/tools/cutehmi.view.4/src/main.cpp @@ -0,0 +1,331 @@ +#include "../cutehmi.metadata.hpp" +#include "../cutehmi.dirs.hpp" +#include "cutehmi/view/logging.hpp" + +#include +#include +#include +#include + +#include + +// +#include +// Instead of: +// #include +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace cutehmi::view; + +/** + * Main function. + * @param argc number of arguments passed to the program. + * @param argv list of arguments passed to the program. + * @return return code. + */ +int main(int argc, char * argv[]) +{ +#ifdef CUTEHMI_VIEW_DEFAULT_INIT + static constexpr const char * DEFAULT_INIT = CUTEHMI_VIEW_DEFAULT_INIT; +#else + static constexpr const char * DEFAULT_INIT = "qrc:/qml/ExtensionLoader.qml"; +#endif +#ifdef CUTEHMI_VIEW_DEFAULT_EXTENSION + static constexpr const char * DEFAULT_EXTENSION = CUTEHMI_VIEW_DEFAULT_EXTENSION; +#else + static constexpr const char * DEFAULT_EXTENSION = ""; +#endif +#ifdef CUTEHMI_VIEW_DEFAULT_COMPONENT + static constexpr const char * DEFAULT_COMPONENT = CUTEHMI_VIEW_DEFAULT_COMPONENT; +#else + static constexpr const char * DEFAULT_COMPONENT = "View"; +#endif +#ifdef CUTEHMI_VIEW_DEFAULT_MINOR + static constexpr const char * DEFAULT_MINOR = CUTEHMI_VIEW_DEFAULT_MINOR; +#else + static constexpr const char * DEFAULT_MINOR = "0"; +#endif + + QCoreApplication::setOrganizationName(CUTEHMI_VIEW_VENDOR); + QCoreApplication::setOrganizationDomain(CUTEHMI_VIEW_DOMAIN); + QCoreApplication::setApplicationName(CUTEHMI_VIEW_FRIENDLY_NAME); + QCoreApplication::setApplicationVersion(QString("%1.%2.%3").arg(CUTEHMI_VIEW_MAJOR).arg(CUTEHMI_VIEW_MINOR).arg(CUTEHMI_VIEW_MICRO)); + + try { + +#ifdef CUTEHMI_VIEW_VIRTUAL_KEYBOARD + if (qgetenv("QT_IM_MODULE").isEmpty()) + qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); + CUTEHMI_DEBUG("Input method: " << qgetenv("QT_IM_MODULE")); +#else + CUTEHMI_DEBUG("Support for virtual keyboard is disabled."); +#endif + + if (qgetenv("QT_IM_MODULE") == "qtvirtualkeyboard") { + if (qgetenv("QT_VIRTUALKEYBOARD_LAYOUT_PATH").isEmpty()) + qputenv("QT_VIRTUALKEYBOARD_LAYOUT_PATH", QByteArray(QDir("../layouts").absolutePath().toLocal8Bit())); + CUTEHMI_DEBUG("Qt Virtual Keyboard layouts path: " << qgetenv("QT_VIRTUALKEYBOARD_LAYOUT_PATH")); + } + + // + // "In general, creating QObjects before the QApplication is not supported and can lead to weird crashes on exit, depending on the + // platform. This means static instances of QObject are also not supported. A properly structured single or multi-threaded application + // should make the QApplication be the first created, and last destroyed QObject." + + // + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + cutehmi::gui::CuteApplication app(argc, argv); + // Instead of: + // QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + // QGuiApplication app(argc, argv); + // + app.setWindowIcon(QIcon(":/img/icon.png")); + + + QString language = QLocale::system().name(); +#ifdef CUTEHMI_VIEW_DEFAULT_LANGUAGE + language = CUTEHMI_VIEW_DEFAULT_LANGUAGE; +#endif + if (!qgetenv("CUTEHMI_LANGUAGE").isEmpty()) { + language = qgetenv("CUTEHMI_LANGUAGE"); + CUTEHMI_DEBUG("Language set by 'CUTEHMI_LANGUAGE' environmental variable: " << qgetenv("CUTEHMI_LANGUAGE")); + } + QTranslator qtTranslator; + if (!qtTranslator.load("qt_" + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + CUTEHMI_WARNING("Could not load translations file '" << "qt_" + language << "'."); + app.installTranslator(& qtTranslator); + + QTranslator viewTranslator; + QString translationsDir = QDir("/" CUTEHMI_DIRS_TOOLS_INSTALL_SUBDIR).relativeFilePath("/" CUTEHMI_DIRS_TRANSLATIONS_INSTALL_SUBDIR); + QString viewTranslationFilePrefix = QString(CUTEHMI_VIEW_NAME).replace('.', '-') + "_"; + QString viewTranslationFile = viewTranslationFilePrefix + language; + if (!viewTranslator.load(viewTranslationFile, translationsDir)) + CUTEHMI_WARNING("Could not load translations file '" << viewTranslationFile << "'."); + app.installTranslator(& viewTranslator); + + + QCommandLineParser cmd; + cmd.setApplicationDescription(CUTEHMI_VIEW_TRANSLATED_FRIENDLY_NAME + "\n" + CUTEHMI_VIEW_TRANSLATED_DESCRIPTION); + cmd.addHelpOption(); + cmd.addVersionOption(); + + QCommandLineOption fullScreenOption({"f", "fullscreen"}, QCoreApplication::translate("main", "Run application in full screen mode.")); + cmd.addOption(fullScreenOption); + + QCommandLineOption initOption("init", QCoreApplication::translate("main", "Override loader by specifying initial QML to load."), QCoreApplication::translate("main", "file")); + initOption.setDefaultValue(DEFAULT_INIT); + cmd.addOption(initOption); + + QCommandLineOption minorOption({"m", "minor"}, QCoreApplication::translate("main", "Use for extension minor version to import."), QCoreApplication::translate("main", "version")); + minorOption.setDefaultValue(DEFAULT_MINOR); + cmd.addOption(minorOption); + + QCommandLineOption hideCursorOption({"t", "touch"}, QCoreApplication::translate("main", "Touch screen (hides mouse cursor).")); + cmd.addOption(hideCursorOption); + + QCommandLineOption styleOption("qstyle", QCoreApplication::translate("main", "Set Qt Quick