From 448f410dc262b49734ef18645dd9a2d5705cb581 Mon Sep 17 00:00:00 2001 From: Andrei-Fabian-Pop Date: Thu, 29 Aug 2024 14:30:24 +0300 Subject: [PATCH] iio-widgets: Add empty data strategy Signed-off-by: Andrei-Fabian-Pop --- gr-util/src/grdeviceaddon.cpp | 5 +- gr-util/src/grtimechanneladdon.cpp | 2 +- .../datastrategy/emptydatastrategy.h | 36 ++++++++++ .../iio-widgets/iioconfigurationpopup.h | 2 + iio-widgets/include/iio-widgets/iiowidget.h | 6 +- .../include/iio-widgets/iiowidgetbuilder.h | 17 +++-- .../src/datastrategy/emptydatastrategy.cpp | 38 ++++++++++ iio-widgets/src/iioconfigurationpopup.cpp | 13 ++-- iio-widgets/src/iiowidget.cpp | 69 +++++++++++++------ iio-widgets/src/iiowidgetbuilder.cpp | 33 +++++---- .../src/menus/channelattributesmenu.cpp | 3 +- .../src/iioexplorer/iiostandarditem.cpp | 3 +- plugins/swiot/src/ad74413r/buffermenu.cpp | 42 ++++------- 13 files changed, 185 insertions(+), 84 deletions(-) create mode 100644 iio-widgets/include/iio-widgets/datastrategy/emptydatastrategy.h create mode 100644 iio-widgets/src/datastrategy/emptydatastrategy.cpp diff --git a/gr-util/src/grdeviceaddon.cpp b/gr-util/src/grdeviceaddon.cpp index 3b4af9383b..6095871085 100644 --- a/gr-util/src/grdeviceaddon.cpp +++ b/gr-util/src/grdeviceaddon.cpp @@ -27,15 +27,14 @@ QWidget *GRDeviceAddon::createAttrMenu(QWidget *parent) MenuSectionWidget *attrContainer = new MenuSectionWidget(parent); MenuCollapseSection *attr = new MenuCollapseSection("ATTRIBUTES", MenuCollapseSection::MHCW_NONE, attrContainer); - QList attrWidgets = IIOWidgetBuilder().device(m_src->iioDev()).parent(parent).buildAll(); + QList attrWidgets = IIOWidgetBuilder(parent).device(m_src->iioDev()).buildAll(); const struct iio_context *ctx = iio_device_get_context(m_src->iioDev()); - attrWidgets.append(IIOWidgetBuilder() + attrWidgets.append(IIOWidgetBuilder(parent) .context(const_cast(ctx)) .device(m_src->iioDev()) .attribute("Triggers") .uiStrategy(IIOWidgetBuilder::UIS::ComboUi) .dataStrategy(IIOWidgetBuilder::DS::TriggerData) - .parent(parent) .buildSingle()); auto layout = new QVBoxLayout(); diff --git a/gr-util/src/grtimechanneladdon.cpp b/gr-util/src/grtimechanneladdon.cpp index 0a60a2ac45..f5738a9609 100644 --- a/gr-util/src/grtimechanneladdon.cpp +++ b/gr-util/src/grtimechanneladdon.cpp @@ -193,7 +193,7 @@ QWidget *GRTimeChannelAddon::createAttrMenu(QWidget *parent) MenuSectionWidget *attrcontainer = new MenuSectionWidget(parent); MenuCollapseSection *attr = new MenuCollapseSection("ATTRIBUTES", MenuCollapseSection::MHCW_NONE, attrcontainer); - QList attrWidgets = IIOWidgetBuilder().channel(grch()->channel()).parent(parent).buildAll(); + QList attrWidgets = IIOWidgetBuilder(parent).channel(grch()->channel()).buildAll(); auto layout = new QVBoxLayout(); layout->setSpacing(10); diff --git a/iio-widgets/include/iio-widgets/datastrategy/emptydatastrategy.h b/iio-widgets/include/iio-widgets/datastrategy/emptydatastrategy.h new file mode 100644 index 0000000000..8efb929d15 --- /dev/null +++ b/iio-widgets/include/iio-widgets/datastrategy/emptydatastrategy.h @@ -0,0 +1,36 @@ +#ifndef EMPTYDATASTRATEGY_H +#define EMPTYDATASTRATEGY_H + +#include +#include "datastrategy/datastrategyinterface.h" +#include "scopy-iio-widgets_export.h" + +namespace scopy { +class SCOPY_IIO_WIDGETS_EXPORT EmptyDataStrategy : public QObject, public DataStrategyInterface +{ + Q_OBJECT + Q_INTERFACES(scopy::DataStrategyInterface) +public: + explicit EmptyDataStrategy(QObject *parent = nullptr); + + QString data() override; + QString optionalData() override; + +public Q_SLOTS: + int write(QString data) override; + QPair read() override; + void writeAsync(QString data) override; + void readAsync() override; + +Q_SIGNALS: + void sendData(QString data, QString dataOptions) override; + void aboutToWrite(QString oldData, QString newData) override; + void emitStatus(QDateTime timestamp, QString oldData, QString newData, int returnCode, bool isReadOp) override; + +private: + QString m_data; + QString m_previousData; +}; +} // namespace scopy + +#endif // EMPTYDATASTRATEGY_H diff --git a/iio-widgets/include/iio-widgets/iioconfigurationpopup.h b/iio-widgets/include/iio-widgets/iioconfigurationpopup.h index bcce6ac46a..dc450aa200 100644 --- a/iio-widgets/include/iio-widgets/iioconfigurationpopup.h +++ b/iio-widgets/include/iio-widgets/iioconfigurationpopup.h @@ -25,6 +25,7 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOConfigurationPopup : public QWidget Q_SIGNALS: void selectButtonClicked(IIOItem *selected); + void emptyButtonClicked(); void exitButtonClicked(); protected Q_SLOTS: @@ -39,6 +40,7 @@ protected Q_SLOTS: IIOWidgetSelector *m_widgetSelector; QPushButton *m_exitButton; QPushButton *m_selectButton; + QPushButton *m_emptyButton; IIOItem *m_root; }; } // namespace scopy diff --git a/iio-widgets/include/iio-widgets/iiowidget.h b/iio-widgets/include/iio-widgets/iiowidget.h index cef418bb2b..104c173c0b 100644 --- a/iio-widgets/include/iio-widgets/iiowidget.h +++ b/iio-widgets/include/iio-widgets/iiowidget.h @@ -232,19 +232,19 @@ protected Q_SLOTS: void setLastOperationTimestamp(QDateTime timestamp); void setLastOperationState(IIOWidget::State state); - // Core variables + /* Core variables */ GuiStrategyInterface *m_uiStrategy; DataStrategyInterface *m_dataStrategy; IIOWidgetFactoryRecipe m_recipe; - // Logged data + /* Logged data */ QString m_lastData; SmallProgressBar *m_progressBar; QDateTime *m_lastOpTimestamp; int m_lastReturnCode; IIOWidget::State *m_lastOpState; - // Optional configuration + /* Optional configuration */ QPushButton *m_configBtn; IIOConfigurationPopup *m_configPopup; bool m_isConfigurable; diff --git a/iio-widgets/include/iio-widgets/iiowidgetbuilder.h b/iio-widgets/include/iio-widgets/iiowidgetbuilder.h index 1ac82b3403..7122351ea4 100644 --- a/iio-widgets/include/iio-widgets/iiowidgetbuilder.h +++ b/iio-widgets/include/iio-widgets/iiowidgetbuilder.h @@ -42,6 +42,7 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOWidgetBuilder : public QObject TriggerData, DeviceAttrData, ContextAttrData, + EmptyData, }; enum UIS @@ -53,7 +54,7 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOWidgetBuilder : public QObject RangeUi, }; - explicit IIOWidgetBuilder(QObject *parent = nullptr); + explicit IIOWidgetBuilder(QWidget *parent = nullptr); ~IIOWidgetBuilder(); /** @@ -101,6 +102,13 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOWidgetBuilder : public QObject */ IIOWidgetBuilder &configMode(bool isConfigurable); + /** + * @brief title Sets the title of the IIOWidget + * @param title QString + * @return + */ + IIOWidgetBuilder &title(QString title); + /** * @brief Sets the context that will be used, if no iio_device or iio_channel * is set, the build functions will work with the context. @@ -160,12 +168,6 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOWidgetBuilder : public QObject */ IIOWidgetBuilder &uiStrategy(IIOWidgetBuilder::UIS uiStrategy); - /** - * @brief Sets the parent of the IIOWidget that will be built. - * @param parent - */ - IIOWidgetBuilder &parent(QWidget *parent); - private: DataStrategyInterface *createDS(); GuiStrategyInterface *createUIS(); @@ -179,6 +181,7 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOWidgetBuilder : public QObject QString m_attribute; QString m_optionsAttribute; QString m_optionsValues; + QString m_title; IIOWidgetBuilder::DS m_dataStrategy; IIOWidgetBuilder::UIS m_uiStrategy; QWidget *m_widgetParent; diff --git a/iio-widgets/src/datastrategy/emptydatastrategy.cpp b/iio-widgets/src/datastrategy/emptydatastrategy.cpp new file mode 100644 index 0000000000..2b4051f2cb --- /dev/null +++ b/iio-widgets/src/datastrategy/emptydatastrategy.cpp @@ -0,0 +1,38 @@ +#include "emptydatastrategy.h" + +using namespace scopy; + +EmptyDataStrategy::EmptyDataStrategy(QObject *parent) + : QObject{parent} + , m_data("") + , m_previousData("") +{} + +QString EmptyDataStrategy::data() { return m_data; } + +QString EmptyDataStrategy::optionalData() { return ""; } + +int EmptyDataStrategy::write(QString data) +{ + m_previousData = data; + m_data = data; + return 0; +} + +QPair EmptyDataStrategy::read() { return {m_data, ""}; } + +void EmptyDataStrategy::writeAsync(QString data) +{ + int res = write(data); + Q_EMIT emitStatus(QDateTime::currentDateTime(), m_data, data, (int)(res), false); + readAsync(); +} + +void EmptyDataStrategy::readAsync() +{ + QPair res = read(); + Q_EMIT emitStatus(QDateTime::currentDateTime(), m_previousData, m_data, 0, true); + Q_EMIT sendData(res.first, res.second); +} + +#include "moc_emptydatastrategy.cpp" diff --git a/iio-widgets/src/iioconfigurationpopup.cpp b/iio-widgets/src/iioconfigurationpopup.cpp index 68ea66a3f9..31e6e22cf0 100644 --- a/iio-widgets/src/iioconfigurationpopup.cpp +++ b/iio-widgets/src/iioconfigurationpopup.cpp @@ -134,6 +134,7 @@ void IIOConfigurationPopup::init() Q_EMIT selectButtonClicked(iioItem); }); + QObject::connect(m_emptyButton, &QPushButton::clicked, this, &IIOConfigurationPopup::emptyButtonClicked); QObject::connect(m_exitButton, &QPushButton::clicked, this, &IIOConfigurationPopup::exitButtonClicked); m_selectButton->setDisabled(true); } @@ -161,12 +162,11 @@ void IIOConfigurationPopup::initUI() buttonGroupLayout->setSpacing(10); m_selectButton = new QPushButton("Select", buttonGroup); - m_selectButton->setObjectName("selectButton"); - + m_emptyButton = new QPushButton("No Data", buttonGroup); m_exitButton = new QPushButton("Exit", buttonGroup); - m_exitButton->setObjectName("exitButton"); buttonGroupLayout->addWidget(m_exitButton); + buttonGroupLayout->addWidget(m_emptyButton); buttonGroupLayout->addWidget(m_selectButton); backgroundLayout->addWidget(m_titleLabel); @@ -175,9 +175,10 @@ void IIOConfigurationPopup::initUI() backgroundWidget->setLayout(backgroundLayout); - StyleHelper::TutorialChapterTitleLabel(m_titleLabel, "titleLabel"); - StyleHelper::BlueButton(m_selectButton, "selectButton"); - StyleHelper::BlueButton(m_exitButton, "exitButton"); + StyleHelper::TutorialChapterTitleLabel(m_titleLabel, "TitleLabel"); + StyleHelper::BlueButton(m_selectButton, "SelectButton"); + StyleHelper::BlueButton(m_emptyButton, "EmptyButton"); + StyleHelper::BlueButton(m_exitButton, "ExitButton"); StyleHelper::OverlayMenu(this, "IIOConfigurationPopupOverlay"); } diff --git a/iio-widgets/src/iiowidget.cpp b/iio-widgets/src/iiowidget.cpp index 85581d3f36..87faf7933d 100644 --- a/iio-widgets/src/iiowidget.cpp +++ b/iio-widgets/src/iiowidget.cpp @@ -19,16 +19,18 @@ */ #include "iiowidget.h" -#include "channelattrdatastrategy.h" -#include "contextattrdatastrategy.h" -#include "deviceattrdatastrategy.h" -#include "iiowidgetselector.h" +#include "datastrategy/channelattrdatastrategy.h" +#include "datastrategy/contextattrdatastrategy.h" +#include "datastrategy/deviceattrdatastrategy.h" +#include "datastrategy/emptydatastrategy.h" + #include -#include -#include #include #include +#include +#include + using namespace scopy; Q_LOGGING_CATEGORY(CAT_IIOWIDGET, "iioWidget") @@ -44,41 +46,61 @@ IIOWidget::IIOWidget(GuiStrategyInterface *uiStrategy, DataStrategyInterface *da , m_lastReturnCode(0) , m_isConfigurable(false) { + // Config button + m_configBtn->setStyleSheet("border-image: url(\":/gui/icons/scopy-default/icons/gear_wheel.svg\");"); + m_configBtn->setVisible(m_isConfigurable); + + // General layout setLayout(new QVBoxLayout(this)); layout()->setContentsMargins(0, 0, 0, 0); layout()->setSpacing(0); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + QWidget *topWidget = new QWidget(this); + topWidget->setLayout(new QHBoxLayout(topWidget)); + topWidget->layout()->setContentsMargins(0, 0, 0, 0); + QWidget *ui = m_uiStrategy->ui(); if(ui) { - layout()->addWidget(ui); + topWidget->layout()->addWidget(ui); } + topWidget->layout()->addWidget(m_configBtn); + + layout()->addWidget(topWidget); layout()->addWidget(m_progressBar); - QObject *uiStrategyObject = dynamic_cast(m_uiStrategy); - QObject *dataStrategyObject = dynamic_cast(m_dataStrategy); + QObject *uiStrategyWidget = dynamic_cast(m_uiStrategy); + QObject *dataStrategyWidget = dynamic_cast(m_dataStrategy); - uiStrategyObject->setParent(this); - dataStrategyObject->setParent(this); + uiStrategyWidget->setParent(this); + dataStrategyWidget->setParent(this); + connect(m_configBtn, &QPushButton::clicked, this, &IIOWidget::reconfigure); connect(m_progressBar, &SmallProgressBar::progressFinished, this, [this]() { this->saveData(m_lastData); }); - connect(uiStrategyObject, SIGNAL(emitData(QString)), this, SLOT(startTimer(QString))); + connect(uiStrategyWidget, SIGNAL(emitData(QString)), this, SLOT(startTimer(QString))); + connect(uiStrategyWidget, SIGNAL(emitData(QString)), this, SIGNAL(emitData(QString))); + connect(uiStrategyWidget, SIGNAL(displayedNewData(QString, QString)), this, + SIGNAL(displayedNewData(QString, QString))); - connect(dataStrategyObject, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, + connect(dataStrategyWidget, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, SLOT(emitDataStatus(QDateTime, QString, QString, int, bool))); // forward data request from ui strategy to data strategy - connect(uiStrategyObject, SIGNAL(requestData()), dataStrategyObject, SLOT(readAsync())); + connect(uiStrategyWidget, SIGNAL(requestData()), dataStrategyWidget, SLOT(readAsync())); + connect(dataStrategyWidget, SIGNAL(sendData(QString, QString)), this, SIGNAL(sendData(QString, QString))); + connect(dataStrategyWidget, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, + SIGNAL(emitStatus(QDateTime, QString, QString, int, bool))); // forward data from data strategy to ui strategy - connect(dataStrategyObject, SIGNAL(sendData(QString, QString)), uiStrategyObject, + connect(dataStrategyWidget, SIGNAL(sendData(QString, QString)), uiStrategyWidget, SLOT(receiveData(QString, QString))); + connect(dataStrategyWidget, SIGNAL(aboutToWrite(QString, QString)), this, + SIGNAL(aboutToWrite(QString, QString))); // intercept the sendData from dataStrategy to collect information - connect(dataStrategyObject, SIGNAL(sendData(QString, QString)), this, SLOT(storeReadInfo(QString, QString))); + connect(dataStrategyWidget, SIGNAL(sendData(QString, QString)), this, SLOT(storeReadInfo(QString, QString))); - // The data will be populated here bool useLazyLoading = Preferences::GetInstance()->get("iiowidgets_use_lazy_loading").toBool(); if(!useLazyLoading) { // force skip lazy load LAZY_LOAD(initialize); @@ -95,9 +117,9 @@ void IIOWidget::writeAsync(QString data) { m_dataStrategy->writeAsync(data); } DataStrategyInterface *IIOWidget::swapDataStrategy(DataStrategyInterface *dataStrategy) { - QWidget *dataStrategyWidget = dynamic_cast(m_dataStrategy); - QWidget *uiStrategyWidget = dynamic_cast(m_uiStrategy); - QWidget *newDataStrategyWidget = dynamic_cast(dataStrategy); + QObject *dataStrategyWidget = dynamic_cast(m_dataStrategy); + QObject *uiStrategyWidget = dynamic_cast(m_uiStrategy); + QObject *newDataStrategyWidget = dynamic_cast(dataStrategy); // disconnect old data strategy disconnect(dataStrategyWidget, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, @@ -241,6 +263,13 @@ void IIOWidget::reconfigure() connect(m_configPopup, &IIOConfigurationPopup::exitButtonClicked, this, [&]() { m_configPopup->deleteLater(); }); + connect(m_configPopup, &IIOConfigurationPopup::emptyButtonClicked, this, [&]() { + DataStrategyInterface *ds = new EmptyDataStrategy(this); + DataStrategyInterface *oldDS = swapDataStrategy(ds); + delete oldDS; + delete m_configPopup; + m_uiStrategy->changeName("Empty"); + }); connect(m_configPopup, &IIOConfigurationPopup::selectButtonClicked, this, [&](IIOItem *item) { DataStrategyInterface *dsCreated = nullptr; switch(item->type()) { diff --git a/iio-widgets/src/iiowidgetbuilder.cpp b/iio-widgets/src/iiowidgetbuilder.cpp index 6f0aeea34b..b57e54a72e 100644 --- a/iio-widgets/src/iiowidgetbuilder.cpp +++ b/iio-widgets/src/iiowidgetbuilder.cpp @@ -21,14 +21,15 @@ #include "iiowidgetbuilder.h" #include "guistrategy/editableguistrategy.h" #include "guistrategy/switchguistrategy.h" +#include "guistrategy/comboguistrategy.h" +#include "guistrategy/rangeguistrategy.h" #include "datastrategy/channelattrdatastrategy.h" #include "datastrategy/triggerdatastrategy.h" #include "datastrategy/deviceattrdatastrategy.h" #include "datastrategy/contextattrdatastrategy.h" #include "datastrategy/cmdqchannelattrdatastrategy.h" #include "datastrategy/cmdqdeviceattrdatastrategy.h" -#include "guistrategy/comboguistrategy.h" -#include "guistrategy/rangeguistrategy.h" +#include "datastrategy/emptydatastrategy.h" #include #include @@ -36,20 +37,21 @@ using namespace scopy; Q_LOGGING_CATEGORY(CAT_ATTRBUILDER, "AttrBuilder") -IIOWidgetBuilder::IIOWidgetBuilder(QObject *parent) +IIOWidgetBuilder::IIOWidgetBuilder(QWidget *parent) : QObject(parent) , m_connection(nullptr) , m_isCompact(false) - , m_isConfigurable(false) + , m_isConfigurable(true) , m_context(nullptr) , m_device(nullptr) , m_channel(nullptr) , m_attribute("") , m_optionsAttribute("") , m_optionsValues("") + , m_title("") , m_dataStrategy(DS::NoDataStrategy) , m_uiStrategy(UIS::NoUIStrategy) - , m_widgetParent(nullptr) + , m_widgetParent(parent) {} IIOWidgetBuilder::~IIOWidgetBuilder() {} @@ -59,7 +61,7 @@ IIOWidget *IIOWidgetBuilder::buildSingle() DataStrategyInterface *ds = nullptr; GuiStrategyInterface *ui = nullptr; - if(!m_context && !m_device && !m_channel) { + if(!m_context && !m_device && !m_channel && m_dataStrategy != DS::EmptyData) { qWarning(CAT_ATTRBUILDER) << "No channel/device/context set."; return nullptr; } @@ -85,6 +87,9 @@ IIOWidget *IIOWidgetBuilder::buildSingle() IIOWidget *widget = new IIOWidget(ui, ds, m_widgetParent); widget->setRecipe(m_generatedRecipe); widget->setConfigurable(m_isConfigurable); + if(!m_title.isEmpty()) { + widget->changeTitle(m_title); + } return widget; } @@ -185,6 +190,7 @@ void IIOWidgetBuilder::clear() m_attribute = ""; m_optionsAttribute = ""; m_optionsValues = ""; + m_title = ""; m_dataStrategy = DS::NoDataStrategy; m_uiStrategy = UIS::NoUIStrategy; m_widgetParent = nullptr; @@ -208,6 +214,12 @@ IIOWidgetBuilder &IIOWidgetBuilder::configMode(bool isConfigurable) return *this; } +IIOWidgetBuilder &IIOWidgetBuilder::title(QString title) +{ + m_title = title; + return *this; +} + IIOWidgetBuilder &IIOWidgetBuilder::context(iio_context *context) { m_context = context; @@ -256,12 +268,6 @@ IIOWidgetBuilder &IIOWidgetBuilder::uiStrategy(UIS uiStrategy) return *this; } -IIOWidgetBuilder &IIOWidgetBuilder::parent(QWidget *parent) -{ - m_widgetParent = parent; - return *this; -} - DataStrategyInterface *IIOWidgetBuilder::createDS() { DataStrategyInterface *ds = nullptr; @@ -302,6 +308,9 @@ DataStrategyInterface *IIOWidgetBuilder::createDS() case DS::TriggerData: ds = new TriggerDataStrategy(m_generatedRecipe, m_widgetParent); break; + case DS::EmptyData: + ds = new EmptyDataStrategy(m_widgetParent); + break; default: qWarning(CAT_ATTRBUILDER) << "No valid Data Strategy was provided."; break; diff --git a/plugins/datalogger/src/menus/channelattributesmenu.cpp b/plugins/datalogger/src/menus/channelattributesmenu.cpp index 51cd5a28f5..2006555065 100644 --- a/plugins/datalogger/src/menus/channelattributesmenu.cpp +++ b/plugins/datalogger/src/menus/channelattributesmenu.cpp @@ -39,9 +39,8 @@ ChannelAttributesMenu::ChannelAttributesMenu(DataMonitorModel *model, QWidget *p if(qobject_cast(model)) { QList attrWidgets = - IIOWidgetBuilder() + IIOWidgetBuilder(parent) .channel(dynamic_cast(model)->iioChannel()) - .parent(parent) .buildAll(); for(auto w : attrWidgets) { diff --git a/plugins/debugger/src/iioexplorer/iiostandarditem.cpp b/plugins/debugger/src/iioexplorer/iiostandarditem.cpp index 6f5b6a6ac6..cbf1bc0795 100644 --- a/plugins/debugger/src/iioexplorer/iiostandarditem.cpp +++ b/plugins/debugger/src/iioexplorer/iiostandarditem.cpp @@ -143,8 +143,7 @@ void IIOStandardItem::connectLog() // this is leaf iio widget, it can probably read/write IIOWidget *widget = m_iioWidgets.at(0); - connect(dynamic_cast(widget->getDataStrategy()), - SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, + connect(widget, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, SLOT(forwardLog(QDateTime, QString, QString, int, bool))); } diff --git a/plugins/swiot/src/ad74413r/buffermenu.cpp b/plugins/swiot/src/ad74413r/buffermenu.cpp index af1431bfe7..ae179a0e02 100644 --- a/plugins/swiot/src/ad74413r/buffermenu.cpp +++ b/plugins/swiot/src/ad74413r/buffermenu.cpp @@ -37,13 +37,12 @@ BufferMenu::BufferMenu(QWidget *parent, QString chnlFunction, Connection *conn, , m_chnls(chnls) { if(m_chnls.contains(INPUT_CHNL)) { - m_samplingFreq = IIOWidgetBuilder() + m_samplingFreq = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[INPUT_CHNL])) .attribute("sampling_frequency") .optionsAttribute("sampling_frequency_available") .uiStrategy(IIOWidgetBuilder::UIS::ComboUi) - .parent(this) .buildSingle(); addMenuWidget(m_samplingFreq); connect(m_samplingFreq, &IIOWidget::displayedNewData, this, @@ -88,12 +87,11 @@ CurrentInLoopMenu::CurrentInLoopMenu(QWidget *parent, QString chnlFunction, Conn : BufferMenu(parent, chnlFunction, conn, chnls) { // dac code - output channel - IIOWidget *dacCode = IIOWidgetBuilder() + IIOWidget *dacCode = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("raw") .optionsValues("[0 1 8191]") - .parent(this) .buildSingle(); dacCode->changeTitle("DAC_CODE"); addMenuWidget(dacCode); @@ -134,24 +132,22 @@ DigitalInLoopMenu::DigitalInLoopMenu(QWidget *parent, QString chnlFunction, Conn : BufferMenu(parent, chnlFunction, conn, chnls) { // threshold - input channel - m_threshold = IIOWidgetBuilder() + m_threshold = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[INPUT_CHNL])) .attribute("threshold") .optionsValues("[0 1 16000]") - .parent(this) .buildSingle(); addMenuWidget(m_threshold); connect(m_threshold, &IIOWidget::emitData, this, &BufferMenu::thresholdChangeStart); connect(m_threshold, &IIOWidget::emitStatus, this, &DigitalInLoopMenu::onEmitStatus); // dac code - output channel - IIOWidget *dacCode = IIOWidgetBuilder() + IIOWidget *dacCode = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("raw") .optionsValues("[0 1 8191]") - .parent(this) .buildSingle(); dacCode->changeTitle("DAC_CODE"); addMenuWidget(dacCode); @@ -212,12 +208,11 @@ VoltageOutMenu::VoltageOutMenu(QWidget *parent, QString chnlFunction, Connection : BufferMenu(parent, chnlFunction, conn, chnls) { // dac code - output channel - IIOWidget *dacCode = IIOWidgetBuilder() + IIOWidget *dacCode = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("raw") .optionsValues("[0 1 8191]") - .parent(this) .buildSingle(); dacCode->changeTitle("DAC_CODE"); addMenuWidget(dacCode); @@ -236,34 +231,31 @@ VoltageOutMenu::VoltageOutMenu(QWidget *parent, QString chnlFunction, Connection connect(dacCode, &IIOWidget::sendData, this, &VoltageOutMenu::updateCnvtLabel); // slew - output channel - IIOWidget *slewOptions = IIOWidgetBuilder() + IIOWidget *slewOptions = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("slew_en") .optionsValues("0 1") - .parent(this) .buildSingle(); addMenuWidget(slewOptions); // slew step - output channel - IIOWidget *slewStep = IIOWidgetBuilder() + IIOWidget *slewStep = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("slew_step") .optionsAttribute("slew_step_available") .uiStrategy(IIOWidgetBuilder::UIS::ComboUi) - .parent(this) .buildSingle(); addMenuWidget(slewStep); // slew rate - output channel - IIOWidget *slewRate = IIOWidgetBuilder() + IIOWidget *slewRate = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("slew_rate") .optionsAttribute("slew_rate_available") .uiStrategy(IIOWidgetBuilder::UIS::ComboUi) - .parent(this) .buildSingle(); addMenuWidget(slewRate); } @@ -290,12 +282,11 @@ CurrentOutMenu::CurrentOutMenu(QWidget *parent, QString chnlFunction, Connection : BufferMenu(parent, chnlFunction, conn, chnls) { // dac code - output channel - IIOWidget *dacCode = IIOWidgetBuilder() + IIOWidget *dacCode = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("raw") .optionsValues("[0 1 8191]") - .parent(this) .buildSingle(); dacCode->changeTitle("DAC_CODE"); addMenuWidget(dacCode); @@ -314,34 +305,31 @@ CurrentOutMenu::CurrentOutMenu(QWidget *parent, QString chnlFunction, Connection connect(dacCode, &IIOWidget::sendData, this, &CurrentOutMenu::updateCnvtLabel); // slew - output channel - IIOWidget *slewOptions = IIOWidgetBuilder() + IIOWidget *slewOptions = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("slew_en") .optionsValues("0 1") - .parent(this) .buildSingle(); addMenuWidget(slewOptions); // slew step - output channel - IIOWidget *slewStep = IIOWidgetBuilder() + IIOWidget *slewStep = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("slew_step") .optionsAttribute("slew_step_available") .uiStrategy(IIOWidgetBuilder::UIS::ComboUi) - .parent(this) .buildSingle(); addMenuWidget(slewStep); // slew rate - output channel - IIOWidget *slewRate = IIOWidgetBuilder() + IIOWidget *slewRate = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("slew_rate") .optionsAttribute("slew_rate_available") .uiStrategy(IIOWidgetBuilder::UIS::ComboUi) - .parent(this) .buildSingle(); addMenuWidget(slewRate); } @@ -368,13 +356,12 @@ DiagnosticMenu::DiagnosticMenu(QWidget *parent, QString chnlFunction, Connection : BufferMenu(parent, chnlFunction, conn, chnls) { // diag options - input channel - IIOWidget *diagOptions = IIOWidgetBuilder() + IIOWidget *diagOptions = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[INPUT_CHNL])) .attribute("diag_function") .optionsAttribute("diag_function_available") .uiStrategy(IIOWidgetBuilder::UIS::ComboUi) - .parent(this) .buildSingle(); addMenuWidget(diagOptions); @@ -412,12 +399,11 @@ DigitalInMenu::DigitalInMenu(QWidget *parent, QString chnlFunction, Connection * : BufferMenu(parent, chnlFunction, conn, chnls) { // threshold - input channel - m_threshold = IIOWidgetBuilder() + m_threshold = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[INPUT_CHNL])) .attribute("threshold") .optionsValues("[0 1 16000]") - .parent(this) .buildSingle(); addMenuWidget(m_threshold); connect(m_threshold, &IIOWidget::emitData, this, &BufferMenu::thresholdChangeStart);