fix not termintated thread in windowrace + added preparation for highlighting absolute best times
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.4.0, 2017-09-09T12:01:57. -->
|
||||
<!-- Written by QtCreator 4.4.0, 2017-09-12T11:24:18. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
||||
@@ -178,31 +178,35 @@ void HardwareSetup::run(){
|
||||
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 << "Time: vor emit" << (int)buffer[i].time << endl;
|
||||
cout << "Dea Zeit 2: " << (int)buffer[i].time << endl;
|
||||
emit Dea((int)buffer[i].time, 2);
|
||||
break;
|
||||
case 4:
|
||||
// cout << "emit shell" << endl;
|
||||
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(buffer[0].update != 0){
|
||||
cout << "Got " << nBytes << " bytes: " << (int)buffer[2].time << ", " << (int)buffer[2].id << endl;
|
||||
}
|
||||
//}
|
||||
|
||||
if(nBytes < 0)
|
||||
|
||||
@@ -9,6 +9,12 @@ TimeModel::TimeModel(QVector<QVector<int>> timeData, QObject *parent)
|
||||
{
|
||||
this->timeData = timeData;
|
||||
}
|
||||
TimeModel::TimeModel(QVector<QVector<int>> timeData, QVector<int> topTime, QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
this->topTime = topTime;
|
||||
this->timeData = timeData;
|
||||
}
|
||||
|
||||
QVariant TimeModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
@@ -62,7 +68,23 @@ QColor TimeModel::getColor(const QVector<QVector<int>> data, const int col, cons
|
||||
compare.append(data.at(i).at(col));
|
||||
}
|
||||
}
|
||||
if(data.at(row).at(col) == getMin(compare)){
|
||||
if(data.at(row).at(col) == getMin(compare)){ // at least personal best time
|
||||
if(col < 3){ // sector time
|
||||
// std::cout << this->topTime.size() << std::endl;
|
||||
if(this->topTime.size() > col){ // absolute top time exists
|
||||
// std::cout << "local besttime" << std::endl;
|
||||
if(this->topTime.at(col) >= data.at(row).at(col)){
|
||||
return QColor(Qt::magenta);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{ // lap time
|
||||
if(this->topTime.size() == 3){
|
||||
if(this->topTime.at(0) + this->topTime.at(1) + this->topTime.at(2) >= data.at(row).at(col)){
|
||||
return QColor(Qt::magenta);
|
||||
}
|
||||
}
|
||||
}
|
||||
return QColor(Qt::green);
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -11,6 +11,7 @@ class TimeModel : public QAbstractTableModel
|
||||
|
||||
public:
|
||||
explicit TimeModel(QVector<QVector<int>> timeData, QObject *parent = nullptr);
|
||||
explicit TimeModel(QVector<QVector<int>> timeData, QVector<int> topTime, QObject *parent = nullptr);
|
||||
|
||||
// Header:
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
@@ -30,6 +31,7 @@ private:
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
#endif // TIMEMODEL_H
|
||||
|
||||
20
training.cpp
20
training.cpp
@@ -80,17 +80,8 @@ void Training::ResetDea(){
|
||||
this->firstTimeDea = true;
|
||||
}
|
||||
void Training::Reset(){
|
||||
this->VecShell.clear();
|
||||
this->VecDea.clear();
|
||||
// this->ui->lWDeaTime->clear();
|
||||
// this->ui->lWShellTime->clear();
|
||||
|
||||
this->ui->lBestZeitDea->setText("∞");
|
||||
this->ui->lBestZeitShell->setText("∞");
|
||||
this->ui->lCurRoundTimeShell->setText("∞");
|
||||
this->ui->lCurRoundDea->setText("∞");
|
||||
this->firstTimeShell = true;
|
||||
this->firstTimeDea = true;
|
||||
this->ResetDea();
|
||||
this->ResetShell();
|
||||
}
|
||||
void Training::prepareNextRace(){
|
||||
this->firstTimeShell = true;
|
||||
@@ -110,11 +101,12 @@ void Training::prepareNextRace(){
|
||||
}
|
||||
|
||||
void Training::shellSlot(int time, int sector){
|
||||
// cout << "Shell slot" << endl;
|
||||
// slot is called when a sector is finished
|
||||
// time is given in ms
|
||||
// counting of sector beginns at 1
|
||||
|
||||
cout << "received Shelltime: " << time << sector << endl;
|
||||
|
||||
if(started && !paused && !this->finished){
|
||||
if(firstTimeShell){
|
||||
firstTimeShell = false;
|
||||
@@ -177,6 +169,10 @@ void Training::deaSlot(int time, int sector){
|
||||
// slot is called when a sector is finished
|
||||
// time is given in ms
|
||||
// counting of sector beginns at 1
|
||||
|
||||
cout << "received Deatime: " << time << sector << endl;
|
||||
|
||||
|
||||
if(started && !paused && !this->finished){
|
||||
if(firstTimeDea){
|
||||
firstTimeDea = false;
|
||||
|
||||
@@ -25,7 +25,6 @@ WindowRace::WindowRace(DataBase *db, QWidget *parent) :
|
||||
|
||||
this->wRennlisteSeted = false;
|
||||
|
||||
|
||||
this->db = db;
|
||||
|
||||
vector< vector< QString > > res;
|
||||
@@ -240,6 +239,7 @@ void WindowRace::setDriverAndCarId(vector<QString> vec){
|
||||
}
|
||||
void WindowRace::closeEvent(QCloseEvent *event){
|
||||
countdown->setStop();
|
||||
this->Hardware->setStop();
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Wirklich schliessen?");
|
||||
@@ -337,13 +337,18 @@ void WindowRace::shellSlot(int time, int sector){
|
||||
}
|
||||
else{
|
||||
// long zeit = counterShell.getTime();
|
||||
QVector<int> test;
|
||||
switch(sector){
|
||||
case 1:
|
||||
VecShell.append(QVector<int>());
|
||||
VecShell.last().append(time);
|
||||
|
||||
// update tableview
|
||||
this->timeModelShell = new TimeModel(VecShell, this);
|
||||
|
||||
test.append(1);
|
||||
test.append(2);
|
||||
test.append(3);
|
||||
this->timeModelShell = new TimeModel(VecShell, test, this);
|
||||
// this->ui->lWShellTime->setModel(this->timeModelShell);
|
||||
ui->lWShellTime->setModel(this->timeModelShell);
|
||||
break;
|
||||
@@ -354,7 +359,12 @@ void WindowRace::shellSlot(int time, int sector){
|
||||
VecShell.last().append(time);
|
||||
}
|
||||
// update tableview
|
||||
timeModelShell = new TimeModel(VecShell, this);
|
||||
|
||||
test.append(1);
|
||||
test.append(2);
|
||||
test.append(3);
|
||||
this->timeModelShell = new TimeModel(VecShell, test, this);
|
||||
// timeModelShell = new TimeModel(VecShell, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
}
|
||||
break;
|
||||
@@ -370,7 +380,12 @@ void WindowRace::shellSlot(int time, int sector){
|
||||
ui->lCurRoundTimeShell->setText(QString::number((double)QVectorHelper::getCurTime(VecShell.last())/1000));
|
||||
|
||||
// update tableview
|
||||
timeModelShell = new TimeModel(VecShell, this);
|
||||
|
||||
test.append(1);
|
||||
test.append(2);
|
||||
test.append(3);
|
||||
this->timeModelShell = new TimeModel(VecShell, test, this);
|
||||
// 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)+
|
||||
|
||||
Reference in New Issue
Block a user