From 4dd765b341caa62a86e1d4a00ba5ca9ff161178e Mon Sep 17 00:00:00 2001 From: JPaehr Date: Fri, 30 Nov 2018 14:19:38 +0100 Subject: [PATCH] code cleanup --- CMakeLists.txt | 5 +++++ hardwaresetup.cpp | 13 ++++++++++++- hardwaresetup.h | 15 +++++++++------ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b7a6fe0..c3f0cbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,8 @@ find_package(Qt5Widgets CONFIG REQUIRED) find_package(Qt5Sql REQUIRED) + + # Populate a CMake variable with the sources set(helloworld_SRCS main.cpp @@ -27,6 +29,8 @@ set(helloworld_SRCS database.cpp windowrennliste.cpp training.cpp + timemodel.cpp + qvectorhelper.cpp mainwindow.ui windowrace.ui @@ -36,5 +40,6 @@ set(helloworld_SRCS ) # Tell CMake to create the helloworld executable add_executable(Rennbahn ${helloworld_SRCS}) + # Use the Widgets module from Qt 5 target_link_libraries(Rennbahn Qt5::Widgets Qt5::Core Qt5::Sql) diff --git a/hardwaresetup.cpp b/hardwaresetup.cpp index ad2ce93..33d77d8 100644 --- a/hardwaresetup.cpp +++ b/hardwaresetup.cpp @@ -8,7 +8,9 @@ #include #include #include -#include +#ifdef ATMEGA + #include +#endif #define USB_LED_ON 1 #define USB_LED_OFF 0 @@ -32,7 +34,9 @@ HardwareSetup::HardwareSetup() { // //perror("ioperm"); // } this->stop = 0; +#ifdef ATMEGA this->handle = nullptr; +#endif this->fd = 0; } void HardwareSetup::setStop() { @@ -48,10 +52,12 @@ HardwareSetup::~HardwareSetup() { this->stop = 1; if (HARDWARE_VERSION == 2) { +#ifdef ATMEGA if (this->handle) { usb_close(this->handle); } this->handle = NULL; +#endif } else if (HARDWARE_VERSION == 3) { // close filedescriptor @@ -63,6 +69,7 @@ HardwareSetup::~HardwareSetup() { } } } +#ifdef ATMEGA /* Used to get descriptor strings for device identification */ int HardwareSetup::usbGetDescriptorString(usb_dev_handle * dev, int index, @@ -158,12 +165,14 @@ usb_dev_handle * HardwareSetup::usbOpenDevice(int vendor, char * vendorName, } return NULL; } +#endif void HardwareSetup::run() { struct TransStruct buffer[6]; if (HARDWARE_VERSION == 2) { + #ifdef ATMEGA int testmode = 0; int nBytes = 0; @@ -300,7 +309,9 @@ void HardwareSetup::run() { } } } + #endif } // end HARDWARE_VERSION 2 + else if (HARDWARE_VERSION == 3) { fd = open(PORT_PATH, O_RDONLY); diff --git a/hardwaresetup.h b/hardwaresetup.h index 8e276e5..39cd6b6 100644 --- a/hardwaresetup.h +++ b/hardwaresetup.h @@ -5,8 +5,9 @@ #include #include #include -#include - +#ifdef ATMEGA + #include +#endif struct TransStruct { uint16_t time; uint8_t id; @@ -21,17 +22,19 @@ class HardwareSetup : public QThread { private: bool shellBefore; bool deaBefore; +#ifdef ATMEGA usb_dev_handle * handle; + int usbGetDescriptorString(usb_dev_handle * dev, int index, int langid, + char * buf, int buflen); + usb_dev_handle * usbOpenDevice(int vendor, char * vendorName, int product, + char * productName); +#endif int fd; bool getShell(); bool getDea(); int * findBit(int * array, int zahl); bool stop; - int usbGetDescriptorString(usb_dev_handle * dev, int index, int langid, - char * buf, int buflen); - usb_dev_handle * usbOpenDevice(int vendor, char * vendorName, int product, - char * productName); public: void setStop();