From 5ee809680da244ec83924a534f71078f4332a787 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Feb 2014 13:35:53 +0100 Subject: [PATCH] application logic fix --- Spherebot_UI/Spherebot_UI.pro.user | 2 +- Spherebot_UI/mainwindow.cpp | 14 +++++++++++--- Spherebot_UI/txthread.cpp | 11 ++++++++++- Spherebot_UI/txthread.h | 2 ++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Spherebot_UI/Spherebot_UI.pro.user b/Spherebot_UI/Spherebot_UI.pro.user index e0cbb56..0eea0c6 100644 --- a/Spherebot_UI/Spherebot_UI.pro.user +++ b/Spherebot_UI/Spherebot_UI.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/Spherebot_UI/mainwindow.cpp b/Spherebot_UI/mainwindow.cpp index 311ebc5..93f26cd 100644 --- a/Spherebot_UI/mainwindow.cpp +++ b/Spherebot_UI/mainwindow.cpp @@ -218,7 +218,9 @@ void MainWindow::finishedTransmission() { disconnectTranceiver(); ui->sendFileButton->setText("Send File"); + ui->loadFileButton->setText("Load File"); ui->controllBox->setEnabled(true); + ui->resetButton->setEnabled(false); ui->fileSendProgressBar->setEnabled(false); ui->loadFileButton->setEnabled(true); statusBar()->showMessage(tr("File successfully sent")); @@ -502,7 +504,7 @@ void MainWindow::setState(MainWindow::SendStates state) case(Idle): switch(sendState) { - case(Stoped): + case(Stoped): //abort print disconnectTranceiver(); ui->sendFileButton->setText("Send File"); ui->loadFileButton->setText("Load File"); @@ -526,11 +528,13 @@ void MainWindow::setState(MainWindow::SendStates state) ui->controllBox->setEnabled(false); ui->fileSendProgressBar->setEnabled(true); ui->sendFileButton->setText("Stop"); + ui->restartButton->setEnabled(true); + ui->loadFileButton->setText("Abort"); + ui->loadFileButton->setEnabled(true); ui->sendString->setEnabled(false); ui->controllBox->setEnabled(false); ui->sendButton->setEnabled(false); ui->sendString->setEnabled(false); - ui->loadFileButton->setEnabled(false); Transceiver.set(ui->fileTextEdit->toPlainText(),(*this->bot)); Transceiver.run(); statusBar()->showMessage(tr("Sending File")); @@ -538,10 +542,14 @@ void MainWindow::setState(MainWindow::SendStates state) case(Stoped): //continue sendState = Sending; connectTranceiver(); +#ifdef Watchdog Transceiver.watchdogTimer->start(); +#endif this->Transceiver.sendNext(); ui->loadFileButton->setEnabled(false); - ui->restartButton->setEnabled(false); + ui->resetButton->setEnabled(true); + ui->loadFileButton->setText("Abort"); + ui->loadFileButton->setEnabled(true); ui->sendFileButton->setText("Stop"); ui->controllBox->setEnabled(false); ui->sendButton->setEnabled(false); diff --git a/Spherebot_UI/txthread.cpp b/Spherebot_UI/txthread.cpp index 151a72e..86a67d6 100644 --- a/Spherebot_UI/txthread.cpp +++ b/Spherebot_UI/txthread.cpp @@ -8,7 +8,12 @@ txThread::txThread() watchdogTimer->setInterval(1000); //because of sudden stops during sending a file } //I use a watchdogTimer to force sending the next //command if there is a too long pause of communication -txThread::~txThread() //This is only a workaround!! + //This is only a workaround!! + //EDIT: I found out that this sometimes happens because of timing issues in the firmware. + + + +txThread::~txThread() { } @@ -51,7 +56,9 @@ void txThread::run() { qDebug()<<"entering run"; lineCounter = 0; +#ifdef Watchdog watchdogTimer->start(); +#endif sendNext(); } @@ -73,7 +80,9 @@ void txThread::sendNext() emit fileTransmitted(); return; } +#ifdef Watchdog watchdogTimer->start(); +#endif if(tmp.contains("G4")) { msleep(300); diff --git a/Spherebot_UI/txthread.h b/Spherebot_UI/txthread.h index af65dcd..5b681a3 100644 --- a/Spherebot_UI/txthread.h +++ b/Spherebot_UI/txthread.h @@ -6,6 +6,8 @@ #include #include +//#define Watchdog + class txThread : public QThread { Q_OBJECT