Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
#define DATALOGGER_API_H

#include "scopy-datalogger_export.h"

#include <dataloggerplugin.h>
#include <sevensegmentdisplay.hpp>
#include <sevensegmentmonitorsettings.hpp>
#include <pluginbase/apiobject.h>

namespace scopy::datamonitor {

class DataLoggerPlugin;

class SCOPY_DATALOGGER_EXPORT DataLogger_API : public ApiObject
{
Q_OBJECT
Expand Down Expand Up @@ -61,6 +60,11 @@ class SCOPY_DATALOGGER_EXPORT DataLogger_API : public ApiObject
Q_INVOKABLE void continuousLogAtPathForTool(QString toolName, QString path);
Q_INVOKABLE void stopContinuousLogForTool(QString toolName);
Q_INVOKABLE void importDataFromPathForTool(QString toolName, QString path);
Q_INVOKABLE void setMonitorDisplayName(QString toolName, QString monitor, QString displayName);
Q_INVOKABLE void setMonitorUnitOfMeasurementName(QString toolName, QString monitor, QString name);
Q_INVOKABLE void setMonitorUnitOfMeasurementSymbol(QString toolName, QString monitor, QString symbol);
Q_INVOKABLE void setDisplayMode(QString toolName, int mode);
Q_INVOKABLE void setToolName(QString currentToolName, QString newToolName);

private:
DataLoggerPlugin *m_dataLoggerPlugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class SCOPY_DATALOGGER_EXPORT DataLoggerPlugin : public QObject, public PluginBa
QString description() override;
QString pkgName() override;

DataLogger_API *getApi() const;

public Q_SLOTS:
bool onConnect() override;
bool onDisconnect() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class SCOPY_DATALOGGER_EXPORT SevenSegmentDisplay : public QWidget

void updatePrecision(int precision);
void togglePeakHolder(bool toggle);
QVBoxLayout *getLayout() const;

signals:

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class SCOPY_DATALOGGER_EXPORT DatamonitorTool : public QWidget
RunBtn *getRunButton() const;
void setEnableAddRemovePlot(bool);
void setEnableAddRemoveInstrument(bool);
void setDisplayMode(int mode);

SevenSegmentDisplay *getSevenSegmetMonitors() const;

Q_SIGNALS:
void requestNewTool();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <QBoxLayout>
#include <QWidget>
#include <datamonitor/dmmdatamonitormodel.hpp>
#include <datamonitor/unitofmeasurement.hpp>
#include "scopy-datalogger_export.h"
#include <QComboBox>
#include <monitorplotmanager.h>
Expand Down
86 changes: 86 additions & 0 deletions packages/generic-plugins/plugins/datalogger/src/datalogger_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#include "datalogger_api.hpp"
#include "menus/datamonitorsettings.hpp"
#include <dataloggerplugin.h>
#include <sevensegmentdisplay.hpp>
#include <sevensegmentmonitorsettings.hpp>

using namespace scopy::datamonitor;

Expand Down Expand Up @@ -311,4 +314,87 @@ void DataLogger_API::importDataFromPathForTool(QString toolName, QString path)
}
}

void DataLogger_API::setMonitorDisplayName(QString toolName, QString monitor, QString displayName)
{
Q_ASSERT(!m_dataLoggerPlugin->m_toolList.isEmpty());

ToolMenuEntry *tool = ToolMenuEntry::findToolMenuEntryByName(m_dataLoggerPlugin->m_toolList, toolName);
if(tool) {
DatamonitorTool *monitorTool = dynamic_cast<DatamonitorTool *>(tool->tool());
if(!monitorTool->m_dataAcquisitionManager->getDataMonitorMap()->contains(monitor)) {
return;
} else {
monitorTool->m_dataAcquisitionManager->getDataMonitorMap()->value(monitor)->setDisplayName(
displayName);
}
}
}

