imported all internal guh plugins

This commit is contained in:
Michael Zanetti 2017-07-11 14:14:07 +02:00
commit 12a0afd90c
9 changed files with 533 additions and 0 deletions

View File

@ -0,0 +1,118 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2015 Simon Stürz <simon.stuerz@guh.io> *
* *
* This file is part of guh. *
* *
* This library 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 2.1 of the License, or (at your option) any later version. *
* *
* This library 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. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; If not, see *
* <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\page genericelements.html
\title Generic elements
\brief Common elements to test the rule engine.
\ingroup plugins
\ingroup guh-tests
The generic elements plugin allows you create virtual buttons, which can be connected with a rule. This gives you
the possibility to execute multiple \l{Action}{Actions} with one signal. Without a rule this generic elements are
useless.
\chapter Toggle Button
With the "Toggle Button" \l{DeviceClass} you can create a button with one \l{Action} \unicode{0x2192} toggle. In the \tt state \l{State} you can find out,
what happens if the button will be pressed. The states can be true or false.
\chapter Button
With the "Button" \l{DeviceClass} you can create a button with one \l{Action} \unicode{0x2192} press. This button just creates one \l{Event}.
\chapter ON/OFF Button
With the "ON/OFF Button" \l{DeviceClass} you create a button pair with the \l{Action}{Actions} \unicode{0x2192} ON and OFF.
\chapter Plugin properties
Following JSON file contains the definition and the description of all available \l{DeviceClass}{DeviceClasses}
and \l{Vendor}{Vendors} of this \l{DevicePlugin}.
For more details how to read this JSON file please check out the documentation for \l{The plugin JSON File}.
\quotefile plugins/deviceplugins/genericelements/deviceplugingenericelements.json
*/
#include "deviceplugingenericelements.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include <QDebug>
DevicePluginGenericElements::DevicePluginGenericElements()
{
}
DeviceManager::HardwareResources DevicePluginGenericElements::requiredHardware() const
{
return DeviceManager::HardwareResourceNone;
}
DeviceManager::DeviceSetupStatus DevicePluginGenericElements::setupDevice(Device *device)
{
// Toggle Button
if (device->deviceClassId() == toggleButtonDeviceClassId) {
return DeviceManager::DeviceSetupStatusSuccess;
}
// Button
if (device->deviceClassId() == buttonDeviceClassId) {
return DeviceManager::DeviceSetupStatusSuccess;
}
// ON/OFF Button
if (device->deviceClassId() == onOffButtonDeviceClassId) {
return DeviceManager::DeviceSetupStatusSuccess;
}
return DeviceManager::DeviceSetupStatusFailure;
}
DeviceManager::DeviceError DevicePluginGenericElements::executeAction(Device *device, const Action &action)
{
// Toggle Button
if (device->deviceClassId() == toggleButtonDeviceClassId ) {
if (action.actionTypeId() == stateActionTypeId) {
device->setStateValue(stateStateTypeId, !device->stateValue(stateStateTypeId).toBool());
return DeviceManager::DeviceErrorNoError;
}
return DeviceManager::DeviceErrorActionTypeNotFound;
}
// Button
if (device->deviceClassId() == buttonDeviceClassId ) {
if (action.actionTypeId() == buttonPressActionTypeId) {
emit emitEvent(Event(buttonPressedEventTypeId, device->id()));
return DeviceManager::DeviceErrorNoError;
}
return DeviceManager::DeviceErrorActionTypeNotFound;
}
// ON/OFF Button
if (device->deviceClassId() == onOffButtonDeviceClassId ) {
if (action.actionTypeId() == onOffButtonOnActionTypeId) {
emit emitEvent(Event(onOffButtonOnEventTypeId, device->id()));
return DeviceManager::DeviceErrorNoError;
}
if (action.actionTypeId() == onOffButtonOffActionTypeId) {
emit emitEvent(Event(onOffButtonOffEventTypeId, device->id()));
return DeviceManager::DeviceErrorNoError;
}
return DeviceManager::DeviceErrorActionTypeNotFound;
}
return DeviceManager::DeviceErrorDeviceClassNotFound;
}

