Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adc: refactor time and FFT instruments #1687

Merged
merged 60 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
960b352
adc: big adc refactor
adisuciu May 15, 2024
2ad2ce4
adc: implement units from iio-util
adisuciu Jun 26, 2024
6e79261
adc: fix measurement widget height
adisuciu Jun 26, 2024
b84e02f
adc: fix measurement panel update
adisuciu Jun 26, 2024
c983789
adc: y-axis label and tracker fix
adisuciu Jun 27, 2024
c53a454
adc: multiplot menus
adisuciu Jun 28, 2024
01bf0bd
adc: use units on plotlabels
adisuciu Jul 3, 2024
e4cdc6b
adc: various fixes
adisuciu Jul 3, 2024
7f02d54
adc: add multi-instrument time
adisuciu Jul 3, 2024
66cddfb
adc: use synccontroller to sync instruments
adisuciu Jul 5, 2024
fd716fd
adc: plotmanager refactor
adisuciu Jul 10, 2024
45e3de6
adc: fix plot change autoscale and yctrl bug
adisuciu Jul 11, 2024
9f751be
adc: added fft boilerplate - wip
adisuciu Jul 11, 2024
12a61f8
adc: Added power offset
adisuciu Jul 29, 2024
0b5a350
adc: added cursors
adisuciu Aug 1, 2024
8ed759f
adc: some fixes to plot labels
adisuciu Aug 2, 2024
e4e5144
gui: menuspinbox first implementation
adisuciu Aug 5, 2024
2f997fb
adc: added plotinfo
adisuciu Aug 7, 2024
4fdcd99
adc: fix plotaxisHandle deinit bug
adisuciu Aug 7, 2024
93edccf
adc: fix cursor bug on add/remove channels
adisuciu Aug 7, 2024
e9ae55c
adc: fixed plotnavigator delete bug
adisuciu Aug 7, 2024
f047104
gui: added menuspinbox - wip
adisuciu Aug 7, 2024
efc0a78
adc: add buffer previewer
adisuciu Aug 8, 2024
0329f58
gui: added menuspinbox
adisuciu Aug 9, 2024
7269586
adc: update cursor tracking on replot
adisuciu Aug 16, 2024
ee7b7af
adc: auto select one channel
adisuciu Aug 16, 2024
9932c2e
adc: fix poweroffset bug
adisuciu Aug 16, 2024
4ea502a
adc: connect toolmenuentry to adc instrument
adisuciu Aug 16, 2024
8f99d7b
adc: various fixes
adisuciu Aug 19, 2024
99f0958
adc: format.sh
adisuciu Aug 19, 2024
2656e50
gui: add plotbuttonmanager
adisuciu Aug 20, 2024
6ce4650
adc: fix complex fft magnitude
adisuciu Aug 20, 2024
20123e5
gui: various fixes
adisuciu Aug 21, 2024
ce85262
adc: fix time measurement sample rate setting
adisuciu Aug 21, 2024
60e8991
adc: add marker for frequency
adisuciu Aug 21, 2024
c7c4df7
general: tools/format.sh
adisuciu Aug 26, 2024
70b89c2
adc: marker fixup
adisuciu Aug 27, 2024
e3b574a
adc: frequency magnitude fixup
adisuciu Aug 27, 2024
36e1856
adc: add FPS to plot
adisuciu Aug 28, 2024
ef8d2de
adc: fix complex channel generation for fft
adisuciu Aug 29, 2024
d46b0e1
adc: add preference for add/remove plot/instrument
adisuciu Aug 29, 2024
98fac76
adc: cleanup plotinfo on time/fft plots
adisuciu Aug 29, 2024
007d230
adc: added autoscale to fftplot
adisuciu Aug 29, 2024
c6fc910
adc: format.sh
adisuciu Aug 29, 2024
8b63cd3
adc/GRDeviceComponent: Add checks for nullptr
Andrei-Fabian-Pop Sep 6, 2024
b4e669a
adc: added doc initial revision
adisuciu Sep 12, 2024
49da907
adc: multiple plot cursors fix
andrei47w Sep 2, 2024
0615282
cursor readouts: draggable background fix
andrei47w Sep 2, 2024
476e6d0
plot widget: changed grid color
andrei47w Sep 2, 2024
96325ce
buffer previewer: fixed bad limits
andrei47w Sep 2, 2024
6b29183
adc: add cursor/navigator sync to fft instrument
adisuciu Sep 6, 2024
644838a
adc: move default position of cursor readouts to bottom right
adisuciu Sep 6, 2024
42519fe
adc: fixed scroll bar showing when only 1 marker is enabled
adisuciu Sep 6, 2024
710d904
adc: changed display name of instruments
adisuciu Sep 6, 2024
fb929ce
gui: added scroll area to VerticalChannelManager
andrei47w Sep 4, 2024
f9cfd07
BufferPreviewer: rework previewer to use PlotMagnifier
andrei47w Sep 6, 2024
424b855
PlotNavigator: added sync function for all axes
andrei47w Sep 10, 2024
46f6ef3
adc: Fixed plot navigator sync
andrei47w Sep 11, 2024
4f7d5c8
adc: primary plot cannot be deleted
andrei47w Sep 12, 2024
03eaf29
gr-util: fix unit tests
adisuciu Sep 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions core/src/scopymainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ ScopyMainWindow::ScopyMainWindow(QWidget *parent)
#ifdef SCOPY_DEV_MODE
// this is an example of how autoconnect is done

