code cleanup
This commit is contained in:
@@ -2,6 +2,15 @@ cmake_minimum_required(VERSION 3.1.0)
|
|||||||
|
|
||||||
project(Rennbahn)
|
project(Rennbahn)
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
|
message("Build type: RELEASE")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||||
|
|
||||||
# Find includes in corresponding build directories
|
# Find includes in corresponding build directories
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
# Instruct CMake to run moc automatically when needed
|
# Instruct CMake to run moc automatically when needed
|
||||||
@@ -14,8 +23,6 @@ find_package(Qt5Widgets CONFIG REQUIRED)
|
|||||||
|
|
||||||
find_package(Qt5Sql REQUIRED)
|
find_package(Qt5Sql REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Populate a CMake variable with the sources
|
# Populate a CMake variable with the sources
|
||||||
set(helloworld_SRCS
|
set(helloworld_SRCS
|
||||||
main.cpp
|
main.cpp
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ Counter::Counter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Counter::start() {
|
void Counter::start() {
|
||||||
gettimeofday(&startTime, NULL);
|
gettimeofday(&startTime, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
long Counter::getTime() {
|
long Counter::getTime() {
|
||||||
gettimeofday(&endTime, NULL);
|
gettimeofday(&endTime, nullptr);
|
||||||
long back = (endTime.tv_usec - startTime.tv_usec) / 1000 +
|
long back = (endTime.tv_usec - startTime.tv_usec) / 1000 +
|
||||||
(endTime.tv_sec - startTime.tv_sec) * 1000;
|
(endTime.tv_sec - startTime.tv_sec) * 1000;
|
||||||
this->start();
|
this->start();
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ DataBase::DataBase() {
|
|||||||
this->db = new QSqlDatabase();
|
this->db = new QSqlDatabase();
|
||||||
*this->db = QSqlDatabase::addDatabase("QSQLITE");
|
*this->db = QSqlDatabase::addDatabase("QSQLITE");
|
||||||
this->db->setDatabaseName("Renndatenbank.sqlite");
|
this->db->setDatabaseName("Renndatenbank.sqlite");
|
||||||
std::cout << "Konstruktor Database" << std::endl;
|
// std::cout << "Konstruktor Database" << std::endl;
|
||||||
}
|
}
|
||||||
DataBase::~DataBase() {
|
DataBase::~DataBase() {
|
||||||
std::cout << "Destruktor aus Datenbank" << std::endl;
|
// std::cout << "Destruktor aus Datenbank" << std::endl;
|
||||||
delete this->db;
|
delete this->db;
|
||||||
// delete this;
|
// delete this;
|
||||||
}
|
}
|
||||||
@@ -50,6 +50,7 @@ vector<vector<QString>> DataBase::getData(std::string statement, int cols) {
|
|||||||
bool ok = this->db->open();
|
bool ok = this->db->open();
|
||||||
QString qstr;
|
QString qstr;
|
||||||
if (ok) {
|
if (ok) {
|
||||||
|
std::cout << "alles ok bis hier" << std::endl;
|
||||||
QSqlQuery query(buffer);
|
QSqlQuery query(buffer);
|
||||||
|
|
||||||
while (query.next()) {
|
while (query.next()) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#ifdef ATMEGA
|
#ifdef ATMEGA
|
||||||
#include <usb.h>
|
#include <usb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define USB_LED_ON 1
|
#define USB_LED_ON 1
|
||||||
@@ -169,10 +169,9 @@ usb_dev_handle * HardwareSetup::usbOpenDevice(int vendor, char * vendorName,
|
|||||||
|
|
||||||
void HardwareSetup::run() {
|
void HardwareSetup::run() {
|
||||||
|
|
||||||
struct TransStruct buffer[6];
|
|
||||||
|
|
||||||
if (HARDWARE_VERSION == 2) {
|
if (HARDWARE_VERSION == 2) {
|
||||||
#ifdef ATMEGA
|
#ifdef ATMEGA
|
||||||
|
struct TransStruct buffer[6];
|
||||||
int testmode = 0;
|
int testmode = 0;
|
||||||
|
|
||||||
int nBytes = 0;
|
int nBytes = 0;
|
||||||
@@ -309,8 +308,8 @@ void HardwareSetup::run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif // ATMEGA
|
||||||
} // end HARDWARE_VERSION 2
|
} // end HARDWARE_VERSION 2
|
||||||
|
|
||||||
else if (HARDWARE_VERSION == 3) {
|
else if (HARDWARE_VERSION == 3) {
|
||||||
|
|
||||||
|
|||||||
@@ -16,15 +16,12 @@ using std::vector;
|
|||||||
MainWindow::MainWindow(QWidget * parent)
|
MainWindow::MainWindow(QWidget * parent)
|
||||||
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->interfaceTraining = NULL;
|
this->interfaceTraining = nullptr;
|
||||||
|
|
||||||
this->interfaceRace = NULL;
|
this->interfaceRace = nullptr;
|
||||||
this->interfaceSettings = NULL;
|
this->interfaceSettings = nullptr;
|
||||||
this->interfaceRennliste = NULL;
|
this->interfaceRennliste = nullptr;
|
||||||
|
|
||||||
// test = new HardwareSetup;
|
|
||||||
|
|
||||||
// this->test->start();
|
|
||||||
QObject::connect(ui->pushButton, SIGNAL(clicked()), this,
|
QObject::connect(ui->pushButton, SIGNAL(clicked()), this,
|
||||||
SLOT(NewWindowSettings()));
|
SLOT(NewWindowSettings()));
|
||||||
|
|
||||||
@@ -43,9 +40,10 @@ MainWindow::MainWindow(QWidget * parent)
|
|||||||
|
|
||||||
this->db = new DataBase;
|
this->db = new DataBase;
|
||||||
|
|
||||||
vector<vector<QString>> daten = db->getData("select * from Fahrer", 2);
|
// vector<vector<QString>> daten = db->getData("select * from Fahrer", 2);
|
||||||
}
|
}
|
||||||
void MainWindow::closeEvent(QCloseEvent * event) {
|
void MainWindow::closeEvent(QCloseEvent * event) {
|
||||||
|
Q_UNUSED(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#include "qvectorhelper.h"
|
#include "qvectorhelper.h"
|
||||||
#include <qvector.h>
|
#include <qvector.h>
|
||||||
|
|
||||||
int QVectorHelper::minSec1;
|
int QVectorHelper::minSec1; // set by database
|
||||||
int QVectorHelper::minSec2;
|
int QVectorHelper::minSec2; // set by database
|
||||||
int QVectorHelper::minSec3;
|
int QVectorHelper::minSec3; // set by database
|
||||||
int QVectorHelper::minTrackTime;
|
int QVectorHelper::minTrackTime; // set by database
|
||||||
|
|
||||||
QVectorHelper::QVectorHelper() {
|
QVectorHelper::QVectorHelper() {
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ int QVectorHelper::getMinSec1(const QVector<QVector<int>> x) {
|
|||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
int QVectorHelper::getMinSec2(const QVector<QVector<int>> x) {
|
int QVectorHelper::getMinSec2(const QVector<QVector<int>> x) {
|
||||||
int min;
|
int min = 9999;
|
||||||
if (x.size() > 0) {
|
if (x.size() > 0) {
|
||||||
if (x.at(0).size() >= 3) {
|
if (x.at(0).size() >= 3) {
|
||||||
if (x.at(0).at(1) >= minSec2) {
|
if (x.at(0).at(1) >= minSec2) {
|
||||||
@@ -73,7 +73,7 @@ int QVectorHelper::getMinSec2(const QVector<QVector<int>> x) {
|
|||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
int QVectorHelper::getMinSec3(const QVector<QVector<int>> x) {
|
int QVectorHelper::getMinSec3(const QVector<QVector<int>> x) {
|
||||||
int min;
|
int min = 9999;
|
||||||
if (x.size() > 0) {
|
if (x.size() > 0) {
|
||||||
if (x.at(0).size() >= 3) {
|
if (x.at(0).size() >= 3) {
|
||||||
if (x.at(0).at(2) >= minSec3) {
|
if (x.at(0).at(2) >= minSec3) {
|
||||||
@@ -101,7 +101,7 @@ int QVectorHelper::getMinSec3(const QVector<QVector<int>> x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int QVectorHelper::getMin(const QVector<QVector<int>> x) {
|
int QVectorHelper::getMin(const QVector<QVector<int>> x) {
|
||||||
int min;
|
int min = 9999;
|
||||||
if (x.size() > 0) {
|
if (x.size() > 0) {
|
||||||
if (x.at(0).size() >= 3) {
|
if (x.at(0).size() >= 3) {
|
||||||
if (getCurTime(x.at(0)) >= minTrackTime &&
|
if (getCurTime(x.at(0)) >= minTrackTime &&
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ QColor TimeModel::getColor(const QVector<QVector<int>> data, const int col,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int TimeModel::getMin(const QVector<int> x) const {
|
int TimeModel::getMin(const QVector<int> x) const {
|
||||||
int min;
|
int min = 9999;
|
||||||
if (x.size() > 0) {
|
if (x.size() > 0) {
|
||||||
min = x.at(0);
|
min = x.at(0);
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,9 @@ QVariant TimeModel::data(const QModelIndex & index, int role) const {
|
|||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
if (timeData.at(index.row()).size() > index.column()) {
|
if (timeData.at(index.row()).size() > index.column()) {
|
||||||
return QString::number(
|
return QString::number(
|
||||||
(double)timeData.at(index.row()).at(index.column()) / 1000);
|
static_cast<double>(
|
||||||
|
timeData.at(index.row()).at(index.column())) /
|
||||||
|
1000);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return QString("∞");
|
return QString("∞");
|
||||||
|
|||||||
37
training.cpp
37
training.cpp
@@ -158,7 +158,8 @@ void Training::shellSlot(int time, int sector) {
|
|||||||
this->ui->lWShellTime->setModel(timeModelShell);
|
this->ui->lWShellTime->setModel(timeModelShell);
|
||||||
|
|
||||||
this->ui->lBridgeShellTop->setText(QString::number(
|
this->ui->lBridgeShellTop->setText(QString::number(
|
||||||
(double)QVectorHelper::getMinSec1(VecShell) / 1000));
|
static_cast<double>(QVectorHelper::getMinSec1(VecShell)) /
|
||||||
|
1000));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
@@ -174,7 +175,8 @@ void Training::shellSlot(int time, int sector) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->ui->lStraightShellTop->setText(QString::number(
|
this->ui->lStraightShellTop->setText(QString::number(
|
||||||
(double)QVectorHelper::getMinSec2(VecShell) / 1000));
|
static_cast<double>(QVectorHelper::getMinSec2(VecShell)) /
|
||||||
|
1000));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (VecShell.size() > 0) {
|
if (VecShell.size() > 0) {
|
||||||
@@ -197,15 +199,19 @@ void Training::shellSlot(int time, int sector) {
|
|||||||
if (QVectorHelper::getCurTime(VecShell.last()) <=
|
if (QVectorHelper::getCurTime(VecShell.last()) <=
|
||||||
QVectorHelper::getMin(VecShell)) {
|
QVectorHelper::getMin(VecShell)) {
|
||||||
ui->lBestZeitShell->setText(QString::number(
|
ui->lBestZeitShell->setText(QString::number(
|
||||||
(double)QVectorHelper::getMin(VecShell) / 1000));
|
static_cast<double>(
|
||||||
|
QVectorHelper::getMin(VecShell)) /
|
||||||
|
1000));
|
||||||
}
|
}
|
||||||
ui->lCurRoundTimeShell->setText(QString::number(
|
ui->lCurRoundTimeShell->setText(QString::number(
|
||||||
(double)QVectorHelper::getCurTime(VecShell.last()) /
|
static_cast<double>(
|
||||||
|
QVectorHelper::getCurTime(VecShell.last())) /
|
||||||
1000));
|
1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
this->ui->lCurvesShellTop->setText(QString::number(
|
this->ui->lCurvesShellTop->setText(QString::number(
|
||||||
(double)QVectorHelper::getMinSec3(VecShell) / 1000));
|
static_cast<double>(QVectorHelper::getMinSec3(VecShell)) /
|
||||||
|
1000));
|
||||||
theoreticalMinShell = 9999;
|
theoreticalMinShell = 9999;
|
||||||
theoreticalMinShell = QVectorHelper::getMinSec1(VecShell) +
|
theoreticalMinShell = QVectorHelper::getMinSec1(VecShell) +
|
||||||
QVectorHelper::getMinSec2(VecShell) +
|
QVectorHelper::getMinSec2(VecShell) +
|
||||||
@@ -213,7 +219,7 @@ void Training::shellSlot(int time, int sector) {
|
|||||||
deltaShell =
|
deltaShell =
|
||||||
QVectorHelper::getMin(VecShell) - theoreticalMinShell;
|
QVectorHelper::getMin(VecShell) - theoreticalMinShell;
|
||||||
this->ui->lDeltaTopTimeShell->setText(
|
this->ui->lDeltaTopTimeShell->setText(
|
||||||
QString::number((double)deltaShell / 1000));
|
QString::number(static_cast<double>(deltaShell) / 1000));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ui->lWShellTime->scrollToBottom();
|
ui->lWShellTime->scrollToBottom();
|
||||||
@@ -224,7 +230,7 @@ void Training::shellSlot(int time, int sector) {
|
|||||||
}
|
}
|
||||||
void Training::closeEvent(QCloseEvent * event) {
|
void Training::closeEvent(QCloseEvent * event) {
|
||||||
Hardware->setStop();
|
Hardware->setStop();
|
||||||
// delete this->Hardware;
|
Q_UNUSED(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Training::deaSlot(int time, int sector) {
|
void Training::deaSlot(int time, int sector) {
|
||||||
@@ -247,7 +253,8 @@ void Training::deaSlot(int time, int sector) {
|
|||||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||||
this->ui->lBridgeDeaTop->setText(QString::number(
|
this->ui->lBridgeDeaTop->setText(QString::number(
|
||||||
(double)QVectorHelper::getMinSec1(VecDea) / 1000));
|
static_cast<double>(QVectorHelper::getMinSec1(VecDea)) /
|
||||||
|
1000));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (VecDea.size() > 0) {
|
if (VecDea.size() > 0) {
|
||||||
@@ -262,7 +269,8 @@ void Training::deaSlot(int time, int sector) {
|
|||||||
// VecDea[VecDea.size()-1].append(9999);
|
// VecDea[VecDea.size()-1].append(9999);
|
||||||
}
|
}
|
||||||
this->ui->lStraightDeaTop->setText(QString::number(
|
this->ui->lStraightDeaTop->setText(QString::number(
|
||||||
(double)QVectorHelper::getMinSec2(VecDea) / 1000));
|
static_cast<double>(QVectorHelper::getMinSec2(VecDea)) /
|
||||||
|
1000));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
@@ -289,14 +297,17 @@ void Training::deaSlot(int time, int sector) {
|
|||||||
if (QVectorHelper::getCurTime(VecDea.last()) <=
|
if (QVectorHelper::getCurTime(VecDea.last()) <=
|
||||||
QVectorHelper::getMin(VecDea)) {
|
QVectorHelper::getMin(VecDea)) {
|
||||||
ui->lBestZeitDea->setText(QString::number(
|
ui->lBestZeitDea->setText(QString::number(
|
||||||
(double)QVectorHelper::getMin(VecDea) / 1000));
|
static_cast<double>(QVectorHelper::getMin(VecDea)) /
|
||||||
|
1000));
|
||||||
}
|
}
|
||||||
ui->lCurRoundDea->setText(QString::number(
|
ui->lCurRoundDea->setText(QString::number(
|
||||||
(double)QVectorHelper::getCurTime(VecDea.last()) /
|
static_cast<double>(
|
||||||
|
QVectorHelper::getCurTime(VecDea.last())) /
|
||||||
1000));
|
1000));
|
||||||
|
|
||||||
this->ui->lCurvesDeaTop->setText(QString::number(
|
this->ui->lCurvesDeaTop->setText(QString::number(
|
||||||
(double)QVectorHelper::getMinSec3(VecDea) / 1000));
|
static_cast<double>(QVectorHelper::getMinSec3(VecDea)) /
|
||||||
|
1000));
|
||||||
theoreticalMinDea = 9999;
|
theoreticalMinDea = 9999;
|
||||||
theoreticalMinDea = QVectorHelper::getMinSec1(VecDea) +
|
theoreticalMinDea = QVectorHelper::getMinSec1(VecDea) +
|
||||||
QVectorHelper::getMinSec2(VecDea) +
|
QVectorHelper::getMinSec2(VecDea) +
|
||||||
@@ -304,7 +315,7 @@ void Training::deaSlot(int time, int sector) {
|
|||||||
deltaDea =
|
deltaDea =
|
||||||
QVectorHelper::getMin(VecDea) - theoreticalMinDea;
|
QVectorHelper::getMin(VecDea) - theoreticalMinDea;
|
||||||
this->ui->lDeltaTopTimeDea->setText(
|
this->ui->lDeltaTopTimeDea->setText(
|
||||||
QString::number((double)deltaDea / 1000));
|
QString::number(static_cast<double>(deltaDea) / 1000));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user