Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 125 lines (94 sloc) 3.81 KB
* Copyright (c) 2011 Nokia Corporation
* This file is part of the Push Snowboarding Project, More info at:
* Author: Clovis Scotti <>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <>.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <QObject>
#include <QString>
//#include <QVector>
#include "npushlogtick.h"
#include "npushgenreport.h"
/* This is the base class for all devices.
* This adds to all its subclasses the following functionalities
* Adds QObject basic functionality for all devices (emit/slots/signals)
* Periodic timer for sensor pooling (subclasses assign period value to timerPeriod variable)
* defines the common interface for all sensors
* Devices name should follow:
* All devices: push.*
-> n8 specific devices: push.n8.*
-> bt specific devices:*
-> qt specific devices/sensors: push.qt.*
-> abstract devices: push.abstract.*
-> trick detectors: push.abstract.snowb.* (things that only make sense in the snowboarding world)
-> report generators:
-> network devices:*
-> (TEMP) saver (yeh.. this'll be a device!): push.logsaver
-> (TEMP) auto run manager (yes... we should have that!): push.runmanager.
* push.(device|framework|abstract|report).
class PushBurtonGenericDevice : public QObject
PushBurtonGenericDevice(QObject * parent = 0);
virtual ~PushBurtonGenericDevice() = 0;
virtual QString getName() = 0;
virtual void start_readings();
virtual void stop_readings();
virtual bool is_online() = 0;
virtual void disconnect_from_backend();
virtual bool start_run();
virtual bool end_run();
//Just speeds up the connection.. preventing any checks if this is false!
virtual bool subscribesToAny();
* Devices can subscribe to others
* by either checking the device type (via RTTI typeid() )
* -> specific (implm) device
* -> the subscribing design will cast the publisher
* or by checking the device name via getName();
* -> subscribing to a "class" of devices
* -> implementation independent subscribing
e.g.: subscribing to QRegExp("push.(\w|.)*.imu")
QString s1 = "";
QString s2 = "push.n9.nw.imu";
qDebug() << "a: " << s1.contains(QRegExp("push.(_*|.)*.imu")); //true
qDebug() << "b: " << s2.contains(QRegExp("push.(_*|.)*.imu")); //true
Note that ALL devices transparently subscribe to the simulation device.
virtual bool subscribesTo(PushBurtonGenericDevice* deviceType);
int timerId;
int timerPeriod;
public slots:
virtual void incoming_reading(NPushLogTick *);
void reading_ready(NPushLogTick *);
void report_ready(NPushGenReport *);
void connected();
void disconnected();