<commit_before>/**
   @file sensorhandler.cpp
   @brief sensor handler
   <p>
   Copyright (C) 2010-2011 Nokia Corporation

   @author <NAME> <<EMAIL>>
   @author <NAME> <<EMAIL>>
   @author <NAME> <<EMAIL>>

   This file is part of Sensord.

   Sensord is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License
   version 2.1 as published by the Free Software Foundation.

   Sensord is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with Sensord.  If not, see <http://www.gnu.org/licenses/>.
   </p>
*/

#include "sensorhandler_qtapi.h"
#include "logging.h"
#include "qt-api/sensormanagerinterface.h"
#include "qt-api/orientationsensor_i.h"
#include "qt-api/accelerometersensor_i.h"
#include "qt-api/compasssensor_i.h"
#include "qt-api/tapsensor_i.h"
#include "qt-api/alssensor_i.h"
#include "qt-api/proximitysensor_i.h"
#include "qt-api/rotationsensor_i.h"
#include "qt-api/magnetometersensor_i.h"

SensorHandler::SensorHandler(const QString& sensorName, QObject *parent) :
    AbstractSensorHandler(sensorName, parent),
    sensorChannelInterface_(NULL)
{
}

void SensorHandler::receivedData(const MagneticField& data)
{
    dataCount_++;
    sensordLogT() << sensorName_ << " sample " << dataCount_ << ": "
                  << data.x() << " " << data.y() << " " <<   data.z();
}

void SensorHandler::receivedData(const XYZ& data)
{
    dataCount_++;
    sensordLogT() << sensorName_ << " sample " << dataCount_ << ": "
                  << data.x() << " " << data.y() << " " <<   data.z();
}

void SensorHandler::receivedData(const Compass& data)
{
    dataCount_++;
    sensordLogT() << sensorName_ << " sample " << dataCount_ << ": "
                  << data.degrees() << " " << data.level();
}

void SensorHandler::receivedData(const Unsigned& data)
{
    dataCount_++;
    sensordLogT() << sensorName_ << " sample " << dataCount_ << ": "
                  << data.x();
}

void SensorHandler::receivedData(const Tap& data)
{
    dataCount_++;
    sensordLogT() << sensorName_ << " sample " << dataCount_ << ": "
                  << data.direction() << " " << data.type();
}

void SensorHandler::receivedData(const Proximity& data)
{
    dataCount_++;
    sensordLogT() << sensorName_ << " sample " << dataCount_ << ": "
                  << data.UnsignedData().value_ << " " << data.proximityData().value_;
}

void SensorHandler::receivedFrame(const QVector<MagneticField>& frame)
{
    frameCount_++;
    sensordLogT() << sensorName_ << " frame " << frameCount_ << " size " << frame.size();
    foreach (const MagneticField& data, frame)
    {
        sensordLogT() << data.x() << " " << data.y() << " " << data.z();
    }
}

void SensorHandler::receivedFrame(const QVector<XYZ>& frame)
{
    frameCount_++;
    sensordLogT() << sensorName_ << " frame " << frameCount_ << " size " << frame.size();
    foreach (const XYZ& data, frame)
    {
        sensordLogT() << data.x() << " " << data.y() << " " << data.z();
    }
}

bool SensorHandler::startClient()
{
    createSensorInterface();
    if (sensorChannelInterface_ == 0)
    {
         sensordLogD() << "Creating sensor client interface fails.";
         return false;
    }
    sensordLogD() << "Created sensor: " << sensorChannelInterface_->description();
    sensordLogD() << "Support intervals: " << toString(sensorChannelInterface_->getAvailableIntervals());
    sensordLogD() << "Support dataranges: " << toString(sensorChannelInterface_->getAvailableDataRanges());
    sensorChannelInterface_->setInterval(interval_);
    sensorChannelInterface_->setBufferInterval(bufferinterval_);
    sensorChannelInterface_->setBufferSize(buffersize_);
    sensorChannelInterface_->setStandbyOverride(standbyoverride_);
    sensorChannelInterface_->setDownsampling(downsample_);
    sensorChannelInterface_->start();

    return true;
}