// auto id = api->addDevice("ip:127.0.0.1", "m2k");
// auto id = api->addDevice("ip:10.48.65.163", "iio");
// auto id = api->addDevice("ip:192.168.2.1", "iio");
// auto id = api->addDevice("", "test");
// auto id = api->addDevice("ip:127.0.0.1", "m2k");
// auto id = api->addDevice("ip:10.48.65.163", "iio");
auto id = api->addDevice("ip:192.168.2.1", "iio");
// auto id = api->addDevice("", "test");

// api->connectDevice(id);
// api->switchTool(id, "Oscilloscope");
// api->connectDevice(id);
// api->switchTool(id, "Time");
#endif

qInfo(CAT_BENCHMARK) << "ScopyMainWindow constructor took: " << timer.elapsed() << "ms";
Expand Down
1 change: 1 addition & 0 deletions core/src/toolmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ void ToolManager::unlockToolList(QString s)
void ToolManager::updateToolEntry(ToolMenuEntry *tme)
{
auto m = tm->getToolMenuItemFor(tme->uuid());
QSignalBlocker sb(m->getToolRunBtn());
m->setVisible(tme->visible());
m->setEnabled(tme->enabled());
m->setName(tme->name());
Expand Down
70 changes: 70 additions & 0 deletions docs/plugins/adc/adc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.. _adc:

ADC plugin
================================================================================

Description:

The ADC plugin is used to interface with IIO ADCs that implement an IIO buffer mechanism. The plugin implements two instruments for data acquisition and visualization in time and frequency domain.

Compatible:

The plugin is compatible with contexts that have at least an IIO device that implements an IIO buffer interface.

Usage:

Time:

Plot
Plot Controls
- buffersize
- plot size
- rolling mode
- XMode
- sampling rate (autoread)
- autoscale
- XY
- Plot/Curve settings

Channel controls
- Y-Axis controls
- Measurements
- Scaling (autoread)
- Curve
- Attributes
- Plot


Device controls:
- Attributes

Cursors

Frequency
Plot
Plot Controls
- buffersize
- XMode
- Sampling rate
- Frequency offset
- YAxis
- Power offset
- Window
- Window correction
- Plot/Curve settings

Channel Controls
- Y-Axis
- Marker
- Marker types
- Curve
- Attributes
- Plot

Complex mode


Preferences:

Usecases:

3 changes: 2 additions & 1 deletion docs/plugins/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ What is a Scopy plugin ?

General IIO plugins

* ADC Plugin
* :ref: `ADC Plugin <adc>`

* DAC plugin

Expand Down Expand Up @@ -60,6 +60,7 @@ Contents
.. toctree::
:maxdepth: 3

adc/adc
datalogger/datalogger
registermap/registermap
m2k/index
Expand Down
74 changes: 74 additions & 0 deletions gr-util/include/gr-util/grfftfloatproxy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#ifndef GRFFTPROC_H
#define GRFFTPROC_H

#include "grproxyblock.h"
#include "scopy-gr-util_export.h"

#include <gnuradio/blocks/stream_to_vector.h>
#include <gnuradio/fft/fft_v.h>
#include <gnuradio/fft/window.h>
#include <gnuradio/blocks/float_to_complex.h>
#include <gnuradio/blocks/vector_sink.h>
#include <gnuradio/blocks/complex_to_mag_squared.h>
#include <gnuradio/blocks/nlog10_ff.h>
#include <gnuradio/blocks/multiply_const.h>
#include <gnuradio/blocks/add_const_v.h>
#include <QMap>

namespace scopy::grutil {
class SCOPY_GR_UTIL_EXPORT GRFFTFloatProc : public GRProxyBlock
{
public:
GRFFTFloatProc(QObject *parent = nullptr);
void setWindow(gr::fft::window::win_type w);
void setWindowCorrection(bool b);
void setPowerOffset(double);
void setNrBits(int);
void build_blks(GRTopBlock *top);
void destroy_blks(GRTopBlock *top);

protected:
double m_powerOffset;
int nrBits;
gr::fft::fft_v<float, true>::sptr fft;
bool m_windowCorr;
gr::blocks::multiply_const_ff::sptr mult_nrbits;
gr::blocks::complex_to_mag_squared::sptr ctm;
gr::blocks::multiply_const_cc::sptr mult_wind_corr;
gr::blocks::multiply_const_ff::sptr mult_const1;
gr::blocks::nlog10_ff::sptr nlog10;
gr::blocks::add_const_vff::sptr powerOffset;

gr::fft::window::win_type m_fftwindow;
GRTopBlock *m_top;
};

class SCOPY_GR_UTIL_EXPORT GRFFTComplexProc : public GRProxyBlock
{
public:
GRFFTComplexProc(QObject *parent = nullptr);
void setWindow(gr::fft::window::win_type w);
void setPowerOffset(double);
void setWindowCorrection(bool b);
void setNrBits(int);
void build_blks(GRTopBlock *top);
void destroy_blks(GRTopBlock *top);

protected:
double m_powerOffset;
int nrBits;
bool m_windowCorr;
gr::fft::fft_v<gr_complex, true>::sptr fft_complex;
gr::blocks::multiply_const_cc::sptr mult_nrbits;
gr::blocks::complex_to_mag_squared::sptr ctm;
gr::blocks::multiply_const_cc::sptr mult_wind_corr;
gr::blocks::multiply_const_ff::sptr mult_const1;
gr::blocks::nlog10_ff::sptr nlog10;
gr::blocks::add_const_vff::sptr powerOffset;

gr::fft::window::win_type m_fftwindow;
GRTopBlock *m_top;
};
} // namespace scopy::grutil

#endif // GRFFTFLOATPROXY_H
6 changes: 6 additions & 0 deletions gr-util/include/gr-util/griiocomplexchannelsrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <gnuradio/blocks/float_to_complex.h>
#include <gnuradio/blocks/short_to_float.h>
#include <gnuradio/blocks/stream_to_vector.h>

namespace scopy::grutil {

Expand All @@ -22,11 +23,16 @@ class SCOPY_GR_UTIL_EXPORT GRIIOComplexChannelSrc : public GRIIOChannel
const QString &getChannelNameI() const;
const QString &getChannelNameQ() const;

const iio_data_format *getFmt() const;

protected:
QString channelNameI;
QString channelNameQ;

const iio_data_format *fmt;
gr::blocks::short_to_float::sptr s2f[2];
gr::blocks::float_to_complex::sptr f2c;
gr::blocks::stream_to_vector::sptr s2v;
};
} // namespace scopy::grutil
#endif // GRIIOCOMPLEXCHANNELSRC_H
13 changes: 9 additions & 4 deletions gr-util/include/gr-util/griiodevicesource.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@ class SCOPY_GR_UTIL_EXPORT GRIIOChannel : public GRProxyBlock
GRIIOChannel(QString channelName, GRIIODeviceSource *dev, QObject *parent = nullptr)
: GRProxyBlock(parent)
, channelName(channelName)
, dev(dev)
, m_dev(dev)
{}
GRIIODeviceSource *getDeviceSrc() { return dev; }
GRIIODeviceSource *getDeviceSrc() { return m_dev; }
QString getChannelName() { return channelName; }
virtual bool sampleRateAvailable() { return false; }
virtual bool samplerateAttributeAvailable() { return false; }
virtual double readSampleRate() { return -1; }
static QString findAttribute(QStringList possibleNames, iio_channel *);

