diff options
Diffstat (limited to 'src/plugins/sensors/simulator')
21 files changed, 0 insertions, 1720 deletions
diff --git a/src/plugins/sensors/simulator/main.cpp b/src/plugins/sensors/simulator/main.cpp deleted file mode 100644 index 167711a9..00000000 --- a/src/plugins/sensors/simulator/main.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatoraccelerometer.h" -#include "simulatorambientlightsensor.h" -#include "simulatorlightsensor.h" -#include "simulatorcompass.h" -#include "simulatorproximitysensor.h" -#include "simulatorirproximitysensor.h" -#include "simulatormagnetometer.h" -#include <QSensorPluginInterface> -#include <QSensorBackend> -#include <QSensorManager> - -class SimulatorSensorPlugin : public QObject, public QSensorPluginInterface, public QSensorBackendFactory -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "com.qt-project.Qt.QSensorPluginInterface/1.0" FILE "plugin.json") - Q_INTERFACES(QSensorPluginInterface) -public: - SimulatorSensorPlugin() - { - SensorsConnection *connection = SensorsConnection::instance(); - if (!connection) return; // hardly likely but just in case... - connect(connection, SIGNAL(setAvailableFeatures(quint32)), this, SLOT(setAvailableFeatures(quint32))); - } - - void registerSensors() override - { - QSensorManager::registerBackend(QAccelerometer::type, SimulatorAccelerometer::id, this); - QSensorManager::registerBackend(QAmbientLightSensor::type, SimulatorAmbientLightSensor::id, this); - QSensorManager::registerBackend(QLightSensor::type, SimulatorLightSensor::id, this); - QSensorManager::registerBackend(QCompass::type, SimulatorCompass::id, this); - QSensorManager::registerBackend(QProximitySensor::type, SimulatorProximitySensor::id, this); - QSensorManager::registerBackend(QIRProximitySensor::type, SimulatorIRProximitySensor::id, this); - QSensorManager::registerBackend(QMagnetometer::type, SimulatorMagnetometer::id, this); - } - - QSensorBackend *createBackend(QSensor *sensor) override - { - if (sensor->identifier() == SimulatorAccelerometer::id) { - return new SimulatorAccelerometer(sensor); - } - - if (sensor->identifier() == SimulatorAmbientLightSensor::id) { - return new SimulatorAmbientLightSensor(sensor); - } - - if (sensor->identifier() == SimulatorLightSensor::id) { - return new SimulatorLightSensor(sensor); - } - - if (sensor->identifier() == SimulatorProximitySensor::id) { - return new SimulatorProximitySensor(sensor); - } - - if (sensor->identifier() == SimulatorIRProximitySensor::id) { - return new SimulatorIRProximitySensor(sensor); - } - - if (sensor->identifier() == SimulatorCompass::id) { - return new SimulatorCompass(sensor); - } - - if (sensor->identifier() == SimulatorMagnetometer::id) { - return new SimulatorMagnetometer(sensor); - } - - return 0; - } - - // Copied from the emulator codebase - enum Features { - Accelerometer = 0x01, - Magnetometer = 0x02, - Compass = 0x04, - Infraredsensor = 0x08, - Lightsensor = 0x10 - }; - -public slots: - void setAvailableFeatures(quint32 features) - { - check(features&Accelerometer, QAccelerometer::type, SimulatorAccelerometer::id); - check(features&Lightsensor, QLightSensor::type, SimulatorLightSensor::id); - check(features&Lightsensor, QAmbientLightSensor::type, SimulatorAmbientLightSensor::id); - check(features&Magnetometer, QMagnetometer::type, SimulatorMagnetometer::id); - check(features&Compass, QCompass::type, SimulatorCompass::id); - check(features&Infraredsensor, QIRProximitySensor::type, SimulatorIRProximitySensor::id); - check(features&Infraredsensor, QProximitySensor::type, SimulatorProximitySensor::id); - } - -private: - void check(bool test, const QByteArray &type, const QByteArray &id) - { - if (test) { - if (!QSensorManager::isBackendRegistered(type, id)) - QSensorManager::registerBackend(type, id, this); - } else { - if (QSensorManager::isBackendRegistered(type, id)) - QSensorManager::unregisterBackend(type, id); - } - } -}; - -#include "main.moc" - diff --git a/src/plugins/sensors/simulator/plugin.json b/src/plugins/sensors/simulator/plugin.json deleted file mode 100644 index 77f47afe..00000000 --- a/src/plugins/sensors/simulator/plugin.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "simulator" ] } diff --git a/src/plugins/sensors/simulator/qsensordata_simulator.cpp b/src/plugins/sensors/simulator/qsensordata_simulator.cpp deleted file mode 100644 index 3e590d66..00000000 --- a/src/plugins/sensors/simulator/qsensordata_simulator.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsensordata_simulator_p.h" - -#include <QtCore/QDataStream> - -namespace QtMobility { - -void qt_registerSensorTypes() -{ - qRegisterMetaTypeStreamOperators<QAmbientLightReadingData>("QtMobility::QAmbientLightReadingData"); - qRegisterMetaTypeStreamOperators<QLightReadingData>("QtMobility::QLightReadingData"); - qRegisterMetaTypeStreamOperators<QAccelerometerReadingData>("QtMobility::QAccelerometerReadingData"); - qRegisterMetaTypeStreamOperators<QCompassReadingData>("QtMobility::QCompassReadingData"); - qRegisterMetaTypeStreamOperators<QProximityReadingData>("QtMobility::QProximityReadingData"); - qRegisterMetaTypeStreamOperators<QIRProximityReadingData>("QtMobility::QIRProximityReadingData"); - qRegisterMetaTypeStreamOperators<QMagnetometerReadingData>("QtMobility::QMagnetometerReadingData"); -} - -QDataStream &operator<<(QDataStream &out, const QAmbientLightReadingData &s) -{ - out << static_cast<qint32>(s.lightLevel) << s.timestamp; - return out; -} - -QDataStream &operator>>(QDataStream &in, QAmbientLightReadingData &s) -{ - qint32 lightLevel; - in >> lightLevel >> s.timestamp; - s.lightLevel = static_cast<SimulatorLightLevel>(lightLevel); - return in; -} - -QDataStream &operator<<(QDataStream &out, const QLightReadingData &s) -{ - out << s.lux << s.timestamp; - return out; -} - -QDataStream &operator>>(QDataStream &in, QLightReadingData &s) -{ - in >> s.lux >> s.timestamp; - return in; -} - -QDataStream &operator<<(QDataStream &out, const QAccelerometerReadingData &s) -{ - out << s.x << s.y << s.z << s.timestamp; - return out; -} - -QDataStream &operator>>(QDataStream &in, QAccelerometerReadingData &s) -{ - in >> s.x >> s.y >> s.z >> s.timestamp; - return in; -} - -QDataStream &operator<<(QDataStream &out, const QCompassReadingData &s) -{ - out << s.azimuth << s.calibrationLevel << s.timestamp; - return out; -} - -QDataStream &operator>>(QDataStream &in, QCompassReadingData &s) -{ - in >> s.azimuth >> s.calibrationLevel >> s.timestamp; - return in; -} - -QDataStream &operator<<(QDataStream &out, const QProximityReadingData &s) -{ - out << s.close << s.timestamp; - return out; -} - -QDataStream &operator>>(QDataStream &in, QProximityReadingData &s) -{ - in >> s.close >> s.timestamp; - return in; -} - -QDataStream &operator<<(QDataStream &out, const QIRProximityReadingData &s) -{ - out << s.irProximity << s.timestamp; - return out; -} - -QDataStream &operator>>(QDataStream &in, QIRProximityReadingData &s) -{ - in >> s.irProximity >> s.timestamp; - return in; -} - -QDataStream &operator<<(QDataStream &out, const QMagnetometerReadingData &s) -{ - out << s.x << s.y << s.z << s.calibrationLevel << s.timestamp; - return out; -} - -QDataStream &operator>>(QDataStream &in, QMagnetometerReadingData &s) -{ - in >> s.x >> s.y >> s.z >> s.calibrationLevel >> s.timestamp; - return in; -} - -} // namespace diff --git a/src/plugins/sensors/simulator/qsensordata_simulator_p.h b/src/plugins/sensors/simulator/qsensordata_simulator_p.h deleted file mode 100644 index 410078d8..00000000 --- a/src/plugins/sensors/simulator/qsensordata_simulator_p.h +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSENSORDATA_SIMULATOR_P_H -#define QSENSORDATA_SIMULATOR_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/QMetaType> -#include <QtCore/QDateTime> - -namespace QtMobility { - -enum SimulatorLightLevel { - Undefined = 0, - Dark, - Twilight, - Light, - Bright, - Sunny -}; - -struct QAmbientLightReadingData -{ - SimulatorLightLevel lightLevel; - QDateTime timestamp; -}; - -struct QLightReadingData -{ - double lux; - QDateTime timestamp; -}; - -struct QAccelerometerReadingData -{ - double x; - double y; - double z; - QDateTime timestamp; -}; - -struct QMagnetometerReadingData -{ - double x; - double y; - double z; - double calibrationLevel; - QDateTime timestamp; -}; - -struct QCompassReadingData -{ - double azimuth; - double calibrationLevel; - QDateTime timestamp; -}; - -struct QProximityReadingData -{ - bool close; - QDateTime timestamp; -}; - -struct QIRProximityReadingData -{ - double irProximity; - QDateTime timestamp; -}; - -void qt_registerSensorTypes(); - -} - -Q_DECLARE_METATYPE(QtMobility::QAmbientLightReadingData) -Q_DECLARE_METATYPE(QtMobility::QLightReadingData) -Q_DECLARE_METATYPE(QtMobility::QAccelerometerReadingData) -Q_DECLARE_METATYPE(QtMobility::QMagnetometerReadingData) -Q_DECLARE_METATYPE(QtMobility::QCompassReadingData) -Q_DECLARE_METATYPE(QtMobility::QProximityReadingData) -Q_DECLARE_METATYPE(QtMobility::QIRProximityReadingData) - -#endif // QSENSORDATA_SIMULATOR_P_H diff --git a/src/plugins/sensors/simulator/simulator.pro b/src/plugins/sensors/simulator/simulator.pro deleted file mode 100644 index ac8ea506..00000000 --- a/src/plugins/sensors/simulator/simulator.pro +++ /dev/null @@ -1,32 +0,0 @@ -TARGET = qtsensors_simulator - -QT=core gui network sensors simulator - -HEADERS += \ - simulatorcommon.h\ - simulatoraccelerometer.h\ - simulatorambientlightsensor.h\ - simulatorlightsensor.h\ - simulatorcompass.h\ - simulatorproximitysensor.h\ - simulatorirproximitysensor.h\ - simulatormagnetometer.h\ - qsensordata_simulator_p.h - -SOURCES += \ - simulatorcommon.cpp\ - simulatoraccelerometer.cpp\ - simulatorambientlightsensor.cpp\ - simulatorlightsensor.cpp\ - simulatorcompass.cpp\ - simulatorproximitysensor.cpp\ - simulatorirproximitysensor.cpp\ - simulatormagnetometer.cpp\ - qsensordata_simulator.cpp\ - main.cpp - -OTHER_FILES = plugin.json - -PLUGIN_TYPE = sensors -PLUGIN_CLASS_NAME = SimulatorSensorPlugin -load(qt_plugin) diff --git a/src/plugins/sensors/simulator/simulatoraccelerometer.cpp b/src/plugins/sensors/simulator/simulatoraccelerometer.cpp deleted file mode 100644 index 481128f4..00000000 --- a/src/plugins/sensors/simulator/simulatoraccelerometer.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatoraccelerometer.h" -#include <QDebug> -#include <QtGlobal> - -const char *SimulatorAccelerometer::id("Simulator.Accelerometer"); - -SimulatorAccelerometer::SimulatorAccelerometer(QSensor *sensor) - : SimulatorCommon(sensor) -{ - setReading<QAccelerometerReading>(&m_reading); -} - -void SimulatorAccelerometer::poll() -{ - QtMobility::QAccelerometerReadingData data = SensorsConnection::instance()->qtAccelerometerData; - quint64 newTimestamp; - if (!data.timestamp.isValid()) - newTimestamp = QDateTime::currentMSecsSinceEpoch() / 1000; - else - newTimestamp = data.timestamp.toTime_t(); - if (m_reading.x() != data.x - || m_reading.y() != data.y - || m_reading.z() != data.z) { - m_reading.setTimestamp(newTimestamp); - m_reading.setX(data.x); - m_reading.setY(data.y); - m_reading.setZ(data.z); - - newReadingAvailable(); - } -} - diff --git a/src/plugins/sensors/simulator/simulatoraccelerometer.h b/src/plugins/sensors/simulator/simulatoraccelerometer.h deleted file mode 100644 index a4205867..00000000 --- a/src/plugins/sensors/simulator/simulatoraccelerometer.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORACCELEROMETER_H -#define SIMULATORACCELEROMETER_H - -#include "simulatorcommon.h" -#include <qaccelerometer.h> - -class SimulatorAccelerometer : public SimulatorCommon -{ -public: - static const char *id; - - SimulatorAccelerometer(QSensor *sensor); - - void poll() override; -private: - QAccelerometerReading m_reading; -}; - -#endif - diff --git a/src/plugins/sensors/simulator/simulatorambientlightsensor.cpp b/src/plugins/sensors/simulator/simulatorambientlightsensor.cpp deleted file mode 100644 index 177684fe..00000000 --- a/src/plugins/sensors/simulator/simulatorambientlightsensor.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatorambientlightsensor.h" -#include <QDebug> -#include <QtGlobal> - -const char *SimulatorAmbientLightSensor::id("Simulator.AmbientLightSensor"); - -SimulatorAmbientLightSensor::SimulatorAmbientLightSensor(QSensor *sensor) - : SimulatorCommon(sensor) -{ - setReading<QAmbientLightReading>(&m_reading); -} - -void SimulatorAmbientLightSensor::poll() -{ - QtMobility::QAmbientLightReadingData data = SensorsConnection::instance()->qtAmbientLightData; - QAmbientLightReading::LightLevel convertedLightLevel; - switch (data.lightLevel) { - case QtMobility::Dark: - convertedLightLevel = QAmbientLightReading::Dark; - break; - case QtMobility::Twilight: - convertedLightLevel = QAmbientLightReading::Twilight; - break; - case QtMobility::Light: - convertedLightLevel = QAmbientLightReading::Light; - break; - case QtMobility::Bright: - convertedLightLevel = QAmbientLightReading::Bright; - break; - case QtMobility::Sunny: - convertedLightLevel = QAmbientLightReading::Sunny; - break; - default: - convertedLightLevel = QAmbientLightReading::Undefined; - break; - } - - quint64 newTimestamp; - if (!data.timestamp.isValid()) - newTimestamp = QDateTime::currentMSecsSinceEpoch() / 1000; - else - newTimestamp = data.timestamp.toTime_t(); - if (m_reading.lightLevel() != convertedLightLevel) { - m_reading.setTimestamp(newTimestamp); - m_reading.setLightLevel(convertedLightLevel); - - newReadingAvailable(); - } -} - diff --git a/src/plugins/sensors/simulator/simulatorambientlightsensor.h b/src/plugins/sensors/simulator/simulatorambientlightsensor.h deleted file mode 100644 index 0aadffe6..00000000 --- a/src/plugins/sensors/simulator/simulatorambientlightsensor.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORAMBIENTLIGHTSENSOR_H -#define SIMULATORAMBIENTLIGHTSENSOR_H - -#include "simulatorcommon.h" -#include <qambientlightsensor.h> - -class SimulatorAmbientLightSensor : public SimulatorCommon -{ -public: - static const char *id; - - SimulatorAmbientLightSensor(QSensor *sensor); - - void poll() override; -private: - QAmbientLightReading m_reading; -}; - -#endif - diff --git a/src/plugins/sensors/simulator/simulatorcommon.cpp b/src/plugins/sensors/simulator/simulatorcommon.cpp deleted file mode 100644 index a1693364..00000000 --- a/src/plugins/sensors/simulator/simulatorcommon.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatorcommon.h" -#include "qsensordata_simulator_p.h" -#include <QtSimulator/QtSimulator> -#include <QDebug> -#include <QThread> - -using namespace Simulator; - -Q_GLOBAL_STATIC(SensorsConnection, sensorsConnection) - -class SimulatorAsyncConnection: public QThread -{ - Q_OBJECT -public: - SimulatorAsyncConnection() - : QThread() - { - QtMobility::qt_registerSensorTypes(); - - moveToThread(this); - connect(this, SIGNAL(queueConnectToServer()), - this, SLOT(doConnectToServer()), - Qt::QueuedConnection); - - start(); - } - - ~SimulatorAsyncConnection() - { - quit(); - wait(); - } - - void connectToServer() - { - emit queueConnectToServer(); - } - -signals: - void queueConnectToServer(); - - void initialSensorsDataSent(); - void connectionFailed(); - void setAvailableFeatures(quint32 features); - void setAmbientLightData(const QtMobility::QAmbientLightReadingData &); - void setLightData(const QtMobility::QLightReadingData &); - void setAccelerometerData(const QtMobility::QAccelerometerReadingData &); - void setMagnetometerData(const QtMobility::QMagnetometerReadingData &); - void setCompassData(const QtMobility::QCompassReadingData &); - void setProximityData(const QtMobility::QProximityReadingData &); - void setIRProximityData(const QtMobility::QIRProximityReadingData &); - -private slots: - void doConnectToServer() - { - mConnection.reset(new Connection(Connection::Client, "QtSimulator_Mobility_ServerName1.3.0.0", - 0xbeef+1, Version(1,0,0,0), this)); - mWorker.reset(mConnection->connectToServer(Connection::simulatorHostName(true), 0xbeef+1)); - if (!mWorker) { - qWarning("QtSensors simulator backend could not connect to the simulator!"); - emit connectionFailed(); - return; - } - mWorker->addReceiver(this); - mWorker->call("setRequestsSensors"); - } - -private: - QScopedPointer<Simulator::Connection> mConnection; - QScopedPointer<Simulator::ConnectionWorker> mWorker; -}; - -SensorsConnection::SensorsConnection(QObject *parent) - : QObject(parent) - , mInitialDataSent(false) - , mConnectionFailed(false) -{ - mConnection = new SimulatorAsyncConnection(); - - connect(mConnection, SIGNAL(initialSensorsDataSent()), - this, SLOT(initialSensorsDataSent())); - connect(mConnection, SIGNAL(connectionFailed()), - this, SLOT(slotConnectionFailed())); - connect(mConnection, SIGNAL(setAvailableFeatures(quint32)), - this, SIGNAL(setAvailableFeatures(quint32))); - connect(mConnection, SIGNAL(setAmbientLightData(QtMobility::QAmbientLightReadingData)), - this, SLOT(setAmbientLightData(QtMobility::QAmbientLightReadingData))); - connect(mConnection, SIGNAL(setLightData(QtMobility::QLightReadingData)), - this, SLOT(setLightData(QtMobility::QLightReadingData))); - connect(mConnection, SIGNAL(setAccelerometerData(QtMobility::QAccelerometerReadingData)), - this, SLOT(setAccelerometerData(QtMobility::QAccelerometerReadingData))); - connect(mConnection, SIGNAL(setMagnetometerData(QtMobility::QMagnetometerReadingData)), - this, SLOT(setMagnetometerData(QtMobility::QMagnetometerReadingData))); - connect(mConnection, SIGNAL(setCompassData(QtMobility::QCompassReadingData)), - this, SLOT(setCompassData(QtMobility::QCompassReadingData))); - connect(mConnection, SIGNAL(setProximityData(QtMobility::QProximityReadingData)), - this, SLOT(setProximityData(QtMobility::QProximityReadingData))); - connect(mConnection, SIGNAL(setIRProximityData(QtMobility::QIRProximityReadingData)), - this, SLOT(setIRProximityData(QtMobility::QIRProximityReadingData))); - - mConnection->connectToServer(); -} - -SensorsConnection::~SensorsConnection() -{ - delete mConnection; -} - -SensorsConnection *SensorsConnection::instance() -{ - SensorsConnection *connection = sensorsConnection(); - // It's safe to return 0 because this is checked when used - //if (!connection) qFatal("Cannot return from SensorsConnection::instance because sensorsConnection() returned 0"); - return connection; -} - -void SensorsConnection::setAmbientLightData(const QtMobility::QAmbientLightReadingData &data) -{ - qtAmbientLightData = data; -} - -void SensorsConnection::setLightData(const QtMobility::QLightReadingData &data) -{ - qtLightData = data; -} - -void SensorsConnection::setAccelerometerData(const QtMobility::QAccelerometerReadingData &data) -{ - qtAccelerometerData = data; -} - -void SensorsConnection::setMagnetometerData(const QtMobility::QMagnetometerReadingData &data) -{ - qtMagnetometerData = data; -} - -void SensorsConnection::setCompassData(const QtMobility::QCompassReadingData &data) -{ - qtCompassData = data; -} - -void SensorsConnection::setProximityData(const QtMobility::QProximityReadingData &data) -{ - qtProximityData = data; -} - -void SensorsConnection::setIRProximityData(const QtMobility::QIRProximityReadingData &data) -{ - qtIRProximityData = data; -} - -void SensorsConnection::initialSensorsDataSent() -{ - mInitialDataSent = true; -} - -void SensorsConnection::slotConnectionFailed() -{ - mInitialDataSent = false; - mConnectionFailed = true; -} - -SimulatorCommon::SimulatorCommon(QSensor *sensor) - : QSensorBackend(sensor) - , m_timerid(0) -{ - addDataRate(1, 100); - sensor->setDataRate(20); - (void)SensorsConnection::instance(); // Ensure this exists -} - -void SimulatorCommon::start() -{ - SensorsConnection *connection = SensorsConnection::instance(); - if (!connection) { - sensorStopped(); - return; - } - - if (m_timerid) - return; - - int rate = sensor()->dataRate(); - if (rate == 0) - rate = 20; - int interval = 1000 / rate; - if (interval < 0) - interval = 1000; - - if (interval) - m_timerid = startTimer(interval); -} - -void SimulatorCommon::stop() -{ - if (m_timerid) { - killTimer(m_timerid); - m_timerid = 0; - } -} - -void SimulatorCommon::timerEvent(QTimerEvent * /*event*/) -{ - SensorsConnection *connection = SensorsConnection::instance(); - if (!connection || connection->connectionFailed()) { - stop(); - sensorStopped(); - } - if (!connection->safe()) return; // wait until it's safe to read the data - poll(); -} - -#include "simulatorcommon.moc" diff --git a/src/plugins/sensors/simulator/simulatorcommon.h b/src/plugins/sensors/simulator/simulatorcommon.h deleted file mode 100644 index e47f24d0..00000000 --- a/src/plugins/sensors/simulator/simulatorcommon.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORCOMMON_H -#define SIMULATORCOMMON_H - -#include <qsensorbackend.h> -#include "qsensordata_simulator_p.h" - -class QTimer; - -class SimulatorAsyncConnection; - -class SensorsConnection : public QObject -{ - Q_OBJECT -public: - explicit SensorsConnection(QObject *parent = 0); - virtual ~SensorsConnection(); - - static SensorsConnection *instance(); - bool safe() const { return mInitialDataSent; } - bool connectionFailed() const { return mConnectionFailed; } - -signals: - void setAvailableFeatures(quint32 features); - -public slots: - void setAmbientLightData(const QtMobility::QAmbientLightReadingData &); - void setLightData(const QtMobility::QLightReadingData &); - void setAccelerometerData(const QtMobility::QAccelerometerReadingData &); - void setMagnetometerData(const QtMobility::QMagnetometerReadingData &); - void setCompassData(const QtMobility::QCompassReadingData &); - void setProximityData(const QtMobility::QProximityReadingData &); - void setIRProximityData(const QtMobility::QIRProximityReadingData &); - void initialSensorsDataSent(); - void slotConnectionFailed(); - -private: - SimulatorAsyncConnection *mConnection; - bool mInitialDataSent; - bool mConnectionFailed; - -public: - QtMobility::QAmbientLightReadingData qtAmbientLightData; - QtMobility::QLightReadingData qtLightData; - QtMobility::QAccelerometerReadingData qtAccelerometerData; - QtMobility::QMagnetometerReadingData qtMagnetometerData; - QtMobility::QCompassReadingData qtCompassData; - QtMobility::QProximityReadingData qtProximityData; - QtMobility::QIRProximityReadingData qtIRProximityData; -}; - -class SimulatorCommon : public QSensorBackend -{ -public: - SimulatorCommon(QSensor *sensor); - - void start() override; - void stop() override; - virtual void poll() = 0; - void timerEvent(QTimerEvent * /*event*/) override; - -private: - int m_timerid; -}; - -#endif - diff --git a/src/plugins/sensors/simulator/simulatorcompass.cpp b/src/plugins/sensors/simulator/simulatorcompass.cpp deleted file mode 100644 index fc68c513..00000000 --- a/src/plugins/sensors/simulator/simulatorcompass.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatorcompass.h" -#include <QDebug> -#include <QtGlobal> - -const char *SimulatorCompass::id("Simulator.Compass"); - -SimulatorCompass::SimulatorCompass(QSensor *sensor) - : SimulatorCommon(sensor) -{ - setReading<QCompassReading>(&m_reading); -} - -void SimulatorCompass::poll() -{ - QtMobility::QCompassReadingData data = SensorsConnection::instance()->qtCompassData; - quint64 newTimestamp; - if (!data.timestamp.isValid()) - newTimestamp = QDateTime::currentMSecsSinceEpoch() / 1000; - else - newTimestamp = data.timestamp.toTime_t(); - if (m_reading.azimuth() != data.azimuth - || m_reading.calibrationLevel() != data.calibrationLevel) { - m_reading.setTimestamp(newTimestamp); - m_reading.setAzimuth(data.azimuth); - m_reading.setCalibrationLevel(data.calibrationLevel); - - newReadingAvailable(); - } -} - diff --git a/src/plugins/sensors/simulator/simulatorcompass.h b/src/plugins/sensors/simulator/simulatorcompass.h deleted file mode 100644 index 69162c69..00000000 --- a/src/plugins/sensors/simulator/simulatorcompass.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORCOMPASS_H -#define SIMULATORCOMPASS_H - -#include "simulatorcommon.h" -#include <qcompass.h> - -class SimulatorCompass : public SimulatorCommon -{ -public: - static const char *id; - - SimulatorCompass(QSensor *sensor); - - void poll() override; -private: - QCompassReading m_reading; -}; - -#endif - diff --git a/src/plugins/sensors/simulator/simulatorirproximitysensor.cpp b/src/plugins/sensors/simulator/simulatorirproximitysensor.cpp deleted file mode 100644 index 4499128f..00000000 --- a/src/plugins/sensors/simulator/simulatorirproximitysensor.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatorirproximitysensor.h" -#include <QDebug> -#include <QtGlobal> - -const char *SimulatorIRProximitySensor::id("Simulator.IRProximitySensor"); - -SimulatorIRProximitySensor::SimulatorIRProximitySensor(QSensor *sensor) - : SimulatorCommon(sensor) -{ - setReading<QIRProximityReading>(&m_reading); -} - -void SimulatorIRProximitySensor::poll() -{ - QtMobility::QIRProximityReadingData data = SensorsConnection::instance()->qtIRProximityData; - quint64 newTimestamp; - if (!data.timestamp.isValid()) - newTimestamp = QDateTime::currentMSecsSinceEpoch() / 1000; - else - newTimestamp = data.timestamp.toTime_t(); - if (m_reading.reflectance() != data.irProximity) { - m_reading.setTimestamp(newTimestamp); - m_reading.setReflectance(data.irProximity); - - newReadingAvailable(); - } -} - diff --git a/src/plugins/sensors/simulator/simulatorirproximitysensor.h b/src/plugins/sensors/simulator/simulatorirproximitysensor.h deleted file mode 100644 index db20968b..00000000 --- a/src/plugins/sensors/simulator/simulatorirproximitysensor.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORIRPROXIMITYSENSOR_H -#define SIMULATORIRPROXIMITYSENSOR_H - -#include "simulatorcommon.h" -#include <qirproximitysensor.h> - -class SimulatorIRProximitySensor : public SimulatorCommon -{ -public: - static const char *id; - - SimulatorIRProximitySensor(QSensor *sensor); - - void poll() override; -private: - QIRProximityReading m_reading; -}; - -#endif - diff --git a/src/plugins/sensors/simulator/simulatorlightsensor.cpp b/src/plugins/sensors/simulator/simulatorlightsensor.cpp deleted file mode 100644 index 40d9edbd..00000000 --- a/src/plugins/sensors/simulator/simulatorlightsensor.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatorlightsensor.h" -#include <QDebug> -#include <QtGlobal> - -const char *SimulatorLightSensor::id("Simulator.LightSensor"); - -SimulatorLightSensor::SimulatorLightSensor(QSensor *sensor) - : SimulatorCommon(sensor) -{ - setReading<QLightReading>(&m_reading); -} - -void SimulatorLightSensor::poll() -{ - QtMobility::QLightReadingData data = SensorsConnection::instance()->qtLightData; - quint64 newTimestamp; - if (!data.timestamp.isValid()) - newTimestamp = QDateTime::currentMSecsSinceEpoch() / 1000; - else - newTimestamp = data.timestamp.toTime_t(); - if (m_reading.lux() != data.lux) { - m_reading.setTimestamp(newTimestamp); - m_reading.setLux(data.lux); - - newReadingAvailable(); - } -} - diff --git a/src/plugins/sensors/simulator/simulatorlightsensor.h b/src/plugins/sensors/simulator/simulatorlightsensor.h deleted file mode 100644 index 3af3a526..00000000 --- a/src/plugins/sensors/simulator/simulatorlightsensor.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORLIGHTSENSOR_H -#define SIMULATORLIGHTSENSOR_H - -#include "simulatorcommon.h" -#include <qlightsensor.h> - -class SimulatorLightSensor : public SimulatorCommon -{ -public: - static const char *id; - - SimulatorLightSensor(QSensor *sensor); - - void poll() override; -private: - QLightReading m_reading; -}; - -#endif - diff --git a/src/plugins/sensors/simulator/simulatormagnetometer.cpp b/src/plugins/sensors/simulator/simulatormagnetometer.cpp deleted file mode 100644 index 64a31776..00000000 --- a/src/plugins/sensors/simulator/simulatormagnetometer.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatormagnetometer.h" -#include <QDebug> -#include <QtGlobal> - -const char *SimulatorMagnetometer::id("Simulator.Magnetometer"); - -SimulatorMagnetometer::SimulatorMagnetometer(QSensor *sensor) - : SimulatorCommon(sensor) -{ - setReading<QMagnetometerReading>(&m_reading); -} - -void SimulatorMagnetometer::poll() -{ - QtMobility::QMagnetometerReadingData data = SensorsConnection::instance()->qtMagnetometerData; - quint64 newTimestamp; - if (!data.timestamp.isValid()) - newTimestamp = QDateTime::currentMSecsSinceEpoch() / 1000; - else - newTimestamp = data.timestamp.toTime_t(); - if (m_reading.x() != data.x - || m_reading.y() != data.y - || m_reading.z() != data.z - || m_reading.calibrationLevel() != data.calibrationLevel) { - m_reading.setTimestamp(newTimestamp); - m_reading.setX(data.x); - m_reading.setY(data.y); - m_reading.setZ(data.z); - m_reading.setCalibrationLevel(data.calibrationLevel); - - newReadingAvailable(); - } -} - diff --git a/src/plugins/sensors/simulator/simulatormagnetometer.h b/src/plugins/sensors/simulator/simulatormagnetometer.h deleted file mode 100644 index facbad41..00000000 --- a/src/plugins/sensors/simulator/simulatormagnetometer.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORMAGNETOMETER_H -#define SIMULATORMAGNETOMETER_H - -#include "simulatorcommon.h" -#include <qmagnetometer.h> - -class SimulatorMagnetometer : public SimulatorCommon -{ -public: - static const char *id; - - SimulatorMagnetometer(QSensor *sensor); - - void poll() override; -private: - QMagnetometerReading m_reading; -}; - -#endif - diff --git a/src/plugins/sensors/simulator/simulatorproximitysensor.cpp b/src/plugins/sensors/simulator/simulatorproximitysensor.cpp deleted file mode 100644 index b4430959..00000000 --- a/src/plugins/sensors/simulator/simulatorproximitysensor.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatorproximitysensor.h" -#include <QDebug> -#include <QtGlobal> - -const char *SimulatorProximitySensor::id("Simulator.ProximitySensor"); - -SimulatorProximitySensor::SimulatorProximitySensor(QSensor *sensor) - : SimulatorCommon(sensor) -{ - setReading<QProximityReading>(&m_reading); -} - -void SimulatorProximitySensor::poll() -{ - QtMobility::QProximityReadingData data = SensorsConnection::instance()->qtProximityData; - quint64 newTimestamp; - if (!data.timestamp.isValid()) - newTimestamp = QDateTime::currentMSecsSinceEpoch() / 1000; - else - newTimestamp = data.timestamp.toTime_t(); - if (m_reading.close() != data.close) { - m_reading.setTimestamp(newTimestamp); - m_reading.setClose(data.close); - - newReadingAvailable(); - } -} - diff --git a/src/plugins/sensors/simulator/simulatorproximitysensor.h b/src/plugins/sensors/simulator/simulatorproximitysensor.h deleted file mode 100644 index 16e6f6bb..00000000 --- a/src/plugins/sensors/simulator/simulatorproximitysensor.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORPROXIMITYSENSOR_H -#define SIMULATORPROXIMITYSENSOR_H - -#include "simulatorcommon.h" -#include <qproximitysensor.h> - -class SimulatorProximitySensor : public SimulatorCommon -{ -public: - static const char *id; - - SimulatorProximitySensor(QSensor *sensor); - - void poll() override; -private: - QProximityReading m_reading; -}; - -#endif - |