Skip to content

Commit e4bb3ae

Browse files
committed
adrv9002: ui updates and multithreading for performance
Signed-off-by: IonutMuthi <[email protected]>
1 parent f0cf3b0 commit e4bb3ae

File tree

10 files changed

+307
-180
lines changed

10 files changed

+307
-180
lines changed

packages/adrv9002/plugins/adrv9002plugin/CMakeLists.txt

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
#
2+
# Copyright (c) 2025 Analog Devices Inc.
3+
#
4+
# This file is part of Scopy
5+
# (see https://www.github.com/analogdevicesinc/scopy).
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
#
20+
121
cmake_minimum_required(VERSION 3.9)
222

323
set(SCOPY_MODULE adrv9002plugin)
@@ -6,22 +26,15 @@ message(STATUS "building plugin: " ${SCOPY_MODULE})
626

727
project(scopy-${SCOPY_MODULE} VERSION 0.1 LANGUAGES CXX)
828

9-
set(PLUGIN_DISPLAY_NAME ADRV9002 (NAVASSA))
10-
set(PLUGIN_DESCRIPTION
11-
ADRV9002
12-
RF
13-
TRANSCEIVER
14-
PLUGIN
15-
PORTED
16-
FROM
17-
IIO-OSCILLOSCOPE
18-
)
29+
set(PLUGIN_NAME ADRV9002Plugin)
30+
set(PLUGIN_DISPLAY_NAME "ADRV9002")
31+
set(PLUGIN_DESCRIPTION " ADRV9002 RF TRANSCEIVER PLUGIN")
1932

2033
include(GenerateExportHeader)
2134

2235
# TODO: split stylesheet/resources and add here TODO: export header files correctly
2336

24-
set(CMAKE_CXX_STANDARD 20)
37+
set(CMAKE_CXX_STANDARD 17)
2538
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2639

2740
set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/ui)
@@ -60,14 +73,6 @@ generate_export_header(
6073
${PROJECT_NAME} EXPORT_FILE_NAME ${CMAKE_CURRENT_SOURCE_DIR}/include/${SCOPY_MODULE}/${PROJECT_NAME}_export.h
6174
)
6275