void DataLogger_API::setMonitorUnitOfMeasurementName(QString toolName, QString monitor, QString name)
{
Q_ASSERT(!m_dataLoggerPlugin->m_toolList.isEmpty());

ToolMenuEntry *tool = ToolMenuEntry::findToolMenuEntryByName(m_dataLoggerPlugin->m_toolList, toolName);
if(tool) {
DatamonitorTool *monitorTool = dynamic_cast<DatamonitorTool *>(tool->tool());
if(!monitorTool->m_dataAcquisitionManager->getDataMonitorMap()->contains(monitor)) {
return;
} else {
monitorTool->m_dataAcquisitionManager->getDataMonitorMap()
->value(monitor)
->getUnitOfMeasure()
->setName(name);
}
}
}

void DataLogger_API::setMonitorUnitOfMeasurementSymbol(QString toolName, QString monitor, QString symbol)
{
Q_ASSERT(!m_dataLoggerPlugin->m_toolList.isEmpty());

ToolMenuEntry *tool = ToolMenuEntry::findToolMenuEntryByName(m_dataLoggerPlugin->m_toolList, toolName);
if(tool) {
DatamonitorTool *monitorTool = dynamic_cast<DatamonitorTool *>(tool->tool());
if(!monitorTool->m_dataAcquisitionManager->getDataMonitorMap()->contains(monitor)) {
return;
} else {
monitorTool->m_dataAcquisitionManager->getDataMonitorMap()
->value(monitor)
->getUnitOfMeasure()
->setSymbol(symbol);
}
}
}

void DataLogger_API::setDisplayMode(QString toolName, int mode)
{
// mode: 0 = plot, 1 = text, 2 = seven segment
if(mode < 0 || mode > 2) {
qWarning() << "Invalid display mode:" << mode;
return;
}

ToolMenuEntry *tool = ToolMenuEntry::findToolMenuEntryByName(m_dataLoggerPlugin->m_toolList, toolName);
if(!tool) {
qWarning() << "Tool not found:" << toolName;
return;
}

DatamonitorTool *monitorTool = qobject_cast<DatamonitorTool *>(tool->tool());
if(monitorTool) {
monitorTool->setDisplayMode(mode);
}
}

void DataLogger_API::setToolName(QString currentToolName, QString newToolName)
{
ToolMenuEntry *tool = ToolMenuEntry::findToolMenuEntryByName(m_dataLoggerPlugin->m_toolList, currentToolName);
if(!tool) {
qWarning() << "Tool not found:" << currentToolName;
return;
}

tool->setName(newToolName);
}

#include "moc_datalogger_api.cpp"
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ bool DataLoggerPlugin::onConnect()
removeTool("DataMonitorPreview");
addNewTool();
initApi();

return true;
}

Expand Down Expand Up @@ -257,6 +256,8 @@ void DataLoggerPlugin::initApi()
js->registerApi(api);
}

DataLogger_API *DataLoggerPlugin::getApi() const { return api; }

void DataLoggerPlugin::initMetadata()
{
loadMetadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,6 @@ void SevenSegmentDisplay::togglePeakHolder(bool toggle)
}
}

QVBoxLayout *SevenSegmentDisplay::getLayout() const { return layout; }

#include "moc_sevensegmentdisplay.cpp"
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ void DatamonitorTool::resetStartTime()
Q_EMIT m_plotManager->requestSetStartTime();
}

SevenSegmentDisplay *DatamonitorTool::getSevenSegmetMonitors() const { return sevenSegmetMonitors; }

