initial commit

This commit is contained in:
2014-09-05 14:12:37 +02:00
commit 990a6ad03d
29 changed files with 5477 additions and 0 deletions

3073
Makefile Normal file

File diff suppressed because it is too large Load Diff

47
RennbahnZeitmessung.pro Normal file
View File

@@ -0,0 +1,47 @@
#-------------------------------------------------
#
# Project created by QtCreator 2014-08-18T22:07:00
#
#-------------------------------------------------
QT += core gui
QT += sql
QT += core
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = RennbahnZeitmessung
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
windowrace.cpp \
hardwaresetup.cpp \
windowssettings.cpp \
counter.cpp \
countdown.cpp \
ampel.cpp \
database.cpp \
windowrennliste.cpp
HEADERS += \
mainwindow.h \
windowrace.h \
hardwaresetup.h \
windowssettings.h \
counter.h \
countdown.h \
ampel.h \
database.h \
windowrennliste.h
FORMS += mainwindow.ui \
windowrace.ui \
windowssettings.ui \
windowrennliste.ui
OTHER_FILES +=
RESOURCES += \
resource.qrc

View File

@@ -0,0 +1,260 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.0.1, 2014-09-04T23:23:32. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</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">{afd67bb0-e1fe-490f-9c05-717bc9979c59}</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/C/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">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">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/C/build-RennbahnZeitmessung-Desktop-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>
<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">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">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">Release</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="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<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.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.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<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/C/RennbahnZeitmessung/RennbahnZeitmessung.pro</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="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
<value type="QByteArray">{5a3b068d-48fb-4b9d-beda-5a5c38651d77}</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">15</value>
</data>
</qtcreator>

21
ampel.cpp Normal file
View File

@@ -0,0 +1,21 @@
#include "ampel.h"
#include <unistd.h>
Ampel::Ampel()
{
}
void Ampel::run(){
int anzahl = 0;
while(1){
anzahl++;
if(anzahl < 6){
usleep(800000);
}
else{
usleep(1400000);
}
emit ampelUpdate();
}
}

16
ampel.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef AMPEL_H
#define AMPEL_H
#include <QtCore>
class Ampel:public QThread
{
Q_OBJECT
public:
Ampel();
protected:
void run();
signals:
void ampelUpdate();
};
#endif // AMPEL_H

BIN
ampel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

11
countdown.cpp Normal file
View File

@@ -0,0 +1,11 @@
#include "countdown.h"
#include "unistd.h"
Countdown::Countdown()
{
}
void Countdown::run(){
while(1){
sleep(1);
emit CountdownUpdate();
}
}

16
countdown.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef COUNTDOWN_H
#define COUNTDOWN_H
#include <QtCore>
class Countdown : public QThread
{
Q_OBJECT
protected:
void run();
public:
Countdown();
signals:
void CountdownUpdate();
};
#endif // COUNTDOWN_H

21
counter.cpp Normal file
View File

@@ -0,0 +1,21 @@
#include "counter.h"
#include <sys/time.h>
#include <iostream>
#include <cstddef>
Counter::Counter()
{
}
void Counter::start(){
gettimeofday(&startTime, NULL);
}
long Counter::getTime(){
gettimeofday(&endTime, NULL);
long back = (endTime.tv_usec-startTime.tv_usec)/1000+(endTime.tv_sec-startTime.tv_sec)*1000;
this->start();
return back;
}

15
counter.h Normal file
View File

@@ -0,0 +1,15 @@
#ifndef COUNTER_H
#define COUNTER_H
#include <sys/time.h>
class Counter
{
public:
Counter();
void start();
long getTime();
struct timeval startTime, endTime;
};
#endif // COUNTER_H

50
database.cpp Normal file
View File

