changed more pointers to smart points
This commit is contained in:
@@ -313,6 +313,7 @@ void HardwareSetup::run() {
|
|||||||
} // end HARDWARE_VERSION 2
|
} // end HARDWARE_VERSION 2
|
||||||
|
|
||||||
else if (HARDWARE_VERSION == 3) {
|
else if (HARDWARE_VERSION == 3) {
|
||||||
|
uint8_t dummy[sizeof(struct TransCheck)] = {0};
|
||||||
|
|
||||||
fd = open(PORT_PATH, O_RDONLY);
|
fd = open(PORT_PATH, O_RDONLY);
|
||||||
while (this->fd < 0) {
|
while (this->fd < 0) {
|
||||||
@@ -360,8 +361,8 @@ void HardwareSetup::run() {
|
|||||||
|
|
||||||
usleep(50000); // 150ms
|
usleep(50000); // 150ms
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++) {
|
|
||||||
if (received->begin == '#' && received->end == '!') {
|
if (received->begin == '#' && received->end == '!') {
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
cout << "i: " << i << " time: "
|
cout << "i: " << i << " time: "
|
||||||
<< static_cast<int>(received->data[i].time)
|
<< static_cast<int>(received->data[i].time)
|
||||||
<< " update: "
|
<< " update: "
|
||||||
@@ -412,12 +413,16 @@ void HardwareSetup::run() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} // dataframe ok
|
} // dataframe ok
|
||||||
else {
|
else {
|
||||||
// dataframe not ok
|
// dataframe not ok
|
||||||
tcflush(fd, TCIFLUSH);
|
tcflush(fd, TCIFLUSH);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// overwrite received data to prevent same data gets read one more
|
||||||
|
// time; dummy data is array of zeros
|
||||||
|
memcpy(received.get(), dummy, sizeof(struct TransCheck));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -56,9 +56,10 @@ MainWindow::~MainWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::WindowTraining() {
|
void MainWindow::WindowTraining() {
|
||||||
// this->interfaceTraining = new Training(this, this->db);
|
{
|
||||||
this->interfaceTraining = std::make_shared<Training>(this, this->db);
|
this->interfaceTraining = std::make_shared<Training>(this, this->db);
|
||||||
this->interfaceTraining->show();
|
this->interfaceTraining->show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::NewWindowSettings() {
|
void MainWindow::NewWindowSettings() {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ int QVectorHelper::getCurTime(const QVector<int> x) {
|
|||||||
int QVectorHelper::getMinSec1(const QVector<QVector<int>> x) {
|
int QVectorHelper::getMinSec1(const QVector<QVector<int>> x) {
|
||||||
int min = 9999;
|
int min = 9999;
|
||||||
if (x.size() > 0) {
|
if (x.size() > 0) {
|
||||||
if (x.at(0).size() >= 3) {
|
if (x.at(0).size() >= 4) {
|
||||||
if (x.at(0).at(0) >= minSec1) {
|
if (x.at(0).at(0) >= minSec1) {
|
||||||
min = x.at(0).at(0);
|
min = x.at(0).at(0);
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ int QVectorHelper::getMinSec1(const QVector<QVector<int>> x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i < x.size(); i++) {
|
for (int i = 1; i < x.size(); i++) {
|
||||||
if (x.at(i).size() >= 1) {
|
if (x.at(i).size() >= 3) { // entire lap
|
||||||
if (x.at(i).at(0) < min) {
|
if (x.at(i).at(0) < min) {
|
||||||
if (x.at(i).at(0) >= minSec1) {
|
if (x.at(i).at(0) >= minSec1) {
|
||||||
min = x.at(i).at(0);
|
min = x.at(i).at(0);
|
||||||
@@ -62,7 +62,7 @@ int QVectorHelper::getMinSec2(const QVector<QVector<int>> x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i < x.size(); i++) {
|
for (int i = 1; i < x.size(); i++) {
|
||||||
if (x.at(0).size() >= 2) {
|
if (x.at(0).size() >= 3) { // entire lap
|
||||||
if (x.at(i).at(1) < min) {
|
if (x.at(i).at(1) < min) {
|
||||||
if (x.at(0).at(1) >= minSec2) {
|
if (x.at(0).at(1) >= minSec2) {
|
||||||
min = x.at(i).at(1);
|
min = x.at(i).at(1);
|
||||||
@@ -89,7 +89,7 @@ int QVectorHelper::getMinSec3(const QVector<QVector<int>> x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i < x.size(); i++) {
|
for (int i = 1; i < x.size(); i++) {
|
||||||
if (x.at(i).size() >= 3) {
|
if (x.at(i).size() >= 3) { // entire lap
|
||||||
if (x.at(i).at(2) < min) {
|
if (x.at(i).at(2) < min) {
|
||||||
if (x.at(0).at(2) >= minSec3) {
|
if (x.at(0).at(2) >= minSec3) {
|
||||||
min = x.at(i).at(2);
|
min = x.at(i).at(2);
|
||||||
|
|||||||
21
training.cpp
21
training.cpp
@@ -3,6 +3,7 @@
|
|||||||
#include "timemodel.h"
|
#include "timemodel.h"
|
||||||
#include "ui_training.h"
|
#include "ui_training.h"
|
||||||
#include "unistd.h"
|
#include "unistd.h"
|
||||||
|
#include <QCloseEvent>
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
@@ -49,13 +50,15 @@ Training::Training(QWidget * parent, std::shared_ptr<DataBase> db)
|
|||||||
// SLOT(prepareNextRace())); QObject::connect(this->ui->pBStop,
|
// SLOT(prepareNextRace())); QObject::connect(this->ui->pBStop,
|
||||||
// SIGNAL(clicked()), this, SLOT(stopClicked()));
|
// SIGNAL(clicked()), this, SLOT(stopClicked()));
|
||||||
|
|
||||||
QShortcut * shortcut = new QShortcut(QKeySequence("Ctrl+Q"), this);
|
shortcut = std::make_shared<QShortcut>(QKeySequence("Ctrl+Q"), this);
|
||||||
QShortcut * shellReset = new QShortcut(QKeySequence("Ctrl+s"), this);
|
shellReset = std::make_shared<QShortcut>(QKeySequence("Ctrl+s"), this);
|
||||||
QShortcut * deaReset = new QShortcut(QKeySequence("Ctrl+d"), this);
|
deaReset = std::make_shared<QShortcut>(QKeySequence("Ctrl+d"), this);
|
||||||
|
|
||||||
QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(close()));
|
QObject::connect(shortcut.get(), SIGNAL(activated()), this, SLOT(close()));
|
||||||
QObject::connect(shellReset, SIGNAL(activated()), this, SLOT(ResetShell()));
|
QObject::connect(shellReset.get(), SIGNAL(activated()), this,
|
||||||
QObject::connect(deaReset, SIGNAL(activated()), this, SLOT(ResetDea()));
|
SLOT(ResetShell()));
|
||||||
|
QObject::connect(deaReset.get(), SIGNAL(activated()), this,
|
||||||
|
SLOT(ResetDea()));
|
||||||
|
|
||||||
QObject::connect(this->ui->pBReset, SIGNAL(clicked()), this, SLOT(Reset()));
|
QObject::connect(this->ui->pBReset, SIGNAL(clicked()), this, SLOT(Reset()));
|
||||||
QObject::connect(this->ui->pBResetDea, SIGNAL(clicked()), this,
|
QObject::connect(this->ui->pBResetDea, SIGNAL(clicked()), this,
|
||||||
@@ -86,7 +89,7 @@ Training::Training(QWidget * parent, std::shared_ptr<DataBase> db)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Training::ResetShell() {
|
void Training::ResetShell() {
|
||||||
|
cout << "reset shell" << endl;
|
||||||
this->VecShell.clear();
|
this->VecShell.clear();
|
||||||
|
|
||||||
// this->ui->lWShellTime->clear();
|
// this->ui->lWShellTime->clear();
|
||||||
@@ -104,6 +107,7 @@ void Training::ResetShell() {
|
|||||||
this->ui->lShellLaps->setText("0");
|
this->ui->lShellLaps->setText("0");
|
||||||
}
|
}
|
||||||
void Training::ResetDea() {
|
void Training::ResetDea() {
|
||||||
|
cout << "reset dea" << endl;
|
||||||
this->VecDea.clear();
|
this->VecDea.clear();
|
||||||
|
|
||||||
// this->ui->lWDeaTime->clear();
|
// this->ui->lWDeaTime->clear();
|
||||||
@@ -255,8 +259,7 @@ void Training::shellSlot(int time, int sector) {
|
|||||||
}
|
}
|
||||||
void Training::closeEvent(QCloseEvent * event) {
|
void Training::closeEvent(QCloseEvent * event) {
|
||||||
Hardware->setStop();
|
Hardware->setStop();
|
||||||
this->close();
|
event->accept();
|
||||||
Q_UNUSED(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Training::deaSlot(int time, int sector) {
|
void Training::deaSlot(int time, int sector) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "hardwaresetup.h"
|
#include "hardwaresetup.h"
|
||||||
#include "timemodel.h"
|
#include "timemodel.h"
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QShortcut>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -53,6 +54,11 @@ class Training : public QMainWindow {
|
|||||||
TimeModel * timeModelShell;
|
TimeModel * timeModelShell;
|
||||||
QVector<int> minSecTime;
|
QVector<int> minSecTime;
|
||||||
|
|
||||||
|
// shortcuts
|
||||||
|
std::shared_ptr<QShortcut> shellReset;
|
||||||
|
std::shared_ptr<QShortcut> shortcut;
|
||||||
|
std::shared_ptr<QShortcut> deaReset;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void ResetShell();
|
void ResetShell();
|
||||||
void ResetDea();
|
void ResetDea();
|
||||||
|
|||||||
Reference in New Issue
Block a user