fixed multiple creation of mock autodevice on each start

pull/135/head
Simon Stürz 2014-10-17 10:26:37 +02:00 committed by Michael Zanetti
parent 04ed3f5685
commit 4e5656b299
4 changed files with 104 additions and 40 deletions

View File

@ -615,6 +615,7 @@ void DeviceManager::loadConfiguredDevices()
// it means that it was working at some point so lets still add it as there might
// be rules associated with this device. Device::setupCompleted() will be false.
setupDevice(device);
m_configuredDevices.append(device);
}
settings.endGroup();

View File

@ -3,7 +3,7 @@
"id": "2b267f81-d9ae-4f4f-89a0-7386b547cfd3",
"vendors": [
{
"name": "Electronic Roos",
"name": "Elro",
"id": "435a13a0-65ca-4f0c-94c1-e5873b258db5",
"deviceClasses": [
{
@ -12,23 +12,23 @@
"createMethods": ["user"],
"paramTypes": [
{
"name": "channel1",
"name": "channel 1",
"type": "bool"
},
{
"name": "channel2",
"name": "channel 2",
"type": "bool"
},
{
"name": "channel3",
"name": "channel 3",
"type": "bool"
},
{
"name": "channel4",
"name": "channel 4",
"type": "bool"
},
{
"name": "channel5",
"name": "channel 5",
"type": "bool"
}
],
@ -91,23 +91,23 @@
"createMethods": ["user"],
"paramTypes": [
{
"name": "channel1",
"name": "channel 1",
"type": "bool"
},
{
"name": "channel2",
"name": "channel 2",
"type": "bool"
},
{
"name": "channel3",
"name": "channel 3",
"type": "bool"
},
{
"name": "channel4",
"name": "channel 4",
"type": "bool"
},
{
"name": "channel5",
"name": "channel 5",
"type": "bool"
},
{
@ -150,22 +150,6 @@
"createMethods": ["discovery"]
}
]
},
{
"name": "Mumbi",
"id": "5f91c01c-0168-4bdf-a5ed-37cb6971b775"
},
{
"name": "Vivanco",
"id": "3826a836-ba69-4e50-8408-bb827fc92128"
},
{
"name": "Brennenstuhl",
"id": "4ac9dd1f-9ca9-4a76-aae1-3e91cfb86f5b"
},
{
"name": "BAT",
"id": "30115ad4-c83d-454a-a483-c781c951d3b6"
}
]
}

View File

@ -26,6 +26,11 @@
#include <QStringList>
DeviceClassId mockDeviceClassId = DeviceClassId("753f0d32-0468-4d08-82ed-1964aab03298");
DeviceClassId mockDeviceAutoClassId = DeviceClassId("ab4257b3-7548-47ee-9bd4-7dc3004fd197");
//DeviceClassId mockDeviceDiscoveryClassId = DeviceClassId("1bbaf751-36b7-4d3d-b05a-58dab2a3be8c");
//DeviceClassId mockDeviceAsyncSetupClassId = DeviceClassId("c08a8b27-8200-413d-b96b-4cff78b864d9");
//DeviceClassId mockDeviceBrokenClassId = DeviceClassId("ba5fb404-c9ce-4db4-8cd4-f48c61c24b13");
//DeviceClassId mockDeviceBrokenAsyncSetupClassId = DeviceClassId("bd5b78c5-53c9-4417-8eac-8ab2bce97bd0");
EventTypeId mockEvent1Id = EventTypeId("45bf3752-0fc6-46b9-89fd-ffd878b5b22b");
EventTypeId mockEvent2Id = EventTypeId("863d5920-b1cf-4eb9-88bd-8f7b8583b1cf");
StateTypeId mockIntStateId = StateTypeId("80baec19-54de-4948-ac46-31eabfaceb83");
@ -94,12 +99,12 @@ void DevicePluginMock::deviceRemoved(Device *device)
void DevicePluginMock::startMonitoringAutoDevices()
{
foreach (Device *device, myDevices()) {
if (device->paramValue("auto").toBool()) {
if (device->deviceClassId() == mockDeviceAutoClassId) {
return; // We already have a Auto Mock device... do nothing.
}
}
DeviceDescriptor mockDescriptor(mockDeviceClassId, "Mock Device (Auto created)");
DeviceDescriptor mockDescriptor(mockDeviceAutoClassId, "Mock Device (Auto created)");
ParamList params;
qsrand(QDateTime::currentMSecsSinceEpoch());
@ -111,7 +116,7 @@ void DevicePluginMock::startMonitoringAutoDevices()
QList<DeviceDescriptor> deviceDescriptorList;
deviceDescriptorList.append(mockDescriptor);
emit autoDevicesAppeared(mockDeviceClassId, deviceDescriptorList);
emit autoDevicesAppeared(mockDeviceAutoClassId, deviceDescriptorList);
}
QList<ParamType> DevicePluginMock::configurationDescription() const

View File

@ -9,15 +9,7 @@
{
"deviceClassId": "753f0d32-0468-4d08-82ed-1964aab03298",
"name": "Mock Device",
"createMethods": ["user", "auto", "discovery"],
"discoveryParamTypes": [
{
"name": "resultCount",
"type": "int",
"defaultValue": 2,
"allowedValues": [1, 2]
}
],
"createMethods": ["user","discovery"],
"paramTypes": [
{
"name": "httpport",
@ -42,7 +34,89 @@
},
{
"id": "9dd6a97c-dfd1-43dc-acbd-367932742310",
"name:": "Dummy boo state",
"name:": "Dummy bool state",
"defaultValue": "false"
}
],
"eventTypes": [
{
"id": "45bf3752-0fc6-46b9-89fd-ffd878b5b22b",
"name": "Mock Event 1"
},
{
"id": "863d5920-b1cf-4eb9-88bd-8f7b8583b1cf",
"name": "Mock Event 2",
"paramTypes": [
{
"name": "mockParamInt",
"type": "int",
"defaultValue": 10
}
]
}
],
"actionTypes": [
{
"id": "dea0f4e1-65e3-4981-8eaa-2701c53a9185",
"name": "Mock Action 1 (with params)",
"paramTypes": [
{
"name": "mockActionParam1",
"type": "int"
},
{
"name": "mockActionParam2",
"type": "bool"
}
]
},
{
"id": "defd3ed6-1a0d-400b-8879-a0202cf39935",
"name": "Mock Action 2 (without params)"
},
{
"id": "fbae06d3-7666-483e-a39e-ec50fe89054e",
"name": "Mock Action 3 (async)"
},
{
"id": "df3cf33d-26d5-4577-9132-9823bd33fad0",
"name": "Mock Action 4 (broken)"
},
{
"id": "bfe89a1d-3497-4121-8318-e77c37537219",
"name": "Mock Action 5 (async, broken)"
}
]
},
{
"deviceClassId": "ab4257b3-7548-47ee-9bd4-7dc3004fd197",
"name": "Mock Device (Auto created)",
"createMethods": ["auto"],
"paramTypes": [
{
"name": "httpport",
"type": "int"
},
{
"name": "async",
"type": "bool",
"defaultValue": false
},
{
"name": "broken",
"type": "bool",
"defaultValue": false
}
],
"stateTypes": [
{
"id": "80baec19-54de-4948-ac46-31eabfaceb83",
"name": "Dummy int state",
"defaultValue": 10
},
{
"id": "9dd6a97c-dfd1-43dc-acbd-367932742310",
"name:": "Dummy bool state",
"defaultValue": "false"
}
],