Skip to content
Browse files

Removed deprecated code (append_to_xml); \n Added read_from_xml(); \n…

… Made digitalAcc detection bounded to IMU tick\'s world (static); \n Fixed simulationDevice xml reading.. looks a lot less confused now.
  • Loading branch information...
1 parent 63452f9 commit 42aa3910ca364429c8637093fc33c0083ab5400f Clovis Scotti committed Jun 15, 2011
View
5 PushBurton2/broadcasterdevice.cpp
@@ -135,3 +135,8 @@ void BroadcasterDevice::tryToDisconnect()
emit connectionUpdate(false);
}
+
+bool BroadcasterDevice::subscribesTo(PushBurtonGenericDevice * dev)
+{
+ return dev->getName().contains(QRegExp("push.(n8|qt)"));
+}
View
4 PushBurton2/broadcasterdevice.h
@@ -9,6 +9,8 @@
#include <QXmlStreamWriter>
#include <QIODevice>
+#include <QRegExp>
+
#include <QDebug>
class BroadcasterDevice : public PushBurtonGenericDevice
@@ -31,7 +33,7 @@ class BroadcasterDevice : public PushBurtonGenericDevice
bool subscribesToAny() { return true; }
//This function will return true when the given device is a AirTimeDetector
- bool subscribesTo(PushBurtonGenericDevice*) { return true; }
+ bool subscribesTo(PushBurtonGenericDevice*);
bool start_run();
bool end_run();
View
199 PushBurton2/npushacctick.cpp
@@ -1,90 +1,109 @@
-/*
- * 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 "npushacctick.h"
-
-NPushAccTick::NPushAccTick(QAccelerometerReading * reading)
-{
- tick.copyValuesFrom(reading);
-
- uint secs_to_epoch;
- uint msecs;
-
- secs_to_epoch = QDateTime::currentDateTime().toTime_t();
- msecs = QTime::currentTime().msec();
- uint aft = QDateTime::currentDateTime().toTime_t();
-
- //ugly work around, will be fized with msecsToEpoc from Qt 4.7
- if(aft != secs_to_epoch)//on a second slip
- {
- msecs = 0;
- secs_to_epoch = aft;
- }
-
- msecsToEpoch = (double)secs_to_epoch*1000.0+(double)msecs;
-
- pAccAbsMag = qSqrt(tick.x()*tick.x()+
- tick.y()*tick.y()+
- tick.z()*tick.z());
-}
-
-//Used to generate simulated ticks (tstamp comes directly from the xml file)
-NPushAccTick::NPushAccTick(QAccelerometerReading * reading, quint64 a_msecsToEpoch)
-{
- tick.copyValuesFrom(reading);
- msecsToEpoch = a_msecsToEpoch;
-
- pAccAbsMag = qSqrt(tick.x()*tick.x()+
- tick.y()*tick.y()+
- tick.z()*tick.z());
-}
-
-NPushAccTick::~NPushAccTick()
-{
-}
-
-void NPushAccTick::dump_to_xml(QXmlStreamWriter& xml) const
-{
- xml.writeStartElement("acc_data");
-
- xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
-
- xml.writeAttribute("x", QString::number(tick.x()));
- xml.writeAttribute("y", QString::number(tick.y()));
- xml.writeAttribute("z", QString::number(tick.z()));
- xml.writeAttribute("r", QString::number(pAccAbsMag));
- xml.writeEndElement();//acc_data
-}
-
-QString NPushAccTick::get_pretty_print() const
-{
- return QString("P.Acc= %1;%2;%3")
- .arg(QString::number(tick.x()))
- .arg(QString::number(tick.y()))
- .arg(QString::number(tick.z()));
-}
-
+/*
+ * 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 "npushacctick.h"
+
+NPushAccTick::NPushAccTick(QAccelerometerReading * reading)
+{
+ tick.copyValuesFrom(reading);
+
+ uint secs_to_epoch;
+ uint msecs;
+
+ secs_to_epoch = QDateTime::currentDateTime().toTime_t();
+ msecs = QTime::currentTime().msec();
+ uint aft = QDateTime::currentDateTime().toTime_t();
+
+ //ugly work around, will be fized with msecsToEpoc from Qt 4.7
+ if(aft != secs_to_epoch)//on a second slip
+ {
+ msecs = 0;
+ secs_to_epoch = aft;
+ }
+
+ msecsToEpoch = (double)secs_to_epoch*1000.0+(double)msecs;
+
+ pAccAbsMag = qSqrt(tick.x()*tick.x()+
+ tick.y()*tick.y()+
+ tick.z()*tick.z());
+}
+
+//Used to generate simulated ticks (tstamp comes directly from the xml file)
+NPushAccTick::NPushAccTick(QAccelerometerReading * reading, quint64 a_msecsToEpoch)
+{
+ tick.copyValuesFrom(reading);
+ msecsToEpoch = a_msecsToEpoch;
+
+ pAccAbsMag = qSqrt(tick.x()*tick.x()+
+ tick.y()*tick.y()+
+ tick.z()*tick.z());
+}
+
+NPushAccTick::~NPushAccTick()
+{
+}
+
+void NPushAccTick::read_from_xml( QXmlStreamReader& xml)
+{
+ // if(xml.attributes().hasAttribute("x"))
+ tick.setX(xml.attributes().value("x").toString().toFloat());
+
+ // if(xml.attributes().hasAttribute("y"))
+ tick.setY(xml.attributes().value("y").toString().toFloat());
+
+ // if(xml.attributes().hasAttribute("z"))
+ tick.setZ(xml.attributes().value("z").toString().toFloat());
+
+ pAccAbsMag = qSqrt(tick.x()*tick.x()+
+ tick.y()*tick.y()+
+ tick.z()*tick.z());
+
+ // if(xml.attributes().hasAttribute("tstamp"))
+ msecsToEpoch = (quint64)((double)xml.attributes().value("tstamp").toString().toDouble()*1000.0);
+}
+
+void NPushAccTick::dump_to_xml(QXmlStreamWriter& xml) const
+{
+ xml.writeStartElement("acc_data");
+
+ xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
+
+ xml.writeAttribute("x", QString::number(tick.x()));
+ xml.writeAttribute("y", QString::number(tick.y()));
+ xml.writeAttribute("z", QString::number(tick.z()));
+ xml.writeAttribute("r", QString::number(pAccAbsMag));
+ xml.writeEndElement();//acc_data
+}
+
+QString NPushAccTick::get_pretty_print() const
+{
+ return QString("P.Acc= %1;%2;%3")
+ .arg(QString::number(tick.x()))
+ .arg(QString::number(tick.y()))
+ .arg(QString::number(tick.z()));
+}
+
View
117 PushBurton2/npushacctick.h
@@ -1,57 +1,60 @@
-/*
- * 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
- *
- */
-
-#ifndef NPUSHACCTICK_H
-#define NPUSHACCTICK_H
-
-#include "npushlogtick.h"
-#include <qmath.h>
-#include <QAccelerometer>
-#include <QtXml>
-#include <QTime>
-
-QTM_USE_NAMESPACE
-class NPushAccTick : public NPushLogTick
-{
-public:
- NPushAccTick(QAccelerometerReading * reading);
- NPushAccTick(QAccelerometerReading * reading, quint64 a_msecsToEpoch);
- ~NPushAccTick();
-
- void dump_to_xml(QXmlStreamWriter& xml) const;
-
- QString get_pretty_print() const;
-
- QAccelerometerReading tick;
- qreal pAccAbsMag;
-
- quint64 msecsToEpoch;
-
- static const qreal freefall_threshold = 7.0;
-};
-
-#endif // NPUSHACCTICK_H
+/*
+ * 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
+ *
+ */
+
+#ifndef NPUSHACCTICK_H
+#define NPUSHACCTICK_H
+
+#include "npushlogtick.h"
+#include <qmath.h>
+#include <QAccelerometer>
+#include <QtXml>
+#include <QTime>
+
+QTM_USE_NAMESPACE
+class NPushAccTick : public NPushLogTick
+{
+public:
+ NPushAccTick() {}
+ NPushAccTick(QAccelerometerReading * reading);
+ NPushAccTick(QAccelerometerReading * reading, quint64 a_msecsToEpoch);
+
+ virtual ~NPushAccTick();
+
+ virtual void read_from_xml( QXmlStreamReader& xml);
+ virtual void dump_to_xml(QXmlStreamWriter& xml) const;
+
+ virtual QString get_pretty_print() const;
+
+ QAccelerometerReading tick;
+ qreal pAccAbsMag;
+
+ quint64 msecsToEpoch;
+
+ static const qreal freefall_threshold = 7.0;
+};
+
+#endif // NPUSHACCTICK_H
View
135 PushBurton2/npushairtimetick.cpp
@@ -1,63 +1,72 @@
-/*
- * 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 "npushairtimetick.h"
-
-
-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;
-}
-
-
-NPushAirTimeTick::~NPushAirTimeTick()
-{
-}
-
-void NPushAirTimeTick::dump_to_xml(QXmlStreamWriter& xml) const
-{
- if(!isOnlyHint) {
- xml.writeStartElement("air_time");
-
- 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
- }
-}
-
-QString NPushAirTimeTick::get_pretty_print() const
-{
- return QString(((landed)?"Landed [%1]":"AIR [%1]"))
- .arg(QString::number(msecsOnAir));
-}
+/*
+ * 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 "npushairtimetick.h"
+
+
+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;
+}
+
+
+NPushAirTimeTick::~NPushAirTimeTick()
+{
+}
+
+void NPushAirTimeTick::read_from_xml( QXmlStreamReader& xml)
+{
+ landed = (xml.attributes().value("landed").toString() == "true");
+ nOfDataPoints = xml.attributes().value("data_points").toString().toInt();
+ msecsOnAir = (quint64)((double)xml.attributes().value("in_air").toString().toDouble()*1000.0);
+ msecsToEpoch = (quint64)((double)xml.attributes().value("tstamp").toString().toDouble()*1000.0);
+ isOnlyHint = false;
+}
+
+void NPushAirTimeTick::dump_to_xml(QXmlStreamWriter& xml) const
+{
+ if(!isOnlyHint) {
+ xml.writeStartElement("air_time");
+
+ 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
+ }
+}
+
+QString NPushAirTimeTick::get_pretty_print() const
+{
+ return QString(((landed)?"Landed [%1]":"AIR [%1]"))
+ .arg(QString::number(msecsOnAir));
+}
View
9 PushBurton2/npushairtimetick.h
@@ -38,10 +38,13 @@ class NPushAirTimeTick : public NPushLogTick
{
public:
NPushAirTimeTick(quint64 a_msecsInAir, bool a_landed, quint64 a_msecsToEpoch, int nDataPts=0, bool a_hint=false);
- ~NPushAirTimeTick();
- void dump_to_xml(QXmlStreamWriter& xml) const;
- QString get_pretty_print() const;
+ virtual ~NPushAirTimeTick();
+
+ virtual void read_from_xml( QXmlStreamReader& xml);
+ virtual void dump_to_xml(QXmlStreamWriter& xml) const;
+
+ virtual QString get_pretty_print() const;
public:
View
182 PushBurton2/npushfoottick.cpp
@@ -1,86 +1,96 @@
-/*
- * 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 "npushfoottick.h"
-
-NPushFootTick::NPushFootTick(char a_side, int a_toes, int a_heel)
-{
- side = a_side;
- toes = a_toes;
- heel = a_heel;
-
- uint secs_to_epoch;
- uint msecs;
-
- secs_to_epoch = QDateTime::currentDateTime().toTime_t();
- msecs = QTime::currentTime().msec();
- uint aft = QDateTime::currentDateTime().toTime_t();
-
- //ugly work around, will be fized with msecsToEpoc from Qt 4.7
- if(aft != secs_to_epoch)//on a second slip
- {
- msecs = 0;
- secs_to_epoch = aft;
- }
-
- msecsToEpoch = (double)secs_to_epoch*1000.0+(double)msecs;
-}
-
-NPushFootTick::NPushFootTick(char a_side, int a_toes, int a_heel, quint64 a_msecsToEpoch)
-{
- side = a_side;
- toes = a_toes;
- heel = a_heel;
-
- msecsToEpoch = a_msecsToEpoch;
-
-}
-
-NPushFootTick::~NPushFootTick()
-{
-
-}
-
-void NPushFootTick::dump_to_xml(QXmlStreamWriter& xml) const
-{
- xml.writeStartElement("foot_data");
- xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
-
- xml.writeAttribute("side", QString(side));
- xml.writeAttribute("toes", QString::number(toes));
- xml.writeAttribute("heel", QString::number(heel));
-
- xml.writeEndElement();//foot_data
-}
-
-QString NPushFootTick::get_pretty_print() const
-{
- return QString("Foot: [%1;T:%2;H:%3]")
- .arg(QString(side))
- .arg(QString::number(toes))
- .arg(QString::number(heel));
-}
+/*
+ * 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 "npushfoottick.h"
+
+NPushFootTick::NPushFootTick(char a_side, int a_toes, int a_heel)
+{
+ side = a_side;
+ toes = a_toes;
+ heel = a_heel;
+
+ uint secs_to_epoch;
+ uint msecs;
+
+ secs_to_epoch = QDateTime::currentDateTime().toTime_t();
+ msecs = QTime::currentTime().msec();
+ uint aft = QDateTime::currentDateTime().toTime_t();
+
+ //ugly work around, will be fized with msecsToEpoc from Qt 4.7
+ if(aft != secs_to_epoch)//on a second slip
+ {
+ msecs = 0;
+ secs_to_epoch = aft;
+ }
+
+ msecsToEpoch = (double)secs_to_epoch*1000.0+(double)msecs;
+}
+
+NPushFootTick::NPushFootTick(char a_side, int a_toes, int a_heel, quint64 a_msecsToEpoch)
+{
+ side = a_side;
+ toes = a_toes;
+ heel = a_heel;
+
+ msecsToEpoch = a_msecsToEpoch;
+
+}
+
+NPushFootTick::~NPushFootTick()
+{
+
+}
+
+void NPushFootTick::read_from_xml( QXmlStreamReader& xml)
+{
+ side = xml.attributes().value("side").toString().at(0).toLatin1();
+
+ toes = xml.attributes().value("toes").toString().toInt();
+ heel = xml.attributes().value("heel").toString().toInt();
+
+ msecsToEpoch = (quint64)((double)xml.attributes().value("tstamp").toString().toDouble()*1000.0);
+}
+
+void NPushFootTick::dump_to_xml(QXmlStreamWriter& xml) const
+{
+ xml.writeStartElement("foot_data");
+ xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
+
+ xml.writeAttribute("side", QString(side));
+ xml.writeAttribute("toes", QString::number(toes));
+ xml.writeAttribute("heel", QString::number(heel));
+
+ xml.writeEndElement();//foot_data
+}
+
+QString NPushFootTick::get_pretty_print() const
+{
+ return QString("Foot: [%1;T:%2;H:%3]")
+ .arg(QString(side))
+ .arg(QString::number(toes))
+ .arg(QString::number(heel));
+}
View
10 PushBurton2/npushfoottick.h
@@ -37,12 +37,16 @@
class NPushFootTick : public NPushLogTick
{
public:
+ NPushFootTick() {}
NPushFootTick(char a_side, int a_toes, int a_heel);
NPushFootTick(char a_side, int a_toes, int a_heel, quint64 a_msecsToEpoch);
- ~NPushFootTick();
- void dump_to_xml(QXmlStreamWriter& xml) const;
- QString get_pretty_print() const;
+ virtual ~NPushFootTick();
+
+ virtual void read_from_xml( QXmlStreamReader& xml);
+ virtual void dump_to_xml(QXmlStreamWriter& xml) const;
+
+ virtual QString get_pretty_print() const;
public:
View
132 PushBurton2/npushgpstick.cpp
@@ -1,57 +1,75 @@
-/*
- * 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 "npushgpstick.h"
-
-NPushGpsTick::NPushGpsTick(const QGeoPositionInfo &info)
-{
- tick = info;
-// QDateTime correctedTstamp;
-// correctedTstamp = tick.timestamp().addSecs(3600);
-// tick.setTimestamp(correctedTstamp);
-}
-
-NPushGpsTick::~NPushGpsTick()
-{
-}
-
-void NPushGpsTick::dump_to_xml(QXmlStreamWriter& xml) const
-{
- xml.writeStartElement("gps_data");
- xml.writeAttribute("tstamp", QString::number(tick.timestamp().toTime_t()));
- xml.writeAttribute("longitude", QString::number(tick.coordinate().longitude()));
- xml.writeAttribute("latitude", QString::number(tick.coordinate().latitude()));
- xml.writeAttribute("altitude", QString::number(tick.coordinate().altitude()));
- xml.writeAttribute("ground_speed", QString::number(tick.attribute(QGeoPositionInfo::GroundSpeed)));
-
- xml.writeEndElement();//gps_data
-}
-
-QString NPushGpsTick::get_pretty_print() const
-{
- return QString("Speed = %1, Alt = %2").arg(QString::number(tick.attribute(QGeoPositionInfo::GroundSpeed)*3.6)).arg(QString::number(tick.coordinate().altitude()));
-}
+/*
+ * 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 "npushgpstick.h"
+
+NPushGpsTick::NPushGpsTick(const QGeoPositionInfo &info)
+{
+ tick = info;
+// QDateTime correctedTstamp;
+// correctedTstamp = tick.timestamp().addSecs(3600);
+// tick.setTimestamp(correctedTstamp);
+}
+
+NPushGpsTick::~NPushGpsTick()
+{
+}
+
+void NPushGpsTick::read_from_xml( QXmlStreamReader& xml)
+{
+ QDateTime tstamp;
+ QGeoCoordinate fakeCoord;
+
+ fakeCoord.setAltitude(xml.attributes().value("altitude").toString().toDouble());
+ fakeCoord.setLatitude(xml.attributes().value("latitude").toString().toDouble());
+ fakeCoord.setLongitude(xml.attributes().value("longitude").toString().toDouble());
+
+ tstamp = QDateTime::fromTime_t(floor(xml.attributes().value("tstamp").toString().toDouble()));//+3600.0));
+
+ tick.setTimestamp(tstamp);
+ tick.setCoordinate(fakeCoord);
+
+ tick.setAttribute(QGeoPositionInfo::GroundSpeed, xml.attributes().value("ground_speed").toString().toFloat());
+
+}
+
+void NPushGpsTick::dump_to_xml(QXmlStreamWriter& xml) const
+{
+ xml.writeStartElement("gps_data");
+ xml.writeAttribute("tstamp", QString::number(tick.timestamp().toTime_t()));
+ xml.writeAttribute("longitude", QString::number(tick.coordinate().longitude()));
+ xml.writeAttribute("latitude", QString::number(tick.coordinate().latitude()));
+ xml.writeAttribute("altitude", QString::number(tick.coordinate().altitude()));
+ xml.writeAttribute("ground_speed", QString::number(tick.attribute(QGeoPositionInfo::GroundSpeed)));
+
+ xml.writeEndElement();//gps_data
+}
+
+QString NPushGpsTick::get_pretty_print() const
+{
+ return QString("Speed = %1, Alt = %2").arg(QString::number(tick.attribute(QGeoPositionInfo::GroundSpeed)*3.6)).arg(QString::number(tick.coordinate().altitude()));
+}
View
9 PushBurton2/npushgpstick.h
@@ -42,12 +42,15 @@ QTM_USE_NAMESPACE
class NPushGpsTick : public NPushLogTick
{
public:
+ NPushGpsTick() {}
NPushGpsTick(const QGeoPositionInfo &info);
- ~NPushGpsTick();
- void dump_to_xml(QXmlStreamWriter& xml) const;
+ virtual ~NPushGpsTick();
- QString get_pretty_print() const;
+ virtual void read_from_xml( QXmlStreamReader& xml);
+ virtual void dump_to_xml(QXmlStreamWriter& xml) const;
+
+ virtual QString get_pretty_print() const;
QGeoPositionInfo tick;
};
View
158 PushBurton2/npushgsrtick.cpp
@@ -1,76 +1,82 @@
-/*
- * 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 "npushgsrtick.h"
-
-NPushGSRTick::NPushGSRTick(int a_reading)
-{
- reading = a_reading;
-
- uint secs_to_epoch;
- uint msecs;
-
- secs_to_epoch = QDateTime::currentDateTime().toTime_t();
- msecs = QTime::currentTime().msec();
- uint aft = QDateTime::currentDateTime().toTime_t();
-
- //ugly work around, will be fized with msecsToEpoc from Qt 4.7
- if(aft != secs_to_epoch)//on a second slip
- {
- msecs = 0;
- secs_to_epoch = aft;
- }
-
- msecsToEpoch = (double)secs_to_epoch*1000.0+(double)msecs;
-}
-
-NPushGSRTick::NPushGSRTick(int a_reading, quint64 a_msecsToEpoch)
-{
- reading = a_reading;
- msecsToEpoch = a_msecsToEpoch;
-}
-
-NPushGSRTick::~NPushGSRTick()
-{
-
-}
-
-void NPushGSRTick::dump_to_xml(QXmlStreamWriter& xml) const
-{
- xml.writeStartElement("gsr_data");
-
- xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
- xml.writeAttribute("reading", QString::number(reading));
-
- xml.writeEndElement();//gsr_data
-}
-
-QString NPushGSRTick::get_pretty_print() const
-{
- return QString("GSR: [%1]")
- .arg(QString::number(reading));
-}
+/*
+ * 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 "npushgsrtick.h"
+
+NPushGSRTick::NPushGSRTick(int a_reading)
+{
+ reading = a_reading;
+
+ uint secs_to_epoch;
+ uint msecs;
+
+ secs_to_epoch = QDateTime::currentDateTime().toTime_t();
+ msecs = QTime::currentTime().msec();
+ uint aft = QDateTime::currentDateTime().toTime_t();
+
+ //ugly work around, will be fized with msecsToEpoc from Qt 4.7
+ if(aft != secs_to_epoch)//on a second slip
+ {
+ msecs = 0;
+ secs_to_epoch = aft;
+ }
+
+ msecsToEpoch = (double)secs_to_epoch*1000.0+(double)msecs;
+}
+
+NPushGSRTick::NPushGSRTick(int a_reading, quint64 a_msecsToEpoch)
+{
+ reading = a_reading;
+ msecsToEpoch = a_msecsToEpoch;
+}
+
+NPushGSRTick::~NPushGSRTick()
+{
+
+}
+
+void NPushGSRTick::read_from_xml( QXmlStreamReader& xml)
+{
+ reading = xml.attributes().value("reading").toString().toInt();
+ msecsToEpoch = (quint64)((double)xml.attributes().value("tstamp").toString().toDouble()*1000.0);
+}
+
+void NPushGSRTick::dump_to_xml(QXmlStreamWriter& xml) const
+{
+ xml.writeStartElement("gsr_data");
+
+ xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
+ xml.writeAttribute("reading", QString::number(reading));
+
+ xml.writeEndElement();//gsr_data
+}
+
+QString NPushGSRTick::get_pretty_print() const
+{
+ return QString("GSR: [%1]")
+ .arg(QString::number(reading));
+}
View
10 PushBurton2/npushgsrtick.h
@@ -37,13 +37,17 @@
class NPushGSRTick : public NPushLogTick
{
public:
+ NPushGSRTick() {}
+
NPushGSRTick(int a_reading);
NPushGSRTick(int a_reading, quint64 a_msecsToEpoch);
- ~NPushGSRTick();
- void dump_to_xml(QXmlStreamWriter& xml) const;
+ virtual ~NPushGSRTick();
+
+ virtual void read_from_xml( QXmlStreamReader& xml);
+ virtual void dump_to_xml(QXmlStreamWriter& xml) const;
- QString get_pretty_print() const;
+ virtual QString get_pretty_print() const;
int reading;
View
175 PushBurton2/npushhearttick.cpp
@@ -1,83 +1,92 @@
-/*
- * 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 "npushhearttick.h"
-
-NPushHeartTick::NPushHeartTick(int a_hr_3, int a_hr_2, int a_hr_1)
-{
-
- hr_3 = a_hr_3;
- hr_2 = a_hr_2;
- hr_1 = a_hr_1;
-
- uint secs_to_epoch;
- uint msecs;
-
- secs_to_epoch = QDateTime::currentDateTime().toTime_t();
- msecs = QTime::currentTime().msec();
- uint aft = QDateTime::currentDateTime().toTime_t();
-
- //ugly work around, will be fized with msecsToEpoc from Qt 4.7
- if(aft != secs_to_epoch)//on a second slip
- {
- msecs = 0;
- secs_to_epoch = aft;
- }
-
- msecsToEpoch = (double)secs_to_epoch*1000.0+(double)msecs;
-}
-
-NPushHeartTick::NPushHeartTick(int a_hr_3, int a_hr_2, int a_hr_1, quint64 a_msecsToEpoch)
-{
- hr_3 = a_hr_3;
- hr_2 = a_hr_2;
- hr_1 = a_hr_1;
-
- msecsToEpoch = a_msecsToEpoch;
-}
-
-NPushHeartTick::~NPushHeartTick()
-{
-}
-
-void NPushHeartTick::dump_to_xml(QXmlStreamWriter& xml) const
-{
- xml.writeStartElement("heart_data");
- xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
-
- xml.writeAttribute("last32", QString::number(hr_3));
- xml.writeAttribute("last16", QString::number(hr_2));
- xml.writeAttribute("lastBeat", QString::number(hr_1));
-
- xml.writeEndElement();//heart_data
-}
-
-QString NPushHeartTick::get_pretty_print() const
-{
- return QString("Heart= %1")
- .arg(QString::number(hr_1));
-}
+/*
+ * 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 "npushhearttick.h"
+
+NPushHeartTick::NPushHeartTick(int a_hr_3, int a_hr_2, int a_hr_1)
+{
+
+ hr_3 = a_hr_3;
+ hr_2 = a_hr_2;
+ hr_1 = a_hr_1;
+
+ uint secs_to_epoch;
+ uint msecs;
+
+ secs_to_epoch = QDateTime::currentDateTime().toTime_t();
+ msecs = QTime::currentTime().msec();
+ uint aft = QDateTime::currentDateTime().toTime_t();
+
+ //ugly work around, will be fized with msecsToEpoc from Qt 4.7
+ if(aft != secs_to_epoch)//on a second slip
+ {
+ msecs = 0;
+ secs_to_epoch = aft;
+ }
+
+ msecsToEpoch = (double)secs_to_epoch*1000.0+(double)msecs;
+}
+
+NPushHeartTick::NPushHeartTick(int a_hr_3, int a_hr_2, int a_hr_1, quint64 a_msecsToEpoch)
+{
+ hr_3 = a_hr_3;
+ hr_2 = a_hr_2;
+ hr_1 = a_hr_1;
+
+ msecsToEpoch = a_msecsToEpoch;
+}
+
+NPushHeartTick::~NPushHeartTick()
+{
+}
+
+void NPushHeartTick::read_from_xml( QXmlStreamReader& xml)
+{
+ hr_3 = xml.attributes().value("last32").toString().toInt();
+ hr_2= xml.attributes().value("last16").toString().toInt();
+ hr_1 = xml.attributes().value("lastBeat").toString().toInt();
+
+ msecsToEpoch = (quint64)((double)xml.attributes().value("tstamp").toString().toDouble()*1000.0);
+}
+
+void NPushHeartTick::dump_to_xml(QXmlStreamWriter& xml) const
+{
+ xml.writeStartElement("heart_data");
+ xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
+
+ xml.writeAttribute("last32", QString::number(hr_3));
+ xml.writeAttribute("last16", QString::number(hr_2));
+ xml.writeAttribute("lastBeat", QString::number(hr_1));
+
+ xml.writeEndElement();//heart_data
+}
+
+QString NPushHeartTick::get_pretty_print() const
+{
+ return QString("Heart= %1")
+ .arg(QString::number(hr_1));
+}
View
10 PushBurton2/npushhearttick.h
@@ -36,15 +36,19 @@
class NPushHeartTick : public NPushLogTick
{
public:
+
+ NPushHeartTick() {}
+
NPushHeartTick(int a_hr_3, int a_hr_2, int a_hr_1);
NPushHeartTick(int a_hr_3, int a_hr_2, int a_hr_1, quint64 a_msecsToEpoch);
- ~NPushHeartTick();
+ virtual ~NPushHeartTick();
- void dump_to_xml(QXmlStreamWriter& xml) const;
+ virtual void read_from_xml( QXmlStreamReader& xml);
+ virtual void dump_to_xml(QXmlStreamWriter& xml) const;
- QString get_pretty_print() const;
+ virtual QString get_pretty_print() const;
int hr_3;
int hr_2;
View
315 PushBurton2/npushimutick.cpp
@@ -1,130 +1,185 @@
-/*
- * 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 "npushimutick.h"
-
-NPushIMUTick::NPushIMUTick(QStringList& values)
-{
- uint secs_to_epoch;
- uint msecs;
-
- secs_to_epoch = QDateTime::currentDateTime().toTime_t();
- msecs = QTime::currentTime().msec();
- uint aft = QDateTime::currentDateTime().toTime_t();
-
- //ugly work around, will be fized with msecsToEpoc from Qt 4.7
- if(aft != secs_to_epoch)//on a second slip
- {
- msecs = 0;
- secs_to_epoch = aft;
- }
-
- digitalAcc = false;
-
- ParseValues(values);
-
- msecsToEpoch = (quint64)((double)secs_to_epoch*1000.0+(double)msecs);
-
-// NPushIMUTick(values, );
-}
-
-
-NPushIMUTick::NPushIMUTick(QStringList &values, quint64 a_msecsToEpoch)
-{
- ParseValues(values);
-
- msecsToEpoch = a_msecsToEpoch;
-}
-
-void NPushIMUTick::ParseValues(QStringList& values)
-{
- if(values.count() != 11)
- {
- qDebug() << "EARLIER PARSING ERROR!";
- return;
- }
-
- for(int i=1;i<values.count();i++)
- {
- if(i < 4)
- gyro[i-1] = values[i].toInt();
- else if(i < 7)
- accel[i-4] = values[i].toInt();
- else if(i < 10)
- mag[i-7] = values[i].toInt();
- }
-}
-
-NPushIMUTick::~NPushIMUTick()
-{
-
-}
-
-void NPushIMUTick::dump_to_xml(QXmlStreamWriter& xml) const
-{
- xml.writeStartElement("imu_data");
-
- xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
-
- xml.writeStartElement("gyro");
- xml.writeCharacters(QString("%1,%2,%3")
- .arg(QString::number(gyro[0]))
- .arg(QString::number(gyro[1]))
- .arg(QString::number(gyro[2])));
- xml.writeEndElement();
-
- xml.writeStartElement("acc");
- xml.writeCharacters(QString("%1,%2,%3")
- .arg(QString::number(accel[0]))
- .arg(QString::number(accel[1]))
- .arg(QString::number(accel[2])));
- xml.writeEndElement();
-
- xml.writeStartElement("mag");
- xml.writeCharacters(QString("%1,%2,%3")
- .arg(QString::number(mag[0]))
- .arg(QString::number(mag[1]))
- .arg(QString::number(mag[2])));
- xml.writeEndElement();
-
- xml.writeEndElement();//imu_data
-}
-
-
-QString NPushIMUTick::get_pretty_print() const
-{
- return QString("GYRO: %1,%2,%3\nACCEL: %4,%5,%6\nMAG: %7,%8,%9")
- .arg(QString::number(gyro[0]))
- .arg(QString::number(gyro[1]))
- .arg(QString::number(gyro[2]))
- .arg(QString::number(accel[0]))
- .arg(QString::number(accel[1]))
- .arg(QString::number(accel[2]))
- .arg(QString::number(mag[0]))
- .arg(QString::number(mag[1]))
- .arg(QString::number(mag[2]));
-}
+/*
+ * 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 "npushimutick.h"
+
+bool NPushIMUTick::digitalAcc = false;
+
+NPushIMUTick::NPushIMUTick(QStringList& values)
+{
+ uint secs_to_epoch;
+ uint msecs;
+
+ secs_to_epoch = QDateTime::currentDateTime().toTime_t();
+ msecs = QTime::currentTime().msec();
+ uint aft = QDateTime::currentDateTime().toTime_t();
+
+ //ugly work around, will be fized with msecsToEpoc from Qt 4.7
+ if(aft != secs_to_epoch)//on a second slip
+ {
+ msecs = 0;
+ secs_to_epoch = aft;
+ }
+
+ ParseValues(values);
+
+ msecsToEpoch = (quint64)((double)secs_to_epoch*1000.0+(double)msecs);
+}
+
+
+NPushIMUTick::NPushIMUTick(QStringList &values, quint64 a_msecsToEpoch)
+{
+ ParseValues(values);
+
+ msecsToEpoch = a_msecsToEpoch;
+}
+
+void NPushIMUTick::ParseValues(QStringList& values)
+{
+ if(values.count() != 11)
+ {
+ qDebug() << "EARLIER PARSING ERROR!";
+ return;
+ }
+
+ for(int i=1;i<values.count();i++)
+ {
+ if(i < 4)
+ gyro[i-1] = values[i].toInt();
+ else if(i < 7)
+ accel[i-4] = values[i].toInt();
+ else if(i < 10)
+ mag[i-7] = values[i].toInt();
+ }
+
+ /*
+ black magic warning! See .h
+ */
+
+ if(!digitalAcc) {
+ if(accel[0] < 0 ||
+ accel[1] < 0 ||
+ accel[2] < 0) {
+ digitalAcc = true;
+ }
+ }
+}
+
+NPushIMUTick::~NPushIMUTick()
+{
+
+}
+
+void NPushIMUTick::read_from_xml( QXmlStreamReader& xml)
+{
+ msecsToEpoch = (quint64)((double)xml.attributes().value("tstamp").toString().toDouble()*1000.0);
+
+ xml.readNextStartElement();
+ while(!(xml.isEndElement())) {
+ if(xml.name() == "acc") {
+
+ QStringList vals = xml.readElementText().split(",");
+ accel[0] = vals.at(0).toInt();
+ accel[1] = vals.at(1).toInt();
+ accel[2] = vals.at(2).toInt();
+
+ } else if(xml.name() == "gyro") {
+
+ QStringList vals = xml.readElementText().split(",");
+ gyro[0] = vals.at(0).toInt();
+ gyro[1] = vals.at(1).toInt();
+ gyro[2] = vals.at(2).toInt();
+
+ } else if(xml.name() == "mag") {
+
+ QStringList vals = xml.readElementText().split(",");
+ mag[0] = vals.at(0).toInt();
+ mag[1] = vals.at(1).toInt();
+ mag[2] = vals.at(2).toInt();
+
+ }
+
+ xml.readNextStartElement();
+ }
+
+ /*
+ black magic warning! See .h
+ */
+
+ if(!digitalAcc) {
+ if(accel[0] < 0 ||
+ accel[1] < 0 ||
+ accel[2] < 0) {
+ digitalAcc = true;
+ }
+ }
+}
+
+void NPushIMUTick::dump_to_xml(QXmlStreamWriter& xml) const
+{
+ xml.writeStartElement("imu_data");
+
+ xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
+
+ xml.writeStartElement("gyro");
+ xml.writeCharacters(QString("%1,%2,%3")
+ .arg(QString::number(gyro[0]))
+ .arg(QString::number(gyro[1]))
+ .arg(QString::number(gyro[2])));
+ xml.writeEndElement();
+
+ xml.writeStartElement("acc");
+ xml.writeCharacters(QString("%1,%2,%3")
+ .arg(QString::number(accel[0]))
+ .arg(QString::number(accel[1]))
+ .arg(QString::number(accel[2])));
+ xml.writeEndElement();
+
+ xml.writeStartElement("mag");
+ xml.writeCharacters(QString("%1,%2,%3")
+ .arg(QString::number(mag[0]))
+ .arg(QString::number(mag[1]))
+ .arg(QString::number(mag[2])));
+ xml.writeEndElement();
+
+ xml.writeEndElement();//imu_data
+}
+
+
+QString NPushIMUTick::get_pretty_print() const
+{
+ return QString("GYRO: %1,%2,%3\nACCEL: %4,%5,%6\nMAG: %7,%8,%9")
+ .arg(QString::number(gyro[0]))
+ .arg(QString::number(gyro[1]))
+ .arg(QString::number(gyro[2]))
+ .arg(QString::number(accel[0]))
+ .arg(QString::number(accel[1]))
+ .arg(QString::number(accel[2]))
+ .arg(QString::number(mag[0]))
+ .arg(QString::number(mag[1]))
+ .arg(QString::number(mag[2]));
+}
View
25 PushBurton2/npushimutick.h
@@ -36,22 +36,37 @@
class NPushIMUTick : public NPushLogTick
{
public:
+
+ NPushIMUTick() {}
+
NPushIMUTick(QStringList& values);
NPushIMUTick(QStringList &values, quint64 a_msecsToEpoch);
- ~NPushIMUTick();
- void ParseValues(QStringList& values);
+ virtual ~NPushIMUTick();
- void dump_to_xml(QXmlStreamWriter& xml) const;
- QString get_pretty_print() const;
+ virtual void read_from_xml( QXmlStreamReader& xml);
+ virtual void dump_to_xml(QXmlStreamWriter& xml) const;
+
+ virtual QString get_pretty_print() const;
+
+ void ParseValues(QStringList& values);
int gyro[3];
int accel[3];
int mag[3];
quint64 msecsToEpoch;
- bool digitalAcc;
+ /*
+ * black magic!!
+ *
+ * So far we still have to cope with old, analog, accelerometers.
+ * Using this static flag, we make sure that after the sensor type
+ * is determined, app will handle it correctly throughout runtime
+ *
+ * (Same happens in simulation)
+ */
+ static bool digitalAcc; //initialized to false
};
#endif // NPUSHIMUTICK_H
View
5 PushBurton2/npushlogtick.cpp
@@ -27,6 +27,11 @@
#include "npushlogtick.h"
+NPushLogTick::NPushLogTick()
+{
+
+}
+
NPushLogTick::~NPushLogTick()
{
}
View
7 PushBurton2/npushlogtick.h
@@ -38,12 +38,15 @@ class NPushLogTick : QObject
Q_OBJECT
public:
+ NPushLogTick();
+
+ virtual ~NPushLogTick() = 0;
+
+ virtual void read_from_xml( QXmlStreamReader& xml) = 0;
virtual void dump_to_xml(QXmlStreamWriter& xml) const = 0;
virtual QString get_pretty_print() const = 0;
- virtual ~NPushLogTick() = 0;
-
};
#endif // NPUSHLOGTICK_H
View
177 PushBurton2/npushmagtick.cpp
@@ -1,84 +1,93 @@
-/*
- * 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 "npushmagtick.h"
-
-NPushMagTick::NPushMagTick(QMagnetometerReading * reading)
-{
- tick.copyValuesFrom(reading);
-
- uint secs_to_epoch;
- uint msecs;
-
- secs_to_epoch = QDateTime::currentDateTime().toTime_t();
- msecs = QTime::currentTime().msec();
- uint aft = QDateTime::currentDateTime().toTime_t();
-
- //ugly work around, will be fized with msecsToEpoc from Qt 4.7
- if(aft != secs_to_epoch)//on a second slip
- {
- msecs = 0;
- secs_to_epoch = aft;
- }
-
- msecsToEpoch = (double)secs_to_epoch*1000.0+(double)msecs;
-}
-
-NPushMagTick::NPushMagTick(QMagnetometerReading *reading, quint64 a_msecsToEpoch)
-{
- tick.copyValuesFrom(reading);
-
- msecsToEpoch = a_msecsToEpoch;
-}
-
-NPushMagTick::~NPushMagTick()
-{
-}
-
-void NPushMagTick::dump_to_xml(QXmlStreamWriter& xml) const
-{
- xml.writeStartElement("mag_data");
-
- xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
-
- xml.writeAttribute("x", QString::number(tick.x()*1000.0,'f',5));
- xml.writeAttribute("y", QString::number(tick.y()*1000.0,'f',5));
- xml.writeAttribute("z", QString::number(tick.z()*1000.0,'f',5));
- xml.writeAttribute("r", QString::number(qSqrt(tick.x()*tick.x()+
- tick.y()*tick.y()+
- tick.z()*tick.z())*1000.0,'f',5));
- xml.writeEndElement();//mag_data
-}
-
-QString NPushMagTick::get_pretty_print() const
-{
- return QString("Magnetometer Update: [x;y;z]mPhi = [%1;%2;%3]")
- .arg(QString::number(tick.x()*1000.0,'f',4))
- .arg(QString::number(tick.y()*1000.0,'f',4))
- .arg(QString::number(tick.z()*1000.0,'f',4));
-}
-
+/*
+ * 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 "npushmagtick.h"
+
+NPushMagTick::NPushMagTick(QMagnetometerReading * reading)
+{
+ tick.copyValuesFrom(reading);
+
+ uint secs_to_epoch;
+ uint msecs;
+
+ secs_to_epoch = QDateTime::currentDateTime().toTime_t();
+ msecs = QTime::currentTime().msec();
+ uint aft = QDateTime::currentDateTime().toTime_t();
+
+ //ugly work around, will be fized with msecsToEpoc from Qt 4.7
+ if(aft != secs_to_epoch)//on a second slip
+ {
+ msecs = 0;
+ secs_to_epoch = aft;
+ }
+
+ msecsToEpoch = (double)secs_to_epoch*1000.0+(double)msecs;
+}
+
+NPushMagTick::NPushMagTick(QMagnetometerReading *reading, quint64 a_msecsToEpoch)
+{
+ tick.copyValuesFrom(reading);
+
+ msecsToEpoch = a_msecsToEpoch;
+}
+
+NPushMagTick::~NPushMagTick()
+{
+}
+
+void NPushMagTick::read_from_xml( QXmlStreamReader& xml)
+{
+ tick.setX(xml.attributes().value("x").toString().toFloat()*0.001);
+ tick.setY(xml.attributes().value("y").toString().toFloat()*0.001);
+ tick.setZ(xml.attributes().value("z").toString().toFloat()*0.001);
+
+ msecsToEpoch = (quint64)((double)xml.attributes().value("tstamp").toString().toDouble()*1000.0);
+}
+
+void NPushMagTick::dump_to_xml(QXmlStreamWriter& xml) const
+{
+ xml.writeStartElement("mag_data");
+
+ xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
+
+ xml.writeAttribute("x", QString::number(tick.x()*1000.0,'f',5));
+ xml.writeAttribute("y", QString::number(tick.y()*1000.0,'f',5));
+ xml.writeAttribute("z", QString::number(tick.z()*1000.0,'f',5));
+ xml.writeAttribute("r", QString::number(qSqrt(tick.x()*tick.x()+
+ tick.y()*tick.y()+
+ tick.z()*tick.z())*1000.0,'f',5));
+ xml.writeEndElement();//mag_data
+}
+
+QString NPushMagTick::get_pretty_print() const
+{
+ return QString("Magnetometer Update: [x;y;z]mPhi = [%1;%2;%3]")
+ .arg(QString::number(tick.x()*1000.0,'f',4))
+ .arg(QString::number(tick.y()*1000.0,'f',4))
+ .arg(QString::number(tick.z()*1000.0,'f',4));
+}
+
View
10 PushBurton2/npushmagtick.h
@@ -38,13 +38,17 @@ QTM_USE_NAMESPACE
class NPushMagTick : public NPushLogTick
{
public:
+ NPushMagTick() {}
+
NPushMagTick(QMagnetometerReading * reading);
NPushMagTick(QMagnetometerReading * reading, quint64 a_msecsToEpoch);
- ~NPushMagTick();
- void dump_to_xml(QXmlStreamWriter& xml) const;
+ virtual ~NPushMagTick();
+
+ virtual void read_from_xml( QXmlStreamReader& xml);
+ virtual void dump_to_xml(QXmlStreamWriter& xml) const;
- QString get_pretty_print() const;
+ virtual QString get_pretty_print() const;
QMagnetometerReading tick;
View
139 PushBurton2/npushnormfeettick.cpp
@@ -1,67 +1,72 @@
-/*
- * 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 "npushnormfeettick.h"
-
-NPushNormFeetTick::NPushNormFeetTick(SnowboradPressureData a_pdata, quint64 a_msecsToEpoc)
- :msecsToEpoch(a_msecsToEpoc), pdata(a_pdata)
-
-{
-}
-
-
-NPushNormFeetTick::~NPushNormFeetTick()
-{
-
-}
-
-void NPushNormFeetTick::dump_to_xml(QXmlStreamWriter& xml) const
-{
- xml.writeStartElement("feet_sum");
-
- xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
- xml.writeAttribute("sum", QString::number(pdata.totalRawSum));
-
-
-// xml.writeAttribute("norm_factor", QString::number(pdata.totalNormFactor));
-
-// xml.writeAttribute("on_air", QString((pdata.totalNormFactor < 0.5)?"true":"false"));
-
-// xml.writeAttribute("valid_cnt", QString::number(pdata.validCount));
-// xml.writeAttribute("minLToe", QString::number(pdata.LToe.minVal));
-// xml.writeAttribute("minLHeel", QString::number(pdata.LHeel.minVal));
-// xml.writeAttribute("minRToe", QString::number(pdata.RToe.minVal));
-// xml.writeAttribute("minRHeel", QString::number(pdata.RHeel.minVal));
-
- xml.writeEndElement();//feet_sum
-}
-
-QString NPushNormFeetTick::get_pretty_print() const
-{
- return QString("Feet PSum [%1]")
- .arg(QString::number(pdata.totalRawSum));
-}
+/*
+ * 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 "npushnormfeettick.h"
+
+NPushNormFeetTick::NPushNormFeetTick(SnowboradPressureData a_pdata, quint64 a_msecsToEpoc)
+ :msecsToEpoch(a_msecsToEpoc), pdata(a_pdata)
+
+{
+}
+
+
+NPushNormFeetTick::~NPushNormFeetTick()
+{
+
+}
+
+void NPushNormFeetTick::read_from_xml( QXmlStreamReader& xml)
+{
+ Q_UNUSED(xml);
+}
+
+void NPushNormFeetTick::dump_to_xml(QXmlStreamWriter& xml) const
+{
+ xml.writeStartElement("feet_sum");
+
+ xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
+ xml.writeAttribute("sum", QString::number(pdata.totalRawSum));
+
+
+// xml.writeAttribute("norm_factor", QString::number(pdata.totalNormFactor));
+
+// xml.writeAttribute("on_air", QString((pdata.totalNormFactor < 0.5)?"true":"false"));
+
+// xml.writeAttribute("valid_cnt", QString::number(pdata.validCount));
+// xml.writeAttribute("minLToe", QString::number(pdata.LToe.minVal));
+// xml.writeAttribute("minLHeel", QString::number(pdata.LHeel.minVal));
+// xml.writeAttribute("minRToe", QString::number(pdata.RToe.minVal));
+// xml.writeAttribute("minRHeel", QString::number(pdata.RHeel.minVal));
+
+ xml.writeEndElement();//feet_sum
+}
+
+QString NPushNormFeetTick::get_pretty_print() const
+{
+ return QString("Feet PSum [%1]")
+ .arg(QString::number(pdata.totalRawSum));
+}
View
7 PushBurton2/npushnormfeettick.h
@@ -36,12 +36,13 @@ class NPushNormFeetTick : public NPushLogTick
{
public:
NPushNormFeetTick(SnowboradPressureData, quint64);
- ~NPushNormFeetTick();
+ virtual ~NPushNormFeetTick();
- void dump_to_xml(QXmlStreamWriter& xml) const;
+ virtual void read_from_xml( QXmlStreamReader& xml);
+ virtual void dump_to_xml(QXmlStreamWriter& xml) const;
- QString get_pretty_print() const;
+ virtual QString get_pretty_print() const;
public:
View
5 PushBurton2/npushrotationstick.cpp
@@ -13,6 +13,11 @@ NPushRotationsTick::~NPushRotationsTick()
{
}
+void NPushRotationsTick::read_from_xml( QXmlStreamReader& xml)
+{
+ Q_UNUSED(xml);
+}
+
void NPushRotationsTick::dump_to_xml(QXmlStreamWriter& xml) const
{
xml.writeStartElement("rot_count");
View
8 PushBurton2/npushrotationstick.h
@@ -13,10 +13,12 @@ class NPushRotationsTick : public NPushLogTick
public:
NPushRotationsTick(double a_rawDegs, quint64 a_msecsToEpoch);
- ~NPushRotationsTick();
+ virtual ~NPushRotationsTick();
- void dump_to_xml(QXmlStreamWriter& xml) const;
- QString get_pretty_print() const;
+ virtual void read_from_xml( QXmlStreamReader& xml);
+ virtual void dump_to_xml(QXmlStreamWriter& xml) const;
+
+ virtual QString get_pretty_print() const;
public:
View
26 PushBurton2/pushburtongenericdevice.h
@@ -43,18 +43,20 @@
* defines the common interface for all sensors
* Devices name should follow:
- All devices: push.*
+ * 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.*
+ -> trick detectors: push.abstract.snowb.* (things that only make sense in the snowboarding world)
-> 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.
+ * push.(device|framework|abstract|report).
+
*/
class PushBurtonGenericDevice : public QObject
@@ -78,7 +80,27 @@ class PushBurtonGenericDevice : public QObject
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 = "push.n8.bt.imu";
+ 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);
protected:
View
10 PushBurton2/pushn8imudevice.cpp
@@ -39,7 +39,6 @@ PushN8IMUDevice::PushN8IMUDevice(QBtDevice a_device, QObject *parent) :
packetStart = "IMU";
packetEnd = "END";
- digitalAcc = false;
}
PushN8IMUDevice::~PushN8IMUDevice()
@@ -54,17 +53,8 @@ void PushN8IMUDevice::gotDataReceived(QString data)
QStringList params;
if(getPackage(data, params))
{
- //detect negative values to switch to digital mode.
- if(!digitalAcc) {
- if(params[4].toInt() < 0 ||
- params[5].toInt() < 0 ||
- params[6].toInt() < 0) {
- digitalAcc = true;
- }
- }
NPushIMUTick * newIMUTick = new NPushIMUTick(params);
- newIMUTick->digitalAcc = digitalAcc;
// qDebug() << "Parms: " << params[1] << "," << params[2] << "," << params[3];
View
3 PushBurton2/pushn8imudevice.h
@@ -48,9 +48,6 @@ class PushN8IMUDevice : public PushN8BtDevice
public slots:
void gotDataReceived(QString);
-private:
- bool digitalAcc;
-
#endif
};
View
206 PushBurton2/pushn8simulationdevice.cpp
@@ -56,8 +56,6 @@ PushN8SimulationDevice::PushN8SimulationDevice(const QString& fname)
qDebug() << "Could not read first start Element";
}
- digitalAcc = false;
-
timerId = 0;
#ifdef Q_OS_LINUX
timerPeriod = 0;
@@ -86,176 +84,58 @@ bool PushN8SimulationDevice::is_online()
void PushN8SimulationDevice::timerEvent(QTimerEvent *)
{
-// while(!(xml.isEndElement() && xml.name() == "N8SensorsLog")) {
-
- bool reachedEnd = false;
- while(xml.readNextStartElement())
- {
- NPushLogTick * newTick = 0;
- if(xml.name() == "acc_data")
- {
- newTick = readAccTick();
- } else if(xml.name() == "mag_data")
- {
- newTick = readMagTick();
- } else if(xml.name() == "gps_data")
- {
- newTick = readGpsTick();
- } else if(xml.name() == "imu_data")
- {
- newTick = readImuTick();
- //Imu tick has inner elements, when it returns we can quit
- reachedEnd = true;
- } else if(xml.name() == "gsr_data")
- {
- newTick = readGsrTick();
- } else if(xml.name() == "heart_data")
- {
- newTick = readHeartTick();
- } else if(xml.name() == "foot_data")
- {
- newTick = readFootTick();
- } else {
- // qDebug() << "Unrecognized tag " << xml.name();
- xml.skipCurrentElement();
- }
-
- if(newTick != 0) {
- if(receivers(SIGNAL(reading_ready(NPushLogTick*))) > 0)
- {
- emit reading_ready(newTick);
- } else {
- delete newTick;
- }
- }
-
- if(reachedEnd)
- break;
- }
-
+ if(!xml.readNextStartElement()) {
if(xml.isEndElement() && xml.name() == "N8SensorsLog") {
qDebug() << "Simulation Ended!!";
emit simulationEnded();
this->stop_readings();
+ return;
}
-// }
-}
-
-NPushAccTick * PushN8SimulationDevice::readAccTick()
-{
- QAccelerometerReading fake;
-
- fake.setX(xml.attributes().value("x").toString().toFloat());
- fake.setY(xml.attributes().value("y").toString().toFloat());
- fake.setZ(xml.attributes().value("z").toString().toFloat());
- quint64 tstamp = (quint64)((double)xml.attributes().value("tstamp").toString().toDouble()*1000.0);
- NPushAccTick * tick = new NPushAccTick(&fake, tstamp);
- return tick;
-}
-
-NPushFootTick * PushN8SimulationDevice::readFootTick()
-{
-
- QChar side = xml.attributes().value("side").toString().at(0);
-
-// qDebug() << "CAUTION!! Flipping to correct runs from yesterday (march 8th)";
- //CAUTION!! Flipping to correct runs from yesterday (march 8th).
- int toes = xml.attributes().value("toes").toString().toInt();
- int heel = xml.attributes().value("heel").toString().toInt();
-
- quint64 tstamp = (quint64)((double)xml.attributes().value("tstamp").toString().toDouble()*1000.0);
-
- NPushFootTick * tick = new NPushFootTick(side.toAscii(), toes, heel, tstamp);
- return tick;
-}
-
-NPushGpsTick * PushN8SimulationDevice::readGpsTick()
-{
-// <gps_data tstamp="1291460032" longitude="11.2806" ground_speed="5.85" latitude="47.1801" altitude="2360" />
-
- QGeoPositionInfo fake;
- QDateTime tstamp;
- QGeoCoordinate fakeCoord;
- fakeCoord.setAltitude(xml.attributes().value("altitude").toString().toDouble());
- fakeCoord.setLatitude(xml.attributes().value("latitude").toString().toDouble());
- fakeCoord.setLongitude(xml.attributes().value("longitude").toString().toDouble());
-
- tstamp = QDateTime::fromTime_t(floor(xml.attributes().value("tstamp").toString().toDouble()));//+3600.0));
-
- fake.setTimestamp(tstamp);
- fake.setCoordinate(fakeCoord);
-
- fake.setAttribute(QGeoPositionInfo::GroundSpeed, xml.attributes().value("ground_speed").toString().toFloat());
-
- NPushGpsTick * tick = new NPushGpsTick(fake);
-
- return tick;
-}
-
-NPushGSRTick * PushN8SimulationDevice::readGsrTick()
-{
- int reading = xml.attributes().value("reading").toString().toInt();
-
- quint64 tstamp = (quint64)((double)xml.attributes().value("tstamp").toString().toDouble()*1000.0);
-
- NPushGSRTick * tick = new NPushGSRTick(reading, tstamp);
- return tick;
-}
-
-NPushHeartTick * PushN8SimulationDevice::readHeartTick()
-{
- int last32 = xml.attributes().value("last32").toString().toInt();
- int last16 = xml.attributes().value("last16").toString().toInt();
- int lastBeat = xml.attributes().value("lastBeat").toString().toInt();
-
- quint64 tstamp = (quint64)((double)xml.attributes().value("tstamp").toString().toDouble()*1000.0);
-
- NPushHeartTick * tick = new NPushHeartTick(last32, last16, lastBeat, tstamp);
- return tick;
-}
+ }
-NPushIMUTick * PushN8SimulationDevice::readImuTick()
-{
- QStringList values;
- values.push_back("IMU");
+ NPushLogTick * newTick = 0;
+ if(xml.name() == "acc_data")
+ {
+ newTick = new NPushAccTick();
+ newTick->read_from_xml(xml);
+ } else if(xml.name() == "mag_data")
+ {
+ newTick = new NPushMagTick();
+ newTick->read_from_xml(xml);
+ } else if(xml.name() == "gps_data")
+ {
+ newTick = new NPushGpsTick();
+ newTick->read_from_xml(xml);
+ } else if(xml.name() == "imu_data")
+ {
+ newTick = new NPushIMUTick();
+ newTick->read_from_xml(xml);
+ } else if(xml.name() == "gsr_data")
+ {
+ newTick = new NPushGSRTick();
+ newTick->read_from_xml(xml);
+ } else if(xml.name() == "heart_data")
+ {
+ newTick = new NPushHeartTick();
+ newTick->read_from_xml(xml);
+ } else if(xml.name() == "foot_data")
+ {
+ newTick = new NPushFootTick();
+ newTick->read_from_xml(xml);
+ } else {
+ xml.skipCurrentElement();
+ }