bool SensorHandler::stopClient()
{
    if (sensorChannelInterface_)
    {
        sensorChannelInterface_->stop();
        delete sensorChannelInterface_;<commit_msg>Testapp data count is incremented for received frames.<commit_after>/**
   @file sensorhandler.cpp
   @brief sensor handler
   <p>
   Copyright (C) 2010-2011 Nokia Corporation

   @author <NAME> <<EMAIL>>
   @author <NAME> <<EMAIL>>
   @author <NAME> <<EMAIL>>

   This file is part of Sensord.

   Sensord is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License
   version 2.1 as published by the Free Software Foundation.

   Sensord is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with Sensord.  If not, see <http://www.gnu.org/licenses/>.
   </p>
*/

#include "sensorhandler_qtapi.h"
#include "logging.h"
#include "qt-api/sensormanagerinterface.h"
#include "qt-api/orientationsensor_i.h"
#include "qt-api/accelerometersensor_i.h"
#include "qt-api/compasssensor_i.h"
#include "qt-api/tapsensor_i.h"
#include "qt-api/alssensor_i.h"
#include "qt-api/proximitysensor_i.h"
#include "qt-api/rotationsensor_i.h"
#include "qt-api/magnetometersensor_i.h"

SensorHandler::SensorHandler(const QString& sensorName, QObject *parent) :
    AbstractSensorHandler(sensorName, parent),
    sensorChannelInterface_(NULL)
{
}

void SensorHandler::receivedData(const MagneticField& data)
{
    ++dataCount_;
    sensordLogT() << sensorName_ << " sample " << dataCount_ << ": "
                  << data.x() << " " << data.y() << " " <<   data.z();
}

void SensorHandler::receivedData(const XYZ& data)
{
    ++dataCount_;
    sensordLogT() << sensorName_ << " sample " << dataCount_ << ": "
                  << data.x() << " " << data.y() << " " <<   data.z();
}

void SensorHandler::receivedData(const Compass& data)
{
    ++dataCount_;
    sensordLogT() << sensorName_ << " sample " << dataCount_ << ": "
                  << data.degrees() << " " << data.level();
}

void SensorHandler::receivedData(const Unsigned& data)
{
    ++dataCount_;
    sensordLogT() << sensorName_ << " sample " << dataCount_ << ": "
                  << data.x();
}

void SensorHandler::receivedData(const Tap& data)
{
    ++dataCount_;
    sensordLogT() << sensorName_ << " sample " << dataCount_ << ": "
                  << data.direction() << " " << data.type();
}

void SensorHandler::receivedData(const Proximity& data)
{
    ++dataCount_;
    sensordLogT() << sensorName_ << " sample " << dataCount_ << ": "
                  << data.UnsignedData().value_ << " " << data.proximityData().value_;
}

void SensorHandler::receivedFrame(const QVector<MagneticField>& frame)
{
    ++frameCount_;
    sensordLogT() << sensorName_ << " frame " << frameCount_ << " size " << frame.size();
    foreach (const MagneticField& data, frame)
    {
        sensordLogT() << data.x() << " " << data.y() << " " << data.z();
        ++dataCount_;
    }
}

void SensorHandler::receivedFrame(const QVector<XYZ>& frame)
{
    ++frameCount_;
    sensordLogT() << sensorName_ << " frame " << frameCount_ << " size " << frame.size();
    foreach (const XYZ& data, frame)
    {
        sensordLogT() << data.x() << " " << data.y() << " " << data.z();
        ++dataCount_;
    }
}

bool SensorHandler::startClient()
{
    createSensorInterface();
    if (sensorChannelInterface_ == 0)
    {
         sensordLogD() << "Creating sensor client interface fails.";
         return false;
    }
    sensordLogD() << "Created sensor: " << sensorChannelInterface_->description();
    sensordLogD() << "Support intervals: " << toString(sensorChannelInterface_->getAvailableIntervals());
    sensordLogD() << "Support dataranges: " << toString(sensorChannelInterface_->getAvailableDataRanges());
    sensorChannelInterface_->setInterval(interval_);
    sensorChannelInterface_->setBufferInterval(bufferinterval_);
    sensorChannelInterface_->setBufferSize(buffersize_);
    sensorChannelInterface_->setStandbyOverride(standbyoverride_);
    sensorChannelInterface_->setDownsampling(downsample_);
    sensorChannelInterface_->start();

    return true;
}

bool SensorHandler::stopClient()
{
    if (sensorChannelInterface_)
    {
        sensorChannelInterface_->stop();
        delete sensorChannelInterface_;
{'fraction_non_alphanumeric': 0.14660831509846828, 'fraction_numerical': 0.002533686513877692, 'mean_word_length': 3.6020137784843667, 'pattern_counts': {'":': 12, '<': 315, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6799757', 'n_tokens_mistral': 2684, 'n_tokens_neox': 2611, 'n_words': 596}