added ui tweaks + fix for accepting wrong laptimes
This commit is contained in:
@@ -137,6 +137,8 @@ usb_dev_handle * HardwareSetup::usbOpenDevice(int vendor, char * vendorName,
|
||||
|
||||
void HardwareSetup::run() {
|
||||
|
||||
int testmode = 0;
|
||||
|
||||
int nBytes = 0;
|
||||
// char buffer[256];
|
||||
struct TransStruct buffer[6];
|
||||
@@ -149,62 +151,108 @@ void HardwareSetup::run() {
|
||||
// printf("usbtext.exe off\n");
|
||||
// exit(1);
|
||||
// }
|
||||
while (!this->handle) {
|
||||
this->handle = usbOpenDevice(0x16C0, "test01", 0x05DC, "USBExample");
|
||||
if (!testmode) {
|
||||
while (!this->handle) {
|
||||
this->handle =
|
||||
usbOpenDevice(0x16C0, "test01", 0x05DC, "USBExample");
|
||||
|
||||
if (this->handle == NULL) {
|
||||
fprintf(stderr, "Could not find USB device!\n");
|
||||
if (this->handle == NULL) {
|
||||
fprintf(stderr, "Could not find USB device!\n");
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
int index;
|
||||
while (!this->stop) {
|
||||
usleep(100000); // 100ms
|
||||
|
||||
// while(1){
|
||||
nBytes = usb_control_msg(
|
||||
this->handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN,
|
||||
USB_DATA_OUT, 0, 0, (char *)buffer, sizeof(buffer), 5000);
|
||||
// test mode
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (buffer[i].update != 0) {
|
||||
switch (buffer[i].id) {
|
||||
case 0:
|
||||
cout << "Shell Zeit 1: " << (int)buffer[i].time << endl;
|
||||
emit Shell((int)buffer[i].time, 1);
|
||||
break;
|
||||
case 1:
|
||||
cout << "Dea Zeit 1: " << (int)buffer[i].time << endl;
|
||||
emit Dea((int)buffer[i].time, 1);
|
||||
break;
|
||||
case 2:
|
||||
cout << "Shell Zeit 2: " << (int)buffer[i].time << endl;
|
||||
emit Shell((int)buffer[i].time, 2);
|
||||
break;
|
||||
case 3:
|
||||
cout << "Dea Zeit 2: " << (int)buffer[i].time << endl;
|
||||
emit Dea((int)buffer[i].time, 2);
|
||||
break;
|
||||
case 4:
|
||||
cout << "Shell Zeit 2: " << (int)buffer[i].time << endl;
|
||||
emit Shell((int)buffer[i].time, 3);
|
||||
break;
|
||||
case 5:
|
||||
cout << "Dea Zeit 3: " << (int)buffer[i].time << endl;
|
||||
emit Dea((int)buffer[i].time, 3);
|
||||
break;
|
||||
if (testmode) {
|
||||
while (1) {
|
||||
int validTimes = 1;
|
||||
if (validTimes) {
|
||||
Shell(1100, 1);
|
||||
sleep(1);
|
||||
Shell(1200, 2);
|
||||
sleep(1);
|
||||
Shell(1300, 3);
|
||||
sleep(1);
|
||||
Dea(1100, 1);
|
||||
sleep(1);
|
||||
Dea(1200, 2);
|
||||
sleep(1);
|
||||
Dea(1300, 3);
|
||||
// this->stop = 0;
|
||||
sleep(1);
|
||||
}
|
||||
else {
|
||||
// invalid times
|
||||
Shell(30, 1);
|
||||
sleep(1);
|
||||
Shell(700, 2);
|
||||
sleep(1);
|
||||
Shell(700, 3);
|
||||
sleep(1);
|
||||
Dea(700, 1);
|
||||
sleep(1);
|
||||
Dea(700, 2);
|
||||
sleep(1);
|
||||
Dea(700, 3);
|
||||
// this->stop = 0;
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (buffer[0].update != 0) {
|
||||
cout << "Got " << nBytes << " bytes: " << (int)buffer[2].time
|
||||
<< ", " << (int)buffer[2].id << endl;
|
||||
}
|
||||
//}
|
||||
else {
|
||||
// normal mode -> no testmode
|
||||
usleep(100000); // 100ms
|
||||
|
||||
if (nBytes < 0)
|
||||
fprintf(stderr, "USB error: %sn", usb_strerror());
|
||||
// while(1){
|
||||
nBytes = usb_control_msg(
|
||||
this->handle,
|
||||
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN,
|
||||
USB_DATA_OUT, 0, 0, (char *)buffer, sizeof(buffer), 5000);
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (buffer[i].update != 0) {
|
||||
switch (buffer[i].id) {
|
||||
case 0:
|
||||
cout << "Shell Zeit 1: " << (int)buffer[i].time << endl;
|
||||
emit Shell((int)buffer[i].time, 1);
|
||||
break;
|
||||
case 1:
|
||||
cout << "Dea Zeit 1: " << (int)buffer[i].time << endl;
|
||||
emit Dea((int)buffer[i].time, 1);
|
||||
break;
|
||||
case 2:
|
||||
cout << "Shell Zeit 2: " << (int)buffer[i].time << endl;
|
||||
emit Shell((int)buffer[i].time, 2);
|
||||
break;
|
||||
case 3:
|
||||
cout << "Dea Zeit 2: " << (int)buffer[i].time << endl;
|
||||
emit Dea((int)buffer[i].time, 2);
|
||||
break;
|
||||
case 4:
|
||||
cout << "Shell Zeit 2: " << (int)buffer[i].time << endl;
|
||||
emit Shell((int)buffer[i].time, 3);
|
||||
break;
|
||||
case 5:
|
||||
cout << "Dea Zeit 3: " << (int)buffer[i].time << endl;
|
||||
emit Dea((int)buffer[i].time, 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (buffer[0].update != 0) {
|
||||
cout << "Got " << nBytes << " bytes: " << (int)buffer[2].time
|
||||
<< ", " << (int)buffer[2].id << endl;
|
||||
}
|
||||
//}
|
||||
|
||||
if (nBytes < 0)
|
||||
fprintf(stderr, "USB error: %sn", usb_strerror());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
#include "qvectorhelper.h"
|
||||
#include <qvector.h>
|
||||
|
||||
int QVectorHelper::minSec1;
|
||||
int QVectorHelper::minSec2;
|
||||
int QVectorHelper::minSec3;
|
||||
int QVectorHelper::minTrackTime;
|
||||
|
||||
QVectorHelper::QVectorHelper() {
|
||||
}
|
||||
|
||||
@@ -13,12 +18,13 @@ int QVectorHelper::getCurTime(const QVector<int> x) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int QVectorHelper::getMinSec1(const QVector<QVector<int>> x) {
|
||||
int min;
|
||||
int min = 9999;
|
||||
if (x.size() > 0) {
|
||||
if (x.at(0).size() >= 3) {
|
||||
min = getCurTime(x.at(0));
|
||||
if (x.at(0).at(0) >= minSec1) {
|
||||
min = x.at(0).at(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 9999;
|
||||
@@ -29,9 +35,11 @@ int QVectorHelper::getMinSec1(const QVector<QVector<int>> x) {
|
||||
}
|
||||
|
||||
for (int i = 1; i < x.size(); i++) {
|
||||
if(x.at(i).size() >= 1){
|
||||
if (x.at(i).size() >= 1) {
|
||||
if (x.at(i).at(0) < min) {
|
||||
min = x.at(i).at(0);
|
||||
if (x.at(i).at(0) >= minSec1) {
|
||||
min = x.at(i).at(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +49,9 @@ int QVectorHelper::getMinSec2(const QVector<QVector<int>> x) {
|
||||
int min;
|
||||
if (x.size() > 0) {
|
||||
if (x.at(0).size() >= 3) {
|
||||
min = getCurTime(x.at(1));
|
||||
if (x.at(0).at(1) >= minSec2) {
|
||||
min = x.at(0).at(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 9999;
|
||||
@@ -54,7 +64,9 @@ int QVectorHelper::getMinSec2(const QVector<QVector<int>> x) {
|
||||
for (int i = 1; i < x.size(); i++) {
|
||||
if (x.at(0).size() >= 2) {
|
||||
if (x.at(i).at(1) < min) {
|
||||
min = x.at(i).at(1);
|
||||
if (x.at(0).at(1) >= minSec2) {
|
||||
min = x.at(i).at(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,7 +76,9 @@ int QVectorHelper::getMinSec3(const QVector<QVector<int>> x) {
|
||||
int min;
|
||||
if (x.size() > 0) {
|
||||
if (x.at(0).size() >= 3) {
|
||||
min = getCurTime(x.at(2));
|
||||
if (x.at(0).at(2) >= minSec3) {
|
||||
min = x.at(0).at(2);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 9999;
|
||||
@@ -75,9 +89,11 @@ int QVectorHelper::getMinSec3(const QVector<QVector<int>> x) {
|
||||
}
|
||||
|
||||
for (int i = 1; i < x.size(); i++) {
|
||||
if(x.at(i).size() >= 3){
|
||||
if (x.at(i).size() >= 3) {
|
||||
if (x.at(i).at(2) < min) {
|
||||
min = x.at(i).at(2);
|
||||
if (x.at(0).at(2) >= minSec3) {
|
||||
min = x.at(i).at(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,7 +104,9 @@ int QVectorHelper::getMin(const QVector<QVector<int>> x) {
|
||||
int min;
|
||||
if (x.size() > 0) {
|
||||
if (x.at(0).size() >= 3) {
|
||||
min = getCurTime(x.at(0));
|
||||
if (getCurTime(x.at(0)) >= minTrackTime) {
|
||||
min = getCurTime(x.at(0));
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 9999;
|
||||
@@ -99,7 +117,9 @@ int QVectorHelper::getMin(const QVector<QVector<int>> x) {
|
||||
}
|
||||
for (int i = 1; i < x.size(); i++) {
|
||||
if (getCurTime(x.at(i)) < min) {
|
||||
min = getCurTime(x.at(i));
|
||||
if (getCurTime(x.at(0)) >= minTrackTime) {
|
||||
min = getCurTime(x.at(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
return min;
|
||||
|
||||
@@ -10,6 +10,10 @@ class QVectorHelper {
|
||||
static int getMinSec1(const QVector<QVector<int>> x);
|
||||
static int getMinSec2(const QVector<QVector<int>> x);
|
||||
static int getMinSec3(const QVector<QVector<int>> x);
|
||||
static int minSec1;
|
||||
static int minSec2;
|
||||
static int minSec3;
|
||||
static int minTrackTime;
|
||||
};
|
||||
|
||||
#endif // QVECTORHELPER_H
|
||||
|
||||
@@ -31,7 +31,7 @@ QVariant TimeModel::headerData(int section, Qt::Orientation orientation,
|
||||
return QString("Gerade");
|
||||
|
||||
case 2:
|
||||
return QString("Kruven");
|
||||
return QString("Kurven");
|
||||
|
||||
case 3:
|
||||
return QString("Runde");
|
||||
@@ -71,7 +71,10 @@ QColor TimeModel::getColor(const QVector<QVector<int>> data, const int col,
|
||||
// lap time
|
||||
if (data.at(row).at(0) < this->minimumTimes.at(0) ||
|
||||
data.at(row).at(1) < this->minimumTimes.at(1) ||
|
||||
data.at(row).at(2) < this->minimumTimes.at(2)) {
|
||||
data.at(row).at(2) < this->minimumTimes.at(2) ||
|
||||
data.at(row).at(0) + data.at(row).at(1) +
|
||||
data.at(row).at(2) <
|
||||
this->minimumTimes.at(3)) {
|
||||
return QColor(Qt::red);
|
||||
}
|
||||
}
|
||||
|
||||
35
timemodel.h
35
timemodel.h
@@ -5,33 +5,42 @@
|
||||
#include <qcolor.h>
|
||||
#include <qvector.h>
|
||||
|
||||
class TimeModel : public QAbstractTableModel
|
||||
{
|
||||
class TimeModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TimeModel(QVector<QVector<int>> timeData, QVector<int> minimumTimes, QObject *parent = nullptr);
|
||||
explicit TimeModel(QVector<QVector<int>> timeData, QVector<int> minimumTimes, QVector<int> topTime, QObject *parent = nullptr);
|
||||
public:
|
||||
explicit TimeModel(QVector<QVector<int>> timeData,
|
||||
QVector<int> minimumTimes, QObject * parent = nullptr);
|
||||
explicit TimeModel(QVector<QVector<int>> timeData,
|
||||
QVector<int> minimumTimes, QVector<int> topTime,
|
||||
QObject * parent = nullptr);
|
||||
|
||||
// Header:
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const override;
|
||||
|
||||
// Basic functionality:
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int rowCount(const QModelIndex & parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex & parent = QModelIndex()) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
QVariant data(const QModelIndex & index,
|
||||
int role = Qt::DisplayRole) const override;
|
||||
|
||||
// Add data:
|
||||
bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
bool insertRows(int row, int count,
|
||||
const QModelIndex & parent = QModelIndex()) override;
|
||||
bool insertColumns(int column, int count,
|
||||
const QModelIndex & parent = QModelIndex()) override;
|
||||
|
||||
private:
|
||||
private:
|
||||
int getMin(const QVector<int> x) const;
|
||||
|
||||
QColor getColor(const QVector<QVector<int>> data, const int col, const int row) const; // row and col starts counting at 0
|
||||
QColor getColor(const QVector<QVector<int>> data, const int col,
|
||||
const int row) const; // row and col starts counting at 0
|
||||
QVector<QVector<int>> timeData;
|
||||
QVector<int> topTime;
|
||||
|
||||
// 4 entries: min sec1, min sec2, min sec3, min for whole time
|
||||
QVector<int> minimumTimes;
|
||||
};
|
||||
|
||||
|
||||
40
training.cpp
40
training.cpp
@@ -129,18 +129,9 @@ void Training::shellSlot(int time, int sector) {
|
||||
timeModelShell = new TimeModel(VecShell, minSecTime, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
|
||||
this->ui->lbridgeShellTop->setText(QString::number(
|
||||
this->ui->lBridgeShellTop->setText(QString::number(
|
||||
(double)QVectorHelper::getMinSec1(VecShell) / 1000));
|
||||
|
||||
theoreticalMinShell = 9999;
|
||||
theoreticalMinShell = QVectorHelper::getMinSec1(VecShell) +
|
||||
QVectorHelper::getMinSec2(VecShell) +
|
||||
QVectorHelper::getMinSec3(VecShell);
|
||||
deltaShell =
|
||||
QVectorHelper::getMin(VecShell) - theoreticalMinShell;
|
||||
this->ui->lDeltaTopTimeShell->setText(
|
||||
QString::number((double)deltaShell / 1000));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
if (VecShell.size() > 0) {
|
||||
@@ -154,7 +145,7 @@ void Training::shellSlot(int time, int sector) {
|
||||
}
|
||||
}
|
||||
|
||||
this->ui->lbridgeShellTop->setText(QString::number(
|
||||
this->ui->lStraightShellTop->setText(QString::number(
|
||||
(double)QVectorHelper::getMinSec2(VecShell) / 1000));
|
||||
break;
|
||||
case 3:
|
||||
@@ -185,9 +176,16 @@ void Training::shellSlot(int time, int sector) {
|
||||
1000));
|
||||
}
|
||||
|
||||
this->ui->lbridgeShellTop->setText(QString::number(
|
||||
this->ui->lCurvesShellTop->setText(QString::number(
|
||||
(double)QVectorHelper::getMinSec3(VecShell) / 1000));
|
||||
|
||||
theoreticalMinShell = 9999;
|
||||
theoreticalMinShell = QVectorHelper::getMinSec1(VecShell) +
|
||||
QVectorHelper::getMinSec2(VecShell) +
|
||||
QVectorHelper::getMinSec3(VecShell);
|
||||
deltaShell =
|
||||
QVectorHelper::getMin(VecShell) - theoreticalMinShell;
|
||||
this->ui->lDeltaTopTimeShell->setText(
|
||||
QString::number((double)deltaShell / 1000));
|
||||
break;
|
||||
}
|
||||
ui->lWShellTime->scrollToBottom();
|
||||
@@ -220,7 +218,8 @@ void Training::deaSlot(int time, int sector) {
|
||||
// cout << "Dea Sektor 1" << endl;
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
|
||||
this->ui->lBridgeDeaTop->setText(QString::number(
|
||||
(double)QVectorHelper::getMinSec1(VecDea) / 1000));
|
||||
break;
|
||||
case 2:
|
||||
if (VecDea.size() > 0) {
|
||||
@@ -234,6 +233,8 @@ void Training::deaSlot(int time, int sector) {
|
||||
else {
|
||||
// VecDea[VecDea.size()-1].append(9999);
|
||||
}
|
||||
this->ui->lStraightDeaTop->setText(QString::number(
|
||||
(double)QVectorHelper::getMinSec2(VecDea) / 1000));
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
@@ -265,6 +266,17 @@ void Training::deaSlot(int time, int sector) {
|
||||
ui->lCurRoundDea->setText(QString::number(
|
||||
(double)QVectorHelper::getCurTime(VecDea.last()) /
|
||||
1000));
|
||||
|
||||
this->ui->lCurvesDeaTop->setText(QString::number(
|
||||
(double)QVectorHelper::getMinSec3(VecDea) / 1000));
|
||||
theoreticalMinDea = 9999;
|
||||
theoreticalMinDea = QVectorHelper::getMinSec1(VecDea) +
|
||||
QVectorHelper::getMinSec2(VecDea) +
|
||||
QVectorHelper::getMinSec3(VecDea);
|
||||
deltaDea =
|
||||
QVectorHelper::getMin(VecDea) - theoreticalMinDea;
|
||||
this->ui->lDeltaTopTimeDea->setText(
|
||||
QString::number((double)deltaDea / 1000));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,9 @@ class Training : public QMainWindow {
|
||||
int theoreticalMinShell;
|
||||
int deltaShell;
|
||||
|
||||
int theoreticalMinDea;
|
||||
int deltaDea;
|
||||
|
||||
// timeModel
|
||||
TimeModel * timeModelDea;
|
||||
TimeModel * timeModelShell;
|
||||
|
||||
10
training.ui
10
training.ui
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>907</width>
|
||||
<width>1136</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -101,7 +101,7 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_14">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbridgeShellTop">
|
||||
<widget class="QLabel" name="lBridgeShellTop">
|
||||
<property name="text">
|
||||
<string>∞</string>
|
||||
</property>
|
||||
@@ -279,7 +279,7 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_19">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel" name="lBridgeDeaTop">
|
||||
<property name="text">
|
||||
<string>∞</string>
|
||||
</property>
|
||||
@@ -389,8 +389,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>907</width>
|
||||
<height>25</height>
|
||||
<width>1136</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
||||
@@ -35,12 +35,20 @@ WindowRace::WindowRace(DataBase * db, QWidget * parent)
|
||||
this->minimumTime = res[0][0].toInt();
|
||||
|
||||
// fill minSecTimes vector
|
||||
statement = "select minsec1, minsec2, minsec3 from renndauer order by id "
|
||||
statement = "select minsec1, minsec2, minsec3, mindestRundenDauer from "
|
||||
"renndauer order by id "
|
||||
"DESC limit 1";
|
||||
res = db->getData(statement, 3);
|
||||
cout << statement << endl;
|
||||
res = db->getData(statement, 4);
|
||||
this->minSecTime.append(res[0][0].toInt());
|
||||
this->minSecTime.append(res[0][1].toInt());
|
||||
this->minSecTime.append(res[0][2].toInt());
|
||||
this->minSecTime.append(res[0][3].toInt());
|
||||
|
||||
QVectorHelper::minSec1 = this->minSecTime.at(0);
|
||||
QVectorHelper::minSec2 = this->minSecTime.at(1);
|
||||
QVectorHelper::minSec3 = this->minSecTime.at(2);
|
||||
QVectorHelper::minTrackTime = this->minSecTime.at(3);
|
||||
|
||||
firstTimeDea = true;
|
||||
firstTimeShell = true;
|
||||
@@ -368,6 +376,9 @@ void WindowRace::shellSlot(int time, int sector) {
|
||||
new TimeModel(VecShell, minSecTime, test, this);
|
||||
// this->ui->lWShellTime->setModel(this->timeModelShell);
|
||||
ui->lWShellTime->setModel(this->timeModelShell);
|
||||
|
||||
this->ui->lBridgeShell->setText(QString::number(
|
||||
(double)QVectorHelper::getMinSec1(VecShell) / 1000));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
@@ -385,6 +396,8 @@ void WindowRace::shellSlot(int time, int sector) {
|
||||
// timeModelShell = new
|
||||
// TimeModel(VecShell, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
this->ui->lStraightShell->setText(QString::number(
|
||||
(double)QVectorHelper::getMinSec2(VecShell) / 1000));
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
@@ -414,17 +427,34 @@ void WindowRace::shellSlot(int time, int sector) {
|
||||
// timeModelShell = new
|
||||
// TimeModel(VecShell, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
int zeit = QVectorHelper::getMin(VecShell);
|
||||
QString statement =
|
||||
"insert into Zeiten (id_rennen, id_fahrer, "
|
||||
"id_auto, id_bahn, zeit) values (" +
|
||||
QString::number(this->renn_id) + ", " +
|
||||
QString::number(this->shellDriverId) + ", " +
|
||||
QString::number(this->shellCarId) + ", 1, " +
|
||||
QString::number(zeit) + ")";
|
||||
cout << statement.toStdString() << endl;
|
||||
|
||||
// this->db->setData(statement.toStdString());
|
||||
this->ui->lCurvesShell->setText(QString::number(
|
||||
(double)QVectorHelper::getMinSec3(VecShell) /
|
||||
1000));
|
||||
theoreticalMinShell = 9999;
|
||||
theoreticalMinShell =
|
||||
QVectorHelper::getMinSec1(VecShell) +
|
||||
QVectorHelper::getMinSec2(VecShell) +
|
||||
QVectorHelper::getMinSec3(VecShell);
|
||||
deltaShell = QVectorHelper::getMin(VecShell) -
|
||||
theoreticalMinShell;
|
||||
this->ui->lDeltaShellTop->setText(
|
||||
QString::number((double)deltaShell / 1000));
|
||||
|
||||
if (VecShell.size() > 0) {
|
||||
int zeit =
|
||||
QVectorHelper::getCurTime(VecShell.last());
|
||||
QString statement =
|
||||
"insert into Zeiten (id_rennen, id_fahrer, "
|
||||
"id_auto, id_bahn, zeit) values (" +
|
||||
QString::number(this->renn_id) + ", " +
|
||||
QString::number(this->shellDriverId) + ", " +
|
||||
QString::number(this->shellCarId) + ", 1, " +
|
||||
QString::number(zeit) + ")";
|
||||
// cout << statement.toStdString() << endl;
|
||||
|
||||
this->db->setData(statement.toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,6 +486,9 @@ void WindowRace::deaSlot(int time, int sector) {
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
|
||||
this->ui->lBridgeDea->setText(QString::number(
|
||||
(double)QVectorHelper::getMinSec1(VecDea) / 1000));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
if (VecDea.size() > 0) {
|
||||
@@ -464,6 +497,8 @@ void WindowRace::deaSlot(int time, int sector) {
|
||||
VecDea[VecDea.size() - 1].push_back(time);
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
this->ui->lStraightDea->setText(QString::number(
|
||||
(double)QVectorHelper::getMinSec2(VecDea) / 1000));
|
||||
}
|
||||
else {
|
||||
// VecDea[VecDea.size()-1].append(9999);
|
||||
@@ -500,17 +535,29 @@ void WindowRace::deaSlot(int time, int sector) {
|
||||
(double)QVectorHelper::getCurTime(VecDea.last()) /
|
||||
1000));
|
||||
}
|
||||
int zeit = QVectorHelper::getMin(VecDea);
|
||||
QString statement = "insert into Zeiten (id_rennen, id_fahrer, "
|
||||
"id_auto, id_bahn, zeit) values (" +
|
||||
QString::number(this->renn_id) + ", " +
|
||||
QString::number(this->deaDriverId) + ", " +
|
||||
QString::number(this->deaCarId) + ", 2, " +
|
||||
QString::number(zeit) + ")";
|
||||
cout << statement.toStdString() << endl;
|
||||
// this->db->setData(statement.toStdString());
|
||||
ui->lWDeaTime->scrollToBottom();
|
||||
|
||||
this->ui->lCurvesDea->setText(QString::number(
|
||||
(double)QVectorHelper::getMinSec3(VecDea) / 1000));
|
||||
theoreticalMinDea = 9999;
|
||||
theoreticalMinDea = QVectorHelper::getMinSec1(VecDea) +
|
||||
QVectorHelper::getMinSec2(VecDea) +
|
||||
QVectorHelper::getMinSec3(VecDea);
|
||||
deltaDea = QVectorHelper::getMin(VecDea) - theoreticalMinDea;
|
||||
this->ui->lDeltaDeaTop->setText(
|
||||
QString::number((double)deltaDea / 1000));
|
||||
if (VecDea.size() > 0) {
|
||||
int zeit = QVectorHelper::getCurTime(VecDea.last());
|
||||
QString statement =
|
||||
"insert into Zeiten (id_rennen, id_fahrer, "
|
||||
"id_auto, id_bahn, zeit) values (" +
|
||||
QString::number(this->renn_id) + ", " +
|
||||
QString::number(this->deaDriverId) + ", " +
|
||||
QString::number(this->deaCarId) + ", 2, " +
|
||||
QString::number(zeit) + ")";
|
||||
// cout << statement.toStdString() << endl;
|
||||
this->db->setData(statement.toStdString());
|
||||
ui->lWDeaTime->scrollToBottom();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
56
windowrace.h
56
windowrace.h
@@ -1,17 +1,17 @@
|
||||
#ifndef WINDOWRACE_H
|
||||
#define WINDOWRACE_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "hardwaresetup.h"
|
||||
#include "counter.h"
|
||||
#include <vector>
|
||||
#include "countdown.h"
|
||||
#include <string>
|
||||
#include "ampel.h"
|
||||
#include "countdown.h"
|
||||
#include "counter.h"
|
||||
#include "database.h"
|
||||
#include "windowrennliste.h"
|
||||
#include <QMessageBox>
|
||||
#include "hardwaresetup.h"
|
||||
#include "timemodel.h"
|
||||
#include "windowrennliste.h"
|
||||
#include <QMainWindow>
|
||||
#include <QMessageBox>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using std::string;
|
||||
|
||||
@@ -19,52 +19,58 @@ namespace Ui {
|
||||
class WindowRace;
|
||||
}
|
||||
|
||||
class WindowRace : public QMainWindow
|
||||
{
|
||||
class WindowRace : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WindowRace(DataBase *db, QWidget *parent = 0);
|
||||
public:
|
||||
explicit WindowRace(DataBase * db, QWidget * parent = 0);
|
||||
~WindowRace();
|
||||
void setWindowRennliste(WindowRennliste *ptrInstance);
|
||||
void setWindowRennliste(WindowRennliste * ptrInstance);
|
||||
void setDriverAndCar(vector<QString> vec);
|
||||
void setDriverAndCarId(vector<QString> vec);
|
||||
|
||||
private:
|
||||
private:
|
||||
int shellDriverId;
|
||||
int deaDriverId;
|
||||
int deaCarId;
|
||||
int shellCarId;
|
||||
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void closeEvent(QCloseEvent * event);
|
||||
bool started;
|
||||
Countdown *countdown;
|
||||
HardwareSetup *Hardware;
|
||||
Ui::WindowRace *ui;
|
||||
Countdown * countdown;
|
||||
HardwareSetup * Hardware;
|
||||
Ui::WindowRace * ui;
|
||||
Counter counterShell;
|
||||
Counter counterDea;
|
||||
bool firstTimeShell;
|
||||
bool firstTimeDea;
|
||||
QVector<QVector<int>> VecShell;
|
||||
QVector<QVector<int>> VecDea;
|
||||
TimeModel *timeModelShell;
|
||||
TimeModel *timeModelDea;
|
||||
TimeModel * timeModelShell;
|
||||
TimeModel * timeModelDea;
|
||||
long getMinimum(std::vector<long> a);
|
||||
QString timeWrapper(long zahl);
|
||||
long countdownValue; //in sec
|
||||
Ampel *startAmpelThread;
|
||||
long countdownValue; // in sec
|
||||
Ampel * startAmpelThread;
|
||||
int ampelCounter;
|
||||
bool paused;
|
||||
DataBase *db;
|
||||
DataBase * db;
|
||||
bool finished;
|
||||
WindowRennliste *wRennliste;
|
||||
WindowRennliste * wRennliste;
|
||||
bool wRennlisteSeted;
|
||||
int fahrzeit;
|
||||
int renn_id;
|
||||
int minimumTime;
|
||||
QVector<int> minSecTime;
|
||||
|
||||
public slots:
|
||||
// sector top times
|
||||
int theoreticalMinShell;
|
||||
int deltaShell;
|
||||
|
||||
int theoreticalMinDea;
|
||||
int deltaDea;
|
||||
|
||||
public slots:
|
||||
void stopClicked();
|
||||
void prepareNextRace();
|
||||
void breakCounter();
|
||||
|
||||
140
windowrace.ui
140
windowrace.ui
@@ -47,7 +47,7 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_12">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="font">
|
||||
@@ -100,6 +100,74 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_14">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_8">
|
||||
<property name="title">
|
||||
<string>Brücke</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_19">
|
||||
<item>
|
||||
<widget class="QLabel" name="lBridgeShell">
|
||||
<property name="text">
|
||||
<string>∞</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_7">
|
||||
<property name="title">
|
||||
<string>Gerade</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_20">
|
||||
<item>
|
||||
<widget class="QLabel" name="lStraightShell">
|
||||
<property name="text">
|
||||
<string>∞</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="title">
|
||||
<string>Kurven</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_21">
|
||||
<item>
|
||||
<widget class="QLabel" name="lCurvesShell">
|
||||
<property name="text">
|
||||
<string>∞</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_5">
|
||||
<property name="title">
|
||||
<string>Delta Topzeit</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_22">
|
||||
<item>
|
||||
<widget class="QLabel" name="lDeltaShellTop">
|
||||
<property name="text">
|
||||
<string>∞</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@@ -581,6 +649,74 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_15">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_12">
|
||||
<property name="title">
|
||||
<string>Brücke</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_23">
|
||||
<item>
|
||||
<widget class="QLabel" name="lBridgeDea">
|
||||
<property name="text">
|
||||
<string>∞</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_11">
|
||||
<property name="title">
|
||||
<string>Gerade</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_24">
|
||||
<item>
|
||||
<widget class="QLabel" name="lStraightDea">
|
||||
<property name="text">
|
||||
<string>∞</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_10">
|
||||
<property name="title">
|
||||
<string>Kurven</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_25">
|
||||
<item>
|
||||
<widget class="QLabel" name="lCurvesDea">
|
||||
<property name="text">
|
||||
<string>∞</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_9">
|
||||
<property name="title">
|
||||
<string>Delta Topzeit</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_26">
|
||||
<item>
|
||||
<widget class="QLabel" name="lDeltaDeaTop">
|
||||
<property name="text">
|
||||
<string>∞</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@@ -640,7 +776,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>840</width>
|
||||
<height>25</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
||||
@@ -27,12 +27,15 @@ WindowsSettings::WindowsSettings(DataBase * db, QWidget * parent)
|
||||
SLOT(SaveDauerAndExitSlot()));
|
||||
|
||||
// update minimal lap time on changeing minimal sector time
|
||||
QObject::connect(this->ui->lEMinTimeSec1, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(repaintMinLapTime()));
|
||||
QObject::connect(this->ui->lEMinTimeSec2, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(repaintMinLapTime()));
|
||||
QObject::connect(this->ui->lEMinTimeSec3, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(repaintMinLapTime()));
|
||||
// QObject::connect(this->ui->lEMinTimeSec1,
|
||||
// SIGNAL(textChanged(QString)),
|
||||
// this, SLOT(repaintMinLapTime()));
|
||||
// QObject::connect(this->ui->lEMinTimeSec2,
|
||||
// SIGNAL(textChanged(QString)),
|
||||
// this, SLOT(repaintMinLapTime()));
|
||||
// QObject::connect(this->ui->lEMinTimeSec3,
|
||||
// SIGNAL(textChanged(QString)),
|
||||
// this, SLOT(repaintMinLapTime()));
|
||||
|
||||
this->db = db;
|
||||
|
||||
@@ -70,8 +73,11 @@ WindowsSettings::WindowsSettings(DataBase * db, QWidget * parent)
|
||||
this->ui->lEMinTimeSec1->setText(res[0][2]);
|
||||
this->ui->lEMinTimeSec2->setText(res[0][3]);
|
||||
this->ui->lEMinTimeSec3->setText(res[0][4]);
|
||||
int minLapTime = res[0][2].toInt() + res[0][3].toInt() + res[0][4].toInt();
|
||||
this->ui->lEMinRundenzeit->setText(QString::number(minLapTime));
|
||||
|
||||
// changed -> not reasonable
|
||||
// int minLapTime = res[0][2].toInt() + res[0][3].toInt() +
|
||||
// res[0][4].toInt();
|
||||
this->ui->lEMinRundenzeit->setText(res[0][1]);
|
||||
|
||||
statement =
|
||||
"SELECT id, minimumroundtime FROM rennen order by id DESC limit 1";
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lEMinRundenzeit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -391,7 +391,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>25</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
||||
Reference in New Issue
Block a user