@@ -0,0 +1,50 @@
#include "database.h"
#include <iostream>
#include <cstring>
#include <QVariant>
using std::vector;
DataBase::DataBase()
{
this->db = new QSqlDatabase();
*this->db = QSqlDatabase::addDatabase("QSQLITE");
this->db->setDatabaseName("Renndatenbank.sqlite");
std::cout << "Konstruktor Database" << std::endl;
}
vector< vector<QString> > DataBase::getData(std::string statement, int cols){
char * buffer = new char[statement.length()-1];
strcpy(buffer,statement.c_str());
vector<QString> data;
vector< vector<QString> > lines;
bool ok = this->db->open();
QString qstr;
if(ok){
QSqlQuery query(buffer);
while(query.next()){
for(int i = 0; i < cols; i++){
qstr = query.value(i).toString();
data.push_back(qstr);
}
lines.push_back(data);
data.erase(data.begin(), data.begin()+cols);
}
}
this->db->close();
return lines;
}
void DataBase::setData(std::string statement){
char * buffer = new char[statement.length()];
strcpy(buffer,statement.c_str());
bool ok = this->db->open();
if(ok){
QSqlQuery query(buffer);
}
this->db->close();
}

22
database.h Normal file
View File

@@ -0,0 +1,22 @@
#ifndef DATABASE_H
#define DATABASE_H
#include <QtSql/QSql>
#include <QtSql/QSqlDatabase>
#include <QDir>
#include <QtSql/QSqlQuery>
#include<vector>
#include <string>
using std::vector;
class DataBase
{
public:
DataBase();
vector< vector<QString> > getData(std::string statement, int cols);
void setData(std::string statement);
private:
QSqlDatabase *db;
};
#endif // DATABASE_H

106
hardwaresetup.cpp Normal file
View File

@@ -0,0 +1,106 @@
#include "hardwaresetup.h"
#include <unistd.h>
#include "sys/io.h"
#include <iostream>
#define BASEPORT 0xe050 /* lp1 */
HardwareSetup::HardwareSetup()
{
if (ioperm(BASEPORT, 3, 1)) {
//perror("ioperm");
}
shellBefore = false;
deaBefore = false;
}
HardwareSetup::~HardwareSetup(){
if (ioperm(BASEPORT, 3, 0)) {
//perror("ioperm");
}
}
void HardwareSetup::run(){
while(1){
usleep(10000);
if(getDea()){
if(!deaBefore){
deaBefore = true;
emit Dea();
}
}
else{
deaBefore = false;
}
if(getShell()){
if(!shellBefore){
shellBefore = true;
emit Shell();
}
}
else{
shellBefore = false;
}
}
}
bool HardwareSetup::getShell(){
int zahl[8] = {0};
if(findBit(zahl, inb(BASEPORT + 1))[7] == 1){
return true;
}
return false;
}
bool HardwareSetup::getDea(){
int zahl[8] = {0};
if(findBit(zahl, inb(BASEPORT + 1))[6] == 0 ){
return true;
}
return false;
}
int* HardwareSetup::findBit(int *array, int zahl){
if(zahl >=128){
array[7] = 1;
zahl -= 128;
}
if(zahl >=64){
array[6] = 1;
zahl -= 64;
}
if(zahl >=32){
array[5] = 1;
zahl -= 32;
}
if(zahl >=16){
array[4] = 1;
zahl -= 16;
}
if(zahl >=8){
array[3] = 1;
zahl -= 8;
}
if(zahl >=4){
array[2] = 1;
zahl -= 4;
}
if(zahl >=2){
array[1] = 1;
zahl -= 2;
}
if(zahl >=1){
array[0] = 1;
zahl -= 1;
}
return array;
}

26
hardwaresetup.h Normal file
View File

@@ -0,0 +1,26 @@
#ifndef HARDWARESETUP_H
#define HARDWARESETUP_H
#include <QtCore>
class HardwareSetup : public QThread
{
Q_OBJECT
protected:
void run();
private:
bool shellBefore;
bool deaBefore;
bool getShell();
bool getDea();
int* findBit(int *array, int zahl);
public:
~HardwareSetup();
HardwareSetup();
signals:
void Shell();
void Dea();
};
#endif // HARDWARESETUP_H

11
main.cpp Normal file
View File

@@ -0,0 +1,11 @@
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

52
mainwindow.cpp Normal file
View File

