Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improved sensorfw examples
  • Loading branch information
Lihan Guo committed Feb 18, 2011
1 parent 57d59d5 commit 1df6fb7
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 29 deletions.
Expand Up @@ -3,6 +3,7 @@ CONFIG += plugin

TARGET = sampleadaptor


include(../../common-config.pri )

HEADERS += sampleadaptor.h \
Expand All @@ -15,6 +16,7 @@ SENSORFW_INCLUDEPATHS = ../.. \
../../include \
../../sensord \
../../datatypes \
../../core \
../../filters

DEPENDPATH += $$SENSORFW_INCLUDEPATHS
Expand All @@ -24,4 +26,3 @@ include(../../common-install.pri)
publicheaders.files += $$HEADERS
target.path = $$PLUGINPATH

INSTALLS += target
10 changes: 4 additions & 6 deletions examples/adaptorplugin/sampleadaptor.cpp
Expand Up @@ -6,6 +6,7 @@
Copyright (C) 2009-2010 Nokia Corporation
@author Timo Rongas <ext-timo.2.rongas@nokia.com>
@author Lihan Guo <ext-lihan.4.guo@nokia.com>
This file is part of Sensord.
Expand All @@ -28,11 +29,8 @@
// Logging entries
#include "logging.h"

// Configuration file access
#include "config.h"

// Provides timestamp utility
#include "datatypes/utils.h"
#include "utils.h"