virtual bool scaleAttributeAvailable() { return false; };
virtual double readScale() { return 1; };

protected:
QString channelName;
GRIIODeviceSource *dev;
GRIIODeviceSource *m_dev;
};

class SCOPY_GR_UTIL_EXPORT GRIIODeviceSource : public GRProxyBlock
Expand All @@ -51,11 +54,13 @@ class SCOPY_GR_UTIL_EXPORT GRIIODeviceSource : public GRProxyBlock
std::vector<std::string> channelNames() const;

QString deviceName() const;
bool sampleRateAvailable();
double readSampleRate();

static QString findAttribute(QStringList possibleNames, iio_device *dev);

iio_device *iioDev() const;
iio_context *ctx() const;

protected:
QList<GRIIOChannel *> m_list;
Expand Down
22 changes: 19 additions & 3 deletions gr-util/include/gr-util/griiofloatchannelsrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,45 @@
#define GRIIOFLOATCHANNELSRC_H

#include "griiodevicesource.h"
#include "iioutil/iiounits.h"
#include "scopy-gr-util_export.h"
#include <gnuradio/blocks/stream_to_vector.h>

namespace scopy::grutil {
class SCOPY_GR_UTIL_EXPORT GRIIOFloatChannelSrc : public GRIIOChannel
{
public:
GRIIOFloatChannelSrc(GRIIODeviceSource *dev, QString channelName, QObject *parent = nullptr);

void build_blks(GRTopBlock *top);
void destroy_blks(GRTopBlock *top);
virtual bool sampleRateAvailable() override;
void build_blks(GRTopBlock *top) override;
void destroy_blks(GRTopBlock *top) override;

virtual bool samplerateAttributeAvailable() override;
virtual double readSampleRate() override;

virtual bool scaleAttributeAvailable() override;
virtual double readScale() override;

IIOUnit unit();

const iio_data_format *getFmt() const;
struct iio_channel *channel() const;
struct iio_device *dev() const;
struct iio_context *ctx() const;

const QString &scaleAttribute() const;

protected:
gr::basic_block_sptr x2f;
gr::blocks::stream_to_vector::sptr s2v;

private:
GRTopBlock *m_top;
IIOUnit m_unit;
const iio_data_format *fmt;
iio_channel *m_iioCh;
QString m_sampleRateAttribute;
QString m_scaleAttribute;
};
} // namespace scopy::grutil
#endif // GRIIOFLOATCHANNELSRC_H
5 changes: 3 additions & 2 deletions gr-util/include/gr-util/grscaleoffsetproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "grproxyblock.h"
#include "scopy-gr-util_export.h"