@@ -0,0 +1,52 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QObject>
#include "windowssettings.h"
#include <iostream>
#include "hardwaresetup.h"
#include "windowrace.h"
#include "database.h"
#include <vector>
#include "windowrennliste2.h"
using std::vector;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
test = new HardwareSetup;
this->test->start();
QObject::connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(NewWindowSettings()));
QObject::connect(ui->pBRennen, SIGNAL(clicked()), this, SLOT(WindowRennen()));
this->db = new DataBase;
vector< vector <QString> > daten = db->getData("select * from Fahrer", 2);
//DataBase ndb;
//vector< vector <QString> > daten2 = ndb.getData("select * from Fahrer", 2);
//DataBase ndb2;
//vector< vector <QString> > daten3 = ndb2.getData("select * from Fahrer", 2);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::NewWindowSettings(){
this->interfaceSettings = new WindowsSettings(this->db, this);
this->interfaceSettings->show();
}
void MainWindow::WindowRennen(){
this->interfaceRace = new WindowRace(this->db, this);
this->interfaceRace->show();
this->interfaceRennliste = new WindowRennliste(this->db, this);
this->interfaceRennliste->show();
this->interfaceRace->setWindowRennliste(this->interfaceRennliste);
}

41
mainwindow.h Normal file
View File

@@ -0,0 +1,41 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
//#include "mainwindow2.h"
#include "hardwaresetup.h"
#include "windowrace.h"
#include "windowssettings.h"
#include "windowrennliste.h"
#include "windowrennliste2.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
public slots:
void NewWindowSettings();
void WindowRennen();
private:
DataBase *db;
HardwareSetup *test;
Ui::MainWindow *ui;
WindowRace *interfaceRace;
WindowsSettings *interfaceSettings;
WindowRennliste *interfaceRennliste;
};
#endif // MAINWINDOW_H

77
mainwindow.ui Normal file
View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>568</width>
<height>427</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>410</x>
<y>10</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Einstellungen</string>
</property>
</widget>
<widget class="QPushButton" name="pBRennen">
<property name="geometry">
<rect>
<x>410</x>
<y>60</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Rennen</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>140</x>
<y>100</y>
<width>113</width>
<height>23</height>
</rect>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>568</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

5
resource.qrc Normal file
View File

@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/new/prefix1">
<file>ampel.png</file>
</qresource>
</RCC>

266
windowrace.cpp Normal file
View File

