diff --git a/deploy/hyperion.tar.gz.REMOVED.git-id b/deploy/hyperion.tar.gz.REMOVED.git-id index 288cb926..a76f2a2a 100644 --- a/deploy/hyperion.tar.gz.REMOVED.git-id +++ b/deploy/hyperion.tar.gz.REMOVED.git-id @@ -1 +1 @@ -ab3338d1164469e008bd9635c817659b6e528a1f \ No newline at end of file +e7867d56a269136c5c795a55b831dca58e962139 \ No newline at end of file diff --git a/libsrc/leddevice/CMakeLists.txt b/libsrc/leddevice/CMakeLists.txt index 098ac38c..ec1ee381 100755 --- a/libsrc/leddevice/CMakeLists.txt +++ b/libsrc/leddevice/CMakeLists.txt @@ -13,6 +13,7 @@ include_directories( # Group the headers that go through the MOC compiler SET(Leddevice_QT_HEADERS + ${CURRENT_SOURCE_DIR}/LedRs232Device.h ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.h ) @@ -20,8 +21,6 @@ SET(Leddevice_HEADERS ${CURRENT_HEADER_DIR}/LedDevice.h ${CURRENT_HEADER_DIR}/LedDeviceFactory.h - ${CURRENT_SOURCE_DIR}/LedRs232Device.h - ${CURRENT_SOURCE_DIR}/LedDeviceLightpack.h ${CURRENT_SOURCE_DIR}/LedDeviceMultiLightpack.h ${CURRENT_SOURCE_DIR}/LedDevicePaintpack.h diff --git a/libsrc/leddevice/LedDeviceAdalight.h b/libsrc/leddevice/LedDeviceAdalight.h index 3621c5ca..bc08200b 100644 --- a/libsrc/leddevice/LedDeviceAdalight.h +++ b/libsrc/leddevice/LedDeviceAdalight.h @@ -12,7 +12,7 @@ /// /// Implementation of the LedDevice interface for writing to an Adalight led device. /// -class LedDeviceAdalight : public QObject, public LedRs232Device +class LedDeviceAdalight : public LedRs232Device { Q_OBJECT diff --git a/libsrc/leddevice/LedRs232Device.cpp b/libsrc/leddevice/LedRs232Device.cpp index c8c185a4..a4b058d2 100644 --- a/libsrc/leddevice/LedRs232Device.cpp +++ b/libsrc/leddevice/LedRs232Device.cpp @@ -4,19 +4,21 @@ #include #include +// Qt includes +#include + // Serial includes #include // Local Hyperion includes #include "LedRs232Device.h" -#include "utils/Sleep.h" - LedRs232Device::LedRs232Device(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms) : _deviceName(outputDevice), _baudRate_Hz(baudrate), _delayAfterConnect_ms(delayAfterConnect_ms), - _rs232Port() + _rs232Port(), + _blockedForDelay(false) { // empty } @@ -40,7 +42,9 @@ int LedRs232Device::open() if (_delayAfterConnect_ms > 0) { - Sleep::msleep(_delayAfterConnect_ms); + _blockedForDelay = true; + QTimer::singleShot(_delayAfterConnect_ms, this, SLOT(unblockAfterDelay())); + std::cout << "Device blocked for " << _delayAfterConnect_ms << " ms" << std::endl; } } catch (const std::exception& e) @@ -54,6 +58,11 @@ int LedRs232Device::open() int LedRs232Device::writeBytes(const unsigned size, const uint8_t * data) { + if (_blockedForDelay) + { + return 0; + } + if (!_rs232Port.isOpen()) { return -1; @@ -102,3 +111,9 @@ int LedRs232Device::writeBytes(const unsigned size, const uint8_t * data) return 0; } + +void LedRs232Device::unblockAfterDelay() +{ + std::cout << "Device unblocked" << std::endl; + _blockedForDelay = false; +} diff --git a/libsrc/leddevice/LedRs232Device.h b/libsrc/leddevice/LedRs232Device.h index f8154581..e11d0a8a 100644 --- a/libsrc/leddevice/LedRs232Device.h +++ b/libsrc/leddevice/LedRs232Device.h @@ -1,5 +1,7 @@ #pragma once +#include + // Serial includes #include @@ -9,8 +11,10 @@ /// /// The LedRs232Device implements an abstract base-class for LedDevices using a RS232-device. /// -class LedRs232Device : public LedDevice +class LedRs232Device : public QObject, public LedDevice { + Q_OBJECT + public: /// /// Constructs the LedDevice attached to a RS232-device @@ -43,6 +47,10 @@ protected: */ int writeBytes(const unsigned size, const uint8_t *data); +private slots: + /// Unblock the device after a connection delay + void unblockAfterDelay(); + private: /// The name of the output device const std::string _deviceName; @@ -55,4 +63,6 @@ private: /// The RS232 serial-device serial::Serial _rs232Port; + + bool _blockedForDelay; };