Permalink
Browse files

Using standard names for all devices; responsible tick disposal when …

…during simulation; slightly different air time fuzzyfication curves; data_samples on air_time;
  • Loading branch information...
1 parent 6e7825d commit c35ef9d4d9102c9feda80f7e9178f9be9391806e Clovis Scotti committed Jun 14, 2011
@@ -27,9 +27,10 @@ BroadcasterDevice::~BroadcasterDevice()
}
-QString BroadcasterDevice::get_description()
+QString BroadcasterDevice::getName()
{
- return QString("push.n8.broadcaster");
+
+ return QString("push.network.broadcaster");
}
@@ -20,7 +20,7 @@ class BroadcasterDevice : public PushBurtonGenericDevice
~BroadcasterDevice();
- QString get_description();
+ QString getName();
bool is_online() {
return true;
}
@@ -91,24 +91,6 @@ class DevicesManager : public QObject
//This may seem abusive at first look
// but makes complete sense since they are just routed from
// signals comming from different objects and well.. at some point you need to break into!
-// void phone_gps_connecting();
-// void phone_gps_connected();
-
-// void motion_box_connecting();
-// void motion_box_connected();
-
-// void heart_connecting();
-// void heart_connected();
-
-// void gsr_connecting();
-// void gsr_connected();
-
-// void foot_l_connecting();
-// void foot_l_connected();
-
-// void foot_r_connecting();
-// void foot_r_connected();
-
public slots:
@@ -46,8 +46,11 @@ FuzzyDetector::FuzzyDetector()
pa_onAir.push_back(Relation(50.0, 0.0));//hell no!
pa_onGrnd.push_back(Relation(0.0, 0.0));//no gravity, hell no
- pa_onGrnd.push_back(Relation(7.0, 0.0));
- pa_onGrnd.push_back(Relation(9.0, 0.5));
+ pa_onGrnd.push_back(Relation(8.0, 0.0));
+ pa_onGrnd.push_back(Relation(8.4, 1.0));
+ pa_onGrnd.push_back(Relation(8.9, 1.0));
+ pa_onGrnd.push_back(Relation(9.3, 1.0));
+ pa_onGrnd.push_back(Relation(9.5, 0.0));
pa_onGrnd.push_back(Relation(15.0, 1.0));//definitely on ground
pa_onGrnd.push_back(Relation(50.0, 1.0));//definitely on ground
View
@@ -103,7 +103,7 @@ void LiveView::UpdateConnectedList()
ui->connectedDevicesList->clear();
for(int i=0; i < configuredDevices->count(); i++)
{
- QListWidgetItem * devItem = new QListWidgetItem(configuredDevices->at(i)->get_description(), ui->connectedDevicesList);
+ QListWidgetItem * devItem = new QListWidgetItem(configuredDevices->at(i)->getName(), ui->connectedDevicesList);
if(configuredDevices->at(i)->is_online())
devItem->setIcon(QIcon(":/main_menu/icon/images/online.png"));
else
@@ -27,20 +27,15 @@
#include "npushairtimetick.h"
-NPushAirTimeTick::NPushAirTimeTick(quint64 a_msecsInAir, bool a_landed, quint64 a_msecsToEpoch)
-{
- landed = a_landed;
- msecsToEpoch = a_msecsToEpoch;
- msecsOnAir = a_msecsInAir;
- isOnlyHint = false;
-}
-NPushAirTimeTick::NPushAirTimeTick(quint64 a_msecsInAir, bool a_landed, quint64 a_msecsToEpoch, bool a_hint)
+NPushAirTimeTick::NPushAirTimeTick(quint64 a_msecsInAir, bool a_landed,
+ quint64 a_msecsToEpoch, int nDataPts, bool a_hint)
{
landed = a_landed;
msecsToEpoch = a_msecsToEpoch;
msecsOnAir = a_msecsInAir;
isOnlyHint = a_hint;
+ nOfDataPoints = nDataPts;
}
@@ -55,6 +50,7 @@ void NPushAirTimeTick::append_to_xml(QDomDocument& doc, QDomElement& root) const
QDomElement tickDom = doc.createElement("air_time");
tickDom.setAttribute("tstamp", (double)(msecsToEpoch*0.001));
tickDom.setAttribute("in_air", (double)(msecsOnAir*0.001));
+ tickDom.setAttribute("data_points", nOfDataPoints);
tickDom.setAttribute("landed", ((landed)?"true":"false") );
root.appendChild(tickDom);
@@ -68,6 +64,7 @@ void NPushAirTimeTick::dump_to_xml(QXmlStreamWriter& xml) const
xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
xml.writeAttribute("in_air", QString::number(((double)msecsOnAir)/(double)1000.0, 'f', 3));
+ xml.writeAttribute("data_points", QString::number(nOfDataPoints));
xml.writeAttribute("landed", ((landed)?"true":"false") );
xml.writeEndElement();//air_time
}
@@ -37,8 +37,7 @@
class NPushAirTimeTick : public NPushLogTick
{
public:
- NPushAirTimeTick(quint64 a_msecsInAir, bool a_landed, quint64 a_msecsToEpoch);
- NPushAirTimeTick(quint64 a_msecsInAir, bool a_landed, quint64 a_msecsToEpoch, bool a_hint);
+ NPushAirTimeTick(quint64 a_msecsInAir, bool a_landed, quint64 a_msecsToEpoch, int nDataPts=0, bool a_hint=false);
~NPushAirTimeTick();
void append_to_xml(QDomDocument& doc, QDomElement& root) const;
@@ -49,6 +48,7 @@ class NPushAirTimeTick : public NPushLogTick
bool isOnlyHint;
+ int nOfDataPoints;
quint64 msecsToEpoch;
quint64 msecsOnAir;
bool landed;
@@ -41,6 +41,21 @@
* 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: push.n8.bt.*
+ -> qt specific devices/sensors: push.qt.*
+ -> abstract devices: push.abstract.*
+ -> trick detectors: push.abstract.snowb.*
+ -> report generators: push.report.
+ -> network devices: push.network.*
+
+ -> (TEMP) saver (yeh.. this'll be a device!): push.logsaver
+ -> (TEMP) auto run manager (yes... we should have that!): push.runmanager.
+
+
*/
class PushBurtonGenericDevice : public QObject
{
@@ -51,7 +66,7 @@ class PushBurtonGenericDevice : public QObject
virtual ~PushBurtonGenericDevice() = 0;
- virtual QString get_description() = 0;
+ virtual QString getName() = 0;
virtual void start_readings();
virtual void stop_readings();
@@ -1,114 +1,114 @@
-/*
- * Copyright (c) 2011 Nokia Corporation
- *
- * This file is part of the Push Snowboarding Project, More info at:
- * www.pushsnowboading.com
- *
- * Author: Clovis Scotti <scotti@ieee.org>
- *
- * 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
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * 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 <http://www.gnu.org/licenses/>.
- *
- * 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 "pushdevicesholder.h"
-
-PushDevicesHolder::PushDevicesHolder()
-{
- tickDisposer = new NPushTickDisposer();
-}
-
-PushDevicesHolder::~PushDevicesHolder()
-{
- for(int i=0;i<this->count();i++)
- {
- qDebug() << "Calling delete for " << this->at(i)->get_description();
- this->at(i)->disconnect_from_backend();
-// this->at(i)->deleteLater()
- delete this->at(i);
-
- }
-
- if(tickDisposer) {
- qDebug() << "Calling delete later for tick disposer";
-// tickDisposer->deleteLater();
- delete tickDisposer;
- }
-}
-
-int PushDevicesHolder::deleteAllAndClear()
-{
- int i;
- for(i=0; i < this->count(); i++)
- {
- PushBurtonGenericDevice * iDev = this->at(i);
- iDev->deleteLater();
- }
- this->clear();
- return i;
-}
-
-bool PushDevicesHolder::CheckForDeviceType(QString& device_type)
-{
-// qDebug() << "checking for: " << device_type;
- for(int i=0; i < this->count(); i++)
- {
- QString thisDevTypeName(typeid(*(this->at(i))).name());
-// qDebug() << "against: " << thisDevTypeName;
- if(thisDevTypeName == device_type)
- {
- return true;
- }
- }
- return false;
-}
-
-void PushDevicesHolder::push_back(PushBurtonGenericDevice* ptr)
-{
- qDebug() << "Adding device to PushDevicesHolder internal list";
- QVector<PushBurtonGenericDevice *>::push_back(ptr);
-
- //Essential connection to logTicksDisposer! Without this the program is a dangling huge memory leaker
- ptr->connect(ptr, SIGNAL(reading_ready(NPushLogTick*)), tickDisposer, SLOT(log_ticks_sink(NPushLogTick*)), Qt::UniqueConnection);
-
- if(typeid(*ptr) == typeid(PushBurtonGenericDevice)){
- qDebug() << "Initial type check O.K.";
- }
-
- //checking if new device subscribes to any of the availables devices
- if(ptr->subscribesToAny()) {
- for(int i=0;i<this->count();i++) {
- PushBurtonGenericDevice* iptr = this->at(i);
- //If new device subscribes to it //PS: This enables recursion!!
- if(ptr->subscribesTo(iptr) || typeid(*iptr) == typeid(PushN8SimulationDevice)) {
- qDebug() << "Connected " << iptr->get_description() << "\'s output to " << ptr->get_description();
- ptr->connect(iptr, SIGNAL(reading_ready(NPushLogTick*)), ptr, SLOT(incoming_reading(NPushLogTick*)), Qt::UniqueConnection);
- }
- }
- }
-
- //Checking if previously available device subscribes to newly added device
- for(int i=0;i<this->count()-1;i++) {
- PushBurtonGenericDevice* iptr = this->at(i);
- if(iptr->subscribesToAny()) {
- if(iptr->subscribesTo(ptr)) {
- qDebug() << "Connected " << ptr->get_description() << "\'s output to " << iptr->get_description();
- iptr->connect(ptr, SIGNAL(reading_ready(NPushLogTick*)), iptr, SLOT(incoming_reading(NPushLogTick*)), Qt::UniqueConnection);
- }
- }
- }
-}
+/*
+ * Copyright (c) 2011 Nokia Corporation
+ *
+ * This file is part of the Push Snowboarding Project, More info at:
+ * www.pushsnowboading.com
+ *
+ * Author: Clovis Scotti <scotti@ieee.org>
+ *
+ * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ * 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 "pushdevicesholder.h"
+
+PushDevicesHolder::PushDevicesHolder()
+{
+ tickDisposer = new NPushTickDisposer();
+}
+
+PushDevicesHolder::~PushDevicesHolder()
+{
+ for(int i=0;i<this->count();i++)
+ {
+ qDebug() << "Calling delete for " << this->at(i)->getName();
+ this->at(i)->disconnect_from_backend();
+// this->at(i)->deleteLater()
+ delete this->at(i);
+
+ }
+
+ if(tickDisposer) {
+ qDebug() << "Calling delete later for tick disposer";
+// tickDisposer->deleteLater();
+ delete tickDisposer;
+ }
+}
+
+int PushDevicesHolder::deleteAllAndClear()
+{
+ int i;
+ for(i=0; i < this->count(); i++)
+ {
+ PushBurtonGenericDevice * iDev = this->at(i);
+ iDev->deleteLater();
+ }
+ this->clear();
+ return i;
+}
+
+bool PushDevicesHolder::CheckForDeviceType(QString& device_type)
+{
+// qDebug() << "checking for: " << device_type;
+ for(int i=0; i < this->count(); i++)
+ {
+ QString thisDevTypeName(typeid(*(this->at(i))).name());
+// qDebug() << "against: " << thisDevTypeName;
+ if(thisDevTypeName == device_type)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+void PushDevicesHolder::push_back(PushBurtonGenericDevice* ptr)
+{
+ qDebug() << "Adding device to PushDevicesHolder internal list";
+ QVector<PushBurtonGenericDevice *>::push_back(ptr);
+
+ //Essential connection to logTicksDisposer! Without this the program is a dangling huge memory leaker
+ ptr->connect(ptr, SIGNAL(reading_ready(NPushLogTick*)), tickDisposer, SLOT(log_ticks_sink(NPushLogTick*)), Qt::UniqueConnection);
+
+ if(typeid(*ptr) == typeid(PushBurtonGenericDevice)){
+ qDebug() << "Initial type check O.K.";
+ }
+
+ //checking if new device subscribes to any of the availables devices
+ if(ptr->subscribesToAny()) {
+ for(int i=0;i<this->count();i++) {
+ PushBurtonGenericDevice* iptr = this->at(i);
+ //If new device subscribes to it //PS: This enables recursion!!
+ if(ptr->subscribesTo(iptr) || typeid(*iptr) == typeid(PushN8SimulationDevice)) {
+ qDebug() << "Connected " << iptr->getName() << "\'s output to " << ptr->getName();
+ ptr->connect(iptr, SIGNAL(reading_ready(NPushLogTick*)), ptr, SLOT(incoming_reading(NPushLogTick*)), Qt::UniqueConnection);
+ }
+ }
+ }
+
+ //Checking if previously available device subscribes to newly added device
+ for(int i=0;i<this->count()-1;i++) {
+ PushBurtonGenericDevice* iptr = this->at(i);
+ if(iptr->subscribesToAny()) {
+ if(iptr->subscribesTo(ptr)) {
+ qDebug() << "Connected " << ptr->getName() << "\'s output to " << iptr->getName();
+ iptr->connect(ptr, SIGNAL(reading_ready(NPushLogTick*)), iptr, SLOT(incoming_reading(NPushLogTick*)), Qt::UniqueConnection);
+ }
+ }
+ }
+}
@@ -66,9 +66,9 @@ bool PushN8AbsNormFeetDevice::subscribesTo(PushBurtonGenericDevice* deviceType)
}
}
-QString PushN8AbsNormFeetDevice::get_description()
+QString PushN8AbsNormFeetDevice::getName()
{
- return "NormalizedFeetAnalizer";
+ return "push.abstract.normfeet";
}
void PushN8AbsNormFeetDevice::start_readings()
Oops, something went wrong.

0 comments on commit c35ef9d

Please sign in to comment.