Update GenericElements plugin
parent
805d834c3d
commit
dc0ed6fd69
|
|
@ -29,52 +29,30 @@ DevicePluginGenericElements::DevicePluginGenericElements()
|
|||
{
|
||||
}
|
||||
|
||||
Device::DeviceSetupStatus DevicePluginGenericElements::setupDevice(Device *device)
|
||||
void DevicePluginGenericElements::setupDevice(DeviceSetupInfo *info)
|
||||
{
|
||||
// Toggle Button
|
||||
if (device->deviceClassId() == toggleButtonDeviceClassId) {
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
// Button
|
||||
if (device->deviceClassId() == buttonDeviceClassId) {
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
// ON/OFF Button
|
||||
if (device->deviceClassId() == onOffButtonDeviceClassId) {
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
}
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
info->finish(Device::DeviceErrorNoError);
|
||||
}
|
||||
|
||||
Device::DeviceError DevicePluginGenericElements::executeAction(Device *device, const Action &action)
|
||||
void DevicePluginGenericElements::executeAction(DeviceActionInfo *info)
|
||||
{
|
||||
Device *device = info->device();
|
||||
Action action = info->action();
|
||||
|
||||
// Toggle Button
|
||||
if (device->deviceClassId() == toggleButtonDeviceClassId ) {
|
||||
if (action.actionTypeId() == toggleButtonStateActionTypeId) {
|
||||
device->setStateValue(toggleButtonStateStateTypeId, action.params().paramValue(toggleButtonStateActionStateParamTypeId).toBool());
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
if (action.actionTypeId() == toggleButtonStateActionTypeId) {
|
||||
device->setStateValue(toggleButtonStateStateTypeId, action.params().paramValue(toggleButtonStateActionStateParamTypeId).toBool());
|
||||
}
|
||||
// Button
|
||||
if (device->deviceClassId() == buttonDeviceClassId ) {
|
||||
if (action.actionTypeId() == buttonButtonPressActionTypeId) {
|
||||
emit emitEvent(Event(buttonButtonPressedEventTypeId, device->id()));
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
if (action.actionTypeId() == buttonButtonPressActionTypeId) {
|
||||
emit emitEvent(Event(buttonButtonPressedEventTypeId, device->id()));
|
||||
}
|
||||
// ON/OFF Button
|
||||
if (device->deviceClassId() == onOffButtonDeviceClassId ) {
|
||||
if (action.actionTypeId() == onOffButtonOnActionTypeId) {
|
||||
emit emitEvent(Event(onOffButtonOnEventTypeId, device->id()));
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
if (action.actionTypeId() == onOffButtonOffActionTypeId) {
|
||||
emit emitEvent(Event(onOffButtonOffEventTypeId, device->id()));
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
if (action.actionTypeId() == onOffButtonOnActionTypeId) {
|
||||
emit emitEvent(Event(onOffButtonOnEventTypeId, device->id()));
|
||||
}
|
||||
return Device::DeviceErrorDeviceClassNotFound;
|
||||
if (action.actionTypeId() == onOffButtonOffActionTypeId) {
|
||||
emit emitEvent(Event(onOffButtonOffEventTypeId, device->id()));
|
||||
}
|
||||
info->finish(Device::DeviceErrorNoError);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ class DevicePluginGenericElements : public DevicePlugin
|
|||
|
||||
public:
|
||||
explicit DevicePluginGenericElements();
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void setupDevice(DeviceSetupInfo *info) override;
|
||||
|
||||
public slots:
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
void executeAction(DeviceActionInfo *info) override;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue