Skip to content
This repository
Browse code

Merge branch 'cool-devices'

  • Loading branch information...
commit e779f8108d40b87312ffe257ea58db366b6b2bd0 2 parents e252bf5 + e5bd885
Clovis Peruchi Scotti cpscotti authored
16 PushBurton2/devicesmanager.cpp
@@ -209,13 +209,13 @@ void DevicesManager::stop_bt_search()
209 209 #endif
210 210 }
211 211
212   -void DevicesManager::switch_to_simulation_device()
  212 +void DevicesManager::switch_to_simulation_device(const QString& fname)
213 213 {
214 214 //TODO
215 215 qDebug() << "Switched to simulation device!";
216 216 configuredDevices->deleteAllAndClear();
217 217
218   - PushN8SimulationDevice * simulationDevice = new PushN8SimulationDevice();
  218 + PushN8SimulationDevice * simulationDevice = new PushN8SimulationDevice(fname);
219 219 configuredDevices->push_back(simulationDevice);
220 220
221 221 SetupAbstractDevices();
@@ -227,12 +227,8 @@ void DevicesManager::switch_to_simulation_device()
227 227 emit device_connected(QString("Location"));
228 228 emit device_connected(QString("Heart"));
229 229
230   -// emit foot_l_connected();
231   -// emit foot_r_connected();
232   -// emit motion_box_connected();
233   -// emit heart_connected();
234   -// emit gsr_connected();
235   -// emit phone_gps_connected();
  230 + emit request_run_start();
  231 + connect(simulationDevice, SIGNAL(simulationEnded()), this, SIGNAL(request_run_end()));
236 232
237 233 }
238 234
@@ -304,6 +300,6 @@ void DevicesManager::SetupAbstractDevices()
304 300 RotationCounter * spin2WinKid = new RotationCounter();
305 301 configuredDevices->push_back(spin2WinKid);
306 302
307   - VirtualBrosDevice * virtualBros = new VirtualBrosDevice();
308   - configuredDevices->push_back(virtualBros);
  303 +// VirtualBrosDevice * virtualBros = new VirtualBrosDevice();
  304 +// configuredDevices->push_back(virtualBros);
309 305 }
29 PushBurton2/devicesmanager.h
@@ -83,26 +83,29 @@ class DevicesManager : public QObject
83 83 void device_connected(const QString&);
84 84 void device_disconnected(const QString&);
85 85
  86 + void request_run_start();
  87 + void request_run_end();
  88 +
86 89 //This may seem abusive at first look
87 90 // but makes complete sense since they are just routed from
88 91 // signals comming from different objects and well.. at some point you need to break into!
89   - void phone_gps_connecting();
90   - void phone_gps_connected();
  92 +// void phone_gps_connecting();
  93 +// void phone_gps_connected();
91 94
92   - void motion_box_connecting();
93   - void motion_box_connected();
  95 +// void motion_box_connecting();
  96 +// void motion_box_connected();
94 97
95   - void heart_connecting();
96   - void heart_connected();
  98 +// void heart_connecting();
  99 +// void heart_connected();
97 100
98   - void gsr_connecting();
99   - void gsr_connected();
  101 +// void gsr_connecting();
  102 +// void gsr_connected();
100 103
101   - void foot_l_connecting();
102   - void foot_l_connected();
  104 +// void foot_l_connecting();
  105 +// void foot_l_connected();
103 106
104   - void foot_r_connecting();
105   - void foot_r_connected();
  107 +// void foot_r_connecting();
  108 +// void foot_r_connected();
106 109
107 110
108 111 public slots:
@@ -116,7 +119,7 @@ public slots:
116 119 void start_bt_search();
117 120 void stop_bt_search();
118 121 void kit_selected(int);
119   - void switch_to_simulation_device();
  122 + void switch_to_simulation_device(const QString& fname = "");
120 123
121 124
122 125 private:
9 PushBurton2/main.cpp
@@ -29,6 +29,7 @@
29 29 #include "mainwindow.h"
30 30
31 31 #include <QDebug>
  32 +#include <QString>