// Constructor should initialise SysfsAdaptor parent.
// id should be passed directly. See #SysfsAdaptor for details on
Expand All @@ -41,7 +39,7 @@
// from configuration (like here). If locating the path needs processing
// the path should be omitted here and set inside the constructor.
SampleAdaptor::SampleAdaptor(const QString& id) :
SysfsAdaptor(id, SysfsAdaptor::SelectMode, Config::configuration()->value("sample_dev_path").toString())
SysfsAdaptor(id, SysfsAdaptor::SelectMode)
{
// One can use SysfsAdaptor::addPath() to add additional paths for
// monitoring. The paths are indexed in the order they are
Expand All @@ -53,7 +51,7 @@ SampleAdaptor::SampleAdaptor(const QString& id) :
// Provide the output buffer with name and description. Name is used
// to locate the buffer from the listening side, description is
// currently unused.
addAdaptedSensor("sample", "Sample sensor, with dummy buffer", outputBuffer_);
setAdaptedSensor("sample", "Sample sensor, with dummy buffer", outputBuffer_);

// Provide information on the data range this adaptor can output
// (based on the adapted sensor naturally). Parameters of DataRange
Expand Down
7 changes: 4 additions & 3 deletions examples/adaptorplugin/sampleadaptor.h
Expand Up @@ -6,6 +6,7 @@
Copyright (C) 2009-2010 Nokia Corporation
@author Timo Rongas <ext-timo.2.rongas@nokia.com>
@author Lihan Guo <ext-lihan.4.guo@nokia.com>
This file is part of Sensord.
Expand All @@ -28,12 +29,12 @@

// Include any parent classes this adaptor is based on
// (deviceadaptor really not necessary, as it's a parent of sysfs)
#include "sensord/deviceadaptor.h"
#include "sensord/sysfsadaptor.h"
#include "deviceadaptor.h"
#include "sysfsadaptor.h"

// Include any datatypes this adaptor produces. For example, let's use
// TimedUnsigned (unsigned int + timestamp)
#include "datatypes/timedunsigned.h"
#include "timedunsigned.h"

/**
* Adaptor description...
Expand Down
Expand Up @@ -18,6 +18,7 @@ SENSORFW_INCLUDEPATHS = ../.. \
../../sensord \
../../datatypes \
../../filters \
../../core \
../../adaptors

DEPENDPATH += $$SENSORFW_INCLUDEPATHS
Expand All @@ -26,5 +27,3 @@ INCLUDEPATH += $$SENSORFW_INCLUDEPATHS
include(../../common-install.pri)
publicheaders.files += $$HEADERS
target.path = $$PLUGINPATH

INSTALLS += target
15 changes: 8 additions & 7 deletions examples/chainplugin/samplechain.cpp
Expand Up @@ -6,6 +6,7 @@
Copyright (C) 2009-2010 Nokia Corporation
@author Timo Rongas <ext-timo.2.rongas@nokia.com>
@author Lihan Guo <ext-lihan.4.guo@nokia.com>
This file is part of Sensord.
Expand All @@ -24,11 +25,11 @@
*/

#include "samplechain.h"
#include "sensord/sensormanager.h"
#include "sensord/bin.h"
#include "sensord/bufferreader.h"
#include "sensord/config.h"
#include "sensord/logging.h"
#include "sensormanager.h"
#include "bin.h"
#include "bufferreader.h"
#include "config.h"
#include "logging.h"

SampleChain::SampleChain(const QString& id) :
AbstractChain(id)
Expand Down Expand Up @@ -104,7 +105,7 @@ bool SampleChain::start()
filterBin_->start();

// Adaptors are started on buffer basis, thus the buffer name
sampleAdaptor_->startSensor("sample");
sampleAdaptor_->startSensor();
}
return true;
}
Expand All @@ -114,7 +115,7 @@ bool SampleChain::stop()
{
if (AbstractSensorChannel::stop()) {
sensordLogD() << "Stopping SampleChain";
sampleAdaptor_->stopSensor("sample");
sampleAdaptor_->stopSensor();
filterBin_->stop();
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion examples/chainplugin/samplechain.h
Expand Up @@ -32,7 +32,7 @@
#include "abstractchain.h"

// Include any used datatypes
#include "datatypes/timedunsigned.h"
#include "timedunsigned.h"

// Definition tricks, included from .cpp
class Bin;
Expand Down
8 changes: 8 additions & 0 deletions examples/examples.pro
@@ -0,0 +1,8 @@
TEMPLATE = subdirs

include( ../common-config.pri )

SUBDIRS = adaptorplugin \
chainplugin \
filterplugin \
sensorplugin
Expand Up @@ -11,6 +11,7 @@ SENSORFW_INCLUDEPATHS = ../.. \
../../include \
.. \
../../sensord \
../../core \
../../datatypes

DEPENDPATH += $$SENSORFW_INCLUDEPATHS
Expand All @@ -24,6 +25,4 @@ SOURCES += samplefilter.cpp \

include(../../common-install.pri)
publicheaders.files = $$HEADERS

target.path = $$PLUGINPATH
INSTALLS += target
5 changes: 3 additions & 2 deletions examples/filterplugin/samplefilter.h
Expand Up @@ -6,6 +6,7 @@
Copyright (C) 2009-2010 Nokia Corporation
@author Timo Rongas <ext-timo.2.rongas@nokia.com>
@author Lihan Guo <ext-lihan.4.guo@nokia.com>
This file is part of Sensord.
Expand All @@ -27,10 +28,10 @@
#define SAMPLEFILTER_H

// Include base
#include "sensord/filter.h"
#include "filter.h"

// Include datatypes for input and output.
#include "datatypes/timedunsigned.h"
#include "timedunsigned.h"

// This is a simplest possible filter, with one input and one output.
// In case you wish to create more complex filters, with several inputs
Expand Down
5 changes: 3 additions & 2 deletions examples/sensorplugin/samplesensor.h
Expand Up @@ -6,6 +6,7 @@
Copyright (C) 2009-2010 Nokia Corporation
@author Timo Rongas <ext-timo.2.rongas@nokia.com>
@author Lihan Guo <ext-lihan.4.guo@nokia.com>
This file is part of Sensord.
Expand All @@ -31,10 +32,10 @@

// Include the dbus adaptor and dbusemitter base class
#include "samplesensor_a.h"
#include "sensord/dbusemitter.h"
#include "dbusemitter.h"

// Include required datatypes
#include "datatypes/timedunsigned.h"
#include "timedunsigned.h"

// Included in .cpp, introduced here.
class Bin;
Expand Down
Expand Up @@ -19,6 +19,7 @@ SENSORFW_INCLUDEPATHS = ../.. \
../../include \
../../sensord \
../../datatypes \
../../core \
../../filters

DEPENDPATH += $$SENSORFW_INCLUDEPATHS
Expand All @@ -27,5 +28,3 @@ INCLUDEPATH += $$SENSORFW_INCLUDEPATHS
include(../../common-install.pri)
publicheaders.files += $$HEADERS
target.path = $$PLUGINPATH

INSTALLS += target
3 changes: 2 additions & 1 deletion sensorfw.pro
Expand Up @@ -8,7 +8,8 @@ SUBDIRS = datatypes \
sensord \
qt-api \
chains \
tests
tests \
examples

sensord.depends = datatypes adaptors sensors chains

Expand Down

0 comments on commit 1df6fb7

Please sign in to comment.