Add A simulated device for the barcodescanner interface
This commit is contained in:
parent
56c173cb63
commit
a5e37670db
@ -61,7 +61,8 @@ void DevicePluginSimulation::setupDevice(DeviceSetupInfo *info)
|
|||||||
device->deviceClassId() == extendedBlindDeviceClassId ||
|
device->deviceClassId() == extendedBlindDeviceClassId ||
|
||||||
device->deviceClassId() == rollerShutterDeviceClassId ||
|
device->deviceClassId() == rollerShutterDeviceClassId ||
|
||||||
device->deviceClassId() == fingerPrintSensorDeviceClassId ||
|
device->deviceClassId() == fingerPrintSensorDeviceClassId ||
|
||||||
device->deviceClassId() == thermostatDeviceClassId) {
|
device->deviceClassId() == thermostatDeviceClassId ||
|
||||||
|
device->deviceClassId() == barcodeScannerDeviceClassId) {
|
||||||
m_simulationTimers.insert(device, new QTimer(device));
|
m_simulationTimers.insert(device, new QTimer(device));
|
||||||
connect(m_simulationTimers[device], &QTimer::timeout, this, &DevicePluginSimulation::simulationTimerTimeout);
|
connect(m_simulationTimers[device], &QTimer::timeout, this, &DevicePluginSimulation::simulationTimerTimeout);
|
||||||
}
|
}
|
||||||
@ -704,5 +705,26 @@ void DevicePluginSimulation::simulationTimerTimeout()
|
|||||||
} else if (device->deviceClassId() == thermostatDeviceClassId) {
|
} else if (device->deviceClassId() == thermostatDeviceClassId) {
|
||||||
device->setStateValue(thermostatBoostStateTypeId, false);
|
device->setStateValue(thermostatBoostStateTypeId, false);
|
||||||
t->stop();
|
t->stop();
|
||||||
|
} else if (device->deviceClassId() == barcodeScannerDeviceClassId) {
|
||||||
|
QString code;
|
||||||
|
int codeIndex = device->property("codeIndex").toInt();
|
||||||
|
switch (codeIndex) {
|
||||||
|
case 0:
|
||||||
|
code = "12345";
|
||||||
|
device->setProperty("codeIndex", 1);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
code = "23456";
|
||||||
|
device->setProperty("codeIndex", 2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
code = "34567";
|
||||||
|
device->setProperty("codeIndex", 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ParamList params = ParamList() << Param(barcodeScannerCodeScannedEventContentParamTypeId, code);
|
||||||
|
Event event(barcodeScannerCodeScannedEventTypeId, device->id(), params);
|
||||||
|
emit emitEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1017,6 +1017,28 @@
|
|||||||
"writable": true
|
"writable": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "672d68ac-c19b-46b0-be01-4468c36dd3da",
|
||||||
|
"name": "barcodeScanner",
|
||||||
|
"displayName": "Barcode Scanner",
|
||||||
|
"createMethods": ["user"],
|
||||||
|
"interfaces": ["barcodescanner"],
|
||||||
|
"eventTypes": [
|
||||||
|
{
|
||||||
|
"id": "20910fac-93ff-4679-bec9-786defcd1875",
|
||||||
|
"name": "codeScanned",
|
||||||
|
"displayName": "Code scanned",
|
||||||
|
"paramTypes": [
|
||||||
|
{
|
||||||
|
"id": "d76c1a34-ee9a-4363-80bb-2042639311c7",
|
||||||
|
"name": "content",
|
||||||
|
"displayName": "Cotent",
|
||||||
|
"type": "QString"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user