#include <gnuradio/blocks/add_const_ff.h>
#include <gnuradio/blocks/add_const_v.h>
#include <gnuradio/blocks/multiply_const.h>

namespace scopy::grutil {
Expand All @@ -18,10 +18,11 @@ class SCOPY_GR_UTIL_EXPORT GRScaleOffsetProc : public GRProxyBlock
void destroy_blks(GRTopBlock *top);

protected:
gr::blocks::add_const_ff::sptr add;
gr::blocks::add_const_v<float>::sptr add;
gr::blocks::multiply_const_ff::sptr mul;
double m_scale;
double m_offset;
GRTopBlock *m_top;
};
} // namespace scopy::grutil
#endif // GRSCALEOFFSETPROC_H
2 changes: 2 additions & 0 deletions gr-util/include/gr-util/grsignalsrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "scopy-gr-util_export.h"

#include <gnuradio/analog/sig_source.h>
#include <gnuradio/blocks/stream_to_vector.h>

namespace scopy::grutil {
class SCOPY_GR_UTIL_EXPORT GRSignalSrc : public GRProxyBlock
Expand All @@ -26,6 +27,7 @@ class SCOPY_GR_UTIL_EXPORT GRSignalSrc : public GRProxyBlock
protected:
gr::analog::sig_source_f::sptr sig;
gr::analog::gr_waveform_t m_waveform;
gr::blocks::stream_to_vector::sptr s2v;
double m_sampling_frequency;
double m_freq;
double m_phase;
Expand Down
7 changes: 7 additions & 0 deletions gr-util/include/gr-util/grtopblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ class SCOPY_GR_UTIL_EXPORT GRTopBlock : public QObject
void registerIIODeviceSource(GRIIODeviceSource *);
void unregisterIIODeviceSource(GRIIODeviceSource *);

void setVLen(size_t vlen);
size_t vlen();

void connect(gr::basic_block_sptr src, int srcPort, gr::basic_block_sptr dst, int dstPort);

gr::top_block_sptr getGrBlock();

QString name() const;

Q_SIGNALS:
void aboutToBuild();
void builtSignalPaths();
Expand All @@ -37,6 +42,7 @@ class SCOPY_GR_UTIL_EXPORT GRTopBlock : public QObject
void aboutToStop();
void stopped();
void finished();
void requestRebuild();

public Q_SLOTS:
void build();
Expand All @@ -51,6 +57,7 @@ public Q_SLOTS:
QString m_name;
bool running;
bool built;
size_t m_vlen;
QList<GRSignalPath *> m_signalPaths;
QList<GRIIODeviceSource *> m_iioDeviceSources;
};
Expand Down
7 changes: 2 additions & 5 deletions gr-util/include/gr-util/time_sink_f.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,19 @@ class SCOPY_GR_UTIL_EXPORT time_sink_f : virtual public gr::sync_block
// scopy::time_sink_f::sptr
typedef std::shared_ptr<time_sink_f> sptr;

static sptr make(int size, float sampleRate, const std::string &name, int nconnections);
static sptr make(int size, size_t vlen, float sampleRate, const std::string &name, int nconnections);
virtual std::string name() const = 0;
virtual void updateData() = 0;
virtual uint64_t updateData() = 0;
virtual const std::vector<float> &time() const = 0;
virtual const std::vector<float> &freq() const = 0;
virtual const std::vector<std::vector<float>> &data() const = 0;
virtual const std::vector<std::vector<PlotTag_t>> &tags() const = 0;
virtual void setRollingMode(bool) = 0;
virtual bool rollingMode() = 0;
virtual void setSingleShot(bool) = 0;
virtual bool singleShot() = 0;
virtual bool finishedAcquisition() = 0;
virtual bool computeTags() = 0;
virtual float freqOffset() = 0;
virtual void setFreqOffset(float) = 0;
virtual void setComputeTags(bool newComputeTags) = 0;
virtual bool fftComplex() = 0;
virtual void setFftComplex(bool) = 0;
};
Expand Down
Loading
Loading