Skip to content
Browse files

Merge branch 'cool-devices'

  • Loading branch information...
2 parents e252bf5 + e5bd885 commit e779f8108d40b87312ffe257ea58db366b6b2bd0 Clovis Scotti committed May 18, 2011
View
16 PushBurton2/devicesmanager.cpp
@@ -209,13 +209,13 @@ void DevicesManager::stop_bt_search()
#endif
}
-void DevicesManager::switch_to_simulation_device()
+void DevicesManager::switch_to_simulation_device(const QString& fname)
{
//TODO
qDebug() << "Switched to simulation device!";
configuredDevices->deleteAllAndClear();
- PushN8SimulationDevice * simulationDevice = new PushN8SimulationDevice();
+ PushN8SimulationDevice * simulationDevice = new PushN8SimulationDevice(fname);
configuredDevices->push_back(simulationDevice);
SetupAbstractDevices();
@@ -227,12 +227,8 @@ void DevicesManager::switch_to_simulation_device()
emit device_connected(QString("Location"));
emit device_connected(QString("Heart"));
-// emit foot_l_connected();
-// emit foot_r_connected();
-// emit motion_box_connected();
-// emit heart_connected();
-// emit gsr_connected();
-// emit phone_gps_connected();
+ emit request_run_start();
+ connect(simulationDevice, SIGNAL(simulationEnded()), this, SIGNAL(request_run_end()));
}
@@ -304,6 +300,6 @@ void DevicesManager::SetupAbstractDevices()
RotationCounter * spin2WinKid = new RotationCounter();
configuredDevices->push_back(spin2WinKid);
- VirtualBrosDevice * virtualBros = new VirtualBrosDevice();
- configuredDevices->push_back(virtualBros);
+// VirtualBrosDevice * virtualBros = new VirtualBrosDevice();
+// configuredDevices->push_back(virtualBros);
}
View
29 PushBurton2/devicesmanager.h
@@ -83,26 +83,29 @@ class DevicesManager : public QObject
void device_connected(const QString&);
void device_disconnected(const QString&);
+ void request_run_start();
+ void request_run_end();
+
//This may seem abusive at first look
// but makes complete sense since they are just routed from
// signals comming from different objects and well.. at some point you need to break into!
- void phone_gps_connecting();
- void phone_gps_connected();
+// void phone_gps_connecting();
+// void phone_gps_connected();
- void motion_box_connecting();
- void motion_box_connected();
+// void motion_box_connecting();
+// void motion_box_connected();
- void heart_connecting();
- void heart_connected();
+// void heart_connecting();
+// void heart_connected();
- void gsr_connecting();
- void gsr_connected();
+// void gsr_connecting();
+// void gsr_connected();
- void foot_l_connecting();
- void foot_l_connected();
+// void foot_l_connecting();
+// void foot_l_connected();
- void foot_r_connecting();
- void foot_r_connected();
+// void foot_r_connecting();
+// void foot_r_connected();
public slots:
@@ -116,7 +119,7 @@ public slots:
void start_bt_search();
void stop_bt_search();
void kit_selected(int);
- void switch_to_simulation_device();
+ void switch_to_simulation_device(const QString& fname = "");
private:
View
9 PushBurton2/main.cpp
@@ -29,6 +29,7 @@
#include "mainwindow.h"
#include <QDebug>
+#include <QString>
#ifdef Q_OS_SYMBIAN
#include <eikenv.h>
@@ -51,7 +52,13 @@ int main(int argc, char *argv[])
#endif
- MainWindow w;
+ QString simulationFname;
+ if(argc > 1) {
+ simulationFname = argv[1];
+ qDebug() << "Simulating: " << simulationFname;
+ }
+
+ MainWindow w(simulationFname);
#if defined(Q_WS_S60)
w.showMaximized();
// w.showFullScreen();
View
13 PushBurton2/mainwindow.cpp
@@ -30,7 +30,7 @@
#include <QWidget>
-MainWindow::MainWindow(QWidget *parent) :
+MainWindow::MainWindow(const QString& simulationData, QWidget *parent) :
QMainWindow(parent),
devicesManager(&devicesHolder,parent),
runManager(&devicesHolder,parent),
@@ -89,6 +89,17 @@ MainWindow::MainWindow(QWidget *parent) :
// connect(homeUsrState, SIGNAL(entered()), this, SLOT(scheduleSshot()));
menuBar->addAction(takeScreenshotAc);
setMenuBar(menuBar);
+
+ if(simulationData != "") {
+ //If simulation file was passed bo main window (via command line arg, for example)
+
+ connect(&devicesManager, SIGNAL(request_run_start()), &runManager, SLOT(start_logging()));
+ connect(&devicesManager, SIGNAL(request_run_end()), &runManager, SLOT(stop_logging()));
+
+ connect(&runManager, SIGNAL(dataSaved()), this, SLOT(close()));
+
+ devicesManager.switch_to_simulation_device(simulationData);
+ }
}
void MainWindow::fillStatesProperties()
View
2 PushBurton2/mainwindow.h
@@ -71,7 +71,7 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
- explicit MainWindow(QWidget *parent = 0);
+ explicit MainWindow(const QString& simulationData = "", QWidget *parent = 0);
~MainWindow();
//Control modules
View
3 PushBurton2/npushrotationstick.cpp
@@ -6,6 +6,7 @@ NPushRotationsTick::NPushRotationsTick(double a_rawDegs, quint64 a_msecsToEpoch)
rawDegs = a_rawDegs;
updateCleanDegs();
+ qDebug() << "Landed a " << cleanDegs;
}
NPushRotationsTick::~NPushRotationsTick()
@@ -14,6 +15,8 @@ NPushRotationsTick::~NPushRotationsTick()
void NPushRotationsTick::append_to_xml(QDomDocument& doc, QDomElement& root) const
{
+ Q_UNUSED(doc);
+ Q_UNUSED(root);
//Not necessary. Append is deprecated
}
View
17 PushBurton2/pushn8airtimedetector.cpp
@@ -32,15 +32,12 @@ void PushN8AirTimeDetector::incoming_reading(NPushLogTick * gtick)
{
bool runFuzzy = false;
if(typeid(*gtick) == typeid(NPushNormFeetTick)) {
- NPushNormFeetTick * ftick = (NPushNormFeetTick *)gtick;
+// NPushNormFeetTick * ftick = (NPushNormFeetTick *)gtick;
- fp = ftick->pdata.totalRawSum;
- currentTstamp = ftick->msecsToEpoch;
+// fp = ftick->pdata.totalRawSum;
+// currentTstamp = ftick->msecsToEpoch;
- runFuzzy = true;
-// if(fp < 2000) {
-// qDebug() << "Got air here";
-// }
+// runFuzzy = true;
// qDebug() << "Got Sum: " << ftick->pdata.totalRawSum;
@@ -108,12 +105,11 @@ void PushN8AirTimeDetector::handle_response_new(Response resp)
case IdleGround:
switch(resp) {
case FlyingLikeAnEagle:
- qDebug() << "Going to Counting Air";
dynamic_state = CountingAir;
takeOffTime = currentTstamp;
lastAirborneTime = takeOffTime;
- qDebug() << "take off: " << takeOffTime;
+// qDebug() << "take off: " << takeOffTime;
//NOTE: To make SpinToWinKid possible
newTick = new NPushAirTimeTick(0, false, currentTstamp, true);
@@ -148,7 +144,6 @@ void PushN8AirTimeDetector::handle_response_new(Response resp)
// qDebug() << "Sliding lika bitch";
if(lastAirborneTime >= takeOffTime) {
dynamic_state = IdleGround;
- qDebug() << "IdleGround";
}
break;
@@ -182,7 +177,7 @@ void PushN8AirTimeDetector::handle_response_new(Response resp)
case SlidingDownLikeAPenguin:
if(lastAirborneTime >= takeOffTime) {
dynamic_state = CountingGround;
- qDebug() << "CountingGround";
+// qDebug() << "CountingGround";
touchDownTime = currentTstamp;
}
break;
View
10 PushBurton2/pushn8simulationdevice.cpp
@@ -27,13 +27,16 @@
#include "pushn8simulationdevice.h"
-PushN8SimulationDevice::PushN8SimulationDevice()
+PushN8SimulationDevice::PushN8SimulationDevice(const QString& fname)
{
+ simulationFile = fname;
+ if(simulationFile == "")
+ simulationFile = QFileDialog::getOpenFileName(0, "Select where to read the log from", FSC_RUNS_FOLDERS_ROOT, "Log Files (RawLog.xml)");
- QString simulationFile = QFileDialog::getOpenFileName(0, "Select where to read the log from", FSC_RUNS_FOLDERS_ROOT, "Log Files (RawLog.xml)");
if(simulationFile == "") {
simulationFile = "E:/sample_input.xml";
}
+
qDebug() << "Simulation input stream is: " << simulationFile;
data_input = new QFile(simulationFile, this);
@@ -56,7 +59,7 @@ PushN8SimulationDevice::PushN8SimulationDevice()
digitalAcc = false;
timerId = 0;
- timerPeriod = 20;
+ timerPeriod = 10;
}
PushN8SimulationDevice::~PushN8SimulationDevice()
@@ -127,6 +130,7 @@ void PushN8SimulationDevice::timerEvent(QTimerEvent *)
if(xml.isEndElement() && xml.name() == "N8SensorsLog") {
qDebug() << "Simulation Ended!!";
+ emit simulationEnded();
this->stop_readings();
}
// }
View
11 PushBurton2/pushn8simulationdevice.h
@@ -30,6 +30,8 @@
#include <QtXml>
+#include <QString>
+
#include <QDebug>
#include <QFile>
#include <QFileDialog>
@@ -55,14 +57,21 @@ class PushN8SimulationDevice : public PushBurtonGenericDevice
{
Q_OBJECT
public:
- PushN8SimulationDevice();
+ PushN8SimulationDevice(const QString& fname = "");
~PushN8SimulationDevice();
QString get_description();
bool is_online();
+
+signals:
+ void simulationEnded();
+
private:
+
+ QString simulationFile;
+
QFile * data_input;
QXmlStreamReader xml;
View
4 PushBurton2/rotationcounter.cpp
@@ -55,7 +55,7 @@ void RotationCounter::incoming_reading(NPushLogTick * tick)
if(airTimeTick->isOnlyHint && afterJumpDecCnter == 0) {
// qDebug() << "SpinToWinKid got hint";
- //This hint points to a possible airTime starting now. But it'll only be confirmed with the landed=true
+ //This 'hint' points to a possible airTime starting now. But it'll only be confirmed with the landed=true
onAir = true;
spinAcc = 0.0;
afterJumpDecCnter = 0;
@@ -71,7 +71,7 @@ void RotationCounter::incoming_reading(NPushLogTick * tick)
lastTstamp = airTimeTick->msecsToEpoch;
} else if(airTimeTick->landed) {
-// qDebug() << "Landed Trick; SpinAcc = " << spinAcc;
+// qDebug() << "Landed Trick; SpinAcc = " << spinAcc;
onAir = false;
afterJumpDecCnter = NEXT_SPIN_ACC_LENGTH;
}
View
2 PushBurton2/runmanager.cpp
@@ -75,6 +75,8 @@ void RunManager::stop_logging()
ubiqSaver = 0;
UpdateDataStreamConnections();
+
+ emit dataSaved();
}
void RunManager::UpdateDataStreamConnections()
View
1 PushBurton2/runmanager.h
@@ -45,6 +45,7 @@ class RunManager : public QObject
~RunManager();
signals:
+ void dataSaved();
public slots:
void start_logging();
View
6 PushBurton2/ubiqlogsaver.cpp
@@ -48,6 +48,8 @@ UbiqLogSaver::UbiqLogSaver(uint a_start_time)
runEnd = false;
this->start();
+
+ tickcount = 0;
}
UbiqLogSaver::~UbiqLogSaver()
@@ -75,6 +77,8 @@ void UbiqLogSaver::run()
tick->dump_to_xml(xml);
dataFile->flush();
ticksLock.lock();
+ tickcount++;
+// qDebug() << "saving tick = " << tickcount;
}
ticksLock.unlock();
@@ -112,7 +116,7 @@ void UbiqLogSaver::run_end()
xml.writeEndElement();//N8SensorsLog
xml.writeEndDocument();
dataFile->close();
- qDebug() << "File closed";
+ qDebug() << "File closed, dumped " << tickcount << " ticks";
}
void UbiqLogSaver::CreateRunDir()
View
2 PushBurton2/ubiqlogsaver.h
@@ -75,6 +75,8 @@ public slots:
QFile* dataFile;
QXmlStreamWriter xml;
+
+ int tickcount;
};
#endif // UBIQLOGSAVER_H

0 comments on commit e779f81

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