Skip to content

Commit

Permalink
plugins/adc: Emit iioEvent when needed.
Browse files Browse the repository at this point in the history
The signal is received by the tool menu through the ToolMenuEntry.

Signed-off-by: andreidanila1 <[email protected]>
  • Loading branch information
andreidanila1 committed Nov 21, 2024
1 parent 60f1bd7 commit 6691907
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugins/adc/src/adcfftinstrumentcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ void ADCFFTInstrumentController::createIIODevice(AcqTreeNode *node)
{
GRIIODeviceSourceNode *griiodsn = dynamic_cast<GRIIODeviceSourceNode *>(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); });
}
Expand All @@ -141,6 +141,7 @@ void ADCFFTInstrumentController::createIIOFloatChannel(AcqTreeNode *node)
GRFFTChannelComponent *c =
new GRFFTChannelComponent(griiofcn, dynamic_cast<FFTPlotComponent *>(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);
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions plugins/adc/src/adcinstrumentcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down Expand Up @@ -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();
}
}
Expand Down
4 changes: 4 additions & 0 deletions plugins/adc/src/adcinstrumentcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -117,6 +120,7 @@ protected Q_SLOTS:

ToolMenuEntry *m_tme;
QString m_uri;
const int IIO_ERROR = -1;
};

} // namespace adc
Expand Down
3 changes: 3 additions & 0 deletions plugins/adc/src/adctimeinstrumentcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -179,6 +180,7 @@ void ADCTimeInstrumentController::createIIOFloatChannel(AcqTreeNode *node)
GRTimeChannelComponent *c =
new GRTimeChannelComponent(griiofcn, dynamic_cast<TimePlotComponent *>(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);
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions plugins/adc/src/freq/grfftchannelcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

#include "grfftchannelcomponent.h"
#include "datastrategy/channelattrdatastrategy.h"
#include <pluginbase/preferences.h>
#include <gui/widgets/menusectionwidget.h>
#include <gui/widgets/menucollapsesection.h>
Expand Down Expand Up @@ -286,6 +287,11 @@ QWidget *GRFFTChannelComponent::createChAttrMenu(iio_channel *ch, QString title,

for(auto w : attrWidgets) {
layout->addWidget(w);
connect(dynamic_cast<ChannelAttrDataStrategy *>(w->getDataStrategy()),
&ChannelAttrDataStrategy::emitStatus, this,
[this](QDateTime timestamp, QString oldData, QString newData, int returnCode, bool isReadOp) {
Q_EMIT iioEvent(returnCode);
});
}

section->contentLayout()->addLayout(layout);
Expand Down
1 change: 1 addition & 0 deletions plugins/adc/src/freq/grfftchannelcomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public Q_SLOTS:
void powerOffsetChanged(double);
void windowChanged(int);
void windowCorrectionChanged(bool);
void iioEvent(int retCode);

private:
double m_powerOffset;
Expand Down
11 changes: 11 additions & 0 deletions plugins/adc/src/grdevicecomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
*/

#include "grdevicecomponent.h"
#include "datastrategy/deviceattrdatastrategy.h"
#include <gui/channelcomponent.h>
#include <widgets/menucollapsesection.h>
#include <widgets/menusectionwidget.h>
#include <widgets/menuheader.h>
#include <iio-widgets/iiowidget.h>
#include <iio-widgets/iiowidgetbuilder.h>
#include <style.h>
#include <datastrategy/multidatastrategy.h>

using namespace scopy;
using namespace scopy::adc;
Expand Down Expand Up @@ -116,6 +118,10 @@ QWidget *GRDeviceComponent::createChCommonAttrMenu(QWidget *parent)

for(auto w : attrWidgets) {
layout->addWidget(w);
connect(dynamic_cast<MultiDataStrategy *>(w->getDataStrategy()), &MultiDataStrategy::emitStatus, this,
[this](QDateTime timestamp, QString oldData, QString newData, int returnCode, bool isReadOp) {
Q_EMIT iioEvent(returnCode);
});
}

attr->contentLayout()->addLayout(layout);
Expand Down Expand Up @@ -145,6 +151,11 @@ QWidget *GRDeviceComponent::createAttrMenu(QWidget *parent)

for(auto w : attrWidgets) {
layout->addWidget(w);
connect(dynamic_cast<DeviceAttrDataStrategy *>(w->getDataStrategy()),
&DeviceAttrDataStrategy::emitStatus, this,
[this](QDateTime timestamp, QString oldData, QString newData, int returnCode, bool isReadOp) {
Q_EMIT iioEvent(returnCode);
});
}

attr->contentLayout()->addLayout(layout);
Expand Down
3 changes: 3 additions & 0 deletions plugins/adc/src/grdevicecomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions plugins/adc/src/time/grtimechannelcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

#include "grtimechannelcomponent.h"
#include "datastrategy/channelattrdatastrategy.h"
#include <pluginbase/preferences.h>
#include <gui/widgets/menusectionwidget.h>
#include <gui/widgets/menucollapsesection.h>
Expand Down Expand Up @@ -95,6 +96,11 @@ QWidget *GRTimeChannelComponent::createYAxisMenu(QWidget *parent)
.channel(m_src->channel())
.attribute(m_src->scaleAttribute())
.buildSingle();
connect(dynamic_cast<ChannelAttrDataStrategy *>(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);
Expand Down Expand Up @@ -210,6 +216,11 @@ QWidget *GRTimeChannelComponent::createAttrMenu(QWidget *parent)

for(auto w : attrWidgets) {
layout->addWidget(w);
connect(dynamic_cast<ChannelAttrDataStrategy *>(w->getDataStrategy()),
&ChannelAttrDataStrategy::emitStatus, this,
[this](QDateTime timestamp, QString oldData, QString newData, int returnCode, bool isReadOp) {
Q_EMIT iioEvent(returnCode);
});
}

section->contentLayout()->addLayout(layout);
Expand Down
1 change: 1 addition & 0 deletions plugins/adc/src/time/grtimechannelcomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public Q_SLOTS:

Q_SIGNALS:
void yModeChanged();
void iioEvent(int retCode);

private:
GRIIOFloatChannelNode *m_node;
Expand Down

0 comments on commit 6691907

Please sign in to comment.