Commit ac17c2cc authored by Antti Virtanen's avatar Antti Virtanen

Refactoring:

 - Fixed doxygen errors
 - filters/* content not copied to libsensord-dev anymore.
 - GyroscopeSensorChannelInterface and GyroscopeSensorChannel cleaned.
parent 8a48c935
/**
@file alsadaptorplugin-sysfs.h
@file alsadaptor-sysfsplugin.h
@brief Plugin for ALSAdaptorSysfs
<p>
......
/**
@file proximityadaptor-asciiplugin.cpp
@file proximityadaptor-asciiplugin.h
@brief plugin for ProximityAdaptorAscii
<p>
......
......@@ -40,7 +40,7 @@
* Provides input data from touchscreen input device.
*
* @todo <ul><li>Kernel update will change all the traffic into one handle,
* separated by sync messages. Change accordingly.</li>
* separated by sync messages. Change accordingly.</li></ul>
*/
class TouchAdaptor : public InputDevAdaptor
{
......@@ -118,4 +118,3 @@ private:
};
#endif
......@@ -46,7 +46,7 @@ typedef struct {
} sensorfw_interval_t;
/**
* @brier Structure containing data range information for sensor.
* @brief Structure containing data range information for sensor.
*/
typedef struct {
int min; ///< Minimum value
......@@ -122,7 +122,7 @@ int sensorfw_get_interval(int sessionId);
* @brief Sets the sample interval for sensor.
*
* See sensorfw_get_interval.
*
*
* @param sessionId Session ID to run this request on.
* @param interval Milliseconds to wait between measurements.
* @return \c true on success, \c false on failure or invalid session ID.
......@@ -167,7 +167,7 @@ bool sensorfw_get_description(int sessionId, char** description);
* @brief Registers a callback function to handle sensor output.
*
* @todo Description of callback requirements.
*
*
* @param sessionId Session ID to run this request on.
* @param cb_func Pointer to function to use as callback.
* @return \c true on success, \c false on failure or invalid session ID.
......
......@@ -41,7 +41,7 @@ class FilterBase;
*
* <b>Output buffers:</b>
* <ul><li>\em accelerometer</li></ul>
*
*
* For direct raw data (no coordinate correction) use #AccelerometerAdaptor.
*/
class AccelerometerChain : public AbstractChain
......
......@@ -6,7 +6,6 @@ libs-pkg: sensord
dev-pkg: libsensord-dev
headers:
/usr/include/sensord/datatypes/*
/usr/include/sensord/filters/*
/usr/include/sensord/*_i.h
libs:
/usr/lib/libsensorclient.so.1.0.0
......
/usr/include/sensord/*.h
/usr/include/sensord/datatypes/*.h
/usr/include/sensord/filters/*.h
/usr/lib/pkgconfig/*.pc
/usr/share/qt4/mkspecs/features/*.prf
......@@ -69,7 +69,7 @@ void AccelerometerSensorChannelInterface::dataReceived()
QVector<AccelerationData> values;
while (read<AccelerationData>(values))
{
if(frameAvailableConnected || values.size() == 1)
if(!frameAvailableConnected || values.size() == 1)
{
foreach(AccelerationData data, values)
emit dataAvailable(XYZ(data));
......
......@@ -63,7 +63,7 @@ public:
/**
* Constructor.
* @param path path.
* @param sessionid session id.
* @param sessionId session id.
*/
AccelerometerSensorChannelInterface(const QString& path, int sessionId);
......@@ -101,7 +101,7 @@ Q_SIGNALS: // SIGNALS
* Sent when new measurement frame has become available.
* If app doesn't connect to this signal content of frames
* will be sent through dataAvailable signal.
* @param data New measurement frame.
* @param frame New measurement frame.
*/
void frameAvailable(const QVector<XYZ>& frame);
};
......
......@@ -85,7 +85,7 @@ Q_SIGNALS: // SIGNALS
/**
* Sent when compass direction or calibration level has changed.
* @param level Current compass measurement.
* @param value Current compass measurement.
*/
void dataAvailable(const Compass& value);
};
......
......@@ -7,6 +7,7 @@
@author Timo Rongas <ext-timo.2.rongas@nokia.com>
@author Samuli Piippo <ext-samuli.1.piippo@nokia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
This file is part of Sensord.
......@@ -22,15 +23,23 @@
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 "sensormanagerinterface.h"
#include "gyroscopesensor_i.h"
#include <datatypes/orientationdata.h>
const char* GyroscopeSensorChannelInterface::staticInterfaceName = "local.GyroscopeSensor";
QDBusAbstractInterface* GyroscopeSensorChannelInterface::factoryMethod(const QString& id, int sessionId)
{
// ToDo: see which arguments can be made explicit
return new GyroscopeSensorChannelInterface(OBJECT_PATH + "/" + id, sessionId);
}
GyroscopeSensorChannelInterface::GyroscopeSensorChannelInterface(const QString &path, int sessionId)
: AbstractSensorChannelInterface(path, GyroscopeSensorChannelInterface::staticInterfaceName(), sessionId),
frameAvailableConnected(false)
: AbstractSensorChannelInterface(path, GyroscopeSensorChannelInterface::staticInterfaceName, sessionId),
frameAvailableConnected(false)
{
}
......@@ -57,32 +66,25 @@ GyroscopeSensorChannelInterface* GyroscopeSensorChannelInterface::controlInterfa
return dynamic_cast<GyroscopeSensorChannelInterface*>(sm.controlInterface(id));
}
void GyroscopeSensorChannelInterface::dataReceived()
{
QVector<AngularVelocityData> values;
while (read<AngularVelocityData>(values))
{
if(values.size() == 1)
emit dataAvailable(XYZ(values.back()));
if(!frameAvailableConnected || values.size() == 1)
{
foreach(AngularVelocityData data, values)
emit dataAvailable(XYZ(data));
}
else
{
if(frameAvailableConnected)
{
QVector<XYZ> realValues;
realValues.reserve(values.size());
foreach(AngularVelocityData data, values)
realValues.push_back(XYZ(data));
emit frameAvailable(realValues);
values.clear();
}
else
{
foreach(AngularVelocityData data, values)
emit dataAvailable(XYZ(data));
}
QVector<XYZ> realValues;
realValues.reserve(values.size());
foreach(AngularVelocityData data, values)
realValues.push_back(XYZ(data));
emit frameAvailable(realValues);
}
values.clear();
}
}
......@@ -100,4 +102,7 @@ QDBusReply<void> GyroscopeSensorChannelInterface::reset()
return callWithArgumentList(QDBus::Block, QLatin1String("reset"), argumentList);
}
XYZ GyroscopeSensorChannelInterface::get() const
{
return qvariant_cast<XYZ>(internalPropGet("value"));
}
......@@ -7,6 +7,7 @@
@author Timo Rongas <ext-timo.2.rongas@nokia.com>
@author Samuli Piippo <ext-samuli.1.piippo@nokia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
This file is part of Sensord.
......@@ -43,33 +44,27 @@
class GyroscopeSensorChannelInterface: public AbstractSensorChannelInterface
{
Q_OBJECT;
Q_DISABLE_COPY(GyroscopeSensorChannelInterface)
Q_PROPERTY(XYZ value READ get)
public:
/**
* Get name of the D-Bus interface for this class.
* @return Name of the interface.
* Name of the D-Bus interface for this class.
*/
static inline const char *staticInterfaceName()
{ return "local.GyroscopeSensor"; }
static const char* staticInterfaceName;
/**
* Get an instance of the class.
* @return Pointer to new instance of the class.
*/
static QDBusAbstractInterface* factoryMethod(const QString& id, int sessionId)
{
// ToDo: see which arguments can be made explicit
return new GyroscopeSensorChannelInterface(OBJECT_PATH + "/" + id, sessionId);
}
static QDBusAbstractInterface* factoryMethod(const QString& id, int sessionId);
Q_PROPERTY(XYZ value READ get);
inline XYZ get() const { return qvariant_cast<XYZ>(internalPropGet("value")); }
XYZ get() const;
public:
/**
* Constructor.
* @param path path.
* @param sessionid session id.
* @param sessionId session id.
*/
GyroscopeSensorChannelInterface(const QString &path, int sessionId);
......@@ -90,16 +85,13 @@ public:
protected:
virtual void connectNotify(const char* signal);
private:
bool frameAvailableConnected;
public Q_SLOTS: // METHODS
void dataReceived();
QDBusReply<void> reset();
Q_SIGNALS: // SIGNALS
/**
* Sent when new measurement data has become available.
......@@ -107,12 +99,11 @@ Q_SIGNALS: // SIGNALS
*/
void dataAvailable(const XYZ& data);
/**
* Sent when new measurement frame has become available.
* If app doesn't connect to this signal content of frames
* will be sent through dataAvailable signal.
* @param data New measurement frame.
* @param frame New measurement frame.
*/
void frameAvailable(const QVector<XYZ>& frame);
......
......@@ -93,7 +93,7 @@ Q_SIGNALS: // SIGNALS
* Sent when new measurement frame has become available.
* If app doesn't connect to this signal content of frames
* will be sent through dataAvailable signal.
* @param data New measurement frame.
* @param frame New measurement frame.
*/
void frameAvailable(const QVector<MagneticField>& frame);
};
......
......@@ -64,7 +64,7 @@ public:
/**
* Constructor.
* @param path path.
* @param sessionid session id.
* @param sessionId session id.
*/
ProximitySensorChannelInterface(const QString& path, int sessionId);
......
......@@ -69,7 +69,7 @@ void RotationSensorChannelInterface::dataReceived()
QVector<TimedXyzData> values;
while (read<TimedXyzData>(values))
{
if(frameAvailableConnected || values.size() == 1)
if(!frameAvailableConnected || values.size() == 1)
{
foreach(TimedXyzData data, values)
emit dataAvailable(XYZ(data));
......
......@@ -92,7 +92,7 @@ Q_SIGNALS: // SIGNALS
* Sent when new measurement frame has become available.
* If app doesn't connect to this signal content of frames
* will be sent through dataAvailable signal.
* @param data New measurement frame.
* @param frame New measurement frame.
*/
void frameAvailable(const QVector<XYZ>& frame);
};
......
......@@ -77,7 +77,7 @@ public:
* written in single operation are available for immediate reading
* with a single operation.
*
* @param unitSize Number of bytes to read.
* @param size Number of bytes to read.
* @param buffer Location for storing the data.
* @return \c true if any bytes were read, \c false otherwise.
*/
......
......@@ -79,9 +79,9 @@ private Q_SLOTS: // METHODS
Q_SIGNALS: // SIGNALS
/**
* Sent when new tap event has occurred.
* @param The tap event.
* @param data The tap event.
*/
void dataAvailable(const Tap&);
void dataAvailable(const Tap& data);
public:
......
......@@ -53,9 +53,9 @@ public:
/**
* Run when a property value has been set in a FilterProperty this tracker
* is monitoring.
* @param Pointer to the calling FilterPropertyBase.
* @param property Pointer to the calling FilterPropertyBase.
*/
virtual void trackWrite(FilterPropertyBase*) {}
virtual void trackWrite(FilterPropertyBase* property) {}
};
......
......@@ -95,8 +95,6 @@ protected:
* Scans through the /dev/input/event* device handles and registers the
* ones that pass the test with the #checkInputDevice method.
* @param matchString String to match in device name fields.
* @param matchingDeviceNumber Pointer to integer where to store the
* last found matching device number.
*
* @return Number of devices detected.
*
......
......@@ -64,7 +64,7 @@ public Q_SLOTS:
/**
* Remove a range request.
* @param sessionID ID of the session whose request to remove.
* @param sessionId ID of the session whose request to remove.
*/
void removeDataRangeRequest(int sessionId);
......@@ -230,6 +230,7 @@ protected:
* it. For nodes which merely get several options from previous nodes
* this won't get invoked.
* @param range The range to set
* @param sessionId The session Id
* @return \c true on succesfull set, \c false otherwise. The base
* class implementation always returns false.
*/
......
......@@ -88,7 +88,7 @@ public:
* @param mode Mode to use for monitoring.
* @param seek Whether lseek() should be called to rewind the monitored fds.
* @param path Path to the sysfs file device to monitor.
* @param id Identifier for the path (used as parameter to processSample).
* @param pathId Identifier for the path (used as parameter to processSample).
*/
SysfsAdaptor(const QString& id, PollMode mode = SelectMode, bool seek = true, const QString& path = "", const int pathId = 0);
......
......@@ -31,7 +31,7 @@
void GyroscopePlugin::Register(class Loader&)
{
qDebug() << "registering gyroscopesensor";
sensordLogD() << "registering gyroscopesensor";
SensorManager& sm = SensorManager::instance();
sm.registerSensor<GyroscopeSensorChannel>("gyroscopesensor");
}
......
......@@ -30,7 +30,6 @@
#include "sensord/bin.h"
#include "sensord/bufferreader.h"
GyroscopeSensorChannel::GyroscopeSensorChannel(const QString& id) :
AbstractSensorChannel(id),
DbusEmitter<AngularVelocityData>(10),
......@@ -73,20 +72,16 @@ GyroscopeSensorChannel::~GyroscopeSensorChannel()
{
SensorManager& sm = SensorManager::instance();
// Disconnect reader
disconnectFromSource(gyroscopeAdaptor_, "gyroscope", gyroscopeReader_);
// Release chain (dont delete!)
sm.releaseDeviceAdaptor("gyroscopeadaptor");
// ...and delete locally owned things
delete gyroscopeReader_;
delete outputBuffer_;
delete marshallingBin_;
delete filterBin_;
}
// Start bins and sources
bool GyroscopeSensorChannel::start()
{
sensordLogD() << "Starting GyroscopeSensorChannel";
......@@ -99,7 +94,6 @@ bool GyroscopeSensorChannel::start()
return true;
}
// Stopping is start() in reverse.
bool GyroscopeSensorChannel::stop()
{
sensordLogD() << "Stopping GyroscopeSensorChannel";
......@@ -112,9 +106,6 @@ bool GyroscopeSensorChannel::stop()
return true;
}
// Store the previous value for use by the accessor function, and
// push data towards clients (the data will be pushed to socket(s) by
// sensormanager).
void GyroscopeSensorChannel::emitToDbus(const AngularVelocityData& value)
{
previousSample_ = value;
......
......@@ -30,30 +30,21 @@
#include "abstractsensor.h"
#include "sensord/deviceadaptor.h"
// Include the dbus adaptor and dbusemitter base class
#include "gyroscopesensor_a.h"
#include "sensord/dbusemitter.h"
// Include required datatypes
#include "datatypes/orientationdata.h"
#include "datatypes/xyz.h"
// Included in .cpp, introduced here.
class Bin;
template <class TYPE> class BufferReader;
class FilterBase;
// Sensors inherit also DbusEmitter
class GyroscopeSensorChannel :
public AbstractSensorChannel,
public DbusEmitter<AngularVelocityData>
{
Q_OBJECT;
// Accessor function for the value for clients. Type must be based
// on QObject and marshallable over D-Bus. Usually it just wraps the
// POD that is used internally.
Q_PROPERTY(XYZ value READ get);
public:
......@@ -64,15 +55,11 @@ public:
static AbstractSensorChannel* factoryMethod(const QString& id)
{
GyroscopeSensorChannel* sc = new GyroscopeSensorChannel(id);
// This creates the dbus adaptor - qobject parent relation
// makes sure it gets destructed correctly.
new GyroscopeSensorChannelAdaptor(sc);
return sc;
}
// Implementation of the accessor function.
XYZ get() const { return previousSample_; }
public Q_SLOTS:
......@@ -80,7 +67,6 @@ public Q_SLOTS:
bool stop();
signals:
// Signal is used whenever we have new data.
void dataAvailable(const AngularVelocityData& data);
protected:
......@@ -91,15 +77,12 @@ private:
Bin* filterBin_;
Bin* marshallingBin_;
// Pointer to chain and a reader for it.
DeviceAdaptor* gyroscopeAdaptor_;
BufferReader<AngularVelocityData>* gyroscopeReader_;
RingBuffer<AngularVelocityData>* outputBuffer_;
// We need to store the previous sample for accessor.
AngularVelocityData previousSample_;
// Function that takes care of pushing the data to clients
void emitToDbus(const AngularVelocityData& value);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment