Update according to new API

pull/1/head
Michael Zanetti 2019-06-18 14:28:03 +02:00
parent d7af7fd57d
commit f6a1c77e24
2 changed files with 17 additions and 18 deletions

View File

@ -53,7 +53,6 @@
#include "deviceplugingenericelements.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include <QDebug>
@ -62,52 +61,52 @@ DevicePluginGenericElements::DevicePluginGenericElements()
{
}
DeviceManager::DeviceSetupStatus DevicePluginGenericElements::setupDevice(Device *device)
Device::DeviceSetupStatus DevicePluginGenericElements::setupDevice(Device *device)
{
// Toggle Button
if (device->deviceClassId() == toggleButtonDeviceClassId) {
return DeviceManager::DeviceSetupStatusSuccess;
return Device::DeviceSetupStatusSuccess;
}
// Button
if (device->deviceClassId() == buttonDeviceClassId) {
return DeviceManager::DeviceSetupStatusSuccess;
return Device::DeviceSetupStatusSuccess;
}
// ON/OFF Button
if (device->deviceClassId() == onOffButtonDeviceClassId) {
return DeviceManager::DeviceSetupStatusSuccess;
return Device::DeviceSetupStatusSuccess;
}
return DeviceManager::DeviceSetupStatusFailure;
return Device::DeviceSetupStatusFailure;
}
DeviceManager::DeviceError DevicePluginGenericElements::executeAction(Device *device, const Action &action)
Device::DeviceError DevicePluginGenericElements::executeAction(Device *device, const Action &action)
{
// Toggle Button
if (device->deviceClassId() == toggleButtonDeviceClassId ) {
if (action.actionTypeId() == toggleButtonStateActionTypeId) {
device->setStateValue(toggleButtonStateStateTypeId, !device->stateValue(toggleButtonStateStateTypeId).toBool());
return DeviceManager::DeviceErrorNoError;
return Device::DeviceErrorNoError;
}
return DeviceManager::DeviceErrorActionTypeNotFound;
return Device::DeviceErrorActionTypeNotFound;
}
// Button
if (device->deviceClassId() == buttonDeviceClassId ) {
if (action.actionTypeId() == buttonButtonPressActionTypeId) {
emit emitEvent(Event(buttonButtonPressedEventTypeId, device->id()));
return DeviceManager::DeviceErrorNoError;
return Device::DeviceErrorNoError;
}
return DeviceManager::DeviceErrorActionTypeNotFound;
return Device::DeviceErrorActionTypeNotFound;
}
// ON/OFF Button
if (device->deviceClassId() == onOffButtonDeviceClassId ) {
if (action.actionTypeId() == onOffButtonOnActionTypeId) {
emit emitEvent(Event(onOffButtonOnEventTypeId, device->id()));
return DeviceManager::DeviceErrorNoError;
return Device::DeviceErrorNoError;
}
if (action.actionTypeId() == onOffButtonOffActionTypeId) {
emit emitEvent(Event(onOffButtonOffEventTypeId, device->id()));
return DeviceManager::DeviceErrorNoError;
return Device::DeviceErrorNoError;
}
return DeviceManager::DeviceErrorActionTypeNotFound;
return Device::DeviceErrorActionTypeNotFound;
}
return DeviceManager::DeviceErrorDeviceClassNotFound;
return Device::DeviceErrorDeviceClassNotFound;
}

View File

@ -23,7 +23,7 @@
#ifndef DEVICEPLUGINGENERICELEMENTS_H
#define DEVICEPLUGINGENERICELEMENTS_H
#include "plugin/deviceplugin.h"
#include "devices/deviceplugin.h"
class DevicePluginGenericElements : public DevicePlugin
{
@ -34,10 +34,10 @@ class DevicePluginGenericElements : public DevicePlugin
public:
explicit DevicePluginGenericElements();
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
Device::DeviceSetupStatus setupDevice(Device *device) override;
public slots:
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
Device::DeviceError executeAction(Device *device, const Action &action) override;
};