diff --git a/RennbahnZeitmessung.pro b/RennbahnZeitmessung.pro index 7914190..e496fa7 100644 --- a/RennbahnZeitmessung.pro +++ b/RennbahnZeitmessung.pro @@ -23,7 +23,8 @@ SOURCES += main.cpp\ countdown.cpp \ ampel.cpp \ database.cpp \ - windowrennliste.cpp + windowrennliste.cpp \ + training.cpp HEADERS += \ mainwindow.h \ @@ -34,12 +35,14 @@ HEADERS += \ countdown.h \ ampel.h \ database.h \ - windowrennliste.h + windowrennliste.h \ + training.h FORMS += mainwindow.ui \ windowrace.ui \ windowssettings.ui \ - windowrennliste.ui + windowrennliste.ui \ + training.ui OTHER_FILES += diff --git a/RennbahnZeitmessung.pro.user b/RennbahnZeitmessung.pro.user index a8cba21..79c8b0f 100644 --- a/RennbahnZeitmessung.pro.user +++ b/RennbahnZeitmessung.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/ampel.cpp b/ampel.cpp index 40f1420..4f5f6c3 100644 --- a/ampel.cpp +++ b/ampel.cpp @@ -3,11 +3,15 @@ Ampel::Ampel() { + this->running = 1; +} +void Ampel::setStop(){ + this->running = 0; } void Ampel::run(){ int anzahl = 0; - while(1){ + while(this->running){ anzahl++; if(anzahl < 6){ usleep(800000); diff --git a/ampel.h b/ampel.h index 22f69bf..b4a9ca3 100644 --- a/ampel.h +++ b/ampel.h @@ -7,8 +7,10 @@ class Ampel:public QThread Q_OBJECT public: Ampel(); + void setStop(); protected: void run(); + bool running; signals: void ampelUpdate(); }; diff --git a/countdown.cpp b/countdown.cpp index c70d24f..1197764 100644 --- a/countdown.cpp +++ b/countdown.cpp @@ -2,9 +2,14 @@ #include "unistd.h" Countdown::Countdown() { + this->running = 1; } +void Countdown::setStop(){ + this->running = 0; +} + void Countdown::run(){ - while(1){ + while(this->running){ sleep(1); emit CountdownUpdate(); } diff --git a/countdown.h b/countdown.h index e828b1b..b5cb764 100644 --- a/countdown.h +++ b/countdown.h @@ -7,7 +7,9 @@ class Countdown : public QThread Q_OBJECT protected: void run(); + bool running; public: + void setStop(); Countdown(); signals: void CountdownUpdate(); diff --git a/database.cpp b/database.cpp index 681dec7..f0301c9 100644 --- a/database.cpp +++ b/database.cpp @@ -13,6 +13,12 @@ DataBase::DataBase() this->db->setDatabaseName("Renndatenbank.sqlite"); std::cout << "Konstruktor Database" << std::endl; } +DataBase::~DataBase(){ + std::cout << "Destruktor aus Datenbank" << std::endl; + delete this->db; + //delete this; +} + vector< vector > DataBase::getData2(std::string statement, int cols){ vector data; diff --git a/database.h b/database.h index 4d6be79..3b99021 100644 --- a/database.h +++ b/database.h @@ -13,6 +13,7 @@ class DataBase { public: DataBase(); + ~DataBase(); vector< vector > getData(std::string statement, int cols); vector< vector > getData2(std::string statement, int cols); void setData(std::string statement); diff --git a/hardwaresetup.cpp b/hardwaresetup.cpp index 8edd88b..de2c88f 100644 --- a/hardwaresetup.cpp +++ b/hardwaresetup.cpp @@ -12,17 +12,23 @@ HardwareSetup::HardwareSetup() } shellBefore = false; deaBefore = false; - + this->stop = 0; } +void HardwareSetup::setStop(){ + this->stop = 1; +} + HardwareSetup::~HardwareSetup(){ - if (ioperm(BASEPORT, 3, 0)) { + /*if (ioperm(BASEPORT, 3, 0)) { //perror("ioperm"); - } + }*/ + std::cout << "Hardware beendet" << std::endl; + } void HardwareSetup::run(){ - while(1){ - usleep(10000); + while(!this->stop){ + usleep(500); if(getDea()){ if(!deaBefore){ deaBefore = true; diff --git a/hardwaresetup.h b/hardwaresetup.h index 1e5de19..8e091ef 100644 --- a/hardwaresetup.h +++ b/hardwaresetup.h @@ -15,7 +15,9 @@ private: bool getShell(); bool getDea(); int* findBit(int *array, int zahl); + bool stop; public: + void setStop(); ~HardwareSetup(); HardwareSetup(); signals: diff --git a/mainwindow.cpp b/mainwindow.cpp index 685a052..ccb6e0a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -8,6 +8,8 @@ #include "database.h" #include #include "windowrennliste2.h" +#include "training.h" +#include "unistd.h" using std::vector; MainWindow::MainWindow(QWidget *parent) : @@ -16,23 +18,36 @@ MainWindow::MainWindow(QWidget *parent) : { ui->setupUi(this); - test = new HardwareSetup; + //test = new HardwareSetup; - this->test->start(); + //this->test->start(); QObject::connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(NewWindowSettings())); QObject::connect(ui->pBRennen, SIGNAL(clicked()), this, SLOT(WindowRennen())); + QObject::connect(this->ui->pBTraining, SIGNAL(clicked()), this, SLOT(WindowTraining())); + + this->db = new DataBase; vector< vector > daten = db->getData("select * from Fahrer", 2); +} +void MainWindow::closeEvent(QCloseEvent *event){ + } MainWindow::~MainWindow() { + delete this->db; delete ui; + } + +void MainWindow::WindowTraining(){ + +} + void MainWindow::NewWindowSettings(){ this->interfaceSettings = new WindowsSettings(this->db, this); this->interfaceSettings->show(); diff --git a/mainwindow.h b/mainwindow.h index 3a030ac..68d7625 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -27,11 +27,12 @@ public: public slots: void NewWindowSettings(); void WindowRennen(); + void WindowTraining(); private: + void closeEvent(QCloseEvent *event); DataBase *db; - HardwareSetup *test; Ui::MainWindow *ui; WindowRace *interfaceRace; WindowsSettings *interfaceSettings; diff --git a/mainwindow.ui b/mainwindow.ui index 338f0f8..adf23eb 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,57 +6,48 @@ 0 0 - 568 - 427 + 512 + 235 MainWindow - - - - 410 - 10 - 80 - 23 - - - - Einstellungen - - - - - - 410 - 60 - 80 - 23 - - - - Rennen - - - - - - 140 - 100 - 113 - 23 - - - + + + + + + + Rennen + + + + + + + Training + + + + + + + Einstellungen + + + + + + 0 0 - 568 + 512 20 diff --git a/training.cpp b/training.cpp new file mode 100644 index 0000000..653e672 --- /dev/null +++ b/training.cpp @@ -0,0 +1,14 @@ +#include "training.h" +#include "ui_training.h" + +Training::Training(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::Training) +{ + ui->setupUi(this); +} + +Training::~Training() +{ + delete ui; +} diff --git a/training.h b/training.h new file mode 100644 index 0000000..fa875c4 --- /dev/null +++ b/training.h @@ -0,0 +1,22 @@ +#ifndef TRAINING_H +#define TRAINING_H + +#include + +namespace Ui { +class Training; +} + +class Training : public QMainWindow +{ + Q_OBJECT + +public: + explicit Training(QWidget *parent = 0); + ~Training(); + +private: + Ui::Training *ui; +}; + +#endif // TRAINING_H diff --git a/training.ui b/training.ui new file mode 100644 index 0000000..afd4df9 --- /dev/null +++ b/training.ui @@ -0,0 +1,609 @@ + + + Training + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + + + + + + + 300 + 16777215 + + + + + 14 + + + + Shell + + + + + + + + + 12 + + + + Bestzeit + + + + + + + 20 + + + + + + + + + + + + + + + 12 + + + + Zeit aktueller Runde + + + + + + + 20 + + + + + + + + + + + + + + + + + 300 + 16777215 + + + + + + + + + + + + + + + + 0 + 0 + + + + + 17 + + + + Verbleibende Zeit + + + + + + + + 170 + 100 + + + + + + + + + + + + + + 23 + 23 + + + + + 23 + 23 + + + + + + + + + 23 + 23 + + + + background-image: url(:/new/prefix1/ampel.png); + + + + + + + + + + + + 23 + 23 + + + + + 23 + 23 + + + + + + + + + 23 + 23 + + + + background-image: url(:/new/prefix1/ampel.png); + + + + + + + + + + + + + + + + 23 + 23 + + + + + 23 + 23 + + + + + + + + + 23 + 23 + + + + background-image: url(:/new/prefix1/ampel.png); + + + + + + + + + + + + 23 + 23 + + + + + 23 + 23 + + + + + + + + + 23 + 23 + + + + background-image: url(:/new/prefix1/ampel.png); + + + + + + + + + + + + + + + + 23 + 23 + + + + + 23 + 23 + + + + + + + + + 23 + 23 + + + + background-image: url(:/new/prefix1/ampel.png); + + + + + + + + + + + + 23 + 23 + + + + + 23 + 23 + + + + + + + + + 23 + 23 + + + + background-image: url(:/new/prefix1/ampel.png); + + + + + + + + + + + + + + + + 23 + 23 + + + + + 23 + 23 + + + + + + + + + 23 + 23 + + + + background-image: url(:/new/prefix1/ampel.png); + + + + + + + + + + + + 23 + 23 + + + + + 23 + 23 + + + + + + + + + 23 + 23 + + + + background-image: url(:/new/prefix1/ampel.png); + + + + + + + + + + + + + + + + 23 + 23 + + + + + 23 + 23 + + + + + + + + + 23 + 23 + + + + background-image: url(:/new/prefix1/ampel.png); + + + + + + + + + + + + 23 + 23 + + + + + 23 + 23 + + + + + + + + + 23 + 23 + + + + background-image: url(:/new/prefix1/ampel.png); + + + + + + + + + + + + + + + + + + + + + + + + 300 + 16777215 + + + + + 14 + + + + Dea + + + + + + + + + 12 + + + + Bestzeit + + + + + + + 20 + + + + + + + + + + + + + + + 12 + + + + Zeit aktueller Runde + + + + + + + 20 + + + + + + + + + + + + + + + + + 300 + 16777215 + + + + + + + + + + + + + + + + + 0 + 0 + 800 + 20 + + + + + + + + diff --git a/windowrace.cpp b/windowrace.cpp index 5c1717e..e1e7258 100644 --- a/windowrace.cpp +++ b/windowrace.cpp @@ -4,6 +4,7 @@ #include #include #include +#include "unistd.h" using std::vector; using std::string; @@ -175,8 +176,8 @@ void WindowRace::setDriverAndCarId(vector vec){ } void WindowRace::closeEvent(QCloseEvent *event){ QMessageBox msgBox; - msgBox.setText("The document has been modified."); - msgBox.setInformativeText("Do you want to save your changes?"); + msgBox.setText("Wirklich schliessen?"); + msgBox.setInformativeText(""); msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Save); int ret = msgBox.exec(); @@ -235,6 +236,15 @@ void WindowRace::countdownUpdate(){ WindowRace::~WindowRace() { + this->startAmpelThread->setStop(); + this->countdown->setStop(); + this->Hardware->setStop(); + usleep(1000010); //eine Sekunde + + delete this->countdown; + delete this->Hardware; + delete this->startAmpelThread; + delete ui; } void WindowRace::shellSlot(){ @@ -362,5 +372,4 @@ void WindowRace::ampelSlot(){ void WindowRace::go(){ startAmpelThread->start(); - } diff --git a/windowrennliste.cpp b/windowrennliste.cpp index 8ee2d7a..7ea06b3 100644 --- a/windowrennliste.cpp +++ b/windowrennliste.cpp @@ -121,6 +121,7 @@ void WindowRennliste::closeEvent(QCloseEvent *event){ void WindowRennliste::schliessen(){ this->windowClose = true; this->close(); + delete this; } void WindowRennliste::setSelection(int row){ diff --git a/windowssettings.cpp b/windowssettings.cpp index b83c738..db38b06 100644 --- a/windowssettings.cpp +++ b/windowssettings.cpp @@ -60,6 +60,7 @@ WindowsSettings::WindowsSettings(DataBase *db, QWidget *parent) : } void WindowsSettings::AbbrechenSlot(){ this->close(); + delete this; } void WindowsSettings::SaveDauerSlot(){ string statement = "update renndauer set dauer="+this->ui->leRenndauer->text().toStdString()+" where id like 1"; @@ -98,6 +99,7 @@ void WindowsSettings::StreckeSpeichernSlot(){ WindowsSettings::~WindowsSettings() { delete ui; + std::cout << "Destruktor einstellungen" << std::endl; } // Get current date/time, format is YYYY-MM-DD.HH:mm:ss