From 7b6e49f770a1327c0d70b29783fe6042eddbd3c6 Mon Sep 17 00:00:00 2001 From: openhands Date: Mon, 30 Jun 2025 14:05:15 +0000 Subject: [PATCH 1/4] Fixed vtable issues and enabled automoc in CMakeLists.txt --- CMakeLists.txt | 8 ++++++-- channelwidget.h | 6 +++--- mainwindow.h | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05adc82..8224829 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # Find Qt6 find_package(Qt6 REQUIRED COMPONENTS Widgets) -# Add the libeismultiplexer library -add_subdirectory(../libeismultiplexer) +# Enable automoc for Qt meta-object compiler +set(CMAKE_AUTOMOC ON) + +# Include the libeismultiplexer library +include_directories(/workspace/libeismultiplexer) +link_directories(/workspace/libeismultiplexer/build) # Add the application executable add_executable(eismultiplexer-qt diff --git a/channelwidget.h b/channelwidget.h index 5a2a6b7..b3c5191 100644 --- a/channelwidget.h +++ b/channelwidget.h @@ -15,9 +15,9 @@ class ChannelWidget : public QWidget Q_OBJECT public: - ChannelWidget(uint16_t deviceSerial, uint16_t channelNumber, struct eismultiplexer* multiplexer, - QWidget *parent = nullptr); - ~ChannelWidget(); + explicit ChannelWidget(uint16_t deviceSerial, uint16_t channelNumber, struct eismultiplexer* multiplexer, + QWidget *parent = nullptr); + ~ChannelWidget() override; private slots: void onChannelToggled(bool checked); diff --git a/mainwindow.h b/mainwindow.h index 519cb37..c4d297b 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -19,8 +19,8 @@ class MainWindow : public QMainWindow Q_OBJECT public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow() override; private: void enumerateDevices(); From b2bd53be80f19a0c81e8e222aed487968f46f9a1 Mon Sep 17 00:00:00 2001 From: openhands Date: Mon, 30 Jun 2025 14:05:45 +0000 Subject: [PATCH 2/4] Add .gitignore file to exclude build directory --- .gitignore | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1e931b8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ + +# Build directory +build/ + +# Qt creator user files +*.user +*.pro.user +*.opensdf +*.sdf + +# CMake cache +CMakeCache.txt +CMakeFiles/ +cmake_install.cmake From 64e01ea5997735c245b380656f0556e68b899c89 Mon Sep 17 00:00:00 2001 From: openhands Date: Mon, 30 Jun 2025 14:19:38 +0000 Subject: [PATCH 3/4] Added QMessageBox notifications for device connection errors and channel control errors --- channelwidget.cpp | 7 +++++++ channelwidget.h | 2 +- mainwindow.cpp | 7 ++++++- mainwindow.h | 2 ++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/channelwidget.cpp b/channelwidget.cpp index ce2366a..5615280 100644 --- a/channelwidget.cpp +++ b/channelwidget.cpp @@ -3,6 +3,7 @@ #include "channelwidget.h" #include +#include ChannelWidget::ChannelWidget(uint16_t deviceSerial, uint16_t channelNumber, struct eismultiplexer* multiplexer, QWidget *parent) @@ -36,13 +37,19 @@ void ChannelWidget::onChannelToggled(bool checked) channel_t channelFlag = static_cast(1 << channelNumber); if (checked) { if (eismultiplexer_connect_channel(multiplexer, channelFlag) < 0) { + QMessageBox::warning(this, tr("Connection Failed"), + tr("Failed to connect channel %1 on device %2").arg(channelNumber).arg(deviceSerial)); qWarning() << "Failed to connect channel" << channelNumber << "on device" << deviceSerial; checkbox->setChecked(false); + setEnabled(false); // Gray out the widget } } else { if (eismultiplexer_disconnect_channel(multiplexer, channelFlag) < 0) { + QMessageBox::warning(this, tr("Disconnection Failed"), + tr("Failed to disconnect channel %1 on device %2").arg(channelNumber).arg(deviceSerial)); qWarning() << "Failed to disconnect channel" << channelNumber << "on device" << deviceSerial; checkbox->setChecked(true); + setEnabled(false); // Gray out the widget } } } diff --git a/channelwidget.h b/channelwidget.h index b3c5191..02f427d 100644 --- a/channelwidget.h +++ b/channelwidget.h @@ -27,7 +27,7 @@ private: uint16_t channelNumber; struct eismultiplexer* multiplexer; QCheckBox* checkbox; - QLabel* label; + QLabel* label; // No need for tr() function, QObject already provides it }; #endif // CHANNELWIDGET_H diff --git a/mainwindow.cpp b/mainwindow.cpp index a6da879..38a0796 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -2,6 +2,7 @@ #include "mainwindow.h" #include +#include #include MainWindow::MainWindow(QWidget *parent) @@ -48,7 +49,9 @@ void MainWindow::enumerateDevices() size_t count = 0; uint16_t* serials = eismultiplexer_list_available_devices(&count); - if (!serials) { + if (!serials || count == 0) { + QMessageBox::warning(this, tr("No Devices Found"), + tr("No EIS multiplexer devices were found. Please connect a device and try again.")); qWarning() << "No EIS multiplexer devices found"; return; } @@ -67,6 +70,8 @@ void MainWindow::enumerateDevices() } eismultiplexer_disconnect(&multiplexer); } else { + QMessageBox::warning(this, tr("Connection Failed"), + tr("Failed to connect to device with serial %1").arg(serial)); qWarning() << "Failed to connect to device with serial" << serial; } } diff --git a/mainwindow.h b/mainwindow.h index c4d297b..999d9fd 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -22,6 +22,8 @@ public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow() override; + // No need for tr() function, QObject already provides it + private: void enumerateDevices(); void setupUi(); From 278db0b23fd301586f1a9a75020668db68f8c9bd Mon Sep 17 00:00:00 2001 From: openhands Date: Mon, 30 Jun 2025 16:33:38 +0200 Subject: [PATCH 4/4] remove build dir from git --- channelwidget.cpp | 20 ++++++++++++++++++++ channelwidget.h | 9 ++++++++- mainwindow.h | 3 ++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/channelwidget.cpp b/channelwidget.cpp index 5615280..b351fe6 100644 --- a/channelwidget.cpp +++ b/channelwidget.cpp @@ -32,8 +32,28 @@ ChannelWidget::~ChannelWidget() // Nothing to clean up } +uint16_t ChannelWidget::getDeviceSerial() const +{ + return deviceSerial; +} + +uint16_t ChannelWidget::getChannelNumber() const +{ + return channelNumber; +} + +bool ChannelWidget::isChecked() const +{ + return checkbox->isChecked(); +} + void ChannelWidget::onChannelToggled(bool checked) { + if (checked) { + // Emit signal before actually turning on the channel + emit channelAboutToBeTurnedOn(deviceSerial, channelNumber); + } + channel_t channelFlag = static_cast(1 << channelNumber); if (checked) { if (eismultiplexer_connect_channel(multiplexer, channelFlag) < 0) { diff --git a/channelwidget.h b/channelwidget.h index 02f427d..a1e2dc1 100644 --- a/channelwidget.h +++ b/channelwidget.h @@ -19,6 +19,13 @@ public: QWidget *parent = nullptr); ~ChannelWidget() override; + uint16_t getDeviceSerial() const; + uint16_t getChannelNumber() const; + bool isChecked() const; + +signals: + void channelAboutToBeTurnedOn(uint16_t deviceSerial, uint16_t channelNumber); + private slots: void onChannelToggled(bool checked); @@ -27,7 +34,7 @@ private: uint16_t channelNumber; struct eismultiplexer* multiplexer; QCheckBox* checkbox; - QLabel* label; // No need for tr() function, QObject already provides it + QLabel* label; }; #endif // CHANNELWIDGET_H diff --git a/mainwindow.h b/mainwindow.h index 999d9fd..4426a48 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -22,7 +22,8 @@ public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow() override; - // No need for tr() function, QObject already provides it +private slots: + void onChannelAboutToBeTurnedOn(uint16_t deviceSerial, uint16_t channelNumber); private: void enumerateDevices();