diff --git a/plugins/adc/src/adcfftinstrumentcontroller.cpp b/plugins/adc/src/adcfftinstrumentcontroller.cpp index 7fd56adaae..d10d02eb35 100644 --- a/plugins/adc/src/adcfftinstrumentcontroller.cpp +++ b/plugins/adc/src/adcfftinstrumentcontroller.cpp @@ -122,13 +122,13 @@ void ADCFFTInstrumentController::createIIODevice(AcqTreeNode *node) { GRIIODeviceSourceNode *griiodsn = dynamic_cast(node); GRDeviceComponent *d = new GRDeviceComponent(griiodsn); - addComponent(d); m_ui->addDevice(d->ctrl(), d); m_acqNodeComponentMap[griiodsn] = (d); m_fftPlotSettingsComponent->addSampleRateProvider(d); addComponent(d); + connect(d, &GRDeviceComponent::iioEvent, this, &ADCInstrumentController::iioEvent); connect(m_fftPlotSettingsComponent, &FFTPlotManagerSettings::samplingInfoChanged, this, [=](SamplingInfo p) { d->setBufferSize(p.bufferSize); }); } @@ -141,6 +141,7 @@ void ADCFFTInstrumentController::createIIOFloatChannel(AcqTreeNode *node) GRFFTChannelComponent *c = new GRFFTChannelComponent(griiofcn, dynamic_cast(m_plotComponentManager->plot(0)), grtsc, chIdP->pen(idx), m_ui->rightStack); + connect(c, &GRFFTChannelComponent::iioEvent, this, &ADCInstrumentController::iioEvent); Q_ASSERT(grtsc); m_plotComponentManager->addChannel(c); @@ -164,6 +165,7 @@ void ADCFFTInstrumentController::createIIOFloatChannel(AcqTreeNode *node) m_ui->addChannel(c->ctrl(), c, cw); + connect(dc, &GRDeviceComponent::iioEvent, this, &ADCInstrumentController::iioEvent); connect(c->ctrl(), &QAbstractButton::clicked, this, [=]() { m_plotComponentManager->selectChannel(c); }); grtsc->addChannel(c); // For matching Sink To Channels @@ -228,6 +230,7 @@ void ADCFFTInstrumentController::createIIOComplexChannel(AcqTreeNode *node_I, Ac m_ui->addChannel(c->ctrl(), c, cw); + connect(dc, &GRDeviceComponent::iioEvent, this, &ADCInstrumentController::iioEvent); connect(c->ctrl(), &QAbstractButton::clicked, this, [=]() { m_plotComponentManager->selectChannel(c); }); grtsc->addChannel(c); // For matching Sink To Channels diff --git a/plugins/adc/src/adcinstrumentcontroller.cpp b/plugins/adc/src/adcinstrumentcontroller.cpp index 7399e8cd34..ca57551851 100644 --- a/plugins/adc/src/adcinstrumentcontroller.cpp +++ b/plugins/adc/src/adcinstrumentcontroller.cpp @@ -57,10 +57,12 @@ ADCInstrumentController::ADCInstrumentController(ToolMenuEntry *tme, QString uri update(); if(m_refreshTimerRunning) m_plotTimer->start(); + Q_EMIT iioEvent(); }, Qt::QueuedConnection); m_ui = new ADCInstrument(tme, nullptr); + connect(this, &ADCInstrumentController::iioEvent, m_tme, &ToolMenuEntry::iioEvent); } ADCInstrumentController::~ADCInstrumentController() {} @@ -110,6 +112,7 @@ void ADCInstrumentController::start() ResourceManager::open("adc" + m_uri, this); bool ret = m_dataProvider->start(); if(!ret) { + Q_EMIT iioEvent(IIO_ERROR); Q_EMIT requestDisconnect(); } } diff --git a/plugins/adc/src/adcinstrumentcontroller.h b/plugins/adc/src/adcinstrumentcontroller.h index 538d187aa9..0b8d6a5ead 100644 --- a/plugins/adc/src/adcinstrumentcontroller.h +++ b/plugins/adc/src/adcinstrumentcontroller.h @@ -71,6 +71,9 @@ public Q_SLOTS: virtual void start(); virtual void stop() override; +Q_SIGNALS: + void iioEvent(int retCode = 0); + protected Q_SLOTS: virtual void stopUpdates(); virtual void startUpdates(); @@ -117,6 +120,7 @@ protected Q_SLOTS: ToolMenuEntry *m_tme; QString m_uri; + const int IIO_ERROR = -1; }; } // namespace adc diff --git a/plugins/adc/src/adctimeinstrumentcontroller.cpp b/plugins/adc/src/adctimeinstrumentcontroller.cpp index 52d5644635..ecc1529db1 100644 --- a/plugins/adc/src/adctimeinstrumentcontroller.cpp +++ b/plugins/adc/src/adctimeinstrumentcontroller.cpp @@ -167,6 +167,7 @@ void ADCTimeInstrumentController::createIIODevice(AcqTreeNode *node) m_timePlotSettingsComponent->addSampleRateProvider(d); addComponent(d); + connect(d, &GRDeviceComponent::iioEvent, this, &ADCInstrumentController::iioEvent); connect(m_timePlotSettingsComponent, &TimePlotManagerSettings::bufferSizeChanged, d, &GRDeviceComponent::setBufferSize); } @@ -179,6 +180,7 @@ void ADCTimeInstrumentController::createIIOFloatChannel(AcqTreeNode *node) GRTimeChannelComponent *c = new GRTimeChannelComponent(griiofcn, dynamic_cast(m_plotComponentManager->plot(0)), grtsc, chIdP->pen(idx), m_ui->rightStack); + connect(c, &GRTimeChannelComponent::iioEvent, this, &ADCInstrumentController::iioEvent); Q_ASSERT(grtsc); m_plotComponentManager->addChannel(c); @@ -215,6 +217,7 @@ void ADCTimeInstrumentController::createIIOFloatChannel(AcqTreeNode *node) m_defaultCh = c; m_plotComponentManager->selectChannel(c); } + connect(dc, &GRDeviceComponent::iioEvent, this, &ADCInstrumentController::iioEvent); } void ADCTimeInstrumentController::createImportFloatChannel(AcqTreeNode *node) diff --git a/plugins/adc/src/freq/grfftchannelcomponent.cpp b/plugins/adc/src/freq/grfftchannelcomponent.cpp index df2d1cc8b0..dfb51d905e 100644 --- a/plugins/adc/src/freq/grfftchannelcomponent.cpp +++ b/plugins/adc/src/freq/grfftchannelcomponent.cpp @@ -20,6 +20,7 @@ */ #include "grfftchannelcomponent.h" +#include "datastrategy/channelattrdatastrategy.h" #include #include #include @@ -286,6 +287,11 @@ QWidget *GRFFTChannelComponent::createChAttrMenu(iio_channel *ch, QString title, for(auto w : attrWidgets) { layout->addWidget(w); + connect(dynamic_cast(w->getDataStrategy()), + &ChannelAttrDataStrategy::emitStatus, this, + [this](QDateTime timestamp, QString oldData, QString newData, int returnCode, bool isReadOp) { + Q_EMIT iioEvent(returnCode); + }); } section->contentLayout()->addLayout(layout); diff --git a/plugins/adc/src/freq/grfftchannelcomponent.h b/plugins/adc/src/freq/grfftchannelcomponent.h index 1259c305b3..d42cdaef13 100644 --- a/plugins/adc/src/freq/grfftchannelcomponent.h +++ b/plugins/adc/src/freq/grfftchannelcomponent.h @@ -198,6 +198,7 @@ public Q_SLOTS: void powerOffsetChanged(double); void windowChanged(int); void windowCorrectionChanged(bool); + void iioEvent(int retCode); private: double m_powerOffset; diff --git a/plugins/adc/src/grdevicecomponent.cpp b/plugins/adc/src/grdevicecomponent.cpp index 7ade95098b..f6e85bfb11 100644 --- a/plugins/adc/src/grdevicecomponent.cpp +++ b/plugins/adc/src/grdevicecomponent.cpp @@ -20,6 +20,7 @@ */ #include "grdevicecomponent.h" +#include "datastrategy/deviceattrdatastrategy.h" #include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include using namespace scopy; using namespace scopy::adc; @@ -116,6 +118,10 @@ QWidget *GRDeviceComponent::createChCommonAttrMenu(QWidget *parent) for(auto w : attrWidgets) { layout->addWidget(w); + connect(dynamic_cast(w->getDataStrategy()), &MultiDataStrategy::emitStatus, this, + [this](QDateTime timestamp, QString oldData, QString newData, int returnCode, bool isReadOp) { + Q_EMIT iioEvent(returnCode); + }); } attr->contentLayout()->addLayout(layout); @@ -145,6 +151,11 @@ QWidget *GRDeviceComponent::createAttrMenu(QWidget *parent) for(auto w : attrWidgets) { layout->addWidget(w); + connect(dynamic_cast(w->getDataStrategy()), + &DeviceAttrDataStrategy::emitStatus, this, + [this](QDateTime timestamp, QString oldData, QString newData, int returnCode, bool isReadOp) { + Q_EMIT iioEvent(returnCode); + }); } attr->contentLayout()->addLayout(layout); diff --git a/plugins/adc/src/grdevicecomponent.h b/plugins/adc/src/grdevicecomponent.h index 5a972970e0..912a5ec73f 100644 --- a/plugins/adc/src/grdevicecomponent.h +++ b/plugins/adc/src/grdevicecomponent.h @@ -61,6 +61,9 @@ public Q_SLOTS: void removeChannel(ChannelComponent *c); void addChannel(ChannelComponent *c); +Q_SIGNALS: + void iioEvent(int retCode); + private: QString name; QWidget *widget; diff --git a/plugins/adc/src/time/grtimechannelcomponent.cpp b/plugins/adc/src/time/grtimechannelcomponent.cpp index 81c008a646..c2df3f697f 100644 --- a/plugins/adc/src/time/grtimechannelcomponent.cpp +++ b/plugins/adc/src/time/grtimechannelcomponent.cpp @@ -20,6 +20,7 @@ */ #include "grtimechannelcomponent.h" +#include "datastrategy/channelattrdatastrategy.h" #include #include #include @@ -95,6 +96,11 @@ QWidget *GRTimeChannelComponent::createYAxisMenu(QWidget *parent) .channel(m_src->channel()) .attribute(m_src->scaleAttribute()) .buildSingle(); + connect(dynamic_cast(m_scaleWidget->getDataStrategy()), + &ChannelAttrDataStrategy::emitStatus, this, + [this](QDateTime timestamp, QString oldData, QString newData, int returnCode, bool isReadOp) { + Q_EMIT iioEvent(returnCode); + }); } m_yCtrl = new MenuPlotAxisRangeControl(m_timePlotComponentChannel->m_timePlotYAxis, m_yaxisMenu); @@ -210,6 +216,11 @@ QWidget *GRTimeChannelComponent::createAttrMenu(QWidget *parent) for(auto w : attrWidgets) { layout->addWidget(w); + connect(dynamic_cast(w->getDataStrategy()), + &ChannelAttrDataStrategy::emitStatus, this, + [this](QDateTime timestamp, QString oldData, QString newData, int returnCode, bool isReadOp) { + Q_EMIT iioEvent(returnCode); + }); } section->contentLayout()->addLayout(layout); diff --git a/plugins/adc/src/time/grtimechannelcomponent.h b/plugins/adc/src/time/grtimechannelcomponent.h index 025fe27bbe..5547c08dea 100644 --- a/plugins/adc/src/time/grtimechannelcomponent.h +++ b/plugins/adc/src/time/grtimechannelcomponent.h @@ -129,6 +129,7 @@ public Q_SLOTS: Q_SIGNALS: void yModeChanged(); + void iioEvent(int retCode); private: GRIIOFloatChannelNode *m_node;