Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 15 additions & 6 deletions gui/style/qss/properties/widget/tableViewWidget.qss
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
QHeaderView::section[&&property&&=true] {
border: 1px solid &content_default&;
background-color: &background_primary&;
QTableWidget QHeaderView::section {
background-color: &background_primary&;
border: 1px solid &background_secondary&;
}

QTableWidget::item[&&property&&=true] {
border-right: 1px dashed &content_default&;
border-bottom: 1px dashed &content_default&;
QTableWidget QTableCornerButton::section {
background-color: &background_primary&;
border: 1px solid &background_secondary&;
}

QTableWidget {
gridline-color: &background_secondary&;
}

QTableWidget::item:selected {
background-color: &interactive_primary_hover&;
color: &content_inverse&;
}
4 changes: 4 additions & 0 deletions packages/pqmon/plugins/pqm/include/pqm/acquisitionmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ private Q_SLOTS:
double convertFromHwToHost(int value, QString chnlId);
void enableBufferChnls(iio_device *dev);
void readData();
void readAttrData();
void readBuffData();
bool readPqmAttributes();
bool readBufferedData();
void setData(QMap<QString, QMap<QString, QString>>);
Expand Down Expand Up @@ -95,6 +97,8 @@ private Q_SLOTS:
bool m_attrHaveBeenRead = false;
bool m_buffHaveBeenRead = false;
bool m_hasFwVers = false;
bool m_concurrentAcq = false;
bool m_alternateExecution = false;
const int THREAD_FINISH_TIMEOUT = 10000;
};
} // namespace scopy::pqm
Expand Down
62 changes: 62 additions & 0 deletions packages/pqmon/plugins/pqm/include/pqm/attrinstrumenthandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2024 Analog Devices Inc.
*
* This file is part of Scopy
* (see https://www.github.com/analogdevicesinc/scopy).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

#ifndef ATTRINSTRUMENTHANDLER_H
#define ATTRINSTRUMENTHANDLER_H

#include <QObject>
#include <harmonicsinstrument.h>
#include <rmsinstrument.h>
#include <pluginbase/resourcemanager.h>

namespace scopy::pqm {
class AttrInstrumentHandler : public QObject, public ResourceUser
{
Q_OBJECT
public:
AttrInstrumentHandler(QString m_uri, QObject *parent = nullptr);
~AttrInstrumentHandler();

void stop() override;

void setHarmonicsInstrument(HarmonicsInstrument *newHarmonicsInstrument);

void setRmsInstrument(RmsInstrument *newRmsInstrument);

public Q_SLOTS:
void onToggle(bool en, const QString &tool);
void concurrentEnable(QString pref, QVariant value);

private:
bool isAnyToolRunning();
void resourceManagerCheck(bool en);
void resetValues();

QMap<QString, bool> m_runningMap = {{RMS_TOOL, false}, {HARMONICS_TOOL, false}};
bool m_concurrentAcq = false;
bool m_resourceLock = false;
QString m_uri;
HarmonicsInstrument *m_harmonicsInstrument = nullptr;
RmsInstrument *m_rmsInstrument = nullptr;
};
} // namespace scopy::pqm

#endif // ATTRINSTRUMENTHANDLER_H
29 changes: 22 additions & 7 deletions packages/pqmon/plugins/pqm/include/pqm/harmonicsinstrument.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,44 @@
#include <gui/flexgridlayout.hpp>
#include <QTableWidget>
#include <QWidget>
#include <dockableareainterface.h>
#include <pqmdatalogger.h>
#include <gui/widgets/measurementlabel.h>
#include <gui/widgets/menucontrolbutton.h>
#include <gui/widgets/toolbuttons.h>
#include <pluginbase/resourcemanager.h>

#define NUMBER_OF_HARMONICS 51
#define HARMONICS_MIN_DEGREE 0
#define HARMONICS_MAX_DEGREE 50
#define MAX_CHNLS 6
#define HARMONICS_TOOL "harmonics"

namespace scopy::pqm {
class SCOPY_PQM_EXPORT HarmonicsInstrument : public QWidget, public ResourceUser
class SCOPY_PQM_EXPORT HarmonicsInstrument : public QWidget
{
Q_OBJECT
public:
HarmonicsInstrument(ToolMenuEntry *tme, QString uri, QWidget *parent = nullptr);
~HarmonicsInstrument();

void showThdWidget(bool show);

public Q_SLOTS:
void stop() override;
void stop();
void toggleHarmonics(bool en);
void onAttrAvailable(QMap<QString, QMap<QString, QString>> attr);

Q_SIGNALS:
void enableTool(bool en, QString toolName = "harmonics");
void enableTool(bool en, QString toolName = HARMONICS_TOOL);
void logData(PqmDataLogger::ActiveInstrument instr, const QString &filePath);
void pqEvent();
void showPlots(bool show);

// Emitted when this instrument requests other instruments to reset their event buttons
void resetEventsRequest();
// Received signal to reset this instrument's event button
void resetEventsBtn();

private Q_SLOTS:
void updateTable();
void onActiveChnlChannged(QString chnlId);
Expand All @@ -66,15 +76,19 @@ private Q_SLOTS:
private:
void initData();
void initTable();
void initPlot();
void setupPlotChannels();
QWidget *createThdWidget();
void initPlot(PlotWidget *plot);
void createCurrentPlots(QWidget *parent = nullptr);
QMap<QString, PlotChannel *> setupPlotChannels(PlotWidget *plot, const QMap<QString, QString> &channels,
int startChIndex = 0);
void concurrentEnable(QString pref, QVariant value);
QWidget *createThdWidget(QWidget *parent = nullptr);
QWidget *createSettingsMenu(QWidget *parent);
QWidget *createMenuGeneralSection(QWidget *parent);
QWidget *createMenuLogSection(QWidget *parent);
bool selectedFromSameCol(QModelIndexList list);
QPushButton *createPQEventsBtn(QWidget *parent);

DockableAreaInterface *m_dockableArea;
QString m_uri;
bool m_running;
QString m_harmonicsType;
Expand All @@ -83,6 +97,7 @@ private Q_SLOTS:
SingleShotBtn *m_singleBtn;
QTableWidget *m_table;
PlotWidget *m_plot;
QMap<QString, PlotWidget *> m_currentPlots;
std::vector<double> m_xTime;
QMap<QString, std::vector<double>> m_yValues;
QMap<QString, MeasurementLabel *> m_labels;
Expand Down
4 changes: 4 additions & 0 deletions packages/pqmon/plugins/pqm/include/pqm/pqmplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <QObject>
#include <acquisitionmanager.h>
#include <attrinstrumenthandler.h>
#include <gui/infopage.h>
#include <pluginbase/plugin.h>
#include <pluginbase/pluginbase.h>
Expand All @@ -41,6 +42,8 @@ class SCOPY_PQM_EXPORT PQMPlugin : public QObject, public PluginBase
public:
void preload() override;
bool compatible(QString m_param, QString category) override;
void initPreferences() override;
bool loadPreferencesPage() override;
bool loadPage() override;
bool loadIcon() override;
void loadToolList() override;
Expand All @@ -61,6 +64,7 @@ public Q_SLOTS:

InfoPage *m_infoPage;
AcquisitionManager *m_acqManager;
AttrInstrumentHandler *m_attrHandler;
};
} // namespace scopy::pqm

Expand Down
13 changes: 9 additions & 4 deletions packages/pqmon/plugins/pqm/include/pqm/rmsinstrument.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
#include <gui/widgets/measurementlabel.h>
#include <gui/docking/dockwrapperinterface.h>
#include <gui/docking/dockableareainterface.h>
#include <pluginbase/resourcemanager.h>
#include <pluginbase/toolmenuentry.h>

#define DEVICE_NAME "pqm"
#define RMS_TOOL "rms"

namespace scopy::pqm {
class SCOPY_PQM_EXPORT RmsInstrument : public QWidget, public ResourceUser
class SCOPY_PQM_EXPORT RmsInstrument : public QWidget
{
Q_OBJECT
public:
Expand All @@ -46,11 +46,16 @@ class SCOPY_PQM_EXPORT RmsInstrument : public QWidget, public ResourceUser

Q_SIGNALS:
void pqEvent();
void enableTool(bool en, QString toolName = "rms");
void enableTool(bool en, QString toolName = RMS_TOOL);
void logData(PqmDataLogger::ActiveInstrument instr, const QString &filePath);

// Emitted when this instrument requests other instruments to reset their event buttons
void resetEventsRequest();
// Received signal to reset this instrument's event button
void resetEventsBtn();

public Q_SLOTS:
void stop() override;
void stop();
void toggleRms(bool en);
void onAttrAvailable(QMap<QString, QMap<QString, QString>> data);

Expand Down
3 changes: 3 additions & 0 deletions packages/pqmon/plugins/pqm/include/pqm/waveforminstrument.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ private Q_SLOTS:
void initData();
void initPlot(PlotWidget *plot, QString unitType, int yMin = -650, int yMax = 650);
void setupChannels(PlotWidget *plot, QMap<QString, QString> chnls);
void resourceManagerCheck(bool en);
void concurrentEnable(QString pref, QVariant value);
QWidget *createSettMenu(QWidget *parent);
QWidget *createMenuLogSection(QWidget *parent);
QWidget *createMenuPlotSection(QWidget *parent);
Expand All @@ -76,6 +78,7 @@ private Q_SLOTS:
void deletePlottingStrategy();
void createTriggeredStrategy(QString triggerChnl);

bool m_concurrentAcq = false;
bool m_running;
PlotWidget *m_voltagePlot;
PlotWidget *m_currentPlot;
Expand Down
51 changes: 41 additions & 10 deletions packages/pqmon/plugins/pqm/src/acquisitionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "qtconcurrentrun.h"
#include <QLoggingCategory>
#include <QTimer>
#include <pluginbase/preferences.h>

Q_LOGGING_CATEGORY(CAT_PQM_ACQ, "PqmAqcManager");
using namespace scopy::pqm;
Expand All @@ -34,6 +35,8 @@ AcquisitionManager::AcquisitionManager(iio_context *ctx, PingTask *pingTask, QOb
, m_buffer(nullptr)
, m_pqmLog(nullptr)
{
Preferences *p = Preferences::GetInstance();
m_concurrentAcq = p->get("pqm_concurrent").toBool();
m_readFw = new QFutureWatcher<void>(this);
m_setFw = new QFutureWatcher<void>(this);
iio_device *dev = iio_context_find_device(m_ctx, DEVICE_PQM);
Expand All @@ -53,6 +56,12 @@ AcquisitionManager::AcquisitionManager(iio_context *ctx, PingTask *pingTask, QOb
connect(m_readFw, &QFutureWatcher<void>::finished, this, &AcquisitionManager::onReadFinished,
Qt::QueuedConnection);
connect(this, &AcquisitionManager::logData, m_pqmLog, &PqmDataLogger::logPressed);
connect(p, &Preferences::preferenceChanged, this, [this](QString pref, QVariant value) {
if(pref == "pqm_concurrent") {
m_concurrentAcq = value.toBool();
m_alternateExecution = !m_concurrentAcq;
}
});
} else {
qWarning(CAT_PQM_ACQ) << "The PQM device is not available!";
}
Expand Down Expand Up @@ -132,19 +141,41 @@ void AcquisitionManager::futureReadData()
void AcquisitionManager::readData()
{
QMutexLocker locker(&m_mutex);
if(m_tools["rms"] || m_tools["harmonics"] || m_tools["settings"]) {
if(!m_processData.load()) {
setProcessData(true);

bool needsAttrData = m_tools["rms"] || m_tools["harmonics"] || m_tools["settings"];
bool needsBufferData = m_tools["waveform"];
if(m_concurrentAcq && needsAttrData && needsBufferData) {
if(m_alternateExecution) {
readBuffData();
} else {
readAttrData();
}
m_attrHaveBeenRead = readPqmAttributes();
adjustMap("angle", &AcquisitionManager::computeAdjustedAngle);
}
if(m_tools["waveform"]) {
if(m_processData.load()) {
setProcessData(false);
m_alternateExecution = !m_alternateExecution;
} else {
if(needsAttrData) {
readAttrData();
}
m_buffHaveBeenRead = readBufferedData();
if(needsBufferData) {
readBuffData();
}
}
}

void AcquisitionManager::readAttrData()
{
if(!m_processData.load()) {
setProcessData(true);
}
m_attrHaveBeenRead = readPqmAttributes();
adjustMap("angle", &AcquisitionManager::computeAdjustedAngle);
}

void AcquisitionManager::readBuffData()
{
if(m_processData.load()) {
setProcessData(false);
}
m_buffHaveBeenRead = readBufferedData();
}

bool AcquisitionManager::readPqmAttributes()
Expand Down
Loading
Loading