View File

@ -0,0 +1,47 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2015 Simon Stürz <simon.stuerz@guh.io> *
* *
* This file is part of guh. *
* *
* This library 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 2.1 of the License, or (at your option) any later version. *
* *
* This library 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. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; If not, see *
* <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef DEVICEPLUGINGENERICELEMENTS_H
#define DEVICEPLUGINGENERICELEMENTS_H
#include "plugin/deviceplugin.h"
class DevicePluginGenericElements : public DevicePlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "guru.guh.DevicePlugin" FILE "deviceplugingenericelements.json")
Q_INTERFACES(DevicePlugin)
public:
explicit DevicePluginGenericElements();
DeviceManager::HardwareResources requiredHardware() const override;
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
public slots:
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
};
#endif // DEVICEPLUGINGENERICELEMENTS_H

View File

@ -0,0 +1,109 @@
{
"name": "Generic Elements",
"idName": "GenericElements",
"id": "6e22161e-39b7-4416-8623-39e730721efb",
"vendors": [
{
"name": "guh",
"idName": "guh",
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6",
"deviceClasses": [
{
"id": "c0f511f9-70f5-499b-bd70-2c0e9ddd68c4",
"idName": "toggleButton",
"name": "Toggle Button",
"deviceIcon": "Switch",
"primaryActionTypeId": "b5e90567-54aa-49bd-a78a-3c19fb38aaf5",
"basicTags": [
"Device",
"Actuator"
],
"createMethods": ["user"],
"paramTypes": [ ],
"stateTypes": [
{
"id": "b5e90567-54aa-49bd-a78a-3c19fb38aaf5",
"idName": "state",
"name": "state",
"eventTypeName": "state changed",
"actionTypeName": "Set state",
"index": 0,
"type": "bool",
"defaultValue": false,
"writable": true
}
]
},
{
"id": "820b2f2d-0d92-48c8-8fd4-f94ce8fc4103",
"idName": "button",
"name": "Button",
"deviceIcon": "Switch",
"primaryActionTypeId": "01f38af1-b2ab-4ec3-844e-ef52f0f229a9",
"basicTags": [
"Device",
"Actuator"
],
"createMethods": ["user"],
"paramTypes": [ ],
"actionTypes": [
{
"id": "01f38af1-b2ab-4ec3-844e-ef52f0f229a9",
"idName": "buttonPress",
"index": 0,
"name": "press"
}
],
"eventTypes": [
{
"id": "effdbc2d-e467-4b0b-80a9-9dda251bfa5c",
"idName": "buttonPressed",
"index": 0,
"name": "button pressed"
}
]
},
{
"id": "430d188c-476d-4825-a9bd-86dfa3094b56",
"idName": "onOffButton",
"name": "ON/OFF Button",
"deviceIcon": "Switch",
"basicTags": [
"Device",
"Actuator"
],
"createMethods": ["user"],
"paramTypes": [ ],
"actionTypes": [
{
"id": "892596d2-0863-4807-97da-469b9f7003f2",
"idName": "onOffButtonOn",
"index": 0,
"name": "press ON"
},
{
"id": "a8d64050-0b58-4ccf-b052-77ce2b7368ad",
"idName": "onOffButtonOff",
"index": 1,
"name": "press OFF"
}
],
"eventTypes": [
{
"id": "4eeba6a2-e4c7-4a2e-8360-2797d98114e6",
"idName": "onOffButtonOn",
"index": 0,
"name": "ON pressed"
},
{
"id": "b636c5f3-2eb0-4682-96d4-88a4aa9d2c12",
"idName": "onOffButtonOff",
"index": 1,
"name": "OFF pressed"
}
]
}
]
}
]
}

View File

@ -0,0 +1,15 @@
TRANSLATIONS = translations/en_US.ts \
translations/de_DE.ts
# Note: include after the TRANSLATIONS definition
include(../plugins.pri)
TARGET = $$qtLibraryTarget(guh_deviceplugingenericelements)
SOURCES += \
deviceplugingenericelements.cpp
HEADERS += \
deviceplugingenericelements.h