void DatamonitorTool::initTutorialProperties()
{
runBtn->setProperty("tutorial_name", "RUN_BUTTON");
Expand Down Expand Up @@ -395,4 +397,20 @@ void DatamonitorTool::setEnableAddRemovePlot(bool en) { m_dataMonitorSettings->s

void DatamonitorTool::setEnableAddRemoveInstrument(bool en) { addMonitorToolButton->setVisible(en); }

void DatamonitorTool::setDisplayMode(int mode)
{
if(mode == 0) {
showPlot->click();
return;
}
if(mode == 1) {
showText->click();
return;
}
if(mode == 2) {
showSegments->click();
return;
}
}

#include "moc_datamonitortool.cpp"
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ ChannelAttributesMenu::ChannelAttributesMenu(DataMonitorModel *model, MonitorPlo
MenuHeaderWidget *header = new MenuHeaderWidget(model->getDisplayName(), model->getColor(), this);
header->title()->setEnabled(true);
connect(header->title(), &QLineEdit::textChanged, model, &DataMonitorModel::setDisplayName);
connect(model, &DataMonitorModel::displayNameChanged, header, [=](QString name) {
header->blockSignals(true);
header->title()->setText(name);
header->blockSignals(false);
});

mainLayout->addWidget(header);

Expand Down Expand Up @@ -264,10 +269,19 @@ ChannelAttributesMenu::ChannelAttributesMenu(DataMonitorModel *model, MonitorPlo
umSymbol->setPlaceholderText("Symbol");

connect(umName, &QLineEdit::textChanged, this, [=](QString text) { model->getUnitOfMeasure()->setName(text); });
connect(model->getUnitOfMeasure(), &UnitOfMeasurement::unitChanged, this, [=]() {
umName->blockSignals(true);
umName->setText(model->getUnitOfMeasure()->getName());
umName->blockSignals(false);
});

connect(umSymbol, &QLineEdit::textChanged, this,
[=](QString text) { model->getUnitOfMeasure()->setSymbol(text); });

connect(model->getUnitOfMeasure(), &UnitOfMeasurement::unitChanged, this, [=]() {
umSymbol->blockSignals(true);
umSymbol->setText(model->getUnitOfMeasure()->getSymbol());
umSymbol->blockSignals(false);
});
umLayout->addWidget(umName);
umLayout->addWidget(umSymbol);

Expand Down
42 changes: 42 additions & 0 deletions packages/rfpowermeter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# 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/>.
#

cmake_minimum_required(VERSION 3.9)

set(SCOPY_MODULE rfpowermeter)
set(CURRENT_PKG_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(PACKAGE_NAME ${SCOPY_MODULE})

message(STATUS "building package: " ${SCOPY_MODULE})

project(scopy-package-${SCOPY_MODULE} VERSION 0.1 LANGUAGES CXX)

configure_file(manifest.json.cmakein ${SCOPY_PACKAGE_BUILD_PATH}/${SCOPY_MODULE}/MANIFEST.json @ONLY)

include_resources(${CMAKE_CURRENT_SOURCE_DIR}/resources ${SCOPY_PACKAGE_BUILD_PATH}/${SCOPY_MODULE}/resources)
message("Including plugins")
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/plugins)
add_plugins(${CMAKE_CURRENT_SOURCE_DIR}/plugins ${SCOPY_PACKAGE_BUILD_PATH}/${SCOPY_MODULE}/plugins)
install_plugins(
${SCOPY_PACKAGE_BUILD_PATH}/${SCOPY_MODULE}/plugins
${SCOPY_PACKAGE_INSTALL_PATH}/${SCOPY_MODULE}/plugins "scopy"
)
endif()
install_pkg(${SCOPY_PACKAGE_BUILD_PATH}/${SCOPY_MODULE} ${SCOPY_PACKAGE_INSTALL_PATH}/${SCOPY_MODULE})
13 changes: 13 additions & 0 deletions packages/rfpowermeter/manifest.json.cmakein
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"id": "rfpowermeter",
"title": "RF Power Meter",
"version": "@PROJECT_VERSION@",
"description": "RF Power Meter plugin package",
"license": "LGPL",
"author": "Analog Devices Inc.",
"download_link": "",
"zip_checksum": "",
"scopy_compatibility": ["@CMAKE_PROJECT_VERSION@"],
"category": ["iio", "plugin"]
}

2 changes: 2 additions & 0 deletions packages/rfpowermeter/plugins/rfpowermeter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include/rfpowermeter/scopy-rfpowermeter_export.h
include/rfpowermeter/scopy-rfpowermeter_config.h
Loading
Loading