diff --git a/platform/qt/dmxwidget/dmxwidget.cpp b/platform/qt/dmxwidget/dmxwidget.cpp index bdb615f..896437e 100644 --- a/platform/qt/dmxwidget/dmxwidget.cpp +++ b/platform/qt/dmxwidget/dmxwidget.cpp @@ -26,9 +26,7 @@ DmxWidget::DmxWidget(QObject *parent) : QObject{parent} , port_(new QSerialPort(this)) - , connected_(false) { - } @@ -42,10 +40,8 @@ void DmxWidget::open() { if (!port_->open(QIODeviceBase::ReadWrite)) return; - ENTTEC::Widget::open(); - connected_ = true; - emit connectedChanged(true); + emit connectedChanged(isConnected()); } @@ -53,9 +49,7 @@ void DmxWidget::close() { port_->close(); ENTTEC::Widget::close(); - - connected_ = false; - emit connectedChanged(false); + emit connectedChanged(isConnected()); } diff --git a/platform/qt/dmxwidget/dmxwidget.h b/platform/qt/dmxwidget/dmxwidget.h index f92f5e6..1afb768 100644 --- a/platform/qt/dmxwidget/dmxwidget.h +++ b/platform/qt/dmxwidget/dmxwidget.h @@ -58,8 +58,6 @@ public: virtual void open() override; virtual void close() override; - bool isConnected() const { return connected_; } - void setPort(const QSerialPortInfo &port) { port_->setPort(port); emit portNameChanged(); } void setPortName(const QString &name) { port_->setPortName(name); emit portNameChanged(); } const QString portName() const { return port_->portName(); } @@ -79,7 +77,6 @@ signals: private: QSerialPort *port_; - bool connected_; }; Q_DECLARE_OPERATORS_FOR_FLAGS(DmxWidget::RxErrors) diff --git a/protocol/enttec/dmx-usb-pro/widget.cpp b/protocol/enttec/dmx-usb-pro/widget.cpp index be0be30..fb685ef 100644 --- a/protocol/enttec/dmx-usb-pro/widget.cpp +++ b/protocol/enttec/dmx-usb-pro/widget.cpp @@ -31,8 +31,8 @@ Widget::Widget() , tx_break_intervals(17) // 181.4 us by default , tx_mab_intervals(10) // 106.7 us by default , tx_rate(40) // 40 packets/s, by default - , rx_update_mode_(Pro::RxNotifyAlways) , usb_mode_(USBunknown) + , rx_update_mode_(Pro::RxNotifyAlways) , token_data_changed_(nullptr) { } diff --git a/protocol/enttec/dmx-usb-pro/widget.h b/protocol/enttec/dmx-usb-pro/widget.h index bede96f..fa9b8f5 100644 --- a/protocol/enttec/dmx-usb-pro/widget.h +++ b/protocol/enttec/dmx-usb-pro/widget.h @@ -48,6 +48,11 @@ public: virtual void halt(); //!< USB Device stop virtual void open(); //!< USB Host start virtual void close(); //!< USB Host stop + /** + * @brief isConnected + * @return + */ + bool isConnected() const { return usb_mode_ != USBunknown; } virtual void setModeController(); virtual void setModeBridge(Pro::DMX_RX_MODE = Pro::RxNotifyAlways); @@ -109,13 +114,12 @@ private: void rxMsgGetWidgetSerialReply(std::shared_ptr); void rxMsgSendRDMDiscovery(std::shared_ptr); - Pro::DMX_RX_MODE rx_update_mode_; - enum OperatingModes { USBunknown, USBhost, USBdevice } usb_mode_; + Pro::DMX_RX_MODE rx_update_mode_; mutable std::mutex mtx_metadata_; std::shared_ptr token_data_changed_;