View File

@ -0,0 +1 @@
<クd<>箆!ソ`。スン

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="de_DE">
<context>
<name>GenericElements</name>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="39"/>
<source>Generic Elements</source>
<extracomment>The name of the plugin Generic Elements (6e22161e-39b7-4416-8623-39e730721efb)</extracomment>
<translation>Generische Elemente</translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="42"/>
<source>guh</source>
<extracomment>The name of the vendor (2062d64d-3232-433c-88bc-0d33c0ba2ba6)</extracomment>
<translation>guh</translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="45"/>
<source>Toggle Button</source>
<extracomment>The name of the DeviceClass (c0f511f9-70f5-499b-bd70-2c0e9ddd68c4)</extracomment>
<translation>Toggle Taster</translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="48"/>
<source>state changed</source>
<extracomment>The name of the autocreated EventType (b5e90567-54aa-49bd-a78a-3c19fb38aaf5)</extracomment>
<translation>Status geändert</translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="51"/>
<source>state</source>
<extracomment>The name of the ParamType of StateType (b5e90567-54aa-49bd-a78a-3c19fb38aaf5) of DeviceClass Toggle Button</extracomment>
<translation>Status</translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="54"/>
<source>Set state</source>
<extracomment>The name of the autocreated ActionType (b5e90567-54aa-49bd-a78a-3c19fb38aaf5)</extracomment>
<translation>Setze Status</translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="57"/>
<source>Button</source>
<extracomment>The name of the DeviceClass (820b2f2d-0d92-48c8-8fd4-f94ce8fc4103)</extracomment>
<translation>Taster</translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="60"/>
<source>press</source>
<extracomment>The name of the ActionType 01f38af1-b2ab-4ec3-844e-ef52f0f229a9 of deviceClass Button</extracomment>
<translation>Drücken</translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="63"/>
<source>button pressed</source>
<extracomment>The name of the EventType effdbc2d-e467-4b0b-80a9-9dda251bfa5c of deviceClass Button</extracomment>
<translation>Taster gedrückt</translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="66"/>
<source>ON/OFF Button</source>
<extracomment>The name of the DeviceClass (430d188c-476d-4825-a9bd-86dfa3094b56)</extracomment>
<translation>An/Aus Taster</translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="69"/>
<source>press ON</source>
<extracomment>The name of the ActionType 892596d2-0863-4807-97da-469b9f7003f2 of deviceClass ON/OFF Button</extracomment>
<translation>Drücke AN</translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="72"/>
<source>press OFF</source>
<extracomment>The name of the ActionType a8d64050-0b58-4ccf-b052-77ce2b7368ad of deviceClass ON/OFF Button</extracomment>
<translation>Drücke AUS</translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="75"/>
<source>ON pressed</source>
<extracomment>The name of the EventType 4eeba6a2-e4c7-4a2e-8360-2797d98114e6 of deviceClass ON/OFF Button</extracomment>
<translation>An gedrückt</translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="78"/>
<source>OFF pressed</source>
<extracomment>The name of the EventType b636c5f3-2eb0-4682-96d4-88a4aa9d2c12 of deviceClass ON/OFF Button</extracomment>
<translation>Aus gedrückt</translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>GenericElements</name>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="39"/>
<source>Generic Elements</source>
<extracomment>The name of the plugin Generic Elements (6e22161e-39b7-4416-8623-39e730721efb)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="42"/>
<source>guh</source>
<extracomment>The name of the vendor (2062d64d-3232-433c-88bc-0d33c0ba2ba6)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="45"/>
<source>Toggle Button</source>
<extracomment>The name of the DeviceClass (c0f511f9-70f5-499b-bd70-2c0e9ddd68c4)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="48"/>
<source>state changed</source>
<extracomment>The name of the autocreated EventType (b5e90567-54aa-49bd-a78a-3c19fb38aaf5)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="51"/>
<source>state</source>
<extracomment>The name of the ParamType of StateType (b5e90567-54aa-49bd-a78a-3c19fb38aaf5) of DeviceClass Toggle Button</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="54"/>
<source>Set state</source>
<extracomment>The name of the autocreated ActionType (b5e90567-54aa-49bd-a78a-3c19fb38aaf5)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="57"/>
<source>Button</source>
<extracomment>The name of the DeviceClass (820b2f2d-0d92-48c8-8fd4-f94ce8fc4103)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="60"/>
<source>press</source>
<extracomment>The name of the ActionType 01f38af1-b2ab-4ec3-844e-ef52f0f229a9 of deviceClass Button</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="63"/>
<source>button pressed</source>
<extracomment>The name of the EventType effdbc2d-e467-4b0b-80a9-9dda251bfa5c of deviceClass Button</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="66"/>
<source>ON/OFF Button</source>
<extracomment>The name of the DeviceClass (430d188c-476d-4825-a9bd-86dfa3094b56)</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="69"/>
<source>press ON</source>
<extracomment>The name of the ActionType 892596d2-0863-4807-97da-469b9f7003f2 of deviceClass ON/OFF Button</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="72"/>
<source>press OFF</source>
<extracomment>The name of the ActionType a8d64050-0b58-4ccf-b052-77ce2b7368ad of deviceClass ON/OFF Button</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="75"/>
<source>ON pressed</source>
<extracomment>The name of the EventType 4eeba6a2-e4c7-4a2e-8360-2797d98114e6 of deviceClass ON/OFF Button</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../build-guh-plugins-5_8_desktop-Debug/genericelements/plugininfo.h" line="78"/>
<source>OFF pressed</source>
<extracomment>The name of the EventType b636c5f3-2eb0-4682-96d4-88a4aa9d2c12 of deviceClass ON/OFF Button</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

61
plugins.pri Normal file
View File

@ -0,0 +1,61 @@
TEMPLATE = lib
CONFIG += plugin
QT += network bluetooth
QMAKE_CXXFLAGS += -Werror -std=c++11 -g
QMAKE_LFLAGS += -std=c++11
INCLUDEPATH += /usr/include/guh
LIBS += -lguh
PLUGIN_PATH=/usr/lib/$$system('dpkg-architecture -q DEB_HOST_MULTIARCH')/guh/plugins/
# Check for Bluetoot LE support (Qt >= 5.4)
equals(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 3) {
DEFINES += BLUETOOTH_LE
}
# Check if this is a snap build
snappy{
INCLUDEPATH+=$$(SNAPCRAFT_STAGE)/usr/include/guh
}
# Create plugininfo file
JSONFILES = deviceplugin"$$TARGET".json
plugininfo.target = plugininfo.h
plugininfo.output = plugininfo.h
plugininfo.CONFIG = no_link
plugininfo.input = JSONFILES
plugininfo.commands = touch ${QMAKE_FILE_OUT}; guh-generateplugininfo \
--filetype i \
--jsonfile ${QMAKE_FILE_NAME} \
--output ${QMAKE_FILE_OUT} \
--builddir $$OUT_PWD \
--translations $$TRANSLATIONS; \
rsync -a "$$OUT_PWD"/translations/*.qm $$shadowed($$PWD)/translations/;
PRE_TARGETDEPS += compiler_plugininfo_make_all
QMAKE_EXTRA_COMPILERS += plugininfo
externplugininfo.target = extern-plugininfo.h
externplugininfo.output = extern-plugininfo.h
externplugininfo.CONFIG = no_link
externplugininfo.input = JSONFILES
externplugininfo.commands = touch ${QMAKE_FILE_OUT}; guh-generateplugininfo \
--filetype e \
--jsonfile ${QMAKE_FILE_NAME} \
--output ${QMAKE_FILE_OUT} \
--builddir $$OUT_PWD \
--translations $$TRANSLATIONS;
PRE_TARGETDEPS += compiler_externplugininfo_make_all
QMAKE_EXTRA_COMPILERS += externplugininfo
# Install translation files
translations.path = /usr/share/guh/translations
translations.files = $$[QT_SOURCE_TREE]/translations/*.qm
# Install plugin
target.path = $$PLUGIN_PATH
INSTALLS += target translations