@@ -0,0 +1,266 @@
#include "windowrace.h"
#include "ui_windowrace.h"
#include <QObject>
#include <string>
#include <sstream>
#include <iostream>
#define FAHRZEIT 5;
using std::vector;
WindowRace::WindowRace(DataBase *db, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::WindowRace)
{
ui->setupUi(this);
this->ui->pBNextRace->setEnabled(false);
this->finished = false;
this->db = db;
vector< vector< QString > > res;
res = db->getData("select id from fahrer", 1);
vector< vector< QString > > res2;
res2 = db->getData("select id from fahrer", 1);
firstTimeDea = true;
firstTimeShell = true;
started = false;
countdownValue = FAHRZEIT;
countdown = new Countdown;
startAmpelThread = new Ampel;
ampelCounter = 0;
ui->pBStart->setFocus();
paused = false;
Hardware = new HardwareSetup;
Hardware->start();
QObject::connect(Hardware, SIGNAL(Dea()), this, SLOT(deaSlot()));
QObject::connect(Hardware, SIGNAL(Shell()), this, SLOT(shellSlot()));
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()));
ui->lCountdown->setText(timeWrapper(countdownValue));
//Ampelsetup
ui->WAmpel15->hide();
ui->WAmpel25->hide();
ui->hW15->setVisible(true);
ui->hW25->setVisible(true);
ui->WAmpel14->hide();
ui->WAmpel24->hide();
ui->hW14->setVisible(true);
ui->hW24->setVisible(true);
ui->WAmpel13->hide();
ui->WAmpel23->hide();
ui->hW13->setVisible(true);
ui->hW23->setVisible(true);
ui->WAmpel12->hide();
ui->WAmpel22->hide();
ui->hW12->setVisible(true);
ui->hw22->setVisible(true);
ui->WAmpel11->hide();
ui->WAmpel21->hide();
ui->hW11->setVisible(true);
ui->hW21->setVisible(true);
}
void WindowRace::prepareNextRace(){
this->finished = false;
this->paused = false;
this->countdownValue = FAHRZEIT;
this->ampelCounter = 0;
this->startAmpelThread->terminate();
this->countdown->terminate();
this->ui->pBNextRace->setEnabled(false);
this->ui->lCountdown->setText(timeWrapper(countdownValue));
}
void WindowRace::setWindowRennliste(WindowRennliste *ptrInstance){
this->wRennliste = ptrInstance;
QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()), this->wRennliste, SLOT(changeSelection()));
}
void WindowRace::breakCounter(){
if(!paused){
paused = true;
ui->pBBreak->setText("Weiter");
}
else{
ui->pBBreak->setText("Pause");
paused = false;
}
}
void WindowRace::laufcheck(){
//std::cout << "thread lauft noch" << std::endl;
}
QString WindowRace::timeWrapper(long zahl){
long min = zahl / 60;
int sec = zahl % 60;
QString sec_q;
if(sec < 10){
sec_q = "0"+QString::number(sec);
}
else{
sec_q = QString::number(sec);
}
QString min_q = QString::number(min);
return min_q+":"+sec_q;
}
void WindowRace::countdownUpdate(){
if(!paused){
countdownValue -= 1;
if(countdownValue <= 15){
ui->lCountdown->setStyleSheet("QLabel { color: red; }");
}
if(countdownValue <= -1){
this->finished = true;
this->ui->pBNextRace->setEnabled(true);
}
else{
ui->lCountdown->setText(timeWrapper(countdownValue));
}
}
}
WindowRace::~WindowRace()
{
delete ui;
}
void WindowRace::shellSlot(){
if(started && !paused && !this->finished){
if(firstTimeShell){
firstTimeShell = false;
counterShell.start();
}
else{
long zeit = counterShell.getTime();
VecShell.push_back(zeit);
QListWidgetItem *item = new QListWidgetItem;
if(getMinimum(VecShell) == zeit && VecShell.size() > 1){
item->setBackgroundColor(Qt::green);
}
item->setText(QString::number((double)zeit/1000));
ui->lWShellTime->addItem(item);
ui->lWShellTime->scrollToBottom();
ui->lBestZeitShell->setText(QString::number((double)getMinimum(VecShell)/1000));
ui->lCurRoundTimeShell->setText(QString::number((double)zeit/1000));
}
}
}
void WindowRace::deaSlot(){
if(started && !paused && !this->finished){
if(firstTimeDea){
firstTimeDea = false;
counterDea.start();
}
else{
long zeit = counterDea.getTime();
VecDea.push_back(zeit);
QListWidgetItem *item = new QListWidgetItem;
if(getMinimum(VecDea) == zeit && VecDea.size() > 1){
item->setBackgroundColor(Qt::green);
}
item->setText(QString::number((double)zeit/1000));
ui->lWDeaTime->addItem(item);
ui->lWDeaTime->scrollToBottom();
ui->lBestZeitDea->setText(QString::number((double)getMinimum(VecDea)/1000));
ui->lCurRoundDea->setText(QString::number((double)zeit/1000));
}
}
}
long WindowRace::getMinimum(std::vector<long> a){
long minimum = a[0];
for(unsigned int i = 0; i < a.size(); i++){
if(a[i] < minimum){
minimum = a[i];
}
}
return minimum;
}
void WindowRace::ampelSlot(){
if(ampelCounter == 5){
ui->WAmpel15->hide();
ui->WAmpel25->hide();
ui->hW15->setVisible(true);
ui->hW25->setVisible(true);
ui->WAmpel14->hide();
ui->WAmpel24->hide();
ui->hW14->setVisible(true);
ui->hW24->setVisible(true);
ui->WAmpel13->hide();
ui->WAmpel23->hide();
ui->hW13->setVisible(true);
ui->hW23->setVisible(true);
ui->WAmpel12->hide();
ui->WAmpel22->hide();
ui->hW12->setVisible(true);
ui->hw22->setVisible(true);
ui->WAmpel11->hide();
ui->WAmpel21->hide();
ui->hW11->setVisible(true);
ui->hW21->setVisible(true);
startAmpelThread->terminate();
started = true;
countdown->start();
}
if(ampelCounter == 4){
ampelCounter = 5;
ui->WAmpel15->setVisible(true);
ui->WAmpel25->setVisible(true);
ui->hW15->hide();
ui->hW25->hide();
}
if(ampelCounter == 3){
ampelCounter = 4;
ui->WAmpel14->setVisible(true);
ui->WAmpel24->setVisible(true);
ui->hW14->hide();
ui->hW24->hide();
}
if(ampelCounter == 2){
ampelCounter = 3;
ui->WAmpel13->setVisible(true);
ui->WAmpel23->setVisible(true);
ui->hW13->hide();
ui->hW23->hide();
}
if(ampelCounter == 1){
ampelCounter = 2;
ui->WAmpel12->setVisible(true);
ui->WAmpel22->setVisible(true);
ui->hW12->hide();
ui->hw22->hide();
}
if(ampelCounter == 0){
ampelCounter = 1;
ui->WAmpel11->setVisible(true);
ui->WAmpel21->setVisible(true);
ui->hW11->hide();
ui->hW21->hide();
}
}
void WindowRace::go(){
startAmpelThread->start();
}

