예제 #1
0
void testsensorimpl::start()
{
    QVariant _exclusive = sensor()->property("exclusive");
    bool exclusive = _exclusive.isValid()?_exclusive.toBool():false;
    if (exclusive) {
        if (!exclusiveHandle) {
            exclusiveHandle = this;
        } else {
            // Hook up the busyChanged signal
            connect(exclusiveHandle, SIGNAL(emitBusyChanged()), sensor(), SIGNAL(busyChanged()));
            sensorBusy(); // report the busy condition
            return;
        }
    }

    QString doThis = sensor()->property("doThis").toString();
    if (doThis == "stop")
        sensorStopped();
    else if (doThis == "error")
        sensorError(1);
    else if (doThis == "setOne") {
        m_reading.setTimestamp(1);
        m_reading.setTest(1);
        newReadingAvailable();
    } else {
        m_reading.setTimestamp(2);
        m_reading.setTest(2);
        newReadingAvailable();
    }
}
예제 #2
0
void n900accelerometer::poll()
{
    // Note that this is a rather inefficient way to generate this data.
    // Ideally the kernel would scale the hardware's values to m/s^2 for us
    // and give us a timestamp along with that data.

    FILE *fd = fopen(filename, "r");
    if (!fd) return;
    int x, y, z;
    int rs = fscanf(fd, "%i %i %i", &x, &y, &z);
    fclose(fd);
    if (rs != 3) return;

    // Convert from milli-Gs to meters per second per second
    // Using 1 G = 9.80665 m/s^2
    qreal ax = x * 0.00980665;
    qreal ay = y * -0.00980665;
    qreal az = z * -0.00980665;

    m_reading.setTimestamp(getTimestamp());
    if (portraitOrientation) {
        m_reading.setX(ay);
        m_reading.setY(-ax);
    } else {
        m_reading.setX(ax);
        m_reading.setY(ay);
    }
    m_reading.setZ(az);

    newReadingAvailable();
}
예제 #3
0
void mockirproximitysensor::parseIrProxyData(const QString &data)
{
    m_reading.setTimestamp(data.section(QLatin1String(","), 0,0).toULongLong());
    m_reading.setReflectance(data.section(QLatin1String(","), 1,1).toDouble());

    newReadingAvailable();
}
예제 #4
0
void mocktapsensor::parseTapData(const QString &data)
{
    m_reading.setTimestamp(data.section(QLatin1String(","), 0,0).toULongLong());
    m_reading.setDoubleTap((data.section(QLatin1String(","), 1,1).toInt() == 1));

    newReadingAvailable();
}
예제 #5
0
void meegoals::start(){
    Unsigned data(((ALSSensorChannelInterface*)m_sensorInterface)->lux());
    m_reading.setLightLevel(getLightLevel(data.x()));
    m_reading.setTimestamp(data.UnsignedData().timestamp_);
    newReadingAvailable();
    meegosensorbase::start();
}
void AndroidAmbientLightSensorBackend::dataAvailable(float data[],qint64 timeEvent,int)
{
    enum {
        Undefined = QAmbientLightReading::Undefined,
        Dark = QAmbientLightReading::Dark,
        Twilight = QAmbientLightReading::Twilight,
        Light = QAmbientLightReading::Light,
        Bright = QAmbientLightReading::Bright,
        Sunny = QAmbientLightReading::Sunny
            };

    int lightLevel = m_reading.lightLevel();
    qreal lux = data[0];

    // Check for change direction to allow for histeresis
    if      (lightLevel < Sunny    && lux >= limits[Sunny   ].min) lightLevel = Sunny;
    else if (lightLevel < Bright   && lux >= limits[Bright  ].min) lightLevel = Bright;
    else if (lightLevel < Light    && lux >= limits[Light   ].min) lightLevel = Light;
    else if (lightLevel < Twilight && lux >= limits[Twilight].min) lightLevel = Twilight;
    else if (lightLevel < Dark     && lux >= limits[Dark    ].min) lightLevel = Dark;
    else if (lightLevel > Dark     && lux <= limits[Dark    ].max) lightLevel = Dark;
    else if (lightLevel > Twilight && lux <= limits[Twilight].max) lightLevel = Twilight;
    else if (lightLevel > Light    && lux <= limits[Light   ].max) lightLevel = Light;
    else if (lightLevel > Bright   && lux <= limits[Bright  ].max) lightLevel = Bright;

    if (static_cast<int>(m_reading.lightLevel()) != lightLevel)
    {
        m_reading.setTimestamp(timeEvent/TOMICRO);
        m_reading.setLightLevel(static_cast<QAmbientLightReading::LightLevel>(lightLevel));
        newReadingAvailable();
    }
}
예제 #7
0
void CAmbientLightSensorSym::ProcessReading()
{
    // Get a lock on the reading data
    iBackendData.iReadingLock.Wait();

    // Reason why switch/case was changed to separate if clauses is that
    // we do not need to use new enums that were added to platform code,
    // so this code should work also in case that those new enums are not
    // defined in some platform where this same QtMobility code is used.
    if (iData.iAmbientLight < TSensrvAmbientLightData::KAmbientLightTwilight) {
        // KAmbientLightVeryDark, KAmbientLightDark
        iReading.setLightLevel(QAmbientLightReading::Dark);
    } else if (iData.iAmbientLight < TSensrvAmbientLightData::KAmbientLightLight) {
        // KAmbientLightTwilight
        iReading.setLightLevel(QAmbientLightReading::Twilight);
    } else if (iData.iAmbientLight < TSensrvAmbientLightData::KAmbientLightBright) {
        // KAmbientLightLight
        iReading.setLightLevel(QAmbientLightReading::Light);
    } else if (iData.iAmbientLight < TSensrvAmbientLightData::KAmbientLightSunny) {
        // KAmbientLightBright
        iReading.setLightLevel(QAmbientLightReading::Bright);
    } else {
        // KAmbientLightCloudy , KAmbientLightCloudySunny, KAmbientLightSunny
        iReading.setLightLevel(QAmbientLightReading::Sunny);
    }

    // Set the timestamp
    iReading.setTimestamp(iData.iTimeStamp.Int64());
    // Release the lock
    iBackendData.iReadingLock.Signal();
    // Notify that a reading is available
    newReadingAvailable();
}
예제 #8
0
void mockorientationsensor::parseOrientData(const QString &data)
{
    m_reading.setTimestamp(data.section(QLatin1String(","), 0,0).toULongLong());
    m_reading.setOrientation(static_cast<QOrientationReading::Orientation>(data.section(QLatin1String(","), 1,1).toInt()));

    newReadingAvailable();
}
예제 #9
0
void mockproximitysensor::parseProxyData(const QString &data)
{
    m_reading.setTimestamp(data.section(QLatin1String(","), 0,0).toULongLong());
    m_reading.setClose((data.section(QLatin1String(","), 1,1).toInt() == 1));

    newReadingAvailable();
}
void meegorotationsensor::slotDataAvailable(const XYZ& data)
{
    m_reading.setX(data.x());
    m_reading.setY(data.y());
    m_reading.setZ(data.z());
    m_reading.setTimestamp(data.XYZData().timestamp_);
    newReadingAvailable();
}
예제 #11
0
void SensorfwGyroscope::slotDataAvailable(const XYZ& data)
{
    m_reading.setX((qreal)(data.x()*MILLI));
    m_reading.setY((qreal)(data.y()*MILLI));
    m_reading.setZ((qreal)(data.z()*MILLI));
    m_reading.setTimestamp(data.XYZData().timestamp_);
    newReadingAvailable();
}
void SensorfwProximitySensor::slotDataAvailable(const Unsigned& data)
{
    bool close = data.x()? true: false;
    if (close == m_exClose) return;
    m_reading.setClose(close);
    m_reading.setTimestamp(data.UnsignedData().timestamp_);
    newReadingAvailable();
    m_exClose = close;
}
예제 #13
0
void AndroidLight::onSensorChanged(jlong timestamp, const jfloat *values, uint size)
{
    if (size < 1)
        return;
    m_reader.setTimestamp(timestamp/1000);
    // check https://developer.android.com/reference/android/hardware/SensorEvent.html#values
    m_reader.setLux(values[0]);
    newReadingAvailable();
}
예제 #14
0
void meegoals::slotDataAvailable(const Unsigned& data)
{
    QAmbientLightReading::LightLevel level = getLightLevel(data.x());
    if (level != m_reading.lightLevel()) {
        m_reading.setLightLevel(level);
        m_reading.setTimestamp(data.UnsignedData().timestamp_);
        newReadingAvailable();
    }
}
예제 #15
0
void meegoorientationsensor::start(){
    if (m_sensorInterface) {
        Unsigned data(((OrientationSensorChannelInterface*)m_sensorInterface)->orientation());
        m_reading.setOrientation(meegoorientationsensor::getOrientation(data.x()));
        m_reading.setTimestamp(data.UnsignedData().timestamp_);
        newReadingAvailable();
    }
    meegosensorbase::start();
}
예제 #16
0
void mockaccelerometer::parseAccelData(const QString &data)
{
    quint64 ts = data.section(QLatin1String(","), 0,0).toULongLong();
    m_reading.setTimestamp(ts);
    m_reading.setX(data.section(QLatin1String(","), 1,1).toDouble());
    m_reading.setY(data.section(QLatin1String(","), 2,2).toDouble());
    m_reading.setZ(data.section(QLatin1String(","), 3,3).toDouble());
    newReadingAvailable();
}
예제 #17
0
void meegoaccelerometer::slotDataAvailable(const XYZ& data)
{
    // Convert from milli-Gs to meters per second per second
    // Using 1 G = 9.80665 m/s^2
    m_reading.setX(-data.x() * GRAVITY_EARTH_THOUSANDTH);
    m_reading.setY(-data.y() * GRAVITY_EARTH_THOUSANDTH);
    m_reading.setZ(-data.z() * GRAVITY_EARTH_THOUSANDTH);
    m_reading.setTimestamp(data.XYZData().timestamp_);
    newReadingAvailable();
}
예제 #18
0
void dummyaccelerometer::poll()
{
    m_reading.setTimestamp(getTimestamp());
    // Your average desktop computer doesn't move :)
    m_reading.setX(0);
    m_reading.setY(9.8); // facing the user, gravity goes here
    m_reading.setZ(0);

    newReadingAvailable();
}
예제 #19
0
void meegomagnetometer::slotDataAvailable(const MagneticField& data)
{
    //nanoTeslas given, divide with 10^9 to get Teslas
    m_reading.setX( NANO * (m_isGeoMagnetometer?data.x():data.rx()));
    m_reading.setY( NANO * (m_isGeoMagnetometer?data.y():data.ry()));
    m_reading.setZ( NANO * (m_isGeoMagnetometer?data.z():data.rz()));
    m_reading.setCalibrationLevel( m_isGeoMagnetometer?((float) data.level()) / 3.0 :1);
    m_reading.setTimestamp(data.timestamp());
    newReadingAvailable();
}
void SensorfwProximitySensor::start()
{
    if (m_sensorInterface) {
        Unsigned data(((ProximitySensorChannelInterface*)m_sensorInterface)->proximity());
        m_reading.setClose(data.x()? true: false);
        m_reading.setTimestamp(data.UnsignedData().timestamp_);
        newReadingAvailable();
    }
    SensorfwSensorBase::start();
}
void dummylightsensor::poll()
{
    m_reading.setTimestamp(getTimestamp());
    if ((qrand() % 100) == 0)
        m_reading.setLightLevel(QAmbientLightReading::Dark);
    else
        m_reading.setLightLevel(QAmbientLightReading::Light);

    newReadingAvailable();
}
void AndroidAccelerometerSensorBackend::dataAvailable(float data[],qint64,int)
{
    qreal x=data[0];
    qreal y=-1 * data[1];
    qreal z=data[2];
    m_reading.setX(x);
    m_reading.setY(y);
    m_reading.setZ(z);
    newReadingAvailable();
}
예제 #23
0
void AndroidMagnetometer::onSensorChanged(jlong timestamp, const jfloat *values, uint size)
{
    if (size<3)
        return;
    m_reader.setTimestamp(timestamp/1000);
    // check https://developer.android.com/reference/android/hardware/SensorEvent.html#values
    m_reader.setX(values[0]/1e6);
    m_reader.setY(values[1]/1e6);
    m_reader.setZ(values[2]/1e6);
    newReadingAvailable();
}
예제 #24
0
void AndroidCompassSensorBackend::dataAvailable(float data[],qint64 timeEvent,int accuracy)
{
    // The scale for level is [0,3], where 3 is the best
    // Qt: Measured as a value from 0 to 1 with higher values being better.
    m_reading.setCalibrationLevel(accuracy);
    // The scale for degrees from sensord is [0,359]
    // Value can be directly used as azimuth
    m_reading.setAzimuth(data[0]);
    m_reading.setTimestamp(timeEvent/TOMICRO);
    newReadingAvailable();
}
void AndroidRotation::onSensorChanged(jlong timestamp, const jfloat *values, uint size)
{
    if (size < 3)
        return;
    m_reader.setTimestamp(timestamp/1000);

    float rz = -values[0]*180/M_PI;
    float rx = -values[1]*180/M_PI;
    float ry = values[2]*180/M_PI;
    m_reader.setFromEuler(rx, ry, rz);
    newReadingAvailable();
}
예제 #26
0
void AndroidTemperature::onSensorChanged(jlong timestamp, const jfloat *values, uint size)
{
    if (size < 1)
        return;
    m_reader.setTimestamp(timestamp/1000);

    // TODO: I was unable to test this since the devices I was testing this with did not have
    //       a temperature sensor. Verify that this works and check that the units are correct.

    m_reader.setTemperature(values[0]);
    newReadingAvailable();
}
예제 #27
0
void SensorfwOrientationSensor::start()
{
    if (reinitIsNeeded)
        init();
    if (m_sensorInterface) {
        Unsigned data(((OrientationSensorChannelInterface*)m_sensorInterface)->orientation());
        m_reading.setOrientation(SensorfwOrientationSensor::getOrientation(data.x()));
        m_reading.setTimestamp(data.UnsignedData().timestamp_);
        newReadingAvailable();
    }
    SensorfwSensorBase::start();
}
예제 #28
0
void CProximitySensorSym::ProcessReading()
    {
    // Get a lock on the reading data
    iBackendData.iReadingLock.Wait();
    iReading.setClose(iData.iProximityState == TSensrvProximityData::EProximityDiscernible);
    // Set the timestamp
    iReading.setTimestamp(iData.iTimeStamp.Int64());
    // Release the lock
    iBackendData.iReadingLock.Signal();
    // Notify that a reading is available
    newReadingAvailable();
    }
예제 #29
0
void SensorfwCompass::slotDataAvailable(const Compass& data)
{
    // The scale for level is [0,3], where 3 is the best
    // Qt: Measured as a value from 0 to 1 with higher values being better.
    m_reading.setCalibrationLevel(((float) data.level()) / 3.0);

    // The scale for degrees from sensord is [0,359]
    // Value can be directly used as azimuth
    m_reading.setAzimuth(data.degrees());

    m_reading.setTimestamp(data.data().timestamp_);
    newReadingAvailable();
}
void QS60SensorApiAccelerometer::HandleDataEventL(TRRSensorInfo aSensor, TRRSensorEvent aEvent)
{
    if (aSensor.iSensorId != KAccelerometerSensorUID) 
        return; 
    
    TTime time;
    time.UniversalTime();
    m_reading.setTimestamp(time.Int64());
    m_reading.setX((qreal)aEvent.iSensorData2 * m_sampleFactor);
    m_reading.setY((qreal)aEvent.iSensorData1 * -m_sampleFactor);
    m_reading.setZ((qreal)aEvent.iSensorData3 * -m_sampleFactor);
    newReadingAvailable();
}