Skip to content
This repository
Newer
Older
100755 97 lines (78 sloc) 2.849 kb
42aa3910 »
2011-06-15 Removed deprecated code (append_to_xml); \n Added read_from_xml(); \n…
1 /*
2 * Copyright (c) 2011 Nokia Corporation
3 *
4 * This file is part of the Push Snowboarding Project, More info at:
5 * www.pushsnowboading.com
6 *
7 * Author: Clovis Scotti <scotti@ieee.org>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 *
26 */
27
28 #include "npushfoottick.h"
29
30 NPushFootTick::NPushFootTick(char a_side, int a_toes, int a_heel)
31 {
32 side = a_side;
33 toes = a_toes;
34 heel = a_heel;
35
36 uint secs_to_epoch;
37 uint msecs;
38
39 secs_to_epoch = QDateTime::currentDateTime().toTime_t();
40 msecs = QTime::currentTime().msec();
41 uint aft = QDateTime::currentDateTime().toTime_t();
42
43 //ugly work around, will be fized with msecsToEpoc from Qt 4.7
44 if(aft != secs_to_epoch)//on a second slip
45 {
46 msecs = 0;
47 secs_to_epoch = aft;
48 }
49
50 msecsToEpoch = (double)secs_to_epoch*1000.0+(double)msecs;
51 }
52
53 NPushFootTick::NPushFootTick(char a_side, int a_toes, int a_heel, quint64 a_msecsToEpoch)
54 {
55 side = a_side;
56 toes = a_toes;
57 heel = a_heel;
58
59 msecsToEpoch = a_msecsToEpoch;
60
61 }
62
63 NPushFootTick::~NPushFootTick()
64 {
65
66 }
67
68 void NPushFootTick::read_from_xml( QXmlStreamReader& xml)
69 {
70 side = xml.attributes().value("side").toString().at(0).toLatin1();
71
72 toes = xml.attributes().value("toes").toString().toInt();
73 heel = xml.attributes().value("heel").toString().toInt();
74
75 msecsToEpoch = (quint64)((double)xml.attributes().value("tstamp").toString().toDouble()*1000.0);
76 }
77
78 void NPushFootTick::dump_to_xml(QXmlStreamWriter& xml) const
79 {
80 xml.writeStartElement("foot_data");
81 xml.writeAttribute("tstamp", QString::number(((double)msecsToEpoch)/(double)1000.0, 'f', 3));
82
83 xml.writeAttribute("side", QString(side));
84 xml.writeAttribute("toes", QString::number(toes));
85 xml.writeAttribute("heel", QString::number(heel));
86
87 xml.writeEndElement();//foot_data
88 }
89
90 QString NPushFootTick::get_pretty_print() const
91 {
92 return QString("Foot: [%1;T:%2;H:%3]")
93 .arg(QString(side))
94 .arg(QString::number(toes))
95 .arg(QString::number(heel));
96 }
Something went wrong with that request. Please try again.