fixes for usb-support
This commit is contained in:
24
.clang-format
Normal file
24
.clang-format
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
# We'll use defaults from the LLVM style, but with 4 columns indentation.
|
||||
BasedOnStyle: LLVM
|
||||
IndentWidth: 4
|
||||
---
|
||||
Language: Cpp
|
||||
# Force pointers to the type for C++.
|
||||
DerivePointerAlignment: false
|
||||
PointerAlignment: Middle
|
||||
AlignTrailingComments: true
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
BeforeElse: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: InlineOnly
|
||||
---
|
||||
Language: JavaScript
|
||||
# Use 100 columns for JS.
|
||||
ColumnLimit: 100
|
||||
---
|
||||
Language: Proto
|
||||
# Don't format .proto files.
|
||||
DisableFormat: true
|
||||
...
|
||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.o
|
||||
moc_*
|
||||
@@ -51,8 +51,11 @@ FORMS += mainwindow.ui \
|
||||
|
||||
OTHER_FILES +=
|
||||
|
||||
INCLUDEPATH += /home/jpaehr/Dokumente/libusb/libusb
|
||||
#INCLUDEPATH += /home/johannes/Dokumente/libusb/libusb
|
||||
LIBS += -L "/usr/lib" -lusb
|
||||
|
||||
RESOURCES += \
|
||||
resource.qrc
|
||||
|
||||
DISTFILES += \
|
||||
.clang-format
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.4.0, 2017-09-12T15:10:06. -->
|
||||
<!-- Written by QtCreator 4.3.1, 2017-12-24T15:47:52. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{15687edb-7104-42fa-a53c-7d0294bb7338}</value>
|
||||
<value type="QByteArray">{fa7f3dc3-5b46-4468-a19f-ea195cf466a8}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
@@ -54,79 +54,21 @@
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap"/>
|
||||
<valuemap type="QVariantMap">
|
||||
<valuelist type="QVariantList" key="ClangStaticAnalyzer.SuppressedDiagnostics"/>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{e7c8e272-6c95-4fb7-9b69-d295b2ca02f0}</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 5.9.1 in PATH (qt5)</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 5.9.1 in PATH (qt5)</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{48e51839-112c-4842-badf-f2eb9bcf81cb}</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jpaehr/Dokumente/build-RennbahnZeitmessung-Desktop-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
|
||||
<value type="QString">-w</value>
|
||||
<value type="QString">-r</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
|
||||
<value type="QString">-w</value>
|
||||
<value type="QString">-r</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jpaehr/Dokumente/build-RennbahnZeitmessung-Desktop-Release</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/johannes/Dokumente/build-RennbahnZeitmessung-Qt_5_9_1_in_PATH_qt5-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
@@ -172,7 +114,7 @@
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
@@ -185,8 +127,8 @@
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jpaehr/Dokumente/build-RennbahnZeitmessung-Desktop-Profile</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/johannes/Dokumente/build-RennbahnZeitmessung-Qt_5_9_1_in_PATH_qt5-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
@@ -196,7 +138,7 @@
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
@@ -232,29 +174,29 @@
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deployment</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Lokales Deployment</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
@@ -304,13 +246,13 @@
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">RennbahnZeitmessung</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/jpaehr/Dokumente/rennbahnc/RennbahnZeitmessung.pro</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/johannes/Dokumente/rennbahnc/RennbahnZeitmessung.pro</value>
|
||||
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">RennbahnZeitmessung.pro</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/jpaehr/Dokumente/build-RennbahnZeitmessung-Desktop-Debug</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/johannes/Dokumente/build-RennbahnZeitmessung-Qt_5_9_1_in_PATH_qt5-Release</value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "ampel.h"
|
||||
#include <unistd.h>
|
||||
|
||||
Ampel::Ampel()
|
||||
{
|
||||
Ampel::Ampel() {
|
||||
this->running = 1;
|
||||
}
|
||||
void Ampel::setStop() {
|
||||
@@ -22,4 +21,3 @@ void Ampel::run(){
|
||||
emit ampelUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "countdown.h"
|
||||
#include "unistd.h"
|
||||
Countdown::Countdown()
|
||||
{
|
||||
Countdown::Countdown() {
|
||||
this->running = 1;
|
||||
}
|
||||
void Countdown::setStop() {
|
||||
|
||||
12
counter.cpp
12
counter.cpp
@@ -1,11 +1,9 @@
|
||||
#include "counter.h"
|
||||
#include <sys/time.h>
|
||||
#include <iostream>
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
#include <sys/time.h>
|
||||
|
||||
Counter::Counter()
|
||||
{
|
||||
|
||||
Counter::Counter() {
|
||||
}
|
||||
|
||||
void Counter::start() {
|
||||
@@ -14,8 +12,8 @@ void Counter::start(){
|
||||
|
||||
long Counter::getTime() {
|
||||
gettimeofday(&endTime, NULL);
|
||||
long back = (endTime.tv_usec-startTime.tv_usec)/1000+(endTime.tv_sec-startTime.tv_sec)*1000;
|
||||
long back = (endTime.tv_usec - startTime.tv_usec) / 1000 +
|
||||
(endTime.tv_sec - startTime.tv_sec) * 1000;
|
||||
this->start();
|
||||
return back;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
#include "database.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <QVariant>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
using std::vector;
|
||||
|
||||
DataBase::DataBase()
|
||||
{
|
||||
DataBase::DataBase() {
|
||||
this->db = new QSqlDatabase();
|
||||
*this->db = QSqlDatabase::addDatabase("QSQLITE");
|
||||
this->db->setDatabaseName("Renndatenbank.sqlite");
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "hardwaresetup.h"
|
||||
#include <unistd.h>
|
||||
#include "sys/io.h"
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <usb.h>
|
||||
|
||||
#define USB_LED_ON 1
|
||||
@@ -17,8 +17,7 @@ using namespace std;
|
||||
// #define BASEPORT 0x378
|
||||
// #define BASEPORT 0xd000
|
||||
|
||||
HardwareSetup::HardwareSetup()
|
||||
{
|
||||
HardwareSetup::HardwareSetup() {
|
||||
// if (ioperm(BASEPORT, 3, 1)) {
|
||||
// //perror("ioperm");
|
||||
// }
|
||||
@@ -39,27 +38,26 @@ HardwareSetup::~HardwareSetup(){
|
||||
usb_close(this->handle);
|
||||
}
|
||||
this->handle = NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Used to get descriptor strings for device identification */
|
||||
int HardwareSetup::usbGetDescriptorString(usb_dev_handle *dev, int index, int langid,
|
||||
char *buf, int buflen) {
|
||||
int HardwareSetup::usbGetDescriptorString(usb_dev_handle * dev, int index,
|
||||
int langid, char * buf, int buflen) {
|
||||
char buffer[256];
|
||||
int rval, i;
|
||||
|
||||
// make standard request GET_DESCRIPTOR, type string and given index
|
||||
// (e.g. dev->iProduct)
|
||||
rval = usb_control_msg(dev,
|
||||
USB_TYPE_STANDARD | USB_RECIP_DEVICE | USB_ENDPOINT_IN,
|
||||
USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) + index, langid,
|
||||
buffer, sizeof(buffer), 1000);
|
||||
rval = usb_control_msg(
|
||||
dev, USB_TYPE_STANDARD | USB_RECIP_DEVICE | USB_ENDPOINT_IN,
|
||||
USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) + index, langid, buffer,
|
||||
sizeof(buffer), 1000);
|
||||
|
||||
if (rval < 0) // error
|
||||
return rval;
|
||||
|
||||
// rval should be bytes read, but buffer[0] contains the actual response size
|
||||
// rval should be bytes read, but buffer[0] contains the actual response
|
||||
// size
|
||||
if ((unsigned char)buffer[0] < rval)
|
||||
rval = (unsigned char)buffer[0]; // string is shorter than bytes read
|
||||
|
||||
@@ -82,8 +80,6 @@ int HardwareSetup::usbGetDescriptorString(usb_dev_handle *dev, int index, int la
|
||||
return i - 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
usb_dev_handle * HardwareSetup::usbOpenDevice(int vendor, char * vendorName,
|
||||
int product, char * productName) {
|
||||
struct usb_bus * bus;
|
||||
@@ -111,7 +107,8 @@ usb_dev_handle * HardwareSetup::usbOpenDevice(int vendor, char *vendorName,
|
||||
|
||||
/* get vendor name */
|
||||
if (usbGetDescriptorString(handle, dev->descriptor.iManufacturer,
|
||||
0x0409, devVendor, sizeof(devVendor)) < 0) {
|
||||
0x0409, devVendor,
|
||||
sizeof(devVendor)) < 0) {
|
||||
fprintf(stderr,
|
||||
"Warning: cannot query manufacturer for device: %sn",
|
||||
usb_strerror());
|
||||
@@ -120,10 +117,9 @@ usb_dev_handle * HardwareSetup::usbOpenDevice(int vendor, char *vendorName,
|
||||
}
|
||||
|
||||
/* get product name */
|
||||
if(usbGetDescriptorString(handle, dev->descriptor.iProduct,
|
||||
0x0409, devProduct, sizeof(devVendor)) < 0) {
|
||||
fprintf(stderr,
|
||||
"Warning: cannot query product for device: %sn",
|
||||
if (usbGetDescriptorString(handle, dev->descriptor.iProduct, 0x0409,
|
||||
devProduct, sizeof(devVendor)) < 0) {
|
||||
fprintf(stderr, "Warning: cannot query product for device: %sn",
|
||||
usb_strerror());
|
||||
usb_close(handle);
|
||||
continue;
|
||||
@@ -139,12 +135,11 @@ usb_dev_handle * HardwareSetup::usbOpenDevice(int vendor, char *vendorName,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void HardwareSetup::run() {
|
||||
|
||||
int nBytes = 0;
|
||||
// char buffer[256];
|
||||
struct TransStruct buffer[2];
|
||||
struct TransStruct buffer[6];
|
||||
// struct TransStruct *buffer = buffer1;
|
||||
// cout << "thread started" << endl;
|
||||
|
||||
@@ -163,18 +158,16 @@ void HardwareSetup::run(){
|
||||
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,
|
||||
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 < 2; i++){
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (buffer[i].update != 0) {
|
||||
switch (buffer[i].id) {
|
||||
case 0:
|
||||
@@ -205,28 +198,25 @@ void HardwareSetup::run(){
|
||||
}
|
||||
}
|
||||
if (buffer[0].update != 0) {
|
||||
cout << "Got " << nBytes << " bytes: " << (int)buffer[2].time << ", " << (int)buffer[2].id << endl;
|
||||
cout << "Got " << nBytes << " bytes: " << (int)buffer[2].time
|
||||
<< ", " << (int)buffer[2].id << endl;
|
||||
}
|
||||
//}
|
||||
|
||||
if (nBytes < 0)
|
||||
fprintf(stderr, "USB error: %sn", usb_strerror());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool HardwareSetup::getShell() {
|
||||
|
||||
// int zahl[8] = {0};
|
||||
|
||||
// if(findBit(zahl, inb(BASEPORT + 1))[7] == 1){
|
||||
|
||||
|
||||
// return true;
|
||||
// }
|
||||
return false;
|
||||
|
||||
}
|
||||
bool HardwareSetup::getDea() {
|
||||
|
||||
|
||||
3
main.cpp
3
main.cpp
@@ -1,8 +1,7 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int main(int argc, char * argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
#include "mainwindow.h"
|
||||
#include "database.h"
|
||||
#include "hardwaresetup.h"
|
||||
#include "training.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "unistd.h"
|
||||
#include "windowrace.h"
|
||||
#include "windowrennliste2.h"
|
||||
#include "windowssettings.h"
|
||||
#include <QObject>
|
||||
#include <QShortcut>
|
||||
#include "windowssettings.h"
|
||||
#include <iostream>
|
||||
#include "hardwaresetup.h"
|
||||
#include "windowrace.h"
|
||||
#include "database.h"
|
||||
#include <vector>
|
||||
#include "windowrennliste2.h"
|
||||
#include "training.h"
|
||||
#include "unistd.h"
|
||||
using std::vector;
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
MainWindow::MainWindow(QWidget * parent)
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||
ui->setupUi(this);
|
||||
this->interfaceTraining = NULL;
|
||||
|
||||
@@ -27,34 +25,32 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
// test = new HardwareSetup;
|
||||
|
||||
// this->test->start();
|
||||
QObject::connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(NewWindowSettings()));
|
||||
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()));
|
||||
QObject::connect(ui->pBRennen, SIGNAL(clicked()), this,
|
||||
SLOT(WindowRennen()));
|
||||
QObject::connect(this->ui->pBTraining, SIGNAL(clicked()), this,
|
||||
SLOT(WindowTraining()));
|
||||
|
||||
QShortcut * startTraining = new QShortcut(QKeySequence("Ctrl+t"), this);
|
||||
QShortcut * startRennen = new QShortcut(QKeySequence("Ctrl+r"), this);
|
||||
|
||||
QObject::connect(startTraining, SIGNAL(activated()), this, SLOT(WindowTraining()));
|
||||
QObject::connect(startRennen, SIGNAL(activated()), this, SLOT(WindowRennen()));
|
||||
|
||||
|
||||
QObject::connect(startTraining, SIGNAL(activated()), this,
|
||||
SLOT(WindowTraining()));
|
||||
QObject::connect(startRennen, SIGNAL(activated()), this,
|
||||
SLOT(WindowRennen()));
|
||||
|
||||
this->db = new DataBase;
|
||||
|
||||
vector<vector<QString>> daten = db->getData("select * from Fahrer", 2);
|
||||
|
||||
|
||||
}
|
||||
void MainWindow::closeEvent(QCloseEvent * event) {
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
MainWindow::~MainWindow() {
|
||||
delete this->db;
|
||||
delete ui;
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::WindowTraining() {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#include "qvectorhelper.h"
|
||||
#include <qvector.h>
|
||||
|
||||
QVectorHelper::QVectorHelper()
|
||||
{
|
||||
|
||||
QVectorHelper::QVectorHelper() {
|
||||
}
|
||||
|
||||
int QVectorHelper::getCurTime(const QVector<int> x) {
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
#include "timemodel.h"
|
||||
#include<qvector.h>
|
||||
#include <iostream>
|
||||
#include <qcolor.h>
|
||||
#include <qvector.h>
|
||||
|
||||
|
||||
TimeModel::TimeModel(QVector<QVector<int>> timeData, QVector<int> minimumTimes, QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
TimeModel::TimeModel(QVector<QVector<int>> timeData, QVector<int> minimumTimes,
|
||||
QObject * parent)
|
||||
: QAbstractTableModel(parent) {
|
||||
this->timeData = timeData;
|
||||
this->minimumTimes = minimumTimes;
|
||||
}
|
||||
TimeModel::TimeModel(QVector<QVector<int>> timeData, QVector<int> minimumTimes, QVector<int> topTime, QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
TimeModel::TimeModel(QVector<QVector<int>> timeData, QVector<int> minimumTimes,
|
||||
QVector<int> topTime, QObject * parent)
|
||||
: QAbstractTableModel(parent) {
|
||||
this->topTime = topTime;
|
||||
this->timeData = timeData;
|
||||
this->minimumTimes = minimumTimes;
|
||||
}
|
||||
|
||||
QVariant TimeModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
QVariant TimeModel::headerData(int section, Qt::Orientation orientation,
|
||||
int role) const {
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
@@ -43,22 +42,21 @@ QVariant TimeModel::headerData(int section, Qt::Orientation orientation, int rol
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int TimeModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
int TimeModel::rowCount(const QModelIndex & parent) const {
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
|
||||
return this->timeData.size();
|
||||
}
|
||||
|
||||
int TimeModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
int TimeModel::columnCount(const QModelIndex & parent) const {
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
return 4;
|
||||
}
|
||||
|
||||
QColor TimeModel::getColor(const QVector<QVector<int>> data, const int col, const int row) const{
|
||||
QColor TimeModel::getColor(const QVector<QVector<int>> data, const int col,
|
||||
const int row) const {
|
||||
if (row == 0) {
|
||||
return QColor(Qt::gray);
|
||||
}
|
||||
@@ -71,9 +69,9 @@ QColor TimeModel::getColor(const QVector<QVector<int>> data, const int col, cons
|
||||
}
|
||||
else {
|
||||
// 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)){
|
||||
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)) {
|
||||
return QColor(Qt::red);
|
||||
}
|
||||
}
|
||||
@@ -84,11 +82,15 @@ 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)){ // at least personal best time
|
||||
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;
|
||||
// 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);
|
||||
}
|
||||
@@ -96,7 +98,9 @@ QColor TimeModel::getColor(const QVector<QVector<int>> data, const int col, cons
|
||||
}
|
||||
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)){
|
||||
if (this->topTime.at(0) + this->topTime.at(1) +
|
||||
this->topTime.at(2) >=
|
||||
data.at(row).at(col)) {
|
||||
return QColor(Qt::magenta);
|
||||
}
|
||||
}
|
||||
@@ -129,15 +133,15 @@ int TimeModel::getMin(const QVector<int> x) const{
|
||||
return min;
|
||||
}
|
||||
|
||||
QVariant TimeModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
QVariant TimeModel::data(const QModelIndex & index, int role) const {
|
||||
// std::cout << "data called" << std::endl;
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
if (timeData.at(index.row()).size() > index.column()) {
|
||||
return QString::number((double)timeData.at(index.row()).at(index.column())/1000);
|
||||
return QString::number(
|
||||
(double)timeData.at(index.row()).at(index.column()) / 1000);
|
||||
}
|
||||
else {
|
||||
return QString("∞");
|
||||
@@ -149,17 +153,18 @@ QVariant TimeModel::data(const QModelIndex &index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool TimeModel::insertRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
bool TimeModel::insertRows(int row, int count, const QModelIndex & parent) {
|
||||
// std::cout << "insert triggert" << std::endl;
|
||||
beginInsertRows(parent, row, row + count - 1);
|
||||
// FIXME: Implement me!
|
||||
endInsertRows();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TimeModel::insertColumns(int column, int count, const QModelIndex &parent)
|
||||
{
|
||||
bool TimeModel::insertColumns(int column, int count,
|
||||
const QModelIndex & parent) {
|
||||
beginInsertColumns(parent, column, column + count - 1);
|
||||
// FIXME: Implement me!
|
||||
endInsertColumns();
|
||||
return true;
|
||||
}
|
||||
|
||||
113
training.cpp
113
training.cpp
@@ -1,27 +1,26 @@
|
||||
#include "training.h"
|
||||
#include "qvectorhelper.h"
|
||||
#include "timemodel.h"
|
||||
#include "ui_training.h"
|
||||
#include <QObject>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <QShortcut>
|
||||
#include "unistd.h"
|
||||
#include <QListWidgetItem>
|
||||
#include "timemodel.h"
|
||||
#include "qvectorhelper.h"
|
||||
#include <QObject>
|
||||
#include <QShortcut>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
Training::Training(QWidget *parent, DataBase *db) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::Training)
|
||||
{
|
||||
Training::Training(QWidget * parent, DataBase * db)
|
||||
: QMainWindow(parent), ui(new Ui::Training) {
|
||||
ui->setupUi(this);
|
||||
this->db = db;
|
||||
string statement = "select mindestrundendauer from renndauer where id like 1";
|
||||
string statement =
|
||||
"select mindestrundendauer from renndauer where id like 1";
|
||||
|
||||
this->minimumTime = this->db->getData(statement, 1)[0][0].toInt();
|
||||
this->finished = false;
|
||||
@@ -35,13 +34,13 @@ Training::Training(QWidget *parent, DataBase *db) :
|
||||
this->Hardware = new HardwareSetup;
|
||||
Hardware->start();
|
||||
|
||||
|
||||
|
||||
|
||||
QObject::connect(Hardware, SIGNAL(Dea(int, int)), this, SLOT(deaSlot(int, int)));
|
||||
QObject::connect(Hardware, SIGNAL(Shell(int, int)), this, SLOT(shellSlot(int, int)));
|
||||
//QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()), this, SLOT(prepareNextRace()));
|
||||
//QObject::connect(this->ui->pBStop, SIGNAL(clicked()), this, SLOT(stopClicked()));
|
||||
QObject::connect(Hardware, SIGNAL(Dea(int, int)), this,
|
||||
SLOT(deaSlot(int, int)));
|
||||
QObject::connect(Hardware, SIGNAL(Shell(int, int)), this,
|
||||
SLOT(shellSlot(int, int)));
|
||||
// QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()), this,
|
||||
// SLOT(prepareNextRace())); QObject::connect(this->ui->pBStop,
|
||||
// SIGNAL(clicked()), this, SLOT(stopClicked()));
|
||||
|
||||
QShortcut * shortcut = new QShortcut(QKeySequence("Ctrl+Q"), this);
|
||||
QShortcut * shellReset = new QShortcut(QKeySequence("Ctrl+s"), this);
|
||||
@@ -52,17 +51,19 @@ Training::Training(QWidget *parent, DataBase *db) :
|
||||
QObject::connect(deaReset, SIGNAL(activated()), this, SLOT(ResetDea()));
|
||||
|
||||
QObject::connect(this->ui->pBReset, SIGNAL(clicked()), this, SLOT(Reset()));
|
||||
QObject::connect(this->ui->pBResetDea, SIGNAL(clicked()), this, SLOT(ResetDea()));
|
||||
QObject::connect(this->ui->pBResetShell, SIGNAL(clicked()), this, SLOT(ResetShell()));
|
||||
QObject::connect(this->ui->pBResetDea, SIGNAL(clicked()), this,
|
||||
SLOT(ResetDea()));
|
||||
QObject::connect(this->ui->pBResetShell, SIGNAL(clicked()), this,
|
||||
SLOT(ResetShell()));
|
||||
|
||||
// fill minSecTimes vector
|
||||
statement = "select minsec1, minsec2, minsec3 from renndauer order by id DESC limit 1";
|
||||
statement = "select minsec1, minsec2, minsec3 from renndauer order by id "
|
||||
"DESC limit 1";
|
||||
vector<vector<QString>> res;
|
||||
res = db->getData(statement, 3);
|
||||
this->minSecTime.append(res[0][0].toInt());
|
||||
this->minSecTime.append(res[0][1].toInt());
|
||||
this->minSecTime.append(res[0][2].toInt());
|
||||
|
||||
}
|
||||
void Training::ResetShell() {
|
||||
this->VecShell.clear();
|
||||
@@ -132,9 +133,11 @@ void Training::shellSlot(int time, int sector){
|
||||
case 2:
|
||||
if (VecShell.size() > 0) {
|
||||
if (VecShell.last().size() == 1) {
|
||||
// cout << time << sector << endl;
|
||||
// cout << time << sector <<
|
||||
// endl;
|
||||
VecShell.last().push_back(time);
|
||||
timeModelShell = new TimeModel(VecShell, minSecTime, this);
|
||||
timeModelShell =
|
||||
new TimeModel(VecShell, minSecTime, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
}
|
||||
}
|
||||
@@ -143,28 +146,35 @@ void Training::shellSlot(int time, int sector){
|
||||
if (VecShell.size() > 0) {
|
||||
// cout << "Time sec 3: " << time << endl;
|
||||
if (VecShell.last().size() == 2) {
|
||||
// cout << time << sector << endl;
|
||||
// cout << time << sector <<
|
||||
// endl;
|
||||
VecShell.last().push_back(time);
|
||||
|
||||
// add sum to vector
|
||||
VecShell.last().push_back(QVectorHelper::getCurTime(VecShell.last()));
|
||||
VecShell.last().push_back(
|
||||
QVectorHelper::getCurTime(VecShell.last()));
|
||||
|
||||
timeModelShell = new TimeModel(VecShell, minSecTime, this);
|
||||
timeModelShell =
|
||||
new TimeModel(VecShell, minSecTime, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
}
|
||||
// best time on widget
|
||||
|
||||
if(QVectorHelper::getCurTime(VecShell.last()) <= QVectorHelper::getMin(VecShell)){
|
||||
ui->lBestZeitShell->setText(QString::number((double)QVectorHelper::getMin(VecShell)/1000));
|
||||
if (QVectorHelper::getCurTime(VecShell.last()) <=
|
||||
QVectorHelper::getMin(VecShell)) {
|
||||
ui->lBestZeitShell->setText(QString::number(
|
||||
(double)QVectorHelper::getMin(VecShell) / 1000));
|
||||
}
|
||||
ui->lCurRoundTimeShell->setText(QString::number((double)QVectorHelper::getCurTime(VecShell.last())/1000));
|
||||
ui->lCurRoundTimeShell->setText(QString::number(
|
||||
(double)QVectorHelper::getCurTime(VecShell.last()) /
|
||||
1000));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
ui->lWShellTime->scrollToBottom();
|
||||
ui->lWShellTime->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
|
||||
ui->lWShellTime->horizontalHeader()->setSectionResizeMode(
|
||||
QHeaderView::Stretch);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,7 +190,6 @@ void Training::deaSlot(int time, int sector){
|
||||
|
||||
cout << "received Deatime: " << time << sector << endl;
|
||||
|
||||
|
||||
if (started && !paused && !this->finished) {
|
||||
if (firstTimeDea) {
|
||||
firstTimeDea = false;
|
||||
@@ -198,7 +207,8 @@ void Training::deaSlot(int time, int sector){
|
||||
case 2:
|
||||
if (VecDea.size() > 0) {
|
||||
if (VecDea.last().size() == 1) {
|
||||
// cout << time << sector << endl;
|
||||
// cout << time << sector <<
|
||||
// endl;
|
||||
VecDea[VecDea.size() - 1].push_back(time);
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
@@ -212,33 +222,42 @@ void Training::deaSlot(int time, int sector){
|
||||
if (VecDea.size() > 0) {
|
||||
// cout << "Time sec 3: " << time << endl;
|
||||
if (VecDea.last().size() == 2) {
|
||||
// cout << time << sector << endl;
|
||||
// cout << time << sector <<
|
||||
// endl;
|
||||
VecDea.last().push_back(time);
|
||||
|
||||
// add sum to vector
|
||||
VecDea.last().push_back(QVectorHelper::getCurTime(VecDea.last()));
|
||||
VecDea.last().push_back(
|
||||
QVectorHelper::getCurTime(VecDea.last()));
|
||||
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
}
|
||||
// best time on widget
|
||||
// cout << "cur time: " << QVectorHelper::getCurTime(VecDea.last()) << endl;
|
||||
// cout << "min time: " << QVectorHelper::getMin(VecDea) << endl;
|
||||
if(QVectorHelper::getCurTime(VecDea.last()) <= QVectorHelper::getMin(VecDea)){
|
||||
ui->lBestZeitDea->setText(QString::number((double)QVectorHelper::getMin(VecDea)/1000));
|
||||
// cout << "cur time: " <<
|
||||
// QVectorHelper::getCurTime(VecDea.last())
|
||||
// << endl; cout << "min time: " <<
|
||||
// QVectorHelper::getMin(VecDea) <<
|
||||
// endl;
|
||||
if (QVectorHelper::getCurTime(VecDea.last()) <=
|
||||
QVectorHelper::getMin(VecDea)) {
|
||||
ui->lBestZeitDea->setText(QString::number(
|
||||
(double)QVectorHelper::getMin(VecDea) / 1000));
|
||||
}
|
||||
ui->lCurRoundDea->setText(QString::number((double)QVectorHelper::getCurTime(VecDea.last())/1000));
|
||||
ui->lCurRoundDea->setText(QString::number(
|
||||
(double)QVectorHelper::getCurTime(VecDea.last()) /
|
||||
1000));
|
||||
}
|
||||
break;
|
||||
}
|
||||
ui->lWDeaTime->scrollToBottom();
|
||||
ui->lWDeaTime->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
ui->lWDeaTime->horizontalHeader()->setSectionResizeMode(
|
||||
QHeaderView::Stretch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Training::~Training()
|
||||
{
|
||||
Training::~Training() {
|
||||
cout << "destr Training" << endl;
|
||||
this->Hardware->setStop();
|
||||
usleep(1000000);
|
||||
|
||||
181
windowrace.cpp
181
windowrace.cpp
@@ -1,24 +1,22 @@
|
||||
#include "windowrace.h"
|
||||
#include "ui_windowrace.h"
|
||||
#include <QObject>
|
||||
#include <string>
|
||||
#include <QShortcut>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include "unistd.h"
|
||||
#include <QKeySequence>
|
||||
#include "qvectorhelper.h"
|
||||
#include "timemodel.h"
|
||||
#include "ui_windowrace.h"
|
||||
#include "unistd.h"
|
||||
#include <QKeySequence>
|
||||
#include <QObject>
|
||||
#include <QShortcut>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
WindowRace::WindowRace(DataBase *db, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::WindowRace)
|
||||
{
|
||||
WindowRace::WindowRace(DataBase * db, QWidget * parent)
|
||||
: QMainWindow(parent), ui(new Ui::WindowRace) {
|
||||
ui->setupUi(this);
|
||||
this->ui->pBNextRace->setEnabled(false);
|
||||
this->finished = false;
|
||||
@@ -31,18 +29,19 @@ WindowRace::WindowRace(DataBase *db, QWidget *parent) :
|
||||
res = db->getData("select dauer from renndauer", 1);
|
||||
this->fahrzeit = res[0][0].toInt();
|
||||
|
||||
string statement = "select minimumroundtime from rennen order by id DESC limit 1";
|
||||
string statement =
|
||||
"select minimumroundtime from rennen order by id DESC limit 1";
|
||||
res = db->getData(statement, 1);
|
||||
this->minimumTime = res[0][0].toInt();
|
||||
|
||||
// fill minSecTimes vector
|
||||
statement = "select minsec1, minsec2, minsec3 from renndauer order by id DESC limit 1";
|
||||
statement = "select minsec1, minsec2, minsec3 from renndauer order by id "
|
||||
"DESC limit 1";
|
||||
res = db->getData(statement, 3);
|
||||
this->minSecTime.append(res[0][0].toInt());
|
||||
this->minSecTime.append(res[0][1].toInt());
|
||||
this->minSecTime.append(res[0][2].toInt());
|
||||
|
||||
|
||||
firstTimeDea = true;
|
||||
firstTimeShell = true;
|
||||
started = false;
|
||||
@@ -59,16 +58,23 @@ WindowRace::WindowRace(DataBase *db, QWidget *parent) :
|
||||
Hardware = new HardwareSetup;
|
||||
Hardware->start();
|
||||
|
||||
QObject::connect(Hardware, SIGNAL(Dea(int, int)), this, SLOT(deaSlot(int, int)));
|
||||
QObject::connect(Hardware, SIGNAL(Shell(int, int)), this, SLOT(shellSlot(int, int)));
|
||||
QObject::connect(Hardware, SIGNAL(Dea(int, int)), this,
|
||||
SLOT(deaSlot(int, int)));
|
||||
QObject::connect(Hardware, SIGNAL(Shell(int, int)), this,
|
||||
SLOT(shellSlot(int, int)));
|
||||
QObject::connect(ui->pBStart, SIGNAL(clicked()), this, SLOT(go()));
|
||||
QObject::connect(countdown, SIGNAL(CountdownUpdate()), this, SLOT(countdownUpdate()));
|
||||
QObject::connect(startAmpelThread, SIGNAL(ampelUpdate()), this, SLOT(ampelSlot()));
|
||||
QObject::connect(startAmpelThread, SIGNAL(ampelUpdate()), this, SLOT(laufcheck()));
|
||||
QObject::connect(ui->pBBreak, SIGNAL(clicked()), this, SLOT(breakCounter()));
|
||||
QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()), this, SLOT(prepareNextRace()));
|
||||
QObject::connect(this->ui->pBStop, SIGNAL(clicked()), this, SLOT(stopClicked()));
|
||||
|
||||
QObject::connect(countdown, SIGNAL(CountdownUpdate()), this,
|
||||
SLOT(countdownUpdate()));
|
||||
QObject::connect(startAmpelThread, SIGNAL(ampelUpdate()), this,
|
||||
SLOT(ampelSlot()));
|
||||
QObject::connect(startAmpelThread, SIGNAL(ampelUpdate()), this,
|
||||
SLOT(laufcheck()));
|
||||
QObject::connect(ui->pBBreak, SIGNAL(clicked()), this,
|
||||
SLOT(breakCounter()));
|
||||
QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()), this,
|
||||
SLOT(prepareNextRace()));
|
||||
QObject::connect(this->ui->pBStop, SIGNAL(clicked()), this,
|
||||
SLOT(stopClicked()));
|
||||
|
||||
ui->lCountdown->setText(timeWrapper(countdownValue));
|
||||
|
||||
@@ -94,28 +100,33 @@ WindowRace::WindowRace(DataBase *db, QWidget *parent) :
|
||||
ui->hW11->setVisible(true);
|
||||
ui->hW21->setVisible(true);
|
||||
|
||||
|
||||
vector<vector<QString>> fahrer, autos, rennid, tableData;
|
||||
statement = "select id_rennen from aktrennen group by id_rennen order by id_rennen DESC limit 1";
|
||||
statement = "select id_rennen from aktrennen group by id_rennen order by "
|
||||
"id_rennen DESC limit 1";
|
||||
rennid = this->db->getData(statement, 1);
|
||||
this->renn_id = rennid[0][0].toInt();
|
||||
statement = "select fahrershellid, autoshellid, fahrerdeaid, autodeaid from aktrennen where id_rennen like "+rennid[0][0].toStdString()+" limit 1";
|
||||
statement = "select fahrershellid, autoshellid, fahrerdeaid, autodeaid "
|
||||
"from aktrennen where id_rennen like " +
|
||||
rennid[0][0].toStdString() + " limit 1";
|
||||
|
||||
tableData = db->getData2(statement, 4);
|
||||
|
||||
|
||||
statement = "select name from fahrer where id like " + tableData[0][0].toStdString();
|
||||
statement = "select name from fahrer where id like " +
|
||||
tableData[0][0].toStdString();
|
||||
fahrer = this->db->getData2(statement, 1);
|
||||
|
||||
statement = "select name from AutoKonfiguration where id_auto like " + tableData[0][1].toStdString()+" order by seit DESC";
|
||||
statement = "select name from AutoKonfiguration where id_auto like " +
|
||||
tableData[0][1].toStdString() + " order by seit DESC";
|
||||
autos = this->db->getData2(statement, 1);
|
||||
|
||||
this->ui->gbShell->setTitle("Shell, " + fahrer[0][0] + ", " + autos[0][0]);
|
||||
|
||||
statement = "select name from fahrer where id like " + tableData[0][2].toStdString();
|
||||
statement = "select name from fahrer where id like " +
|
||||
tableData[0][2].toStdString();
|
||||
fahrer = this->db->getData2(statement, 1);
|
||||
|
||||
statement = "select name from AutoKonfiguration where id_auto like " + tableData[0][3].toStdString()+" order by seit DESC";
|
||||
statement = "select name from AutoKonfiguration where id_auto like " +
|
||||
tableData[0][3].toStdString() + " order by seit DESC";
|
||||
autos = this->db->getData2(statement, 1);
|
||||
|
||||
this->ui->gbDea->setTitle("Dea, " + fahrer[0][0] + ", " + autos[0][0]);
|
||||
@@ -137,7 +148,6 @@ WindowRace::WindowRace(DataBase *db, QWidget *parent) :
|
||||
QObject::connect(keyReturn, SIGNAL(activated()), this, SLOT(ReturnPress()));
|
||||
|
||||
// QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(close()));
|
||||
|
||||
}
|
||||
|
||||
void WindowRace::ReturnPress() {
|
||||
@@ -229,21 +239,20 @@ void WindowRace::setDriverAndCar(vector<QString> vec){
|
||||
}
|
||||
void WindowRace::stopClicked() {
|
||||
this->prepareNextRace();
|
||||
|
||||
}
|
||||
|
||||
void WindowRace::setWindowRennliste(WindowRennliste * ptrInstance) {
|
||||
|
||||
this->wRennliste = ptrInstance;
|
||||
this->wRennlisteSeted = true;
|
||||
QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()), this->wRennliste, SLOT(changeSelection()));
|
||||
QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()), this->wRennliste,
|
||||
SLOT(changeSelection()));
|
||||
}
|
||||
void WindowRace::setDriverAndCarId(vector<QString> vec) {
|
||||
this->shellDriverId = vec[0].toInt();
|
||||
this->shellCarId = vec[1].toInt();
|
||||
this->deaDriverId = vec[2].toInt();
|
||||
this->deaCarId = vec[3].toInt();
|
||||
|
||||
}
|
||||
void WindowRace::closeEvent(QCloseEvent * event) {
|
||||
countdown->setStop();
|
||||
@@ -279,7 +288,6 @@ void WindowRace::breakCounter(){
|
||||
ui->pBBreak->setText("Pause");
|
||||
paused = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void WindowRace::laufcheck() {
|
||||
@@ -306,12 +314,14 @@ void WindowRace::countdownUpdate(){
|
||||
countdownValue -= 1;
|
||||
if (countdownValue <= 15) {
|
||||
this->ui->lCountdown->setStyleSheet("QLabel { color: red; }");
|
||||
this->ui->pbTime->setStyleSheet( "QProgressBar::chunk { background-color: orange; }");
|
||||
this->ui->pbTime->setStyleSheet(
|
||||
"QProgressBar::chunk { background-color: orange; }");
|
||||
// this->ui->pbTime->
|
||||
}
|
||||
if (countdownValue <= -1) {
|
||||
this->finished = true;
|
||||
this->wRennliste->setBesttime(QVectorHelper::getMin(VecShell),QVectorHelper::getMin(this->VecDea));
|
||||
this->wRennliste->setBesttime(QVectorHelper::getMin(VecShell),
|
||||
QVectorHelper::getMin(this->VecDea));
|
||||
this->ui->pBNextRace->setEnabled(true);
|
||||
}
|
||||
else {
|
||||
@@ -321,9 +331,7 @@ void WindowRace::countdownUpdate(){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WindowRace::~WindowRace()
|
||||
{
|
||||
WindowRace::~WindowRace() {
|
||||
this->startAmpelThread->setStop();
|
||||
this->countdown->setStop();
|
||||
this->Hardware->setStop();
|
||||
@@ -356,7 +364,8 @@ void WindowRace::shellSlot(int time, int sector){
|
||||
test.append(1);
|
||||
test.append(2);
|
||||
test.append(3);
|
||||
this->timeModelShell = new TimeModel(VecShell, minSecTime, test, this);
|
||||
this->timeModelShell =
|
||||
new TimeModel(VecShell, minSecTime, test, this);
|
||||
// this->ui->lWShellTime->setModel(this->timeModelShell);
|
||||
ui->lWShellTime->setModel(this->timeModelShell);
|
||||
break;
|
||||
@@ -371,8 +380,10 @@ void WindowRace::shellSlot(int time, int sector){
|
||||
test.append(1);
|
||||
test.append(2);
|
||||
test.append(3);
|
||||
this->timeModelShell = new TimeModel(VecShell, minSecTime, test, this);
|
||||
// timeModelShell = new TimeModel(VecShell, this);
|
||||
this->timeModelShell =
|
||||
new TimeModel(VecShell, minSecTime, test, this);
|
||||
// timeModelShell = new
|
||||
// TimeModel(VecShell, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
}
|
||||
break;
|
||||
@@ -380,44 +391,54 @@ void WindowRace::shellSlot(int time, int sector){
|
||||
if (VecShell.size() > 0) {
|
||||
if (VecShell.last().size() == 2) {
|
||||
VecShell.last().append(time);
|
||||
VecShell.last().append(QVectorHelper::getCurTime(VecShell.last()));
|
||||
VecShell.last().append(
|
||||
QVectorHelper::getCurTime(VecShell.last()));
|
||||
|
||||
if(QVectorHelper::getCurTime(VecShell.last()) <= QVectorHelper::getMin(VecShell)){
|
||||
ui->lBestZeitShell->setText(QString::number((double)QVectorHelper::getMin(VecShell)/1000));
|
||||
if (QVectorHelper::getCurTime(VecShell.last()) <=
|
||||
QVectorHelper::getMin(VecShell)) {
|
||||
ui->lBestZeitShell->setText(QString::number(
|
||||
(double)QVectorHelper::getMin(VecShell) /
|
||||
1000));
|
||||
}
|
||||
ui->lCurRoundTimeShell->setText(QString::number((double)QVectorHelper::getCurTime(VecShell.last())/1000));
|
||||
ui->lCurRoundTimeShell->setText(QString::number(
|
||||
(double)QVectorHelper::getCurTime(VecShell.last()) /
|
||||
1000));
|
||||
|
||||
// update tableview
|
||||
|
||||
test.append(1);
|
||||
test.append(2);
|
||||
test.append(3);
|
||||
this->timeModelShell = new TimeModel(VecShell, minSecTime, test, this);
|
||||
// timeModelShell = new TimeModel(VecShell, this);
|
||||
this->timeModelShell =
|
||||
new TimeModel(VecShell, minSecTime, 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)+
|
||||
", "+QString::number(this->shellDriverId)+", "+QString::number(this->shellCarId)+", 1, "+QString::number(zeit)+")";
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
if (sector == 3) {
|
||||
}
|
||||
|
||||
|
||||
ui->lWShellTime->scrollToBottom();
|
||||
}
|
||||
}
|
||||
ui->lWShellTime->scrollToBottom();
|
||||
ui->lWShellTime->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
ui->lWShellTime->horizontalHeader()->setSectionResizeMode(
|
||||
QHeaderView::Stretch);
|
||||
}
|
||||
void WindowRace::deaSlot(int time, int sector) {
|
||||
if (started && !paused && !this->finished) {
|
||||
@@ -453,33 +474,39 @@ void WindowRace::deaSlot(int time, int sector){
|
||||
if (VecDea.size() > 0) {
|
||||
// cout << "Time sec 3: " << time << endl;
|
||||
if (VecDea.last().size() == 2) {
|
||||
// cout << time << sector << endl;
|
||||
// cout << time << sector <<
|
||||
// endl;
|
||||
VecDea.last().push_back(time);
|
||||
|
||||
// add sum to vector
|
||||
VecDea.last().push_back(QVectorHelper::getCurTime(VecDea.last()));
|
||||
|
||||
|
||||
VecDea.last().push_back(
|
||||
QVectorHelper::getCurTime(VecDea.last()));
|
||||
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// best time on widget
|
||||
cout << "cur time: " << QVectorHelper::getCurTime(VecDea.last()) << endl;
|
||||
cout << "min time: " << QVectorHelper::getMin(VecDea) << endl;
|
||||
if(QVectorHelper::getCurTime(VecDea.last()) <= QVectorHelper::getMin(VecDea)){
|
||||
ui->lBestZeitDea->setText(QString::number((double)QVectorHelper::getMin(VecDea)/1000));
|
||||
cout << "cur time: "
|
||||
<< QVectorHelper::getCurTime(VecDea.last()) << endl;
|
||||
cout << "min time: " << QVectorHelper::getMin(VecDea)
|
||||
<< endl;
|
||||
if (QVectorHelper::getCurTime(VecDea.last()) <=
|
||||
QVectorHelper::getMin(VecDea)) {
|
||||
ui->lBestZeitDea->setText(QString::number(
|
||||
(double)QVectorHelper::getMin(VecDea) / 1000));
|
||||
}
|
||||
ui->lCurRoundDea->setText(QString::number((double)QVectorHelper::getCurTime(VecDea.last())/1000));
|
||||
ui->lCurRoundDea->setText(QString::number(
|
||||
(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)+")";
|
||||
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();
|
||||
@@ -489,7 +516,8 @@ void WindowRace::deaSlot(int time, int sector){
|
||||
}
|
||||
}
|
||||
ui->lWDeaTime->scrollToBottom();
|
||||
ui->lWDeaTime->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
ui->lWDeaTime->horizontalHeader()->setSectionResizeMode(
|
||||
QHeaderView::Stretch);
|
||||
}
|
||||
|
||||
long WindowRace::getMinimum(std::vector<long> a) {
|
||||
@@ -505,7 +533,6 @@ long WindowRace::getMinimum(std::vector<long> a){
|
||||
minimum = a[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return minimum;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
#include "windowrennliste.h"
|
||||
#include "ui_windowrennliste.h"
|
||||
#include <QColor>
|
||||
#include <QBrush>
|
||||
#include <iostream>
|
||||
#include <QDebug>
|
||||
#include "windowrace.h"
|
||||
using std::vector;
|
||||
#include <QBrush>
|
||||
#include <QColor>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
WindowRennliste::WindowRennliste(DataBase *db, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::WindowRennliste)
|
||||
{
|
||||
WindowRennliste::WindowRennliste(DataBase * db, QWidget * parent)
|
||||
: QMainWindow(parent), ui(new Ui::WindowRennliste) {
|
||||
ui->setupUi(this);
|
||||
|
||||
this->windowClose = false;
|
||||
@@ -21,48 +19,64 @@ WindowRennliste::WindowRennliste(DataBase *db, QWidget *parent) :
|
||||
this->ui->tWRennliste->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
this->ui->tWRennliste->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
QObject::connect(this->ui->tWRennliste, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(listClick(const QModelIndex&)));
|
||||
QObject::connect(this->ui->tWRennliste,
|
||||
SIGNAL(doubleClicked(const QModelIndex &)), this,
|
||||
SLOT(listClick(const QModelIndex &)));
|
||||
this->db = db;
|
||||
|
||||
string statement;
|
||||
vector<vector<QString>> fahrer, autos, rennid;
|
||||
statement = "select id_rennen from aktrennen group by id_rennen order by id_rennen DESC limit 1";
|
||||
statement = "select id_rennen from aktrennen group by id_rennen order by "
|
||||
"id_rennen DESC limit 1";
|
||||
rennid = this->db->getData(statement, 1);
|
||||
statement = "select fahrershellid, autoshellid, fahrerdeaid, autodeaid from aktrennen where id_rennen like "+rennid[0][0].toStdString();
|
||||
statement = "select fahrershellid, autoshellid, fahrerdeaid, autodeaid "
|
||||
"from aktrennen where id_rennen like " +
|
||||
rennid[0][0].toStdString();
|
||||
|
||||
this->tableData = db->getData(statement, 4);
|
||||
this->ui->tWRennliste->setRowCount(this->tableData.size());
|
||||
this->ui->tWRennliste->setColumnCount(6);
|
||||
QStringList header;
|
||||
header<< "Fahrer" << "Auto"<< "Zeit"<< "Fahrer"<< "Auto"<< "Zeit";
|
||||
header << "Fahrer"
|
||||
<< "Auto"
|
||||
<< "Zeit"
|
||||
<< "Fahrer"
|
||||
<< "Auto"
|
||||
<< "Zeit";
|
||||
|
||||
this->ui->tWRennliste->setHorizontalHeaderLabels(header);
|
||||
|
||||
|
||||
for(int i = 0; i < this->ui->tWRennliste->horizontalHeader()->count();i++){
|
||||
this->ui->tWRennliste->horizontalHeader()->setSectionResizeMode(i, QHeaderView::Stretch);
|
||||
for (int i = 0; i < this->ui->tWRennliste->horizontalHeader()->count();
|
||||
i++) {
|
||||
this->ui->tWRennliste->horizontalHeader()->setSectionResizeMode(
|
||||
i, QHeaderView::Stretch);
|
||||
}
|
||||
|
||||
|
||||
for (unsigned int i = 0; i < tableData.size(); i++) {
|
||||
statement = "select name from fahrer where id like " + tableData[i][0].toStdString();
|
||||
statement = "select name from fahrer where id like " +
|
||||
tableData[i][0].toStdString();
|
||||
fahrer = this->db->getData(statement, 1);
|
||||
this->ui->tWRennliste->setItem(i, 0, new QTableWidgetItem(fahrer[0][0]));
|
||||
this->ui->tWRennliste->setItem(i, 0,
|
||||
new QTableWidgetItem(fahrer[0][0]));
|
||||
this->ui->tWRennliste->item(i, 0)->setFlags(Qt::ItemIsEnabled);
|
||||
|
||||
statement = "select name from AutoKonfiguration where id_auto like " + tableData[i][1].toStdString()+" order by seit DESC";
|
||||
statement = "select name from AutoKonfiguration where id_auto like " +
|
||||
tableData[i][1].toStdString() + " order by seit DESC";
|
||||
autos = this->db->getData(statement, 1);
|
||||
this->ui->tWRennliste->setItem(i, 1, new QTableWidgetItem(autos[0][0]));
|
||||
this->ui->tWRennliste->item(i, 1)->setFlags(Qt::ItemIsEnabled);
|
||||
|
||||
this->ui->tWRennliste->setItem(i, 2, new QTableWidgetItem());
|
||||
|
||||
statement = "select name from fahrer where id like " + tableData[i][2].toStdString();
|
||||
statement = "select name from fahrer where id like " +
|
||||
tableData[i][2].toStdString();
|
||||
fahrer = this->db->getData(statement, 1);
|
||||
this->ui->tWRennliste->setItem(i, 3, new QTableWidgetItem(fahrer[0][0]));
|
||||
this->ui->tWRennliste->setItem(i, 3,
|
||||
new QTableWidgetItem(fahrer[0][0]));
|
||||
this->ui->tWRennliste->item(i, 3)->setFlags(Qt::ItemIsEnabled);
|
||||
|
||||
statement = "select name from AutoKonfiguration where id_auto like " + tableData[i][3].toStdString()+" order by seit DESC";
|
||||
statement = "select name from AutoKonfiguration where id_auto like " +
|
||||
tableData[i][3].toStdString() + " order by seit DESC";
|
||||
autos = this->db->getData(statement, 1);
|
||||
this->ui->tWRennliste->setItem(i, 4, new QTableWidgetItem(autos[0][0]));
|
||||
this->ui->tWRennliste->item(i, 4)->setFlags(Qt::ItemIsEnabled);
|
||||
@@ -78,10 +92,14 @@ void WindowRennliste::setWindowRace(WindowRace *instance){
|
||||
}
|
||||
vector<QString> WindowRennliste::getDriverAndCarSettings() {
|
||||
vector<QString> vec;
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow+1, 0)->text());
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow+1, 1)->text());
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow+1, 3)->text());
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow+1, 4)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow + 1, 0)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow + 1, 1)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow + 1, 3)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow + 1, 4)->text());
|
||||
return vec;
|
||||
}
|
||||
vector<QString> WindowRennliste::getDriverAndCarId() {
|
||||
@@ -90,8 +108,10 @@ vector<QString> WindowRennliste::getDriverAndCarId(){
|
||||
}
|
||||
|
||||
void WindowRennliste::setBesttime(int shell, int dea) {
|
||||
this->ui->tWRennliste->item(this->selectedRow, 2)->setText(QString::number(shell/1000.0));
|
||||
this->ui->tWRennliste->item(this->selectedRow, 5)->setText(QString::number(dea/1000.0));
|
||||
this->ui->tWRennliste->item(this->selectedRow, 2)
|
||||
->setText(QString::number(shell / 1000.0));
|
||||
this->ui->tWRennliste->item(this->selectedRow, 5)
|
||||
->setText(QString::number(dea / 1000.0));
|
||||
// std::cout << this->selectedRow << std::endl;
|
||||
}
|
||||
|
||||
@@ -112,7 +132,6 @@ void WindowRennliste::listClick(const QModelIndex & index){
|
||||
this->instanceWindowRace->prepareNextRace();
|
||||
this->setSelection(index.row());
|
||||
this->sendIds();
|
||||
|
||||
}
|
||||
void WindowRennliste::closeEvent(QCloseEvent * event) {
|
||||
if (!this->windowClose) {
|
||||
@@ -122,7 +141,6 @@ void WindowRennliste::closeEvent(QCloseEvent *event){
|
||||
else {
|
||||
event->accept();
|
||||
}
|
||||
|
||||
}
|
||||
void WindowRennliste::schliessen() {
|
||||
this->windowClose = true;
|
||||
@@ -132,7 +150,8 @@ void WindowRennliste::schliessen(){
|
||||
|
||||
void WindowRennliste::setSelection(int row) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
this->ui->tWRennliste->item(this->selectedRow, i)->setBackground(Qt::yellow);
|
||||
this->ui->tWRennliste->item(this->selectedRow, i)
|
||||
->setBackground(Qt::yellow);
|
||||
}
|
||||
this->selectedRow = row;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
@@ -145,7 +164,6 @@ void WindowRennliste::setSelection(int row){
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow, 3)->text());
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow, 4)->text());
|
||||
this->instanceWindowRace->setDriverAndCar(vec);
|
||||
|
||||
}
|
||||
void WindowRennliste::sendIds() {
|
||||
this->instanceWindowRace->setDriverAndCarId(this->getDriverAndCarId());
|
||||
@@ -154,23 +172,27 @@ void WindowRennliste::sendIds(){
|
||||
void WindowRennliste::changeSelection() {
|
||||
if (this->selectedRow + 1 < this->tableData.size()) {
|
||||
for (unsigned int i = 0; i < 6; i++) {
|
||||
this->ui->tWRennliste->item(this->selectedRow, i)->setBackground(Qt::gray);
|
||||
this->ui->tWRennliste->item(this->selectedRow+1, i)->setBackground(Qt::green);
|
||||
this->ui->tWRennliste->item(this->selectedRow, i)
|
||||
->setBackground(Qt::gray);
|
||||
this->ui->tWRennliste->item(this->selectedRow + 1, i)
|
||||
->setBackground(Qt::green);
|
||||
}
|
||||
this->selectedRow += 1;
|
||||
this->sendIds();
|
||||
|
||||
vector<QString> vec;
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow, 0)->text());
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow, 1)->text());
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow, 3)->text());
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow, 4)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow, 0)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow, 1)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow, 3)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow, 4)->text());
|
||||
this->instanceWindowRace->setDriverAndCar(vec);
|
||||
}
|
||||
}
|
||||
|
||||
WindowRennliste::~WindowRennliste()
|
||||
{
|
||||
WindowRennliste::~WindowRennliste() {
|
||||
delete ui;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,40 +1,44 @@
|
||||
#include "windowssettings.h"
|
||||
#include "ui_windowssettings.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
#include <vector>
|
||||
|
||||
using std::vector;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
WindowsSettings::WindowsSettings(DataBase *db, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::WindowsSettings)
|
||||
{
|
||||
WindowsSettings::WindowsSettings(DataBase * db, QWidget * parent)
|
||||
: QMainWindow(parent), ui(new Ui::WindowsSettings) {
|
||||
ui->setupUi(this);
|
||||
|
||||
QObject::connect(ui->pBSpeichernStrecke, SIGNAL(clicked()), this, SLOT(StreckeSpeichernSlot()));
|
||||
QObject::connect(ui->pBAbbrechenStrecke, SIGNAL(clicked()), this, SLOT(AbbrechenSlot()));
|
||||
QObject::connect(this->ui->pbAbbrechenDauer, SIGNAL(clicked()), this, SLOT(AbbrechenSlot()));
|
||||
QObject::connect(this->ui->pbSaveDauer, SIGNAL(clicked()), this, SLOT(SaveDauerSlot()));
|
||||
QObject::connect(this->ui->pbSaveAndExitDauer, SIGNAL(clicked()), this, SLOT(SaveDauerAndExitSlot()));
|
||||
QObject::connect(ui->pBSpeichernStrecke, SIGNAL(clicked()), this,
|
||||
SLOT(StreckeSpeichernSlot()));
|
||||
QObject::connect(ui->pBAbbrechenStrecke, SIGNAL(clicked()), this,
|
||||
SLOT(AbbrechenSlot()));
|
||||
QObject::connect(this->ui->pbAbbrechenDauer, SIGNAL(clicked()), this,
|
||||
SLOT(AbbrechenSlot()));
|
||||
QObject::connect(this->ui->pbSaveDauer, SIGNAL(clicked()), this,
|
||||
SLOT(SaveDauerSlot()));
|
||||
QObject::connect(this->ui->pbSaveAndExitDauer, SIGNAL(clicked()), this,
|
||||
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;
|
||||
|
||||
// Shell prepare
|
||||
string statement = "select geraden, kurven_aussen, "
|
||||
string statement =
|
||||
"select geraden, kurven_aussen, "
|
||||
"kurven_innen, steilkurve_innen, steilkurve_aussen, seit "
|
||||
"from Strecke where id_bahn like 1 order by seit DESC limit 1";
|
||||
vector<vector<QString>> res;
|
||||
@@ -51,7 +55,6 @@ WindowsSettings::WindowsSettings(DataBase *db, QWidget *parent) :
|
||||
"kurven_innen, steilkurve_innen, steilkurve_aussen, seit "
|
||||
"from Strecke where id_bahn like 2 order by seit DESC limit 1";
|
||||
|
||||
|
||||
res = db->getData(statement, 6);
|
||||
ui->lEDeaGeraden->setText(res[0][0]);
|
||||
ui->lEDeaKurvenAussen->setText(res[0][1]);
|
||||
@@ -60,7 +63,8 @@ WindowsSettings::WindowsSettings(DataBase *db, QWidget *parent) :
|
||||
ui->lEDeaSteilkurveAussen->setText(res[0][4]);
|
||||
|
||||
// duration prepare
|
||||
statement = "select dauer, mindestrundendauer, minsec1, minsec2, minsec3 from renndauer";
|
||||
statement = "select dauer, mindestrundendauer, minsec1, minsec2, minsec3 "
|
||||
"from renndauer";
|
||||
res = db->getData(statement, 5);
|
||||
this->ui->leRenndauer->setText(res[0][0]);
|
||||
this->ui->lEMinTimeSec1->setText(res[0][2]);
|
||||
@@ -69,11 +73,11 @@ WindowsSettings::WindowsSettings(DataBase *db, QWidget *parent) :
|
||||
int minLapTime = res[0][2].toInt() + res[0][3].toInt() + res[0][4].toInt();
|
||||
this->ui->lEMinRundenzeit->setText(QString::number(minLapTime));
|
||||
|
||||
statement = "SELECT id, minimumroundtime FROM rennen order by id DESC limit 1";
|
||||
statement =
|
||||
"SELECT id, minimumroundtime FROM rennen order by id DESC limit 1";
|
||||
res = this->db->getData(statement, 2);
|
||||
this->rennId = res[0][0].toInt();
|
||||
this->ui->lEMinRundenzeitAktRennen->setText(res[0][1]);
|
||||
|
||||
}
|
||||
void WindowsSettings::repaintMinLapTime() {
|
||||
int minlapTime = 0;
|
||||
@@ -88,16 +92,20 @@ void WindowsSettings::AbbrechenSlot(){
|
||||
delete this;
|
||||
}
|
||||
void WindowsSettings::SaveDauerSlot() {
|
||||
string statement = "update renndauer set "
|
||||
"dauer="+this->ui->leRenndauer->text().toStdString()+", "+
|
||||
"mindestrundendauer="+this->ui->lEMinRundenzeit->text().toStdString()+", "+
|
||||
string statement =
|
||||
"update renndauer set "
|
||||
"dauer=" +
|
||||
this->ui->leRenndauer->text().toStdString() + ", " +
|
||||
"mindestrundendauer=" +
|
||||
this->ui->lEMinRundenzeit->text().toStdString() + ", " +
|
||||
"minsec1=" + this->ui->lEMinTimeSec1->text().toStdString() + ", " +
|
||||
"minsec2=" + this->ui->lEMinTimeSec2->text().toStdString() + ", " +
|
||||
"minsec3=" + this->ui->lEMinTimeSec3->text().toStdString() + " " +
|
||||
" where id like 1";
|
||||
cout << statement << endl;
|
||||
this->db->setData(statement);
|
||||
statement = "update rennen set minimumroundtime="+this->ui->lEMinRundenzeitAktRennen->text().toStdString()+
|
||||
statement = "update rennen set minimumroundtime=" +
|
||||
this->ui->lEMinRundenzeitAktRennen->text().toStdString() +
|
||||
" where id like " + QString::number(this->rennId).toStdString();
|
||||
this->db->setData(statement);
|
||||
}
|
||||
@@ -106,17 +114,23 @@ void WindowsSettings::SaveDauerAndExitSlot(){
|
||||
this->AbbrechenSlot();
|
||||
}
|
||||
|
||||
|
||||
void WindowsSettings::StreckeSpeichernSlot() {
|
||||
QString shellGeraden, shellKurvenAussen, shellKurvenInnen, shellSteilAussen, shellSteilInnen;
|
||||
QString deaGeraden, deaKurvenAussen, deaKurvenInnen, deaSteilAussen, deaSteilInnen;
|
||||
QString shellGeraden, shellKurvenAussen, shellKurvenInnen, shellSteilAussen,
|
||||
shellSteilInnen;
|
||||
QString deaGeraden, deaKurvenAussen, deaKurvenInnen, deaSteilAussen,
|
||||
deaSteilInnen;
|
||||
shellGeraden = ui->lEShellGeraden->text();
|
||||
shellKurvenAussen = ui->lEShellKurvenAussen->text();
|
||||
shellKurvenInnen = ui->lEShellKurvenInnen->text();
|
||||
shellSteilAussen = ui->lEShellSteilkurveaussen->text();
|
||||
shellSteilInnen = ui->lEShellSteilkurveInnen->text();
|
||||
QString statement = QString("insert into strecke (geraden, kurven_aussen, kurven_innen, steilkurve_innen, steilkurve_aussen, seit, id_bahn)"
|
||||
" values ("+shellGeraden+", "+shellKurvenAussen+", "+shellKurvenInnen+", "+shellSteilInnen+", "+shellSteilAussen+", '"+QString::fromStdString(currentDateTime())+"', 1)");
|
||||
QString statement = QString(
|
||||
"insert into strecke (geraden, kurven_aussen, kurven_innen, "
|
||||
"steilkurve_innen, steilkurve_aussen, seit, id_bahn)"
|
||||
" values (" +
|
||||
shellGeraden + ", " + shellKurvenAussen + ", " + shellKurvenInnen +
|
||||
", " + shellSteilInnen + ", " + shellSteilAussen + ", '" +
|
||||
QString::fromStdString(currentDateTime()) + "', 1)");
|
||||
// cout << statement.toStdString() << endl;
|
||||
db->setData(statement.toStdString());
|
||||
|
||||
@@ -125,14 +139,18 @@ void WindowsSettings::StreckeSpeichernSlot(){
|
||||
deaKurvenInnen = ui->lEDeaKurvenInnen->text();
|
||||
deaSteilAussen = ui->lEDeaSteilkurveAussen->text();
|
||||
deaSteilInnen = ui->lEDeaSteilkurveInnen->text();
|
||||
statement = QString("insert into strecke (geraden, kurven_aussen, kurven_innen, steilkurve_innen, steilkurve_aussen, seit, id_bahn)"
|
||||
" values ("+deaGeraden+", "+deaKurvenAussen+", "+deaKurvenInnen+", "+deaSteilInnen+", "+deaSteilAussen+", '"+QString::fromStdString(currentDateTime())+"', 2)");
|
||||
statement =
|
||||
QString("insert into strecke (geraden, kurven_aussen, kurven_innen, "
|
||||
"steilkurve_innen, steilkurve_aussen, seit, id_bahn)"
|
||||
" values (" +
|
||||
deaGeraden + ", " + deaKurvenAussen + ", " + deaKurvenInnen +
|
||||
", " + deaSteilInnen + ", " + deaSteilAussen + ", '" +
|
||||
QString::fromStdString(currentDateTime()) + "', 2)");
|
||||
// cout << statement.toStdString() << endl;
|
||||
db->setData(statement.toStdString());
|
||||
}
|
||||
|
||||
WindowsSettings::~WindowsSettings()
|
||||
{
|
||||
WindowsSettings::~WindowsSettings() {
|
||||
delete ui;
|
||||
std::cout << "Destruktor einstellungen" << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user