63-
message("Generate plugin style:")
64-
include(ScopyStyle)
65-
file(MAKE_DIRECTORY ${SCOPY_PACKAGE_BUILD_PATH}/${PACKAGE_NAME}/style/qss)
66-
generate_style(
67-
"--plugin" ${CMAKE_CURRENT_SOURCE_DIR}/style ${CMAKE_CURRENT_SOURCE_DIR}/include/${SCOPY_MODULE}
68-
${SCOPY_PACKAGE_BUILD_PATH}/${PACKAGE_NAME}
69-
)
70-
7176
configure_file(
7277
include/${SCOPY_MODULE}/scopy-${SCOPY_MODULE}_config.h.cmakein
7378
${CMAKE_CURRENT_SOURCE_DIR}/include/${SCOPY_MODULE}/scopy-${SCOPY_MODULE}_config.h @ONLY
@@ -76,8 +81,7 @@ configure_file(
7681
target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
7782
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/${SCOPY_MODULE})
7883

79-
target_include_directories(${PROJECT_NAME} PUBLIC ${CURRENT_PKG_PATH}/include)
80-
target_include_directories(${PROJECT_NAME} PUBLIC scopy-pluginbase scopy-gui)
84+
target_include_directories(${PROJECT_NAME} PUBLIC scopy-pluginbase scopy-gui scopy-pkg-manager)
8185

8286
target_link_libraries(
8387
${PROJECT_NAME}
@@ -90,8 +94,4 @@ target_link_libraries(
9094
scopy-pkg-manager
9195
)
9296

93-
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
94-
configureinstallersettings(${SCOPY_MODULE} ${PLUGIN_DESCRIPTION} FALSE)
95-
endif()
96-
9797
set(ADRV9002PLUGIN_TARGET_NAME ${PROJECT_NAME} PARENT_SCOPE)

packages/adrv9002/plugins/adrv9002plugin/include/adrv9002plugin/profilegeneratortypes.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ enum ChannelType
3434
CHANNEL_TX2
3535
};
3636

37-
// Simplified for iio-oscilloscope compatibility - UpdateBatcher system removed
38-
3937
struct ChannelConfig
4038
{
4139
bool enabled;

packages/adrv9002/plugins/adrv9002plugin/include/adrv9002plugin/profilegeneratorwidget.h

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,17 @@
4545
#include <QDesktopServices>
4646
#include <QUrl>
4747
#include <QTimer>
48+
#include <QFutureWatcher>
49+
#include <functional>
4850
#include <array>
4951
#include <iio.h>
5052
#include <pluginbase/statusbarmanager.h>
5153
#include <iiowidget.h>
5254
#include <style.h>
5355
#include <channelconfigwidget.h>
5456
#include <gui/widgets/menusectionwidget.h>
57+
#include <gui/widgets/animatedrefreshbtn.h>
58+
#include <gui/widgets/animatedloadingbutton.h>
5559
#include <profilegeneratorconstants.h>
5660
#include <profilegeneratortypes.h>
5761
#include <profileclimanager.h>
@@ -100,6 +104,13 @@ class SCOPY_ADRV9002PLUGIN_EXPORT ProfileGeneratorWidget : public QWidget
100104
~ProfileGeneratorWidget();
101105

102106
Q_SIGNALS:
107+
// Worker thread operation signals
108+
void saveProfileSuccess(const QString &fileName);
109+
void saveProfileFailed(const QString &error);
110+
void saveStreamSuccess(const QString &fileName);
111+
void saveStreamFailed(const QString &error);
112+
void loadToDeviceSuccess();
113+
void loadToDeviceFailed(const QString &error);
103114

104115
public Q_SLOTS:
105116
void refreshProfileData();
@@ -169,9 +180,10 @@ private Q_SLOTS:
169180
void updateSampleRateOptionsForSSI();
170181
QString calculateBandwidthForSampleRate(const QString &sampleRate) const;
171182

172-
// Profile Operations (require CLI)
173-
bool loadProfileToDevice();
174-
bool saveProfileToFile(const QString &filename);
183+
// Worker functions for threaded operations
184+
void doSaveProfileWork(const QString &fileName, const RadioConfig &config);
185+
void doSaveStreamWork(const QString &fileName, const RadioConfig &config);
186+
void doLoadToDeviceWork(const RadioConfig &config);
175187

176188
// Device Communication
177189
QString readDeviceAttribute(const QString &attributeName);
@@ -204,8 +216,8 @@ private Q_SLOTS:
204216
// Action Bar Components
205217
QComboBox *m_presetCombo;
206218
QPushButton *m_refreshProfileBtn;
207-
QPushButton *m_saveToFileBtn;
208-
QPushButton *m_loadToDeviceBtn;
219+
AnimatedLoadingButton *m_saveToFileBtn;
220+
AnimatedLoadingButton *m_loadToDeviceBtn;
209221

210222
// Radio Config Components
211223
QLabel *m_ssiInterfaceLabel; // Read-only like iio-oscilloscope

packages/adrv9002/plugins/adrv9002plugin/include/adrv9002plugin/profilemanager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include <gui/widgets/smallprogressbar.h>
3333
#include <pkg-manager/pkgmanager.h>
3434
#include <pluginbase/statusbarmanager.h>
35+
#include <QFutureWatcher>
36+
#include <functional>
3537
#include <iio.h>
3638

3739
namespace scopy::adrv9002 {
@@ -68,6 +70,7 @@ public Q_SLOTS:
6870

6971
private Q_SLOTS:
7072
void onProfileFileChanged();
73+
void doOnProfileFileChangedInThread();
7174
void onStreamFileChanged();
7275
void updateStatus();
7376

@@ -82,6 +85,9 @@ private Q_SLOTS:
8285
QWidget *createDeviceInfoPanel();
8386
QString getAttributeValue(const QString &attributeName);
8487

88+
// Progress bar animation helper for threaded operations
89+
void executeWithProgress(bool isProfile, std::function<bool()> work);
90+
8591
// Device communication
8692
iio_device *m_device;
8793

packages/adrv9002/plugins/adrv9002plugin/src/adrv9002.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#include <QLoggingCategory>
2727
#include <QFutureWatcher>
28-
#include <QtConcurrent/QtConcurrent>
28+
#include <QtConcurrent>
2929
#include <style.h>
3030
#include <stylehelper.h>
3131

@@ -130,22 +130,11 @@ void Adrv9002::connectSignals()
130130
watcher, &QFutureWatcher<void>::finished, this,
131131
[this, watcher]() {
132132
m_refreshButton->stopAnimation();
133-
134-
// Refresh ProfileManager device info when ADRV9002 refreshes
135-
if(m_profileManager) {
136-
m_profileManager->updateDeviceInfo();
137-
}
138-
139-
// Refresh Initial Calibrations widget when ADRV9002 refreshes
140-
if(m_initialCalibrationsWidget) {
141-
m_initialCalibrationsWidget->refreshStatus();
142-
}
143-
144133
watcher->deleteLater();
145134
},
146135
Qt::QueuedConnection);
147136

148-
auto future = QtConcurrent::run([this]() { Q_EMIT readRequested(); });
137+
QFuture<void> future = QtConcurrent::run([this]() { Q_EMIT readRequested(); });
149138
watcher->setFuture(future);
150139
});
151140
}
@@ -305,6 +294,7 @@ MenuSectionCollapseWidget *Adrv9002::createGlobalSettingsSection(QWidget *parent
305294
// Profile Manager - handles profile_config and stream_config
306295
if(m_profileManager) {
307296
section->add(m_profileManager);
297+
connect(this, &Adrv9002::readRequested, m_profileManager, &ProfileManager::updateDeviceInfo);
308298
}
309299

310300
QWidget *widget = new QWidget(section);
@@ -345,6 +335,8 @@ MenuSectionCollapseWidget *Adrv9002::createGlobalSettingsSection(QWidget *parent
345335
// Initial Calibrations section (if supported)
346336
if(m_initialCalibrationsWidget) {
347337
layout->addWidget(m_initialCalibrationsWidget);
338+
connect(this, &Adrv9002::readRequested, m_initialCalibrationsWidget,
339+
&InitialCalibrationsWidget::refreshStatus);
348340
}
349341

350342
section->add(widget);

packages/adrv9002/plugins/adrv9002plugin/src/channelconfigwidget.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ void ChannelConfigWidget::setupUI()
9696
// Interface Sample Rate (Hz) - matching iio-oscilloscope exactly
9797
m_layout->addWidget(new QLabel("Interface Sample Rate (Hz):"), 4, 0);
9898
m_sampleRateCombo = new QComboBox();
99+
m_sampleRateCombo->setEnabled(true);
99100
m_sampleRateCombo->addItems(FrequencyTable::SAMPLE_RATES_HZ);
100101
m_layout->addWidget(m_sampleRateCombo, 4, 1);
101102

@@ -174,6 +175,8 @@ void ChannelConfigWidget::updateControlsVisibility(bool lteMode)
174175
m_bandwidthCombo->setEnabled(channelEnabled);
175176

176177
m_sampleRateCombo->setEditable(true);
178+
// this is a woraround caused by how Qt treats enable / disable logic for QCombobox
179+
Style::setBackgroundColor(m_sampleRateCombo, json::theme::background_primary);
177180
m_sampleRateCombo->setEnabled(channelEnabled);
178181
}
179182

packages/adrv9002/plugins/adrv9002plugin/src/profileclimanager.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,6 @@ ProfileCliManager::OperationResult ProfileCliManager::loadProfileToDevice(const
231231
return DeviceWriteFailed;
232232
}
233233

234-
Q_EMIT operationProgress("Loading stream image to device...");
235-
236234
// Read generated stream file
237235
QByteArray streamData = readFileContents(streamFile);
238236
if(streamData.isEmpty()) {
@@ -248,10 +246,11 @@ ProfileCliManager::OperationResult ProfileCliManager::loadProfileToDevice(const
248246
return DeviceWriteFailed;
249247
}
250248

249+
Q_EMIT operationProgress("Stream_config write completed successfully");
250+
251251
// Cleanup temp files
252252
cleanupTempFiles(tempFiles);
253253

254-
Q_EMIT operationProgress("Profile and stream loaded to device successfully");
255254
return Success;
256255
}
257256

0 commit comments

Comments
 (0)