Merge PR #182: Simulation: Add a simulated barcode scanner device
This commit is contained in:
commit
764580494c
5
debian/changelog
vendored
5
debian/changelog
vendored
@ -1,3 +1,8 @@
|
|||||||
|
nymea-plugins (0.17.0) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
|
|
||||||
|
-- Michael Zanetti <michael.zanetti@guh.io> Tue, 19 Nov 2019 20:17:07 +0100
|
||||||
|
|
||||||
nymea-plugins (0.16.0) xenial; urgency=medium
|
nymea-plugins (0.16.0) xenial; urgency=medium
|
||||||
|
|
||||||
[ Bernhard Trinnes ]
|
[ Bernhard Trinnes ]
|
||||||
|
|||||||
2
debian/control
vendored
2
debian/control
vendored
@ -4,7 +4,7 @@ Priority: options
|
|||||||
Maintainer: Michael Zanetti <michael.zanetti@guh.io>
|
Maintainer: Michael Zanetti <michael.zanetti@guh.io>
|
||||||
Build-depends: libboblight-dev,
|
Build-depends: libboblight-dev,
|
||||||
debhelper (>= 0.0.0),
|
debhelper (>= 0.0.0),
|
||||||
libnymea1-dev,
|
libnymea1-dev (>= 0.17),
|
||||||
libnymea-mqtt-dev,
|
libnymea-mqtt-dev,
|
||||||
libqt5serialport5-dev,
|
libqt5serialport5-dev,
|
||||||
libqt5websockets5-dev,
|
libqt5websockets5-dev,
|
||||||
|
|||||||
@ -146,7 +146,7 @@ void DevicePluginNetworkDetector::deviceAddressChanged(const QString &address)
|
|||||||
Device *device = m_monitors.value(monitor);
|
Device *device = m_monitors.value(monitor);
|
||||||
if (device->paramValue(networkDeviceDeviceAddressParamTypeId).toString() != address) {
|
if (device->paramValue(networkDeviceDeviceAddressParamTypeId).toString() != address) {
|
||||||
qCDebug(dcNetworkDetector()) << "Device" << device->name() << device->paramValue(networkDeviceDeviceMacAddressParamTypeId).toString() << "changed IP address to" << address;
|
qCDebug(dcNetworkDetector()) << "Device" << device->name() << device->paramValue(networkDeviceDeviceMacAddressParamTypeId).toString() << "changed IP address to" << address;
|
||||||
device->setParamValue(networkDeviceDeviceAddressParamTypeId.toString(), address);
|
device->setParamValue(networkDeviceDeviceAddressParamTypeId, address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -61,13 +61,17 @@ 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);
|
||||||
}
|
}
|
||||||
if (device->deviceClassId() == fingerPrintSensorDeviceClassId && device->stateValue(fingerPrintSensorUsersStateTypeId).toStringList().count() > 0) {
|
if (device->deviceClassId() == fingerPrintSensorDeviceClassId && device->stateValue(fingerPrintSensorUsersStateTypeId).toStringList().count() > 0) {
|
||||||
m_simulationTimers.value(device)->start(10000);
|
m_simulationTimers.value(device)->start(10000);
|
||||||
}
|
}
|
||||||
|
if (device->deviceClassId() == barcodeScannerDeviceClassId) {
|
||||||
|
m_simulationTimers.value(device)->start(10000);
|
||||||
|
}
|
||||||
info->finish(Device::DeviceErrorNoError);
|
info->finish(Device::DeviceErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,5 +708,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