diff options
author | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2017-09-20 09:35:56 +0200 |
---|---|---|
committer | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2017-09-27 06:35:24 +0000 |
commit | cf2ec248f2c8d6fabc539f2acef4df5d3c0e8b6c (patch) | |
tree | 01c4feef45ddf310113a7f2f2d5b06e20b443fbe /tradeshow/iot-sensortag/main.cpp | |
parent | 55ce120e6ceccb40f19a941fbda05edefd22d64c (diff) |
iot-sensortag: Redesign of example
The updated version switches the focus from having multiple sensors
locally towards showing one sensor from a list. This list can display
local or remote sensors and switch on runtime.
Also incorporated many style fixes and cleanups.
Change-Id: If7b8acbb2a784ebba95d467176e76728721c82f7
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'tradeshow/iot-sensortag/main.cpp')
-rw-r--r-- | tradeshow/iot-sensortag/main.cpp | 91 |
1 files changed, 19 insertions, 72 deletions
diff --git a/tradeshow/iot-sensortag/main.cpp b/tradeshow/iot-sensortag/main.cpp index 5164919..30c8813 100644 --- a/tradeshow/iot-sensortag/main.cpp +++ b/tradeshow/iot-sensortag/main.cpp @@ -81,63 +81,29 @@ int main(int argc, char *argv[]) QFontDatabase::addApplicationFont(QString::fromLatin1(":/resources/base/fonts/titilliumweb/TitilliumWeb-Regular.ttf")); app.setFont(QFont("Titillium Web", 13)); - DataProviderPool *dataProviderPool = 0; + DataProviderPool *remoteProviderPool = nullptr; + DataProviderPool *localProviderPool = nullptr; SeriesStorage seriesStorage; QCommandLineParser parser; - parser.addOptions({{"source", "Sensor data source", "cloud | sensor | mock"}, {"fullscreen", "Fullscreen mode", "true | false"}}); + parser.addOptions({{"fullscreen", "Fullscreen mode", "true | false"}}); parser.addHelpOption(); parser.process(app); - QString sensorSource = parser.value("source"); - - if (sensorSource.isEmpty()) - sensorSource = qgetenv("QT_IOT_DEMO_DATA_SOURCE"); - - if (sensorSource.isEmpty()) - // There is no wastorage package available for WinRT -#ifdef Q_OS_WINRT - sensorSource = "mock"; -#else - sensorSource = "cloud"; -#endif - - if (sensorSource == QString("cloud").toLower()) { - qCDebug(boot2QtDemos) << "Running in cloud mode"; - dataProviderPool = new CloudDataProviderPool; - } #if defined(RUNS_AS_HOST) - else if (sensorSource == QString("sensor").toLower()) { - qCDebug(boot2QtDemos) << "Running in sensor mode"; - dataProviderPool = new DemoDataProviderPool; - // List of devices used in Embedded World - static_cast<SensorTagDataProviderPool*>(dataProviderPool)->setMacFilterList(QStringList() << - "24:71:89:BF:3B:82" << - "24:71:89:BC:44:82"); - } +// localProviderPool = new MockDataProviderPool; + localProviderPool = new DemoDataProviderPool; #endif - else if (sensorSource == QString("mock").toLower()){ - qCDebug(boot2QtDemos) << "Running in mock data mode"; - dataProviderPool = new MockDataProviderPool; - } - else { - qCDebug(boot2QtDemos) << "Unknown mode: " << sensorSource; - return 1; - } - - seriesStorage.setDataProviderPool(dataProviderPool); + seriesStorage.setDataProviderPool(remoteProviderPool); qmlRegisterType<SensorTagDataProvider>("SensorTag.DataProvider", 1, 0, "SensorTagData"); - qmlRegisterType<SensorTagDataProvider>("SensorTag.DataProvider", 1, 0, "ProviderState"); qmlRegisterType<DataProviderPool>("SensorTag.DataProvider", 1, 0, "DataProviderPool"); qmlRegisterType<SeriesStorage>("SensorTag.SeriesStorage", 1, 0, "SeriesStorage"); #if defined(RUNS_AS_HOST) && defined(AZURE_UPLOAD) CloudUpdate update; - if (sensorSource == "sensor" || sensorSource == "mock") { - update.setDataProviderPool(dataProviderPool); - update.restart(); - } + update.setDataProviderPool(localProviderPool); + update.restart(); #endif #ifdef DEPLOY_TO_FS @@ -169,34 +135,13 @@ int main(int argc, char *argv[]) addressString.append(QLatin1Char('/')); } } -#if defined(UI_SMALL) - mainFile = namingScheme + QStringLiteral("/resources/small/MainSmall.qml"); - styleFile = namingScheme + QStringLiteral("/resources/small/StyleSmall.qml"); - - uiVariant = "small"; - fullScreen = true; - appWidth = 1920; - appHeight = 1080; - qCDebug(boot2QtDemos) << "Using SMALL UI variant"; -#elif defined(UI_MEDIUM) - mainFile =QStringLiteral("qrc:/resources/medium/MainMedium.qml"); - styleFile = QUrl("qrc:/resources/medium/StyleMedium.qml"); - uiVariant = "medium"; - fullScreen = true; - appWidth = 1920; - appHeight = 1080; - qCDebug(boot2QtDemos) << "Using MEDIUM UI variant"; -#elif defined(UI_LARGE) - mainFile = QStringLiteral("qrc:/resources/large/MainLarge.qml"); - styleFile = QUrl("qrc:/resources/large/StyleLarge.qml"); - uiVariant = "large"; - fullScreen = true; - appWidth = 3840; - appHeight = 2160; - qCDebug(boot2QtDemos) << "Using LARGE UI variant"; -#else -#error "Unknown UI form factor set in the project file" -#endif + mainFile = namingScheme + QStringLiteral("/resources/small/MainSmall.qml"); + styleFile = namingScheme + QStringLiteral("/resources/small/StyleSmall.qml"); + + uiVariant = "small"; + fullScreen = false; + appWidth = 1920; + appHeight = 1080; qmlRegisterSingletonType(styleFile, "Style", 1,0, "Style"); @@ -221,12 +166,14 @@ int main(int argc, char *argv[]) if (fullScreen) item->showFullScreen(); - item->setProperty("dataProviderPool", QVariant::fromValue(dataProviderPool)); + item->setProperty("localProviderPool", QVariant::fromValue(localProviderPool)); + item->setProperty("remoteProviderPool", QVariant::fromValue(remoteProviderPool)); item->setProperty("contentFile", mainFile); item->setProperty("seriesStorage", QVariant::fromValue(&seriesStorage)); item->setProperty("addresses", addressString); } int returnValue = app.exec(); - dataProviderPool->stopScanning(); + remoteProviderPool->stopScanning(); + return returnValue; } |