59
windowrace.h Normal file
View File

@@ -0,0 +1,59 @@
#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 "database.h"
#include "windowrennliste.h"
namespace Ui {
class WindowRace;
}
class WindowRace : public QMainWindow
{
Q_OBJECT
public:
explicit WindowRace(DataBase *db, QWidget *parent = 0);
~WindowRace();
void setWindowRennliste(WindowRennliste *ptrInstance);
private:
bool started;
Countdown *countdown;
HardwareSetup *Hardware;
Ui::WindowRace *ui;
Counter counterShell;
Counter counterDea;
bool firstTimeShell;
bool firstTimeDea;
std::vector<long> VecShell;
std::vector<long> VecDea;
long getMinimum(std::vector<long> a);
QString timeWrapper(long zahl);
long countdownValue; //in sec
Ampel *startAmpelThread;
int ampelCounter;
bool paused;
DataBase *db;
bool finished;
WindowRennliste *wRennliste;
public slots:
void prepareNextRace();
void breakCounter();
void countdownUpdate();
void go();
void ampelSlot();
void laufcheck();
void deaSlot();
void shellSlot();
};
#endif // WINDOWRACE_H

649
windowrace.ui Normal file
View File

@@ -0,0 +1,649 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WindowRace</class>
<widget class="QMainWindow" name="WindowRace">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>840</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>Rennmodus</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_18">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="title">
<string>Shell</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Bestzeit</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QLabel" name="lBestZeitShell">
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Zeit aktueller Runde</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QLabel" name="lCurRoundTimeShell">
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="lWShellTime">
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6" stretch="0,0,1">
<item alignment="Qt::AlignHCenter|Qt::AlignTop">
<widget class="QLabel" name="lCountdown">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>17</pointsize>
</font>
</property>
<property name="text">
<string>Verbleibende Zeit</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QWidget" name="widget" native="true">
<property name="minimumSize">
<size>
<width>170</width>
<height>100</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QWidget" name="hW11" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel11" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QWidget" name="hW21" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel21" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QWidget" name="hW12" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel12" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QWidget" name="hw22" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel22" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_15">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QWidget" name="hW13" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel13" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QWidget" name="hW23" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel23" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_16">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QWidget" name="hW14" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel14" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QWidget" name="hW24" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel24" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_17">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QWidget" name="hW15" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel15" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QWidget" name="hW25" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel25" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="title">
<string>Dea</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Bestzeit</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QLabel" name="lBestZeitDea">
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Zeit aktueller Runde</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QLabel" name="lCurRoundDea">
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="lWDeaTime">
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pBStart">
<property name="text">
<string>start</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pBBreak">
<property name="text">
<string>Pause</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pBStop">
<property name="text">
<string>Stop</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pBNextRace">
<property name="text">
<string>nächstes Rennen</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>840</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<tabstops>
<tabstop>pBStart</tabstop>
<tabstop>pBBreak</tabstop>
<tabstop>pBStop</tabstop>
<tabstop>pBNextRace</tabstop>
<tabstop>lWShellTime</tabstop>
<tabstop>lWDeaTime</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

