Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: pushsnowboarding/Push-Snowboarding
base: f299873ec6
...
head fork: pushsnowboarding/Push-Snowboarding
compare: 42aa3910ca
  • 2 commits
  • 57 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jun 15, 2011
Clovis Scotti Rearranging source tree; Removing Deprecated code in ticks 63452f9
Clovis Scotti 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.
42aa391
Showing with 1,126 additions and 1,190 deletions.
  1. +32 −29 PushBurton2/PushBurton2.pro
  2. 0  PushBurton2/{ → UI}/graphicpixmapbt.cpp
  3. 0  PushBurton2/{ → UI}/graphicpixmapbt.h
  4. 0  PushBurton2/{ → UI}/graphicsconnmenu.cpp
  5. 0  PushBurton2/{ → UI}/graphicsconnmenu.h
  6. 0  PushBurton2/{ → UI}/graphicsdeviceinfo.cpp
  7. 0  PushBurton2/{ → UI}/graphicsdeviceinfo.h
  8. 0  PushBurton2/{ → UI}/graphicslidingdownbts.cpp
  9. 0  PushBurton2/{ → UI}/graphicslidingdownbts.h
  10. 0  PushBurton2/{ → UI}/graphicsreportview.cpp
  11. 0  PushBurton2/{ → UI}/graphicsreportview.h
  12. 0  PushBurton2/{ → UI}/graphicssettings.cpp
  13. 0  PushBurton2/{ → UI}/graphicssettings.h
  14. 0  PushBurton2/{ → UI}/graphictextbt.cpp
  15. 0  PushBurton2/{ → UI}/graphictextbt.h
  16. 0  PushBurton2/{ → UI}/graphicvarplot.cpp
  17. 0  PushBurton2/{ → UI}/graphicvarplot.h
  18. 0  PushBurton2/{ → UI}/liveview.cpp
  19. 0  PushBurton2/{ → UI}/liveview.h
  20. 0  PushBurton2/{ → UI}/liveview.ui
  21. 0  PushBurton2/{ → UI}/mainwindow.cpp
  22. 0  PushBurton2/{ → UI}/mainwindow.h
  23. 0  PushBurton2/{ → UI}/mainwindow.ui
  24. 0  PushBurton2/{ → UI}/pushburtonanimation.cpp
  25. 0  PushBurton2/{ → UI}/pushburtonanimation.h
  26. 0  PushBurton2/{ → UI}/runcontroldialog.cpp
  27. 0  PushBurton2/{ → UI}/runcontroldialog.h
  28. +6 −1 PushBurton2/broadcasterdevice.cpp
  29. +3 −1 PushBurton2/broadcasterdevice.h
  30. +1 −1  PushBurton2/main.cpp
  31. +109 −108 PushBurton2/npushacctick.cpp
  32. +60 −58 PushBurton2/npushacctick.h
  33. +72 −77 PushBurton2/npushairtimetick.cpp
  34. +6 −4 PushBurton2/npushairtimetick.h
  35. +96 −97 PushBurton2/npushfoottick.cpp
  36. +7 −4 PushBurton2/npushfoottick.h
  37. +75 −68 PushBurton2/npushgpstick.cpp
  38. +6 −4 PushBurton2/npushgpstick.h
  39. +82 −84 PushBurton2/npushgsrtick.cpp
  40. +7 −4 PushBurton2/npushgsrtick.h
  41. +92 −95 PushBurton2/npushhearttick.cpp
  42. +7 −4 PushBurton2/npushhearttick.h
  43. +185 −164 PushBurton2/npushimutick.cpp
  44. +20 −6 PushBurton2/npushimutick.h
  45. +5 −0 PushBurton2/npushlogtick.cpp
  46. +5 −3 PushBurton2/npushlogtick.h
  47. +93 −98 PushBurton2/npushmagtick.cpp
  48. +7 −4 PushBurton2/npushmagtick.h
  49. +72 −76 PushBurton2/npushnormfeettick.cpp
  50. +4 −4 PushBurton2/npushnormfeettick.h
  51. +2 −4 PushBurton2/npushrotationstick.cpp
  52. +5 −4 PushBurton2/npushrotationstick.h
  53. +24 −2 PushBurton2/pushburtongenericdevice.h
  54. +0 −10 PushBurton2/pushn8imudevice.cpp
  55. +0 −3  PushBurton2/pushn8imudevice.h
  56. +43 −163 PushBurton2/pushn8simulationdevice.cpp
  57. +0 −10 PushBurton2/pushn8simulationdevice.h