32 33
33 34 #ifdef Q_OS_SYMBIAN
34 35 #include <eikenv.h>
@@ -51,7 +52,13 @@ int main(int argc, char *argv[])
51 52
52 53 #endif
53 54
54   - MainWindow w;
  55 + QString simulationFname;
  56 + if(argc > 1) {
  57 + simulationFname = argv[1];
  58 + qDebug() << "Simulating: " << simulationFname;
  59 + }
  60 +
  61 + MainWindow w(simulationFname);
55 62 #if defined(Q_WS_S60)
56 63 w.showMaximized();
57 64 // w.showFullScreen();
13 PushBurton2/mainwindow.cpp
@@ -30,7 +30,7 @@
30 30
31 31 #include <QWidget>
32 32
33   -MainWindow::MainWindow(QWidget *parent) :
  33 +MainWindow::MainWindow(const QString& simulationData, QWidget *parent) :
34 34 QMainWindow(parent),
35 35 devicesManager(&devicesHolder,parent),
36 36 runManager(&devicesHolder,parent),
@@ -89,6 +89,17 @@ MainWindow::MainWindow(QWidget *parent) :
89 89 // connect(homeUsrState, SIGNAL(entered()), this, SLOT(scheduleSshot()));
90 90 menuBar->addAction(takeScreenshotAc);
91 91 setMenuBar(menuBar);
  92 +
  93 + if(simulationData != "") {
  94 + //If simulation file was passed bo main window (via command line arg, for example)
  95 +
  96 + connect(&devicesManager, SIGNAL(request_run_start()), &runManager, SLOT(start_logging()));
  97 + connect(&devicesManager, SIGNAL(request_run_end()), &runManager, SLOT(stop_logging()));
  98 +
  99 + connect(&runManager, SIGNAL(dataSaved()), this, SLOT(close()));
  100 +
  101 + devicesManager.switch_to_simulation_device(simulationData);
  102 + }
92 103 }
93 104
94 105 void MainWindow::fillStatesProperties()
2  PushBurton2/mainwindow.h
@@ -71,7 +71,7 @@ class MainWindow : public QMainWindow
71 71 Q_OBJECT
72 72
73 73 public:
74   - explicit MainWindow(QWidget *parent = 0);
  74 + explicit MainWindow(const QString& simulationData = "", QWidget *parent = 0);
75 75 ~MainWindow();
76 76
77 77 //Control modules
3  PushBurton2/npushrotationstick.cpp
@@ -6,6 +6,7 @@ NPushRotationsTick::NPushRotationsTick(double a_rawDegs, quint64 a_msecsToEpoch)
6 6 rawDegs = a_rawDegs;
7 7
8 8 updateCleanDegs();
  9 + qDebug() << "Landed a " << cleanDegs;
