From d259f1dbf8ba2039b6cf2eb8980ca75b769c8167 Mon Sep 17 00:00:00 2001 From: Justin Knotzke Date: Thu, 25 Nov 2010 09:00:57 -0500 Subject: [PATCH] Fixed bug whereby CSV file was corrupted. When Device was not available, Realtime was creating a corrupted CSV. If Device is not availble at startup, the ride file is removed. --- src/ANTplusController.cpp | 2 +- src/ComputrainerController.cpp | 4 ++-- src/RealtimeController.h | 2 ++ src/RealtimeWindow.cpp | 24 +++++++++++++++--------- src/RealtimeWindow.h | 2 +- src/SimpleNetworkController.cpp | 2 +- 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/ANTplusController.cpp b/src/ANTplusController.cpp index 83ff80e28..550c2373b 100644 --- a/src/ANTplusController.cpp +++ b/src/ANTplusController.cpp @@ -82,7 +82,7 @@ ANTplusController::getRealtimeData(RealtimeData &rtData) msgBox.setText("Cannot Connect to Quarqd"); msgBox.setIcon(QMessageBox::Critical); msgBox.exec(); - parent->Stop(); + parent->Stop(1); return; } // get latest telemetry diff --git a/src/ComputrainerController.cpp b/src/ComputrainerController.cpp index 4956e8613..57e2db6ad 100644 --- a/src/ComputrainerController.cpp +++ b/src/ComputrainerController.cpp @@ -81,7 +81,7 @@ ComputrainerController::getRealtimeData(RealtimeData &rtData) msgBox.setText("Cannot Connect to Computrainer"); msgBox.setIcon(QMessageBox::Critical); msgBox.exec(); - parent->Stop(); + parent->Stop(1); return; } // get latest telemetry @@ -129,7 +129,7 @@ ComputrainerController::getRealtimeData(RealtimeData &rtData) // if Buttons == 0 we just pressed stop! if (Buttons&CT_RESET) { - parent->Stop(); + parent->Stop(0); } // displaymode diff --git a/src/RealtimeController.h b/src/RealtimeController.h index 760b6241e..aab486774 100644 --- a/src/RealtimeController.h +++ b/src/RealtimeController.h @@ -24,6 +24,8 @@ #ifndef _GC_RealtimeController_h #define _GC_RealtimeController_h 1 +#define DEVICE_ERROR 1 +#define DEVICE_OK 0 class RealtimeController { diff --git a/src/RealtimeWindow.cpp b/src/RealtimeWindow.cpp index d3467bf2c..a7898e616 100644 --- a/src/RealtimeWindow.cpp +++ b/src/RealtimeWindow.cpp @@ -76,7 +76,7 @@ RealtimeWindow::configUpdate() disconnect(stopButton, SIGNAL(clicked()), this, SLOT(warnnoConfig())); connect(startButton, SIGNAL(clicked()), this, SLOT(Start())); connect(pauseButton, SIGNAL(clicked()), this, SLOT(Pause())); - connect(stopButton, SIGNAL(clicked()), this, SLOT(Stop())); + connect(stopButton, SIGNAL(clicked()), this, SLOT(Stop(DEVICE_OK))); } } @@ -165,7 +165,7 @@ RealtimeWindow::RealtimeWindow(MainWindow *parent, TrainTool *trainTool, const Q if (Devices.count() > 0) { connect(startButton, SIGNAL(clicked()), this, SLOT(Start())); connect(pauseButton, SIGNAL(clicked()), this, SLOT(Pause())); - connect(stopButton, SIGNAL(clicked()), this, SLOT(Stop())); + connect(stopButton, SIGNAL(clicked()), this, SLOT(Stop(DEVICE_OK))); } else { connect(startButton, SIGNAL(clicked()), this, SLOT(warnnoConfig())); connect(pauseButton, SIGNAL(clicked()), this, SLOT(warnnoConfig())); @@ -441,7 +441,7 @@ void RealtimeWindow::Pause() // pause capture to recalibrate } } -void RealtimeWindow::Stop() // when stop button is pressed +void RealtimeWindow::Stop(int deviceStatus) // when stop button is pressed { if ((status&RT_RUNNING) == 0) return; @@ -456,10 +456,16 @@ void RealtimeWindow::Stop() // when stop button is pressed // close and reset File recordFile->close(); - // add to the view - using basename ONLY - QString name; - name = recordFile->fileName(); - main->addRide(QFileInfo(name).fileName(), true); + if(deviceStatus == DEVICE_ERROR) + { + recordFile->remove(); + } + else { + // add to the view - using basename ONLY + QString name; + name = recordFile->fileName(); + main->addRide(QFileInfo(name).fileName(), true); + } } if (status & RT_STREAMING) { @@ -793,7 +799,7 @@ void RealtimeWindow::loadUpdate() // we got to the end! if (load == -100) { - Stop(); + Stop(DEVICE_OK); } else { displayLoad = load; deviceController->setLoad(displayLoad); @@ -804,7 +810,7 @@ void RealtimeWindow::loadUpdate() // we got to the end! if (gradient == -100) { - Stop(); + Stop(DEVICE_OK); } else { displayGradient = gradient; deviceController->setGradient(displayGradient); diff --git a/src/RealtimeWindow.h b/src/RealtimeWindow.h index 648eb4488..770a27b5e 100644 --- a/src/RealtimeWindow.h +++ b/src/RealtimeWindow.h @@ -70,7 +70,7 @@ class RealtimeWindow : public QWidget void Start(); // when start button is pressed void Pause(); // when Paude is pressed - void Stop(); // when stop button is pressed + void Stop(int status); // when stop button is pressed void FFwd(); // jump forward when in a workout void Rewind(); // jump backwards when in a workout diff --git a/src/SimpleNetworkController.cpp b/src/SimpleNetworkController.cpp index ac3577f95..32173088e 100644 --- a/src/SimpleNetworkController.cpp +++ b/src/SimpleNetworkController.cpp @@ -81,7 +81,7 @@ void SimpleNetworkController::getRealtimeData(RealtimeData &rtData) { msgBox.setText("Cannot Connect to peer"); msgBox.setIcon(QMessageBox::Critical); msgBox.exec(); - parent->Stop(); + parent->Stop(DEVICE_OK); } if (!client.getRealtimeData(data_cache)) {