updated device API
This commit is contained in:
parent
5309a1d712
commit
fb8cd3b497
@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "deviceplugingenericinterfaces.h"
|
#include "deviceplugingenericinterfaces.h"
|
||||||
#include "devicemanager.h"
|
#include "devices/devicemanager.h"
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -53,56 +53,56 @@ DevicePluginGenericInterfaces::DevicePluginGenericInterfaces()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceManager::DeviceSetupStatus DevicePluginGenericInterfaces::setupDevice(Device *device)
|
Device::DeviceSetupStatus DevicePluginGenericInterfaces::setupDevice(Device *device)
|
||||||
{
|
{
|
||||||
if (device->deviceClassId() == awningDeviceClassId) {
|
if (device->deviceClassId() == awningDeviceClassId) {
|
||||||
return DeviceManager::DeviceSetupStatusSuccess;
|
return Device::DeviceSetupStatusSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->deviceClassId() == blindDeviceClassId) {
|
if (device->deviceClassId() == blindDeviceClassId) {
|
||||||
return DeviceManager::DeviceSetupStatusSuccess;
|
return Device::DeviceSetupStatusSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->deviceClassId() == shutterDeviceClassId) {
|
if (device->deviceClassId() == shutterDeviceClassId) {
|
||||||
return DeviceManager::DeviceSetupStatusSuccess;
|
return Device::DeviceSetupStatusSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->deviceClassId() == socketDeviceClassId) {
|
if (device->deviceClassId() == socketDeviceClassId) {
|
||||||
return DeviceManager::DeviceSetupStatusSuccess;
|
return Device::DeviceSetupStatusSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->deviceClassId() == lightDeviceClassId) {
|
if (device->deviceClassId() == lightDeviceClassId) {
|
||||||
return DeviceManager::DeviceSetupStatusSuccess;
|
return Device::DeviceSetupStatusSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->deviceClassId() == heatingDeviceClassId) {
|
if (device->deviceClassId() == heatingDeviceClassId) {
|
||||||
return DeviceManager::DeviceSetupStatusSuccess;
|
return Device::DeviceSetupStatusSuccess;
|
||||||
}
|
}
|
||||||
return DeviceManager::DeviceSetupStatusFailure;
|
return Device::DeviceSetupStatusFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device *device, const Action &action)
|
Device::DeviceError DevicePluginGenericInterfaces::executeAction(Device *device, const Action &action)
|
||||||
{
|
{
|
||||||
if (device->deviceClassId() == awningDeviceClassId) {
|
if (device->deviceClassId() == awningDeviceClassId) {
|
||||||
if (action.actionTypeId() == awningOpenActionTypeId) {
|
if (action.actionTypeId() == awningOpenActionTypeId) {
|
||||||
device->setStateValue(awningStatusStateTypeId, "Opening");
|
device->setStateValue(awningStatusStateTypeId, "Opening");
|
||||||
device->setStateValue(awningClosingOutputStateTypeId, false);
|
device->setStateValue(awningClosingOutputStateTypeId, false);
|
||||||
device->setStateValue(awningOpeningOutputStateTypeId, true);
|
device->setStateValue(awningOpeningOutputStateTypeId, true);
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return Device::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
if (action.actionTypeId() == awningStopActionTypeId) {
|
if (action.actionTypeId() == awningStopActionTypeId) {
|
||||||
device->setStateValue(awningStatusStateTypeId, "Stopped");
|
device->setStateValue(awningStatusStateTypeId, "Stopped");
|
||||||
device->setStateValue(awningOpeningOutputStateTypeId, false);
|
device->setStateValue(awningOpeningOutputStateTypeId, false);
|
||||||
device->setStateValue(awningClosingOutputStateTypeId, false);
|
device->setStateValue(awningClosingOutputStateTypeId, false);
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return Device::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
if (action.actionTypeId() == awningCloseActionTypeId) {
|
if (action.actionTypeId() == awningCloseActionTypeId) {
|
||||||
device->setStateValue(awningStatusStateTypeId, "Closing");
|
device->setStateValue(awningStatusStateTypeId, "Closing");
|
||||||
device->setStateValue(awningOpeningOutputStateTypeId, false);
|
device->setStateValue(awningOpeningOutputStateTypeId, false);
|
||||||
device->setStateValue(awningClosingOutputStateTypeId, true);
|
device->setStateValue(awningClosingOutputStateTypeId, true);
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return Device::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
return Device::DeviceErrorActionTypeNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->deviceClassId() == blindDeviceClassId ) {
|
if (device->deviceClassId() == blindDeviceClassId ) {
|
||||||
@ -110,21 +110,21 @@ DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device *
|
|||||||
device->setStateValue(blindStatusStateTypeId, "Opening");
|
device->setStateValue(blindStatusStateTypeId, "Opening");
|
||||||
device->setStateValue(blindClosingOutputStateTypeId, false);
|
device->setStateValue(blindClosingOutputStateTypeId, false);
|
||||||
device->setStateValue(blindOpeningOutputStateTypeId, true);
|
device->setStateValue(blindOpeningOutputStateTypeId, true);
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return Device::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
if (action.actionTypeId() == blindStopActionTypeId) {
|
if (action.actionTypeId() == blindStopActionTypeId) {
|
||||||
device->setStateValue(blindStatusStateTypeId, "Stopped");
|
device->setStateValue(blindStatusStateTypeId, "Stopped");
|
||||||
device->setStateValue(blindOpeningOutputStateTypeId, false);
|
device->setStateValue(blindOpeningOutputStateTypeId, false);
|
||||||
device->setStateValue(blindClosingOutputStateTypeId, false);
|
device->setStateValue(blindClosingOutputStateTypeId, false);
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return Device::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
if (action.actionTypeId() == blindCloseActionTypeId) {
|
if (action.actionTypeId() == blindCloseActionTypeId) {
|
||||||
device->setStateValue(blindStatusStateTypeId, "Closing");
|
device->setStateValue(blindStatusStateTypeId, "Closing");
|
||||||
device->setStateValue(blindOpeningOutputStateTypeId, false);
|
device->setStateValue(blindOpeningOutputStateTypeId, false);
|
||||||
device->setStateValue(blindClosingOutputStateTypeId, true);
|
device->setStateValue(blindClosingOutputStateTypeId, true);
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return Device::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
return Device::DeviceErrorActionTypeNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->deviceClassId() == shutterDeviceClassId) {
|
if (device->deviceClassId() == shutterDeviceClassId) {
|
||||||
@ -132,45 +132,45 @@ DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device *
|
|||||||
device->setStateValue(shutterStatusStateTypeId, "Opening");
|
device->setStateValue(shutterStatusStateTypeId, "Opening");
|
||||||
device->setStateValue(shutterClosingOutputStateTypeId, false);
|
device->setStateValue(shutterClosingOutputStateTypeId, false);
|
||||||
device->setStateValue(shutterOpeningOutputStateTypeId, true);
|
device->setStateValue(shutterOpeningOutputStateTypeId, true);
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return Device::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
if (action.actionTypeId() == shutterStopActionTypeId) {
|
if (action.actionTypeId() == shutterStopActionTypeId) {
|
||||||
device->setStateValue(shutterStatusStateTypeId, "Stopped");
|
device->setStateValue(shutterStatusStateTypeId, "Stopped");
|
||||||
device->setStateValue(shutterOpeningOutputStateTypeId, false);
|
device->setStateValue(shutterOpeningOutputStateTypeId, false);
|
||||||
device->setStateValue(shutterClosingOutputStateTypeId, false);
|
device->setStateValue(shutterClosingOutputStateTypeId, false);
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return Device::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
if (action.actionTypeId() == shutterCloseActionTypeId) {
|
if (action.actionTypeId() == shutterCloseActionTypeId) {
|
||||||
device->setStateValue(shutterStatusStateTypeId, "Closing");
|
device->setStateValue(shutterStatusStateTypeId, "Closing");
|
||||||
device->setStateValue(shutterOpeningOutputStateTypeId, false);
|
device->setStateValue(shutterOpeningOutputStateTypeId, false);
|
||||||
device->setStateValue(shutterClosingOutputStateTypeId, true);
|
device->setStateValue(shutterClosingOutputStateTypeId, true);
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return Device::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
return Device::DeviceErrorActionTypeNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->deviceClassId() == socketDeviceClassId) {
|
if (device->deviceClassId() == socketDeviceClassId) {
|
||||||
if (action.actionTypeId() == socketPowerActionTypeId) {
|
if (action.actionTypeId() == socketPowerActionTypeId) {
|
||||||
device->setStateValue(socketPowerStateTypeId, action.param(socketPowerActionPowerParamTypeId).value());
|
device->setStateValue(socketPowerStateTypeId, action.param(socketPowerActionPowerParamTypeId).value());
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return Device::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
return Device::DeviceErrorActionTypeNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->deviceClassId() == lightDeviceClassId) {
|
if (device->deviceClassId() == lightDeviceClassId) {
|
||||||
if (action.actionTypeId() == lightPowerActionTypeId) {
|
if (action.actionTypeId() == lightPowerActionTypeId) {
|
||||||
device->setStateValue(lightPowerStateTypeId, action.param(lightPowerActionPowerParamTypeId).value());
|
device->setStateValue(lightPowerStateTypeId, action.param(lightPowerActionPowerParamTypeId).value());
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return Device::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
return Device::DeviceErrorActionTypeNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->deviceClassId() == heatingDeviceClassId) {
|
if (device->deviceClassId() == heatingDeviceClassId) {
|
||||||
if (action.actionTypeId() == heatingPowerActionTypeId) {
|
if (action.actionTypeId() == heatingPowerActionTypeId) {
|
||||||
device->setStateValue(heatingPowerStateTypeId, action.param(heatingPowerActionPowerParamTypeId).value());
|
device->setStateValue(heatingPowerStateTypeId, action.param(heatingPowerActionPowerParamTypeId).value());
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return Device::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
return Device::DeviceErrorActionTypeNotFound;
|
||||||
}
|
}
|
||||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
return Device::DeviceErrorDeviceClassNotFound;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
#ifndef DEVICEPLUGINGENERICINTERFACES_H
|
#ifndef DEVICEPLUGINGENERICINTERFACES_H
|
||||||
#define DEVICEPLUGINGENERICINTERFACES_H
|
#define DEVICEPLUGINGENERICINTERFACES_H
|
||||||
|
|
||||||
#include "plugin/deviceplugin.h"
|
#include "devices/deviceplugin.h"
|
||||||
|
|
||||||
class DevicePluginGenericInterfaces : public DevicePlugin
|
class DevicePluginGenericInterfaces : public DevicePlugin
|
||||||
{
|
{
|
||||||
@ -34,10 +34,10 @@ class DevicePluginGenericInterfaces : public DevicePlugin
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DevicePluginGenericInterfaces();
|
explicit DevicePluginGenericInterfaces();
|
||||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6",
|
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6",
|
||||||
"deviceClasses": [
|
"deviceClasses": [
|
||||||
{
|
{
|
||||||
"id": "",
|
"id": "9e69585f-90ba-44e4-ad90-5b4bffbe345a",
|
||||||
"name": "awning",
|
"name": "awning",
|
||||||
"displayName": "Awning",
|
"displayName": "Awning",
|
||||||
"createMethods": ["user"],
|
"createMethods": ["user"],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user