9 10 }
10 11
11 12 NPushRotationsTick::~NPushRotationsTick()
@@ -14,6 +15,8 @@ NPushRotationsTick::~NPushRotationsTick()
14 15
15 16 void NPushRotationsTick::append_to_xml(QDomDocument& doc, QDomElement& root) const
16 17 {
  18 + Q_UNUSED(doc);
  19 + Q_UNUSED(root);
17 20 //Not necessary. Append is deprecated
18 21 }
19 22
17 PushBurton2/pushn8airtimedetector.cpp
@@ -32,15 +32,12 @@ void PushN8AirTimeDetector::incoming_reading(NPushLogTick * gtick)
32 32 {
33 33 bool runFuzzy = false;
34 34 if(typeid(*gtick) == typeid(NPushNormFeetTick)) {
35   - NPushNormFeetTick * ftick = (NPushNormFeetTick *)gtick;
  35 +// NPushNormFeetTick * ftick = (NPushNormFeetTick *)gtick;
36 36
37   - fp = ftick->pdata.totalRawSum;
38   - currentTstamp = ftick->msecsToEpoch;
  37 +// fp = ftick->pdata.totalRawSum;
  38 +// currentTstamp = ftick->msecsToEpoch;
39 39
40   - runFuzzy = true;
41   -// if(fp < 2000) {
42   -// qDebug() << "Got air here";
43   -// }
  40 +// runFuzzy = true;
44 41
45 42
46 43 // qDebug() << "Got Sum: " << ftick->pdata.totalRawSum;
@@ -108,12 +105,11 @@ void PushN8AirTimeDetector::handle_response_new(Response resp)
108 105 case IdleGround:
109 106 switch(resp) {
110 107 case FlyingLikeAnEagle:
111   - qDebug() << "Going to Counting Air";
112 108 dynamic_state = CountingAir;
113 109
114 110 takeOffTime = currentTstamp;
115 111 lastAirborneTime = takeOffTime;
116   - qDebug() << "take off: " << takeOffTime;
  112 +// qDebug() << "take off: " << takeOffTime;
117 113
118 114 //NOTE: To make SpinToWinKid possible
119 115 newTick = new NPushAirTimeTick(0, false, currentTstamp, true);
@@ -148,7 +144,6 @@ void PushN8AirTimeDetector::handle_response_new(Response resp)
148 144 // qDebug() << "Sliding lika bitch";
149 145 if(lastAirborneTime >= takeOffTime) {
150 146 dynamic_state = IdleGround;
151   - qDebug() << "IdleGround";
152 147 }
153 148 break;
154 149
@@ -182,7 +177,7 @@ void PushN8AirTimeDetector::handle_response_new(Response resp)
182 177 case SlidingDownLikeAPenguin:
183 178 if(lastAirborneTime >= takeOffTime) {
184 179 dynamic_state = CountingGround;
185   - qDebug() << "CountingGround";
  180 +// qDebug() << "CountingGround";
186 181 touchDownTime = currentTstamp;
187 182 }
188 183 break;
10 PushBurton2/pushn8simulationdevice.cpp
@@ -27,13 +27,16 @@
27 27
28 28 #include "pushn8simulationdevice.h"
29 29
30   -PushN8SimulationDevice::PushN8SimulationDevice()
  30 +PushN8SimulationDevice::PushN8SimulationDevice(const QString& fname)
31 31 {
  32 + simulationFile = fname;
  33 + if(simulationFile == "")
  34 + simulationFile = QFileDialog::getOpenFileName(0, "Select where to read the log from", FSC_RUNS_FOLDERS_ROOT, "Log Files (RawLog.xml)");
32 35
33   - QString simulationFile = QFileDialog::getOpenFileName(0, "Select where to read the log from", FSC_RUNS_FOLDERS_ROOT, "Log Files (RawLog.xml)");
34 36 if(simulationFile == "") {
35 37 simulationFile = "E:/sample_input.xml";
36 38 }
  39 +
37 40 qDebug() << "Simulation input stream is: " << simulationFile;
38 41
39 42 data_input = new QFile(simulationFile, this);
@@ -56,7 +59,7 @@ PushN8SimulationDevice::PushN8SimulationDevice()
56 59 digitalAcc = false;
57 60
58 61 timerId = 0;
59   - timerPeriod = 20;
  62 + timerPeriod = 10;
60 63 }
61 64
62 65 PushN8SimulationDevice::~PushN8SimulationDevice()
@@ -127,6 +130,7 @@ void PushN8SimulationDevice::timerEvent(QTimerEvent *)
127 130
128 131 if(xml.isEndElement() && xml.name() == "N8SensorsLog") {
129 132 qDebug() << "Simulation Ended!!";
  133 + emit simulationEnded();
130 134 this->stop_readings();
131 135 }
132 136 // }
11 PushBurton2/pushn8simulationdevice.h
@@ -30,6 +30,8 @@
30 30
31 31 #include <QtXml>
32 32
  33 +#include <QString>
  34 +
33 35 #include <QDebug>
34 36 #include <QFile>
35 37 #include <QFileDialog>
@@ -55,14 +57,21 @@ class PushN8SimulationDevice : public PushBurtonGenericDevice
55 57 {
56 58 Q_OBJECT
57 59 public:
58   - PushN8SimulationDevice();
  60 + PushN8SimulationDevice(const QString& fname = "");
59 61 ~PushN8SimulationDevice();
60 62
61 63 QString get_description();
62 64
63 65 bool is_online();
64 66
  67 +
  68 +signals:
  69 + void simulationEnded();
  70 +
65 71 private:
  72 +
  73 + QString simulationFile;
  74 +
66 75 QFile * data_input;
67 76 QXmlStreamReader xml;
68 77
4 PushBurton2/rotationcounter.cpp
@@ -55,7 +55,7 @@ void RotationCounter::incoming_reading(NPushLogTick * tick)
55 55
56 56 if(airTimeTick->isOnlyHint && afterJumpDecCnter == 0) {
57 57 // qDebug() << "SpinToWinKid got hint";
58   - //This hint points to a possible airTime starting now. But it'll only be confirmed with the landed=true
  58 + //This 'hint' points to a possible airTime starting now. But it'll only be confirmed with the landed=true
59 59 onAir = true;
60 60 spinAcc = 0.0;
61 61 afterJumpDecCnter = 0;
@@ -71,7 +71,7 @@ void RotationCounter::incoming_reading(NPushLogTick * tick)
71 71
72 72 lastTstamp = airTimeTick->msecsToEpoch;
73 73 } else if(airTimeTick->landed) {
74   -// qDebug() << "Landed Trick; SpinAcc = " << spinAcc;
  74 +// qDebug() << "Landed Trick; SpinAcc = " << spinAcc;
75 75 onAir = false;
76 76 afterJumpDecCnter = NEXT_SPIN_ACC_LENGTH;
77 77 }
2  PushBurton2/runmanager.cpp
@@ -75,6 +75,8 @@ void RunManager::stop_logging()
75 75 ubiqSaver = 0;
76 76
77 77 UpdateDataStreamConnections();
  78 +
  79 + emit dataSaved();
78 80 }
79 81
80 82 void RunManager::UpdateDataStreamConnections()
1  PushBurton2/runmanager.h
@@ -45,6 +45,7 @@ class RunManager : public QObject
45 45 ~RunManager();
46 46
47 47 signals:
  48 + void dataSaved();
48 49
49 50 public slots:
50 51 void start_logging();
6 PushBurton2/ubiqlogsaver.cpp
@@ -48,6 +48,8 @@ UbiqLogSaver::UbiqLogSaver(uint a_start_time)
48 48
49 49 runEnd = false;
50 50 this->start();
  51 +
  52 + tickcount = 0;
51 53 }
52 54
53 55 UbiqLogSaver::~UbiqLogSaver()
@@ -75,6 +77,8 @@ void UbiqLogSaver::run()
75 77 tick->dump_to_xml(xml);
76 78 dataFile->flush();
77 79 ticksLock.lock();
  80 + tickcount++;
  81 +// qDebug() << "saving tick = " << tickcount;
78 82 }
79 83 ticksLock.unlock();
80 84
@@ -112,7 +116,7 @@ void UbiqLogSaver::run_end()
112 116 xml.writeEndElement();//N8SensorsLog
113 117 xml.writeEndDocument();
114 118 dataFile->close();
115   - qDebug() << "File closed";
  119 + qDebug() << "File closed, dumped " << tickcount << " ticks";
116 120 }
117 121
118 122 void UbiqLogSaver::CreateRunDir()
2  PushBurton2/ubiqlogsaver.h
@@ -75,6 +75,8 @@ public slots:
75 75
76 76 QFile* dataFile;
77 77 QXmlStreamWriter xml;
  78 +
  79 + int tickcount;
78 80 };
79 81
80 82 #endif // UBIQLOGSAVER_H

0 comments on commit e779f81

Please sign in to comment.
Something went wrong with that request. Please try again.