88
windowrennliste.cpp Normal file
View File

@@ -0,0 +1,88 @@
#include "windowrennliste.h"
#include "ui_windowrennliste.h"
#include <QColor>
#include <QBrush>
#include <iostream>
#include <QDebug>
using std::vector;
using std::string;
WindowRennliste::WindowRennliste(DataBase *db, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::WindowRennliste)
{
this->selectedRow = 0;
ui->setupUi(this);
this->ui->tWRennliste->setSelectionBehavior(QAbstractItemView::SelectRows);
this->ui->tWRennliste->setSelectionMode(QAbstractItemView::SingleSelection);
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";
rennid = this->db->getData(statement, 1);
statement = "select fahrershellid, autoshellid, fahrerdeaid, autodeaid from aktrennen where id_rennen like "+rennid[0][0].toStdString();
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";
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(unsigned int i = 0; i < tableData.size(); i++){
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->item(i,0)->setFlags(Qt::ItemIsEnabled);
statement = "select name from AutoKonfiguration where id 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();
fahrer = this->db->getData(statement, 1);
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 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);
this->ui->tWRennliste->setItem(i, 5, new QTableWidgetItem());
}
for(int i = 0; i < 6; i++){
this->ui->tWRennliste->item(0, i)->setBackground(Qt::green);
}
}
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->selectedRow += 1;
}
}
WindowRennliste::~WindowRennliste()
{
delete ui;
}

33
windowrennliste.h Normal file
View File

@@ -0,0 +1,33 @@
#ifndef WINDOWRENNLISTE_H
#define WINDOWRENNLISTE_H
#include <QMainWindow>
#include "database.h"
#include <vector>
#include <string>
using std::vector;
namespace Ui {
class WindowRennliste;
}
class WindowRennliste : public QMainWindow
{
Q_OBJECT
public:
explicit WindowRennliste(DataBase *db, QWidget *parent = 0);
~WindowRennliste();
private:
unsigned int selectedRow;
vector< vector<QString> > tableData;
DataBase *db;
Ui::WindowRennliste *ui;
public slots:
void changeSelection();
};
#endif // WINDOWRENNLISTE_H

65
windowrennliste.ui Normal file
View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WindowRennliste</class>
<widget class="QMainWindow" name="WindowRennliste">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Shell</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Dea</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTableWidget" name="tWRennliste"/>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

28
windowrennliste2.h Normal file
View File

@@ -0,0 +1,28 @@
#ifndef WINDOWRENNLISTE2_H
#define WINDOWRENNLISTE2_H
#include <QMainWindow>
#include "database.h"
#include <string>
namespace Ui {
class WindowRennliste2;
}
class WindowRennliste2 : public QMainWindow
{
Q_OBJECT
public:
explicit WindowRennliste2(DataBase *db, QWidget *parent = 0);
~WindowRennliste2();
private:
DataBase *db;
Ui::WindowRennliste2 *ui;
};
#endif // WINDOWRENNLISTE2_H

105
windowssettings.cpp Normal file
View File

