first version of toggle button
This commit is contained in:
parent
ef7458879b
commit
78272ecdd3
1
debian/guh-plugins.install
vendored
1
debian/guh-plugins.install
vendored
@ -10,3 +10,4 @@ usr/lib/guh/plugins/libguh_devicepluginphilipshue.so
|
|||||||
usr/lib/guh/plugins/libguh_devicepluginwakeonlan.so
|
usr/lib/guh/plugins/libguh_devicepluginwakeonlan.so
|
||||||
usr/lib/guh/plugins/libguh_devicepluginwemo.so
|
usr/lib/guh/plugins/libguh_devicepluginwemo.so
|
||||||
usr/lib/guh/plugins/libguh_devicepluginwifidetector.so
|
usr/lib/guh/plugins/libguh_devicepluginwifidetector.so
|
||||||
|
usr/lib/guh/plugins/libguh_deviceplugingenericelements.so
|
||||||
|
|||||||
@ -11,6 +11,7 @@ SUBDIRS += elro \
|
|||||||
mailnotification \
|
mailnotification \
|
||||||
philipshue \
|
philipshue \
|
||||||
lgsmarttv \
|
lgsmarttv \
|
||||||
|
genericelements \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,55 @@
|
|||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
* *
|
||||||
|
* This file is part of guh. *
|
||||||
|
* *
|
||||||
|
* Guh is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* Guh 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 General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
#include "deviceplugingenericelements.h"
|
||||||
|
#include "devicemanager.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
DeviceClassId toggleButtonDeviceClassId = DeviceClassId("c0f511f9-70f5-499b-bd70-2c0e9ddd68c4");
|
||||||
|
ActionTypeId toggleButtonToggleActionTypeId = ActionTypeId("47bdc15a-b393-4dc2-801b-845420cdfda3");
|
||||||
|
StateTypeId toggleButtonStatusStateTypeId = StateTypeId("b5e90567-54aa-49bd-a78a-3c19fb38aaf5");
|
||||||
|
|
||||||
|
DevicePluginGenericElements::DevicePluginGenericElements()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceManager::HardwareResources DevicePluginGenericElements::requiredHardware() const
|
||||||
|
{
|
||||||
|
return DeviceManager::HardwareResourceNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceManager::DeviceSetupStatus DevicePluginGenericElements::setupDevice(Device *device)
|
||||||
|
{
|
||||||
|
if (device->deviceClassId() == toggleButtonDeviceClassId) {
|
||||||
|
device->setName(device->paramValue("name").toString() +" (Toggle Button)");
|
||||||
|
return DeviceManager::DeviceSetupStatusSuccess;
|
||||||
|
}
|
||||||
|
return DeviceManager::DeviceSetupStatusFailure;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceManager::DeviceError DevicePluginGenericElements::executeAction(Device *device, const Action &action)
|
||||||
|
{
|
||||||
|
if (device->deviceClassId() == toggleButtonDeviceClassId
|
||||||
|
&& action.actionTypeId() == toggleButtonToggleActionTypeId) {
|
||||||
|
bool currentStatus = device->stateValue(toggleButtonStatusStateTypeId).toBool();
|
||||||
|
device->setStateValue(toggleButtonStatusStateTypeId, !currentStatus);
|
||||||
|
return DeviceManager::DeviceErrorNoError;
|
||||||
|
}
|
||||||
|
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||||
|
}
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
* *
|
||||||
|
* This file is part of guh. *
|
||||||
|
* *
|
||||||
|
* Guh is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* Guh 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 General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with guh. 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
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"name": "Generic Elements",
|
||||||
|
"id": "6e22161e-39b7-4416-8623-39e730721efb",
|
||||||
|
"vendors": [
|
||||||
|
{
|
||||||
|
"name": "guh",
|
||||||
|
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6",
|
||||||
|
"deviceClasses": [
|
||||||
|
{
|
||||||
|
"deviceClassId": "c0f511f9-70f5-499b-bd70-2c0e9ddd68c4",
|
||||||
|
"name": "Toggle Button",
|
||||||
|
"createMethods": ["user"],
|
||||||
|
"paramTypes": [
|
||||||
|
{
|
||||||
|
"name": "name",
|
||||||
|
"type": "QString"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateTypes": [
|
||||||
|
{
|
||||||
|
"id": "b5e90567-54aa-49bd-a78a-3c19fb38aaf5",
|
||||||
|
"name": "status",
|
||||||
|
"type": "bool",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"actionTypes": [
|
||||||
|
{
|
||||||
|
"id": "47bdc15a-b393-4dc2-801b-845420cdfda3",
|
||||||
|
"name": "toggle"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
11
plugins/deviceplugins/genericelements/genericelements.pro
Normal file
11
plugins/deviceplugins/genericelements/genericelements.pro
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
include(../../plugins.pri)
|
||||||
|
|
||||||
|
TARGET = $$qtLibraryTarget(guh_deviceplugingenericelements)
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
deviceplugingenericelements.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
deviceplugingenericelements.h
|
||||||
|
|
||||||
|
|
||||||
@ -169,7 +169,6 @@ def select_stateOperator():
|
|||||||
def read_paramDescriptors(paramTypes):
|
def read_paramDescriptors(paramTypes):
|
||||||
params = []
|
params = []
|
||||||
for paramType in paramTypes:
|
for paramType in paramTypes:
|
||||||
print paramType['allowedValues']
|
|
||||||
paramValue = raw_input("Please enter value for parameter <%s> (type: %s): " % (paramType['name'], paramType['type']))
|
paramValue = raw_input("Please enter value for parameter <%s> (type: %s): " % (paramType['name'], paramType['type']))
|
||||||
operator = select_valueOperator()
|
operator = select_valueOperator()
|
||||||
param = {}
|
param = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user