make use of parent mechanism in mock device
This commit is contained in:
parent
12ff672216
commit
661a75a988
@ -1370,6 +1370,7 @@ void DeviceManager::onAutoDevicesAppeared(const DeviceClassId &deviceClassId, co
|
|||||||
{
|
{
|
||||||
DeviceClass deviceClass = findDeviceClass(deviceClassId);
|
DeviceClass deviceClass = findDeviceClass(deviceClassId);
|
||||||
if (!deviceClass.isValid()) {
|
if (!deviceClass.isValid()) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Auto device appeared for an unknown DeviceClass. Ignoring...";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -130,7 +130,6 @@ DeviceManager::DeviceSetupStatus DevicePluginMock::setupDevice(Device *device)
|
|||||||
return DeviceManager::DeviceSetupStatusSuccess;
|
return DeviceManager::DeviceSetupStatusSuccess;
|
||||||
} else if (device->deviceClassId() == mockChildDeviceClassId) {
|
} else if (device->deviceClassId() == mockChildDeviceClassId) {
|
||||||
qCDebug(dcMockDevice) << "Setup Child mock device" << device->params();
|
qCDebug(dcMockDevice) << "Setup Child mock device" << device->params();
|
||||||
device->setParentId(DeviceId(device->params().paramValue(mockChildParentUuidParamTypeId).toString()));
|
|
||||||
return DeviceManager::DeviceSetupStatusSuccess;
|
return DeviceManager::DeviceSetupStatusSuccess;
|
||||||
} else if (device->deviceClassId() == mockInputTypeDeviceClassId) {
|
} else if (device->deviceClassId() == mockInputTypeDeviceClassId) {
|
||||||
qCDebug(dcMockDevice) << "Setup InputType mock device" << device->params();
|
qCDebug(dcMockDevice) << "Setup InputType mock device" << device->params();
|
||||||
@ -303,14 +302,14 @@ DeviceManager::DeviceError DevicePluginMock::executeAction(Device *device, const
|
|||||||
}
|
}
|
||||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||||
} else if (device->deviceClassId() == mockParentDeviceClassId) {
|
} else if (device->deviceClassId() == mockParentDeviceClassId) {
|
||||||
if (action.actionTypeId() == mockParentBoolValueParentActionTypeId) {
|
if (action.actionTypeId() == mockParentBoolValueActionTypeId) {
|
||||||
device->setStateValue(mockParentBoolValueParentStateTypeId, action.param(mockParentBoolValueParentStateParamTypeId).value().toBool());
|
device->setStateValue(mockParentBoolValueStateTypeId, action.param(mockParentBoolValueStateParamTypeId).value().toBool());
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||||
} else if (device->deviceClassId() == mockChildDeviceClassId) {
|
} else if (device->deviceClassId() == mockChildDeviceClassId) {
|
||||||
if (action.actionTypeId() == mockChildBoolValueParentActionTypeId) {
|
if (action.actionTypeId() == mockChildBoolValueActionTypeId) {
|
||||||
device->setStateValue(mockChildBoolValueParentStateTypeId, action.param(mockChildBoolValueParentStateParamTypeId).value().toBool());
|
device->setStateValue(mockChildBoolValueStateTypeId, action.param(mockChildBoolValueStateParamTypeId).value().toBool());
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||||
@ -458,11 +457,7 @@ void DevicePluginMock::onDisplayPinPairingFinished()
|
|||||||
void DevicePluginMock::onChildDeviceDiscovered(const DeviceId &parentId)
|
void DevicePluginMock::onChildDeviceDiscovered(const DeviceId &parentId)
|
||||||
{
|
{
|
||||||
qCDebug(dcMockDevice) << "Child device discovered for parent" << parentId.toString();
|
qCDebug(dcMockDevice) << "Child device discovered for parent" << parentId.toString();
|
||||||
DeviceDescriptor mockDescriptor(mockChildDeviceClassId, "Child Mock Device (Auto created)");
|
DeviceDescriptor mockDescriptor(mockChildDeviceClassId, "Child Mock Device (Auto created)", "Child Mock Device (Auto created)", parentId);
|
||||||
ParamList params;
|
|
||||||
params.append(Param(mockChildParentUuidParamTypeId, parentId));
|
|
||||||
mockDescriptor.setParams(params);
|
|
||||||
|
|
||||||
emit autoDevicesAppeared(mockChildDeviceClassId, QList<DeviceDescriptor>() << mockDescriptor);
|
emit autoDevicesAppeared(mockChildDeviceClassId, QList<DeviceDescriptor>() << mockDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -530,7 +530,7 @@
|
|||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
{
|
{
|
||||||
"id": "d24ede5f-4064-4898-bb84-cfb533b1fbc0",
|
"id": "d24ede5f-4064-4898-bb84-cfb533b1fbc0",
|
||||||
"name": "boolValueParent",
|
"name": "boolValue",
|
||||||
"displayName": "bool value",
|
"displayName": "bool value",
|
||||||
"displayNameEvent": "bool value changed",
|
"displayNameEvent": "bool value changed",
|
||||||
"displayNameAction": "Set bool value",
|
"displayNameAction": "Set bool value",
|
||||||
@ -545,23 +545,15 @@
|
|||||||
"name": "mockChild",
|
"name": "mockChild",
|
||||||
"displayName": "Mock Device (Child)",
|
"displayName": "Mock Device (Child)",
|
||||||
"createMethods": ["auto"],
|
"createMethods": ["auto"],
|
||||||
|
"paramTypes": [],
|
||||||
"basicTags": [
|
"basicTags": [
|
||||||
"Device",
|
"Device",
|
||||||
"Actuator"
|
"Actuator"
|
||||||
],
|
],
|
||||||
"paramTypes": [
|
|
||||||
{
|
|
||||||
"id": "104b5288-404e-42d3-bf38-e40682e75681",
|
|
||||||
"name": "parentUuid",
|
|
||||||
"displayName": "parent uuid",
|
|
||||||
"type": "QUuid",
|
|
||||||
"readOnly": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
{
|
{
|
||||||
"id": "d24ede5f-4064-4898-bb84-cfb533b1fbc0",
|
"id": "d24ede5f-4064-4898-bb84-cfb533b1fbc0",
|
||||||
"name": "boolValueParent",
|
"name": "boolValue",
|
||||||
"displayName": "bool value",
|
"displayName": "bool value",
|
||||||
"displayNameEvent": "bool value changed",
|
"displayNameEvent": "bool value changed",
|
||||||
"displayNameAction": "Set bool value",
|
"displayNameAction": "Set bool value",
|
||||||
|
|||||||
Reference in New Issue
Block a user