@@ -0,0 +1,105 @@
#include "windowssettings.h"
#include "ui_windowssettings.h"
#include <iostream>
#include <string>
#include <stdio.h>
#include <time.h>
#include <vector>
using std::vector;
using std::cout;
using std::endl;
using std::string;
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(AbbrechnSlot()));
this->db = db;
//Shell prepare
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;
res = db->getData(statement, 6);
ui->lEShellGeraden->setText(res[0][0]);
ui->lEShellKurvenAussen->setText(res[0][1]);
ui->lEShellKurvenInnen->setText(res[0][2]);
ui->lEShellSteilkurveInnen->setText(res[0][3]);
ui->lEShellSteilkurveaussen->setText(res[0][4]);
//Dea prepare
statement = "select geraden, kurven_aussen, "
"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]);
ui->lEDeaKurvenInnen->setText(res[0][2]);
ui->lEDeaSteilkurveInnen->setText(res[0][3]);
ui->lEDeaSteilkurveAussen->setText(res[0][4]);
//string statement= "insert into AutoKonfiguration ('seit') values ('"+currentDateTime()+"')";
//db->setData(statement);
}
void WindowsSettings::AbbrechnSlot(){
this->close();
}
void WindowsSettings::StreckeSpeichernSlot(){
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)");
//cout << statement.toStdString() << endl;
db->setData(statement.toStdString());
deaGeraden = ui->lEDeaGeraden->text();
deaKurvenAussen = ui->lEDeaKurvenAussen->text();
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)");
//cout << statement.toStdString() << endl;
db->setData(statement.toStdString());
}
WindowsSettings::~WindowsSettings()
{
delete ui;
}
// Get current date/time, format is YYYY-MM-DD.HH:mm:ss
string WindowsSettings::currentDateTime() {
time_t now = time(0);
struct tm tstruct;
char buf[80];
tstruct = *localtime(&now);
// Visit http://en.cppreference.com/w/cpp/chrono/c/strftime
// for more information about date/time format
strftime(buf, sizeof(buf), "%Y-%m-%d.%X", &tstruct);
return buf;
}

32
windowssettings.h Normal file
View File

@@ -0,0 +1,32 @@
#ifndef WINDOWSSETTINGS_H
#define WINDOWSSETTINGS_H
#include <QMainWindow>
#include <string>
#include "database.h"
using std::string;
namespace Ui {
class WindowsSettings;
}
class WindowsSettings : public QMainWindow
{
Q_OBJECT
public:
explicit WindowsSettings(DataBase *db, QWidget *parent = 0);
~WindowsSettings();
private:
Ui::WindowsSettings *ui;
string currentDateTime();
DataBase *db;
public slots:
void AbbrechnSlot();
void StreckeSpeichernSlot();
};
#endif // WINDOWSSETTINGS_H

282
windowssettings.ui Normal file
View File

@@ -0,0 +1,282 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WindowsSettings</class>
<widget class="QMainWindow" name="WindowsSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="Strecke">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="Dauer">
<attribute name="title">
<string>Dauer</string>
</attribute>
<widget class="QGroupBox" name="groupBox_13">
<property name="geometry">
<rect>
<x>60</x>
<y>30</y>
<width>149</width>
<height>65</height>
</rect>
</property>
<property name="title">
<string>Renndauer in Sekunden </string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_17">
<item>
<widget class="QLineEdit" name="lineEdit_11"/>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Strecke</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_16" stretch="0,0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="maximumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="title">
<string>Shell</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Kurven außen</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLineEdit" name="lEShellKurvenAussen"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Kurven innen</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLineEdit" name="lEShellKurvenInnen"/>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Geraden</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLineEdit" name="lEShellGeraden"/>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Steilkurve außen</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLineEdit" name="lEShellSteilkurveaussen"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Steilkurve innen</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLineEdit" name="lEShellSteilkurveInnen"/>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="maximumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="title">
<string>Dea</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string>Kurven außen</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QLineEdit" name="lEDeaKurvenAussen"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_9">
<property name="title">
<string>Kurven innen</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="QLineEdit" name="lEDeaKurvenInnen"/>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_10">
<property name="title">
<string>Geraden</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<widget class="QLineEdit" name="lEDeaGeraden"/>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QGroupBox" name="groupBox_12">
<property name="title">
<string>Steilkurve außen</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_15">
<item>
<widget class="QLineEdit" name="lEDeaSteilkurveAussen"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_11">
<property name="title">
<string>Steilkurve innen</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QLineEdit" name="lEDeaSteilkurveInnen"/>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QPushButton" name="pBAbbrechenStrecke">
<property name="text">
<string>Abbrechen</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pBSpeichernStrecke">
<property name="text">
<string>Speichern</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Autos</string>
</attribute>
<widget class="QTableWidget" name="tableWidget">
<property name="geometry">
<rect>
<x>70</x>
<y>150</y>
<width>256</width>
<height>192</height>
</rect>
</property>
</widget>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>