View
61 PushBurton2/PushBurton2.pro
@@ -32,18 +32,14 @@ TARGET = PushBurton2
TEMPLATE = app
-SOURCES += main.cpp\
- mainwindow.cpp \
- graphicpixmapbt.cpp \
- graphicsdeviceinfo.cpp \
- pushburtonanimation.cpp \
- graphicsconnmenu.cpp \
+SOURCES += \
+ main.cpp\
devicesmanager.cpp \
pushdevicesholder.cpp \
pushburtongenericdevice.cpp \
npushtickdisposer.cpp \
- npushlogtick.cpp \
pushn8simulationdevice.cpp \
+ npushlogtick.cpp \
npushnormfeettick.cpp \
npushmagtick.cpp \
npushimutick.cpp \
@@ -67,31 +63,32 @@ SOURCES += main.cpp\
npushreportairtime.cpp \
fuzzydetector.cpp \
selfshrinkinglist.cpp \
- runcontroldialog.cpp \
runmanager.cpp \
ubiqlogsaver.cpp \
- graphicvarplot.cpp \
- graphictextbt.cpp \
- graphicsreportview.cpp \
- graphicslidingdownbts.cpp \
- liveview.cpp \
- graphicssettings.cpp \
+ UI/runcontroldialog.cpp \
+ UI/graphicvarplot.cpp \
+ UI/graphictextbt.cpp \
+ UI/graphicsreportview.cpp \
+ UI/graphicslidingdownbts.cpp \
+ UI/liveview.cpp \
+ UI/graphicssettings.cpp \
+ UI/mainwindow.cpp \
+ UI/graphicpixmapbt.cpp \
+ UI/graphicsdeviceinfo.cpp \
+ UI/graphicsconnmenu.cpp \
+ UI/pushburtonanimation.cpp \
virtualbrosdevice.cpp \
rotationcounter.cpp \
npushrotationstick.cpp \
broadcasterdevice.cpp
-HEADERS += mainwindow.h \
- graphicpixmapbt.h \
- graphicsdeviceinfo.h \
- pushburtonanimation.h \
- graphicsconnmenu.h \
+HEADERS += \
devicesmanager.h \
pushdevicesholder.h \
pushburtongenericdevice.h \
npushtickdisposer.h \
- npushlogtick.h \
pushn8simulationdevice.h \
+ npushlogtick.h \
npushnormfeettick.h \
npushmagtick.h \
npushimutick.h \
@@ -116,23 +113,29 @@ HEADERS += mainwindow.h \
npushreportairtime.h \
fuzzydetector.h \
selfshrinkinglist.h \
- runcontroldialog.h \
runmanager.h \
ubiqlogsaver.h \
- graphicvarplot.h \
- graphictextbt.h \
- graphicsreportview.h \
- graphicslidingdownbts.h \
- liveview.h \
- graphicssettings.h \
FilesystemConventions.h \
virtualbrosdevice.h \
rotationcounter.h \
npushrotationstick.h \
+ UI/mainwindow.h \
+ UI/graphicpixmapbt.h \
+ UI/graphicsdeviceinfo.h \
+ UI/graphicsconnmenu.h \
+ UI/runcontroldialog.h \
+ UI/graphicvarplot.h \
+ UI/graphictextbt.h \
+ UI/graphicsreportview.h \
+ UI/graphicslidingdownbts.h \
+ UI/liveview.h \
+ UI/graphicssettings.h \
+ UI/pushburtonanimation.h \
broadcasterdevice.h
-FORMS += mainwindow.ui \
- liveview.ui
+FORMS += \
+ UI/mainwindow.ui \
+ UI/liveview.ui
CONFIG += mobility
MOBILITY = location sensors
View
0  PushBurton2/graphicpixmapbt.cpp → PushBurton2/UI/graphicpixmapbt.cpp
File renamed without changes
View
0  PushBurton2/graphicpixmapbt.h → PushBurton2/UI/graphicpixmapbt.h
File renamed without changes
View
0  PushBurton2/graphicsconnmenu.cpp → PushBurton2/UI/graphicsconnmenu.cpp
File renamed without changes
View
0  PushBurton2/graphicsconnmenu.h → PushBurton2/UI/graphicsconnmenu.h
File renamed without changes
View
0  PushBurton2/graphicsdeviceinfo.cpp → PushBurton2/UI/graphicsdeviceinfo.cpp
File renamed without changes
View
0  PushBurton2/graphicsdeviceinfo.h → PushBurton2/UI/graphicsdeviceinfo.h
File renamed without changes
View
0  PushBurton2/graphicslidingdownbts.cpp → PushBurton2/UI/graphicslidingdownbts.cpp
File renamed without changes
View
0  PushBurton2/graphicslidingdownbts.h → PushBurton2/UI/graphicslidingdownbts.h
File renamed without changes
View
0  PushBurton2/graphicsreportview.cpp → PushBurton2/UI/graphicsreportview.cpp
File renamed without changes
View
0  PushBurton2/graphicsreportview.h → PushBurton2/UI/graphicsreportview.h
File renamed without changes
View
0  PushBurton2/graphicssettings.cpp → PushBurton2/UI/graphicssettings.cpp
File renamed without changes
View
0  PushBurton2/graphicssettings.h → PushBurton2/UI/graphicssettings.h
File renamed without changes
View
0  PushBurton2/graphictextbt.cpp → PushBurton2/UI/graphictextbt.cpp
File renamed without changes
View
0  PushBurton2/graphictextbt.h → PushBurton2/UI/graphictextbt.h
File renamed without changes
View
0  PushBurton2/graphicvarplot.cpp → PushBurton2/UI/graphicvarplot.cpp
File renamed without changes
View
0  PushBurton2/graphicvarplot.h → PushBurton2/UI/graphicvarplot.h
File renamed without changes
View
0  PushBurton2/liveview.cpp → PushBurton2/UI/liveview.cpp
File renamed without changes
View
0  PushBurton2/liveview.h → PushBurton2/UI/liveview.h
File renamed without changes
View
0  PushBurton2/liveview.ui → PushBurton2/UI/liveview.ui
File renamed without changes
View
0  PushBurton2/mainwindow.cpp → PushBurton2/UI/mainwindow.cpp
File renamed without changes
View
0  PushBurton2/mainwindow.h → PushBurton2/UI/mainwindow.h
File renamed without changes
View
0  PushBurton2/mainwindow.ui → PushBurton2/UI/mainwindow.ui
File renamed without changes
View
0  PushBurton2/pushburtonanimation.cpp → PushBurton2/UI/pushburtonanimation.cpp
File renamed without changes
View
0  PushBurton2/pushburtonanimation.h → PushBurton2/UI/pushburtonanimation.h
File renamed without changes
View
0  PushBurton2/runcontroldialog.cpp → PushBurton2/UI/runcontroldialog.cpp
File renamed without changes
View
0  PushBurton2/runcontroldialog.h → PushBurton2/UI/runcontroldialog.h
File renamed without changes
View
7 PushBurton2/broadcasterdevice.cpp
@@ -13,7 +13,7 @@ BroadcasterDevice::BroadcasterDevice(QObject *parent) :
- serverAddress = QHostAddress("192.168.0.3");
+ serverAddress = QHostAddress("192.168.0.2");
serverPort = 45454;
@@ -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
2  PushBurton2/main.cpp
@@ -26,7 +26,7 @@
*/
#include <QtGui/QApplication>
-#include "mainwindow.h"
+#include "UI/mainwindow.h"
#include <QDebug>
#include <QString>
View
217 PushBurton2/npushacctick.cpp
@@ -1,108 +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::append_to_xml(QDomDocument& doc, QDomElement& root) const
-{
- QDomElement tickDom = doc.createElement("acc_data");
- tickDom.setAttribute("x", QString::number(tick.x()));
- tickDom.setAttribute("y", QString::number(tick.y()));
- tickDom.setAttribute("z", QString::number(tick.z()));
- tickDom.setAttribute("r", QString::number(pAccAbsMag));
-
- tickDom.setAttribute("tstamp", (double)(msecsToEpoch*0.001));
-
- if(pAccAbsMag < freefall_threshold)
- {
- tickDom.setAttribute("free_fall", "true");
- }
-
- root.appendChild(tickDom);
-}
-
-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
118 PushBurton2/npushacctick.h
@@ -1,58 +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 append_to_xml(QDomDocument& doc, QDomElement& root) const;
- 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
149 PushBurton2/npushairtimetick.cpp
@@ -1,77 +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::append_to_xml(QDomDocument& doc, QDomElement& root) const
-{
- if(!isOnlyHint) {
- 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);
- }
-}
-
-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
10 PushBurton2/npushairtimetick.h
@@ -38,11 +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 append_to_xml(QDomDocument& doc, QDomElement& root) const;
- 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
193 PushBurton2/npushfoottick.cpp
@@ -1,97 +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::append_to_xml(QDomDocument& doc, QDomElement& root) const
-{
- QDomElement tickDom = doc.createElement("foot_data");
- tickDom.setAttribute("side", QString(side));
- tickDom.setAttribute("toes", QString::number(toes));
- tickDom.setAttribute("heel", QString::number(heel));
- tickDom.setAttribute("tstamp", (double)(msecsToEpoch*0.001));
-
- root.appendChild(tickDom);
-}
-
-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
11 PushBurton2/npushfoottick.h
@@ -37,13 +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 append_to_xml(QDomDocument& doc, QDomElement& root) const;
- 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
143 PushBurton2/npushgpstick.cpp
@@ -1,68 +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::append_to_xml(QDomDocument& doc, QDomElement& root) const
-{
- QDomElement tickDom = doc.createElement("gps_data");
- tickDom.setAttribute("tstamp", tick.timestamp().toTime_t());
- tickDom.setAttribute("longitude", QString::number(tick.coordinate().longitude()));
- tickDom.setAttribute("latitude", QString::number(tick.coordinate().latitude()));
- tickDom.setAttribute("altitude", QString::number(tick.coordinate().altitude()));
- tickDom.setAttribute("ground_speed", QString::number(tick.attribute(QGeoPositionInfo::GroundSpeed)));
- root.appendChild(tickDom);
-}
-
-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
10 PushBurton2/npushgpstick.h
@@ -42,13 +42,15 @@ QTM_USE_NAMESPACE
class NPushGpsTick : public NPushLogTick
{
public:
+ NPushGpsTick() {}
NPushGpsTick(const QGeoPositionInfo &info);
- ~NPushGpsTick();
- void append_to_xml(QDomDocument& doc, QDomElement& root) const;
- 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
166 PushBurton2/npushgsrtick.cpp
@@ -1,84 +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::append_to_xml(QDomDocument& doc, QDomElement& root) const
-{
- QDomElement tickDom = doc.createElement("gsr_data");
- tickDom.setAttribute("reading", QString::number(reading));
- tickDom.setAttribute("tstamp", (double)(msecsToEpoch*0.001));
- root.appendChild(tickDom);
-}
-
-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
11 PushBurton2/npushgsrtick.h
@@ -37,14 +37,17 @@
class NPushGSRTick : public NPushLogTick
{
public:
+ NPushGSRTick() {}
+
NPushGSRTick(int a_reading);
NPushGSRTick(int a_reading, quint64 a_msecsToEpoch);
- ~NPushGSRTick();
- void append_to_xml(QDomDocument& doc, QDomElement& root) const;
- 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
187 PushBurton2/npushhearttick.cpp
@@ -1,95 +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::append_to_xml(QDomDocument& doc, QDomElement& root) const
-{
- QDomElement tickDom = doc.createElement("heart_data");
- tickDom.setAttribute("last32", QString::number(hr_3));
- tickDom.setAttribute("last16", QString::number(hr_2));
- tickDom.setAttribute("lastBeat", QString::number(hr_1));
-
- tickDom.setAttribute("tstamp", (double)(msecsToEpoch*0.001));
-
- root.appendChild(tickDom);
-}
-
-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
11 PushBurton2/npushhearttick.h
@@ -36,16 +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 append_to_xml(QDomDocument& doc, QDomElement& root) const;
- 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
349 PushBurton2/npushimutick.cpp
@@ -1,164 +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::append_to_xml(QDomDocument& doc, QDomElement& root) const
-{
- QDomElement tickDom = doc.createElement("imu_data");
-
- QDomNode gyroNode = doc.createElement("gyro");
- QDomText gyroText = doc.createTextNode(QString("%1,%2,%3")
- .arg(QString::number(gyro[0]))
- .arg(QString::number(gyro[1]))
- .arg(QString::number(gyro[2])));
- gyroNode.appendChild(gyroText);
- tickDom.appendChild(gyroNode);
-
- QDomNode accNode = doc.createElement("acc");
- QDomText accText = doc.createTextNode(QString("%1,%2,%3")
- .arg(QString::number(accel[0]))
- .arg(QString::number(accel[1]))
- .arg(QString::number(accel[2])));
-
- accNode.appendChild(accText);
- tickDom.appendChild(accNode);
-
- QDomNode magNode = doc.createElement("mag");
- QDomText magText = doc.createTextNode(QString("%1,%2,%3")
- .arg(QString::number(mag[0]))
- .arg(QString::number(mag[1]))
- .arg(QString::number(mag[2])));
-
- magNode.appendChild(magText);
- tickDom.appendChild(magNode);
-
- tickDom.setAttribute("tstamp", (double)(msecsToEpoch*0.001));
- root.appendChild(tickDom);
-}
-
-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
26 PushBurton2/npushimutick.h
@@ -36,15 +36,20 @@
class NPushIMUTick : public NPushLogTick
{
public:
+
+ NPushIMUTick() {}
+
NPushIMUTick(QStringList& values);
NPushIMUTick(QStringList &values, quint64 a_msecsToEpoch);
- ~NPushIMUTick();
- void ParseValues(QStringList& values);
+ virtual ~NPushIMUTick();
- void append_to_xml(QDomDocument& doc, QDomElement& root) const;
- 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];
@@ -52,7 +57,16 @@ class NPushIMUTick : public NPushLogTick
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
8 PushBurton2/npushlogtick.h
@@ -38,13 +38,15 @@ class NPushLogTick : QObject
Q_OBJECT
public:
- virtual void append_to_xml(QDomDocument& doc, QDomElement& root) const = 0;
+ 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
191 PushBurton2/npushmagtick.cpp
@@ -1,98 +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::append_to_xml(QDomDocument& doc, QDomElement& root) const
-{
- QDomElement tickDom = doc.createElement("mag_data");
- tickDom.setAttribute("x", QString::number(tick.x()*1000.0,'f',5));
- tickDom.setAttribute("y", QString::number(tick.y()*1000.0,'f',5));
- tickDom.setAttribute("z", QString::number(tick.z()*1000.0,'f',5));
- tickDom.setAttribute("r", QString::number(qSqrt(tick.x()*tick.x()+
- tick.y()*tick.y()+
- tick.z()*tick.z())*1000.0,'f',5));
- tickDom.setAttribute("tstamp", (double)(msecsToEpoch*0.001));
-
- root.appendChild(tickDom);
-}
-
-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
11 PushBurton2/npushmagtick.h
@@ -38,14 +38,17 @@ QTM_USE_NAMESPACE
class NPushMagTick : public NPushLogTick
{
public:
+ NPushMagTick() {}
+
NPushMagTick(QMagnetometerReading * reading);
NPushMagTick(QMagnetometerReading * reading, quint64 a_msecsToEpoch);
- ~NPushMagTick();
- void append_to_xml(QDomDocument& doc, QDomElement& root) const;
- 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
148 PushBurton2/npushnormfeettick.cpp
@@ -1,76 +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::append_to_xml(QDomDocument& doc, QDomElement& root) const
-{
- QDomElement tickDom = doc.createElement("feet_sum");
- tickDom.setAttribute("tstamp", (double)(msecsToEpoch*0.001));
- tickDom.setAttribute("sum", pdata.totalRawSum);
-
- root.appendChild(tickDom);
-}
-
-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
+ *
+