From 76c84c55d8ac419cf4d2b5aa4dfc401147e1a6a7 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 30 Jan 2022 07:43:50 +0100 Subject: [PATCH] Spectrum Calibration: implementation of calibration points management --- sdrbase/CMakeLists.txt | 2 + sdrbase/dsp/spectrumcalibrationpoint.cpp | 53 ++ sdrbase/dsp/spectrumcalibrationpoint.h | 55 ++ sdrbase/dsp/spectrumsettings.cpp | 60 +- sdrbase/dsp/spectrumsettings.h | 2 + sdrbase/resources/webapi/doc/html2/index.html | 25 +- .../doc/swagger/include/GLSpectrum.yaml | 17 + sdrgui/CMakeLists.txt | 3 + sdrgui/gui/glspectrum.cpp | 5 + sdrgui/gui/glspectrum.h | 1 + sdrgui/gui/glspectrumgui.cpp | 32 ++ sdrgui/gui/glspectrumgui.h | 2 + sdrgui/gui/glspectrumgui.ui | 14 + .../gui/spectrumcalibrationpointsdialog.cpp | 278 ++++++++++ sdrgui/gui/spectrumcalibrationpointsdialog.h | 72 +++ sdrgui/gui/spectrumcalibrationpointsdialog.ui | 513 ++++++++++++++++++ sdrgui/resources/res.qrc | 1 + sdrgui/resources/ruler.png | Bin 0 -> 975 bytes .../api/swagger/include/GLSpectrum.yaml | 17 + swagger/sdrangel/code/html2/index.html | 25 +- .../code/qt5/client/SWGGLSpectrum.cpp | 29 + .../sdrangel/code/qt5/client/SWGGLSpectrum.h | 7 + .../code/qt5/client/SWGModelFactory.h | 6 + .../client/SWGSpectrumCalibrationPoint.cpp | 154 ++++++ .../qt5/client/SWGSpectrumCalibrationPoint.h | 70 +++ 25 files changed, 1438 insertions(+), 5 deletions(-) create mode 100644 sdrbase/dsp/spectrumcalibrationpoint.cpp create mode 100644 sdrbase/dsp/spectrumcalibrationpoint.h create mode 100644 sdrgui/gui/spectrumcalibrationpointsdialog.cpp create mode 100644 sdrgui/gui/spectrumcalibrationpointsdialog.h create mode 100644 sdrgui/gui/spectrumcalibrationpointsdialog.ui create mode 100644 sdrgui/resources/ruler.png create mode 100644 swagger/sdrangel/code/qt5/client/SWGSpectrumCalibrationPoint.cpp create mode 100644 swagger/sdrangel/code/qt5/client/SWGSpectrumCalibrationPoint.h diff --git a/sdrbase/CMakeLists.txt b/sdrbase/CMakeLists.txt index 7d3bd3c2c..435d92a46 100644 --- a/sdrbase/CMakeLists.txt +++ b/sdrbase/CMakeLists.txt @@ -151,6 +151,7 @@ set(sdrbase_SOURCES dsp/devicesamplemimo.cpp dsp/devicesamplestatic.cpp dsp/spectrummarkers.cpp + dsp/spectrumcalibrationpoint.cpp dsp/spectrumvis.cpp dsp/wavfilerecord.cpp @@ -309,6 +310,7 @@ set(sdrbase_HEADERS dsp/glscopesettings.h dsp/glspectruminterface.h dsp/spectrummarkers.h + dsp/spectrumcalibrationpoint.h dsp/spectrumsettings.h dsp/goertzel.h dsp/hbfilterchainconverter.h diff --git a/sdrbase/dsp/spectrumcalibrationpoint.cpp b/sdrbase/dsp/spectrumcalibrationpoint.cpp new file mode 100644 index 000000000..8761da5b1 --- /dev/null +++ b/sdrbase/dsp/spectrumcalibrationpoint.cpp @@ -0,0 +1,53 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2022 Edouard Griffiths, F4EXB // +// // +// 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 as 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 V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "util/simpleserializer.h" +#include "spectrumcalibrationpoint.h" + +QByteArray SpectrumCalibrationPoint::serialize() const +{ + SimpleSerializer s(1); + + s.writeS64(1, m_frequency); + s.writeFloat(2, m_powerRelativeReference); + s.writeFloat(3, m_powerAbsoluteReference); + + return s.final(); +} + +bool SpectrumCalibrationPoint::deserialize(const QByteArray& data) +{ + SimpleDeserializer d(data); + + if (!d.isValid()) { + return false; + } + + if (d.getVersion() == 1) + { + d.readS64(1, &m_frequency, 0); + d.readFloat(2, &m_powerRelativeReference, 1.0f); + d.readFloat(3, &m_powerAbsoluteReference, 1.0f); + + return true; + } + else + { + return false; + } + +} diff --git a/sdrbase/dsp/spectrumcalibrationpoint.h b/sdrbase/dsp/spectrumcalibrationpoint.h new file mode 100644 index 000000000..2b0c65b28 --- /dev/null +++ b/sdrbase/dsp/spectrumcalibrationpoint.h @@ -0,0 +1,55 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2022 Edouard Griffiths, F4EXB // +// // +// 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 as 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 V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_SPECTRUMCALIBRATIONPOINT_H +#define INCLUDE_SPECTRUMCALIBRATIONPOINT_H + +#include + +#include "export.h" + +struct SDRBASE_API SpectrumCalibrationPoint +{ + qint64 m_frequency; //!< frequency in Hz + float m_powerRelativeReference; //!< relative power level on 0..1 scale + float m_powerAbsoluteReference; //!< absolute power level in mW + + SpectrumCalibrationPoint() : + m_frequency(0), + m_powerRelativeReference(1.0f), + m_powerAbsoluteReference(1.0f) + {} + + SpectrumCalibrationPoint( + quint64 frequency, + float powerRelativeReference, + float powerAbsoluteReference + ) : + m_frequency(frequency), + m_powerRelativeReference(powerRelativeReference), + m_powerAbsoluteReference(powerAbsoluteReference) + {} + + SpectrumCalibrationPoint(const SpectrumCalibrationPoint& other) = default; + SpectrumCalibrationPoint& operator=(const SpectrumCalibrationPoint&) = default; + + QByteArray serialize() const; + bool deserialize(const QByteArray& data); +}; + + +#endif // INCLUDE_SPECTRUMCALIBRATIONPOINTs_H diff --git a/sdrbase/dsp/spectrumsettings.cpp b/sdrbase/dsp/spectrumsettings.cpp index 18fdba76c..95fc978a0 100644 --- a/sdrbase/dsp/spectrumsettings.cpp +++ b/sdrbase/dsp/spectrumsettings.cpp @@ -107,11 +107,17 @@ QByteArray SpectrumSettings::serialize() const s.writeBlob(111+i, m_waterfallMarkers[i].serialize()); } - QByteArray data; - QDataStream *stream = new QDataStream(&data, QIODevice::WriteOnly); + QByteArray dataAnnotation; + QDataStream *stream = new QDataStream(&dataAnnotation, QIODevice::WriteOnly); (*stream) << m_annoationMarkers; delete stream; - s.writeBlob(40, data); + s.writeBlob(40, dataAnnotation); + + QByteArray dataCalibration; + stream = new QDataStream(&dataCalibration, QIODevice::WriteOnly); + (*stream) << m_calibrationPoints; + delete stream; + s.writeBlob(41, dataCalibration); return s.final(); } @@ -126,6 +132,14 @@ QDataStream& operator<<(QDataStream& out, const SpectrumAnnotationMarker& marker return out; } +QDataStream& operator<<(QDataStream& out, const SpectrumCalibrationPoint& calibrationPoint) +{ + out << calibrationPoint.m_frequency; + out << calibrationPoint.m_powerRelativeReference; + out << calibrationPoint.m_powerAbsoluteReference; + return out; +} + bool SpectrumSettings::deserialize(const QByteArray& data) { SimpleDeserializer d(data); @@ -210,6 +224,11 @@ bool SpectrumSettings::deserialize(const QByteArray& data) (*stream) >> m_annoationMarkers; delete stream; + d.readBlob(41, &bytetmp); + stream = new QDataStream(bytetmp); + (*stream) >> m_calibrationPoints; + delete stream; + return true; } else @@ -231,6 +250,14 @@ QDataStream& operator>>(QDataStream& in, SpectrumAnnotationMarker& marker) return in; } +QDataStream& operator>>(QDataStream& in, SpectrumCalibrationPoint& calibrationPoint) +{ + in >> calibrationPoint.m_frequency; + in >> calibrationPoint.m_powerRelativeReference; + in >> calibrationPoint.m_powerAbsoluteReference; + return in; +} + void SpectrumSettings::formatTo(SWGSDRangel::SWGObject *swgObject) const { SWGSDRangel::SWGGLSpectrum *swgSpectrum = static_cast(swgObject); @@ -311,6 +338,19 @@ void SpectrumSettings::formatTo(SWGSDRangel::SWGObject *swgObject) const swgSpectrum->getAnnotationMarkers()->back()->setShow((int) marker.m_show); } } + + if (m_calibrationPoints.size() > 0) + { + swgSpectrum->setCalibrationPoints(new QList); + + for (const auto &calibrationPoint : m_calibrationPoints) + { + swgSpectrum->getCalibrationPoints()->append(new SWGSDRangel::SWGSpectrumCalibrationPoint); + swgSpectrum->getCalibrationPoints()->back()->setFrequency(calibrationPoint.m_frequency); + swgSpectrum->getCalibrationPoints()->back()->setPowerRelativeReference(calibrationPoint.m_powerRelativeReference); + swgSpectrum->getCalibrationPoints()->back()->setPowerAbsoluteReference(calibrationPoint.m_powerAbsoluteReference); + } + } } void SpectrumSettings::updateFrom(const QStringList& keys, const SWGSDRangel::SWGObject *swgObject) @@ -460,6 +500,20 @@ void SpectrumSettings::updateFrom(const QStringList& keys, const SWGSDRangel::SW m_annoationMarkers.back().m_show = (SpectrumAnnotationMarker::ShowState) swgAnnotationMarker->getShow(); } } + + if (keys.contains("spectrumConfig.calibrationPoints")) + { + QList *swgCalibrationPoints = swgSpectrum->getCalibrationPoints(); + m_calibrationPoints.clear(); + + for (const auto &swgCalibrationPoint : *swgCalibrationPoints) + { + m_calibrationPoints.push_back(SpectrumCalibrationPoint()); + m_calibrationPoints.back().m_frequency = swgCalibrationPoint->getFrequency(); + m_calibrationPoints.back().m_powerRelativeReference = swgCalibrationPoint->getPowerRelativeReference(); + m_calibrationPoints.back().m_powerAbsoluteReference = swgCalibrationPoint->getPowerAbsoluteReference(); + } + } } int SpectrumSettings::getAveragingMaxScale(AveragingMode averagingMode) diff --git a/sdrbase/dsp/spectrumsettings.h b/sdrbase/dsp/spectrumsettings.h index 3eb3db932..02f2b859a 100644 --- a/sdrbase/dsp/spectrumsettings.h +++ b/sdrbase/dsp/spectrumsettings.h @@ -25,6 +25,7 @@ #include "dsp/dsptypes.h" #include "dsp/fftwindow.h" #include "dsp/spectrummarkers.h" +#include "dsp/spectrumcalibrationpoint.h" #include "settings/serializable.h" class SDRBASE_API SpectrumSettings : public Serializable @@ -76,6 +77,7 @@ public: QList m_waterfallMarkers; QList m_annoationMarkers; MarkersDisplay m_markersDisplay; + QList m_calibrationPoints; static const int m_log2FFTSizeMin = 6; // 64 static const int m_log2FFTSizeMax = 15; // 32k diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index ff1232575..d8d874ee9 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -6172,6 +6172,12 @@ margin-bottom: 20px; "items" : { "$ref" : "#/definitions/SpectrumAnnotationMarker" } + }, + "calibrationPoints" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/SpectrumCalibrationPoint" + } } }, "description" : "GLSpectrumGUI settings" @@ -11812,6 +11818,23 @@ margin-bottom: 20px; } }, "description" : "Spectrum annotation marker settings" +}; + defs.SpectrumCalibrationPoint = { + "properties" : { + "frequency" : { + "type" : "integer", + "format" : "int64" + }, + "powerRelativeReference" : { + "type" : "number", + "format" : "float" + }, + "powerAbsoluteReference" : { + "type" : "number", + "format" : "float" + } + }, + "description" : "Spectrum calibration point settings" }; defs.SpectrumHistogramMarker = { "properties" : { @@ -51973,7 +51996,7 @@ except ApiException as e:
- Generated 2022-01-22T07:01:26.727+01:00 + Generated 2022-01-29T10:45:16.003+01:00
diff --git a/sdrbase/resources/webapi/doc/swagger/include/GLSpectrum.yaml b/sdrbase/resources/webapi/doc/swagger/include/GLSpectrum.yaml index eedf02343..266dfd2fb 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/GLSpectrum.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/GLSpectrum.yaml @@ -64,6 +64,19 @@ SpectrumAnnotationMarker: * 1 - Only top marker visible * 2 - Fully visible with text and full sized limits +SpectrumCalibrationPoint: + description: Spectrum calibration point settings + properties: + frequency: + type: integer + format: int64 + powerRelativeReference: + type: number + format: float + powerAbsoluteReference: + type: number + format: float + GLSpectrum: description: GLSpectrumGUI settings properties: @@ -159,3 +172,7 @@ GLSpectrum: type: array items: $ref: "/doc/swagger/include/GLSpectrum.yaml#/SpectrumAnnotationMarker" + calibrationPoints: + type: array + items: + $ref: "/doc/swagger/include/GLSpectrum.yaml#/SpectrumCalibrationPoint" diff --git a/sdrgui/CMakeLists.txt b/sdrgui/CMakeLists.txt index b8e66ce04..81537b843 100644 --- a/sdrgui/CMakeLists.txt +++ b/sdrgui/CMakeLists.txt @@ -59,6 +59,7 @@ set(sdrgui_SOURCES gui/scaleengine.cpp gui/scaledimage.cpp gui/sdrangelsplash.cpp + gui/spectrumcalibrationpointsdialog.cpp gui/spectrummarkersdialog.cpp gui/tickedslider.cpp gui/transverterbutton.cpp @@ -148,6 +149,7 @@ set(sdrgui_HEADERS gui/scaleengine.h gui/scaledimage.h gui/sdrangelsplash.h + gui/spectrumcalibrationpointsdialog.h gui/spectrummarkersdialog.h gui/tickedslider.h gui/transverterbutton.h @@ -208,6 +210,7 @@ set(sdrgui_FORMS gui/samplingdevicecontrol.ui gui/samplingdevicedialog.ui gui/spectrummarkersdialog.ui + gui/spectrumcalibrationpointsdialog.ui gui/myposdialog.ui gui/transverterdialog.ui gui/loggingdialog.ui diff --git a/sdrgui/gui/glspectrum.cpp b/sdrgui/gui/glspectrum.cpp index 1ffc9489a..3d43246c2 100644 --- a/sdrgui/gui/glspectrum.cpp +++ b/sdrgui/gui/glspectrum.cpp @@ -2314,6 +2314,11 @@ void GLSpectrum::updateMarkersDisplay() } } +void GLSpectrum::updateCalibrationPoints() +{ + // TODO +} + void GLSpectrum::mouseMoveEvent(QMouseEvent* event) { if (m_displayWaterfall || m_displayHistogram || m_displayMaxHold || m_displayCurrent) diff --git a/sdrgui/gui/glspectrum.h b/sdrgui/gui/glspectrum.h index d4d208a2b..ade155298 100644 --- a/sdrgui/gui/glspectrum.h +++ b/sdrgui/gui/glspectrum.h @@ -168,6 +168,7 @@ public: void updateWaterfallMarkers(); void updateAnnotationMarkers(); void updateMarkersDisplay(); + void updateCalibrationPoints(); SpectrumSettings::MarkersDisplay& getMarkersDisplay() { return m_markersDisplay; } void setMarkersDisplay(SpectrumSettings::MarkersDisplay markersDisplay); diff --git a/sdrgui/gui/glspectrumgui.cpp b/sdrgui/gui/glspectrumgui.cpp index 08efa7dea..3408e1b54 100644 --- a/sdrgui/gui/glspectrumgui.cpp +++ b/sdrgui/gui/glspectrumgui.cpp @@ -29,6 +29,7 @@ #include "gui/crightclickenabler.h" #include "gui/wsspectrumsettingsdialog.h" #include "gui/spectrummarkersdialog.h" +#include "gui/spectrumcalibrationpointsdialog.h" #include "util/simpleserializer.h" #include "util/db.h" #include "ui_glspectrumgui.h" @@ -64,6 +65,9 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) : CRightClickEnabler *wsSpectrumRightClickEnabler = new CRightClickEnabler(ui->wsSpectrum); connect(wsSpectrumRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(openWebsocketSpectrumSettingsDialog(const QPoint &))); + CRightClickEnabler *calibrationPointsRightClickEnabler = new CRightClickEnabler(ui->calibration); + connect(calibrationPointsRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(openCalibrationPointsDialog(const QPoint &))); + displaySettings(); setAveragingCombo(); applySettings(); @@ -726,6 +730,27 @@ void GLSpectrumGUI::openWebsocketSpectrumSettingsDialog(const QPoint& p) } } +void GLSpectrumGUI::openCalibrationPointsDialog(const QPoint& p) +{ + SpectrumCalibrationPointsDialog dialog( + m_settings.m_calibrationPoints, + m_glSpectrum->getHistogramMarkers().size() > 0 ? &m_glSpectrum->getHistogramMarkers()[0] : nullptr, + this + ); + + dialog.setCenterFrequency(m_glSpectrum->getCenterFrequency()); + connect(&dialog, SIGNAL(updateCalibrationPoints()), this, SLOT(updateCalibrationPoints())); + dialog.move(p); + dialog.exec(); + + m_settings.m_histogramMarkers = m_glSpectrum->getHistogramMarkers(); + m_settings.m_waterfallMarkers = m_glSpectrum->getWaterfallMarkers(); + m_settings.m_annoationMarkers = m_glSpectrum->getAnnotationMarkers(); + m_settings.m_markersDisplay = m_glSpectrum->getMarkersDisplay(); + + applySettings(); +} + void GLSpectrumGUI::updateHistogramMarkers() { if (m_glSpectrum) { @@ -753,3 +778,10 @@ void GLSpectrumGUI::updateMarkersDisplay() m_glSpectrum->updateMarkersDisplay(); } } + +void GLSpectrumGUI::updateCalibrationPoints() +{ + if (m_glSpectrum) { + m_glSpectrum->updateCalibrationPoints(); + } +} diff --git a/sdrgui/gui/glspectrumgui.h b/sdrgui/gui/glspectrumgui.h index 4f83b6d9c..090a0859c 100644 --- a/sdrgui/gui/glspectrumgui.h +++ b/sdrgui/gui/glspectrumgui.h @@ -114,11 +114,13 @@ private slots: void handleInputMessages(); void openWebsocketSpectrumSettingsDialog(const QPoint& p); + void openCalibrationPointsDialog(const QPoint& p); void updateHistogramMarkers(); void updateWaterfallMarkers(); void updateAnnotationMarkers(); void updateMarkersDisplay(); + void updateCalibrationPoints(); }; #endif // INCLUDE_GLSPECTRUMGUI_H diff --git a/sdrgui/gui/glspectrumgui.ui b/sdrgui/gui/glspectrumgui.ui index 9c2de1ddc..cad74c59d 100644 --- a/sdrgui/gui/glspectrumgui.ui +++ b/sdrgui/gui/glspectrumgui.ui @@ -568,6 +568,20 @@ + + + + Left: toggle relative / mW units - Right: open calibration dialog + + + + :/ruler.png:/ruler.png + + + true + + + diff --git a/sdrgui/gui/spectrumcalibrationpointsdialog.cpp b/sdrgui/gui/spectrumcalibrationpointsdialog.cpp new file mode 100644 index 000000000..61065b40b --- /dev/null +++ b/sdrgui/gui/spectrumcalibrationpointsdialog.cpp @@ -0,0 +1,278 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2022 F4EXB // +// written by Edouard Griffiths // +// // +// 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 as 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 V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include + +#include "util/db.h" +#include "util/csv.h" +#include "dsp/spectrummarkers.h" + +#include "spectrumcalibrationpointsdialog.h" + +#include "ui_spectrumcalibrationpointsdialog.h" + +SpectrumCalibrationPointsDialog::SpectrumCalibrationPointsDialog( + QList& calibrationPoints, + const SpectrumHistogramMarker *markerZero, + QWidget* parent) : + QDialog(parent), + ui(new Ui::SpectrumCalibrationPointsDialog), + m_calibrationPoints(calibrationPoints), + m_markerZero(markerZero), + m_calibrationPointIndex(0), + m_centerFrequency(0) +{ + ui->setupUi(this); + ui->calibPointFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); + ui->calibPointFrequency->setValueRange(false, 10, -9999999999L, 9999999999L); + ui->calibPoint->setMaximum(m_calibrationPoints.size() - 1); + displayCalibrationPoint(); +} + +SpectrumCalibrationPointsDialog::~SpectrumCalibrationPointsDialog() +{} + +void SpectrumCalibrationPointsDialog::displayCalibrationPoint() +{ + ui->calibPointFrequency->blockSignals(true); + ui->calibPoint->blockSignals(true); + ui->relativePower->blockSignals(true); + ui->absolutePower->blockSignals(true); + + if (m_calibrationPoints.size() == 0) + { + ui->calibPoint->setEnabled(false); + ui->calibPointDel->setEnabled(false); + ui->relativePower->setEnabled(false); + ui->absolutePower->setEnabled(false); + ui->calibPointFrequency->setEnabled(false); + ui->importMarkerZero->setEnabled(false); + ui->centerFrequency->setEnabled(false); + } + else + { + ui->calibPoint->setEnabled(true); + ui->calibPointDel->setEnabled(true); + ui->relativePower->setEnabled(true); + ui->absolutePower->setEnabled(true); + ui->calibPointFrequency->setEnabled(true); + ui->importMarkerZero->setEnabled(true); + ui->centerFrequency->setEnabled(true); + ui->calibPoint->setValue(m_calibrationPointIndex); + ui->calibPointText->setText(tr("%1").arg(m_calibrationPointIndex)); + float powerDB = CalcDb::dbPower(m_calibrationPoints[m_calibrationPointIndex].m_powerRelativeReference); + ui->relativePower->setValue(powerDB*10); + ui->relativePowerText->setText(QString::number(powerDB, 'f', 1)); + powerDB = CalcDb::dbPower(m_calibrationPoints[m_calibrationPointIndex].m_powerAbsoluteReference); + ui->absolutePower->setValue(powerDB*10); + ui->absolutePowerText->setText(QString::number(powerDB, 'f', 1)); + ui->calibPointFrequency->setValue(m_calibrationPoints[m_calibrationPointIndex].m_frequency); + } + + ui->calibPointFrequency->blockSignals(false); + ui->calibPoint->blockSignals(false); + ui->relativePower->blockSignals(false); + ui->absolutePower->blockSignals(false); +} + +void SpectrumCalibrationPointsDialog::on_calibPoint_valueChanged(int value) +{ + if (m_calibrationPoints.size() == 0) { + return; + } + + m_calibrationPointIndex = value; + displayCalibrationPoint(); +} + +void SpectrumCalibrationPointsDialog::on_calibPointAdd_clicked() +{ + m_calibrationPoints.append(SpectrumCalibrationPoint()); + m_calibrationPoints.back().m_frequency = m_centerFrequency; + m_calibrationPointIndex = m_calibrationPoints.size() - 1; + ui->calibPoint->setMaximum(m_calibrationPoints.size() - 1); + ui->calibPoint->setMinimum(0); + displayCalibrationPoint(); +} + +void SpectrumCalibrationPointsDialog::on_calibPointDel_clicked() +{ + if (m_calibrationPoints.size() == 0) { + return; + } + + m_calibrationPoints.removeAt(m_calibrationPointIndex); + m_calibrationPointIndex = m_calibrationPointIndex < m_calibrationPoints.size() ? + m_calibrationPointIndex : m_calibrationPointIndex - 1; + ui->calibPoint->setMaximum(m_calibrationPoints.size() - 1); + ui->calibPoint->setMinimum(0); + displayCalibrationPoint(); +} + +void SpectrumCalibrationPointsDialog::on_relativePower_valueChanged(int value) +{ + if (m_calibrationPoints.size() == 0) { + return; + } + + float powerDB = value / 10.0f; + ui->relativePowerText->setText(QString::number(powerDB, 'f', 1)); + m_calibrationPoints[m_calibrationPointIndex].m_powerRelativeReference = CalcDb::powerFromdB(powerDB); + emit updateCalibrationPoints(); +} + +void SpectrumCalibrationPointsDialog::on_absolutePower_valueChanged(int value) +{ + if (m_calibrationPoints.size() == 0) { + return; + } + + float powerDB = value / 10.0f; + ui->absolutePowerText->setText(QString::number(powerDB, 'f', 1)); + m_calibrationPoints[m_calibrationPointIndex].m_powerAbsoluteReference = CalcDb::powerFromdB(powerDB); + emit updateCalibrationPoints(); +} + +void SpectrumCalibrationPointsDialog::on_calibPointFrequency_changed(qint64 value) +{ + if (m_calibrationPoints.size() == 0) { + return; + } + + m_calibrationPoints[m_calibrationPointIndex].m_frequency = value; + emit updateCalibrationPoints(); +} + +void SpectrumCalibrationPointsDialog::on_importMarkerZero_clicked() +{ + if ((m_calibrationPoints.size() == 0) || (m_markerZero == nullptr)) { + return; + } + + m_calibrationPoints[m_calibrationPointIndex].m_frequency = m_markerZero->m_frequency; + m_calibrationPoints[m_calibrationPointIndex].m_powerRelativeReference = CalcDb::powerFromdB(m_markerZero->m_powerMax); + displayCalibrationPoint(); + emit updateCalibrationPoints(); +} + +void SpectrumCalibrationPointsDialog::on_centerFrequency_clicked() +{ + if (m_calibrationPoints.size() == 0) { + return; + } + + m_calibrationPoints[m_calibrationPointIndex].m_frequency = m_centerFrequency; + displayCalibrationPoint(); + emit updateCalibrationPoints(); +} + +void SpectrumCalibrationPointsDialog::on_calibPointsExport_clicked() +{ + QFileDialog fileDialog( + nullptr, + "Select file to write calibration points to", + QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), + "*.csv" + ); + fileDialog.setAcceptMode(QFileDialog::AcceptSave); + + if (fileDialog.exec()) + { + QStringList fileNames = fileDialog.selectedFiles(); + + if (fileNames.size() > 0) + { + QFile file(fileNames[0]); + + if (file.open(QIODevice::WriteOnly | QIODevice::Text)) + { + QTextStream stream; + stream.setDevice(&file); + stream << "Frequency,Reference,Absolute\n"; + + for (const auto &calibrationPint : m_calibrationPoints) + { + stream << calibrationPint.m_frequency << "," + << calibrationPint.m_powerRelativeReference << "," + << calibrationPint.m_powerAbsoluteReference << "\n"; + } + + stream.flush(); + file.close(); + } + } + } +} + +void SpectrumCalibrationPointsDialog::on_calibPointsImport_clicked() +{ + QFileDialog fileDialog( + nullptr, + "Select .csv calibration points file to read", + QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), + "*.csv" + ); + + if (fileDialog.exec()) + { + QStringList fileNames = fileDialog.selectedFiles(); + + if (fileNames.size() > 0) + { + QFile file(fileNames[0]); + + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + + QTextStream in(&file); + QString error; + QHash colIndexes = CSV::readHeader( + in, + {"Frequency", "Reference", "Absolute"}, + error + ); + + if (error.isEmpty()) + { + QStringList cols; + int frequencyCol = colIndexes.value("Frequency"); + int referenceCol = colIndexes.value("Reference"); + int absoluteCol = colIndexes.value("Absolute"); + + m_calibrationPoints.clear(); + + while (CSV::readRow(in, &cols)) + { + m_calibrationPoints.push_back(SpectrumCalibrationPoint()); + m_calibrationPoints.back().m_frequency = cols[frequencyCol].toLongLong(); + m_calibrationPoints.back().m_powerRelativeReference = cols[referenceCol].toFloat(); + m_calibrationPoints.back().m_powerAbsoluteReference = cols[absoluteCol].toFloat(); + } + + m_calibrationPointIndex = 0; + ui->calibPoint->setMaximum(m_calibrationPoints.size() - 1); + ui->calibPoint->setMinimum(0); + displayCalibrationPoint(); + emit updateCalibrationPoints(); + } + } + } + } +} diff --git a/sdrgui/gui/spectrumcalibrationpointsdialog.h b/sdrgui/gui/spectrumcalibrationpointsdialog.h new file mode 100644 index 000000000..37ae4055e --- /dev/null +++ b/sdrgui/gui/spectrumcalibrationpointsdialog.h @@ -0,0 +1,72 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2022 F4EXB // +// written by Edouard Griffiths // +// // +// 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 as 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 V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef SDRBASE_GUI_SPECTRUMCALIBRATIONPOINTSDIALOG_H_ +#define SDRBASE_GUI_SPECTRUMCALIBRATIONPOINTSDIALOG_H_ + +#include +#include + +#include "dsp/spectrumsettings.h" +#include "dsp/spectrumcalibrationpoint.h" +#include "export.h" + +class SpectrumHistogramMarker; + +namespace Ui { + class SpectrumCalibrationPointsDialog; +} + +class SDRGUI_API SpectrumCalibrationPointsDialog : public QDialog { + Q_OBJECT + +public: + explicit SpectrumCalibrationPointsDialog( + QList& calibrationPoints, + const SpectrumHistogramMarker *markerZero, + QWidget* parent = nullptr + ); + ~SpectrumCalibrationPointsDialog(); + void setCenterFrequency(qint64 centerFrequency) { m_centerFrequency = centerFrequency; } + +private: + Ui::SpectrumCalibrationPointsDialog* ui; + QList& m_calibrationPoints; + const SpectrumHistogramMarker *m_markerZero; + int m_calibrationPointIndex; + qint64 m_centerFrequency; + + void displayCalibrationPoint(); + +private slots: + void on_calibPoint_valueChanged(int value); + void on_calibPointAdd_clicked(); + void on_calibPointDel_clicked(); + void on_relativePower_valueChanged(int value); + void on_absolutePower_valueChanged(int value); + void on_calibPointFrequency_changed(qint64 value); + void on_importMarkerZero_clicked(); + void on_centerFrequency_clicked(); + void on_calibPointsExport_clicked(); + void on_calibPointsImport_clicked(); + +signals: + void updateCalibrationPoints(); +}; + +#endif // SDRBASE_GUI_SPECTRUMCALIBRATIONPOINTSDIALOG_H_ diff --git a/sdrgui/gui/spectrumcalibrationpointsdialog.ui b/sdrgui/gui/spectrumcalibrationpointsdialog.ui new file mode 100644 index 000000000..5afafab3f --- /dev/null +++ b/sdrgui/gui/spectrumcalibrationpointsdialog.ui @@ -0,0 +1,513 @@ + + + SpectrumCalibrationPointsDialog + + + + 0 + 0 + 469 + 131 + + + + Spectrum Calibration Points + + + + + + 2 + + + + + + + + 24 + 0 + + + + Pt + + + + + + + + 25 + 0 + + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 24 + 24 + + + + Calibration point index + + + 0 + + + 1 + + + + + + + 0 + + + + + + 18 + 18 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 190 + 190 + 190 + + + + + + + + + Liberation Sans + 10 + + + + Add a new calibration point + + + + + + + + + + + + 18 + 18 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 190 + 190 + 190 + + + + + + + + + Liberation Sans + 10 + + + + Remove current calibration point + + + - + + + + + + + + + + 15 + 0 + + + + R + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Relative power (dB) + + + -1500 + + + 0 + + + 1 + + + -200 + + + Qt::Horizontal + + + + + + + + 32 + 0 + + + + -100.0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Vertical + + + + + + + + 15 + 0 + + + + A + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Absolute power (dBm) + + + -1500 + + + 400 + + + 1 + + + Qt::Horizontal + + + + + + + + 32 + 0 + + + + -100.0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + F + + + + + + + + 0 + 0 + + + + + 32 + 16 + + + + + DejaVu Sans Mono + 12 + + + + PointingHandCursor + + + Qt::StrongFocus + + + Calibration point frequency (Hz) + + + + + + + + 0 + 0 + + + + + 32 + 16 + + + + PointingHandCursor + + + Qt::StrongFocus + + + Marker frequency (Hz) + + + Hz + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 30 + 24 + + + + Import data from histogram marker 0 + + + M0 + + + + + + + + 24 + 24 + + + + Set calibration point frequency to center frequency + + + C + + + + + + + Export calibration points to .csv file + + + + + + + :/export.png:/export.png + + + + + + + Import calibration points from .csv file + + + + + + + :/import.png:/import.png + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + ValueDialZ + QWidget +
gui/valuedialz.h
+ 1 +
+
+ + + + + + buttonBox + accepted() + SpectrumCalibrationPointsDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + SpectrumCalibrationPointsDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/sdrgui/resources/res.qrc b/sdrgui/resources/res.qrc index 2347c901e..436229a08 100644 --- a/sdrgui/resources/res.qrc +++ b/sdrgui/resources/res.qrc @@ -1,5 +1,6 @@ + ruler.png sort.png audio_mic.png info.png diff --git a/sdrgui/resources/ruler.png b/sdrgui/resources/ruler.png new file mode 100644 index 0000000000000000000000000000000000000000..6c42041e7e3a8c4e16f6ee4d056aa352193de15e GIT binary patch literal 975 zcmV;=12FuFP)EX>4Tx04R}tkvmAkP!xv$KBQ7A4t5Yx$WWauii$XD6^c+H)C#RSnB4RQO&XFE z7e~Rh;NWAi>fqw6tAnc`2tGg@otzY1q{MTRLW>v=T<*tz&;N7pxq!b>VX7G%2UN{6 z(#eF7&8-TdSNJf5AjS}un5oZ+VhW!1bx++?cX6KO-S=npD0!0sK7n|a>4rtTK|H-_ z>74h8qpTz;#OK7L23?T&k?XR{Z=8z``*~*6$fW0qqr^h7gXIopB|{~iB91AlM*04% z%L?Z$&T6H`TKD8HjO4YIWvtQcR@jJmKLVaQq^5AHzUs7iiXP`}^3on2C8-PYti;Bp7(f6^sGa-;w)f1v=ppV2qvfWBKGyyniWb&k^qAVafC-2exN zz(|p@*FE0d-8r{^ds_4R0aCznn&HDV(f|Me24YJ`L;wH)0002_L%V+f000SaNLh0L z04^f{04^f|c%?sf00007bV*G`2j&4C1TZh)L|3~2000?uMObu0Z*6U5Zgc=ca%Ew3 zWn>_CX>@2HM@dakSAh-}0004|Nkl7v79|AMDtiHOQ$z%{3j$3$ zsi#&2VJ}84UG@=L^bz_Pts^wop$pNVRWFJXL@%rC94qtJ<{lV^vCiX6&vNFT|Mko@ z_kBInXjELdh!spW>RuSe27X`*ck6_Y;yV^`0&^iURR{cXz&Fqz*Lv|HMDA3Dx3P+C zJVj55$mDL|&49OY4AUWUGgp&|{KEC!z~ACGp5p+{Vt=9bXwpv03L?o4rXpx@+Wr{4LyyK^v;d`UA`~Dc7)31t
- Generated 2022-01-22T07:01:26.727+01:00 + Generated 2022-01-29T10:45:16.003+01:00
diff --git a/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.cpp b/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.cpp index 31274c07d..aba1fc232 100644 --- a/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.cpp @@ -88,6 +88,8 @@ SWGGLSpectrum::SWGGLSpectrum() { m_waterfall_markers_isSet = false; annotation_markers = nullptr; m_annotation_markers_isSet = false; + calibration_points = nullptr; + m_calibration_points_isSet = false; } SWGGLSpectrum::~SWGGLSpectrum() { @@ -156,6 +158,8 @@ SWGGLSpectrum::init() { m_waterfall_markers_isSet = false; annotation_markers = new QList(); m_annotation_markers_isSet = false; + calibration_points = new QList(); + m_calibration_points_isSet = false; } void @@ -210,6 +214,13 @@ SWGGLSpectrum::cleanup() { } delete annotation_markers; } + if(calibration_points != nullptr) { + auto arr = calibration_points; + for(auto o: *arr) { + delete o; + } + delete calibration_points; + } } SWGGLSpectrum* @@ -283,6 +294,8 @@ SWGGLSpectrum::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&waterfall_markers, pJson["waterfallMarkers"], "QList", "SWGSpectrumWaterfallMarker"); ::SWGSDRangel::setValue(&annotation_markers, pJson["annotationMarkers"], "QList", "SWGSpectrumAnnotationMarker"); + + ::SWGSDRangel::setValue(&calibration_points, pJson["calibrationPoints"], "QList", "SWGSpectrumCalibrationPoint"); } QString @@ -389,6 +402,9 @@ SWGGLSpectrum::asJsonObject() { if(annotation_markers && annotation_markers->size() > 0){ toJsonArray((QList*)annotation_markers, obj, "annotationMarkers", "SWGSpectrumAnnotationMarker"); } + if(calibration_points && calibration_points->size() > 0){ + toJsonArray((QList*)calibration_points, obj, "calibrationPoints", "SWGSpectrumCalibrationPoint"); + } return obj; } @@ -693,6 +709,16 @@ SWGGLSpectrum::setAnnotationMarkers(QList* annotat this->m_annotation_markers_isSet = true; } +QList* +SWGGLSpectrum::getCalibrationPoints() { + return calibration_points; +} +void +SWGGLSpectrum::setCalibrationPoints(QList* calibration_points) { + this->calibration_points = calibration_points; + this->m_calibration_points_isSet = true; +} + bool SWGGLSpectrum::isSet(){ @@ -788,6 +814,9 @@ SWGGLSpectrum::isSet(){ if(annotation_markers && (annotation_markers->size() > 0)){ isObjectUpdated = true; break; } + if(calibration_points && (calibration_points->size() > 0)){ + isObjectUpdated = true; break; + } }while(false); return isObjectUpdated; } diff --git a/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.h b/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.h index 0a8d7acda..6bb51a6da 100644 --- a/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.h +++ b/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.h @@ -23,6 +23,7 @@ #include "SWGSpectrumAnnotationMarker.h" +#include "SWGSpectrumCalibrationPoint.h" #include "SWGSpectrumHistogramMarker.h" #include "SWGSpectrumWaterfallMarker.h" #include @@ -136,6 +137,9 @@ public: QList* getAnnotationMarkers(); void setAnnotationMarkers(QList* annotation_markers); + QList* getCalibrationPoints(); + void setCalibrationPoints(QList* calibration_points); + virtual bool isSet() override; @@ -230,6 +234,9 @@ private: QList* annotation_markers; bool m_annotation_markers_isSet; + QList* calibration_points; + bool m_calibration_points_isSet; + }; } diff --git a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h index 1827124a8..4d7559b41 100644 --- a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h +++ b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h @@ -266,6 +266,7 @@ #include "SWGSoapySDROutputSettings.h" #include "SWGSoapySDRReport.h" #include "SWGSpectrumAnnotationMarker.h" +#include "SWGSpectrumCalibrationPoint.h" #include "SWGSpectrumHistogramMarker.h" #include "SWGSpectrumServer.h" #include "SWGSpectrumServer_clients.h" @@ -1576,6 +1577,11 @@ namespace SWGSDRangel { obj->init(); return obj; } + if(QString("SWGSpectrumCalibrationPoint").compare(type) == 0) { + SWGSpectrumCalibrationPoint *obj = new SWGSpectrumCalibrationPoint(); + obj->init(); + return obj; + } if(QString("SWGSpectrumHistogramMarker").compare(type) == 0) { SWGSpectrumHistogramMarker *obj = new SWGSpectrumHistogramMarker(); obj->init(); diff --git a/swagger/sdrangel/code/qt5/client/SWGSpectrumCalibrationPoint.cpp b/swagger/sdrangel/code/qt5/client/SWGSpectrumCalibrationPoint.cpp new file mode 100644 index 000000000..92e1995fd --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGSpectrumCalibrationPoint.cpp @@ -0,0 +1,154 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 6.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +#include "SWGSpectrumCalibrationPoint.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace SWGSDRangel { + +SWGSpectrumCalibrationPoint::SWGSpectrumCalibrationPoint(QString* json) { + init(); + this->fromJson(*json); +} + +SWGSpectrumCalibrationPoint::SWGSpectrumCalibrationPoint() { + frequency = 0L; + m_frequency_isSet = false; + power_relative_reference = 0.0f; + m_power_relative_reference_isSet = false; + power_absolute_reference = 0.0f; + m_power_absolute_reference_isSet = false; +} + +SWGSpectrumCalibrationPoint::~SWGSpectrumCalibrationPoint() { + this->cleanup(); +} + +void +SWGSpectrumCalibrationPoint::init() { + frequency = 0L; + m_frequency_isSet = false; + power_relative_reference = 0.0f; + m_power_relative_reference_isSet = false; + power_absolute_reference = 0.0f; + m_power_absolute_reference_isSet = false; +} + +void +SWGSpectrumCalibrationPoint::cleanup() { + + + +} + +SWGSpectrumCalibrationPoint* +SWGSpectrumCalibrationPoint::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGSpectrumCalibrationPoint::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&frequency, pJson["frequency"], "qint64", ""); + + ::SWGSDRangel::setValue(&power_relative_reference, pJson["powerRelativeReference"], "float", ""); + + ::SWGSDRangel::setValue(&power_absolute_reference, pJson["powerAbsoluteReference"], "float", ""); + +} + +QString +SWGSpectrumCalibrationPoint::asJson () +{ + QJsonObject* obj = this->asJsonObject(); + + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + delete obj; + return QString(bytes); +} + +QJsonObject* +SWGSpectrumCalibrationPoint::asJsonObject() { + QJsonObject* obj = new QJsonObject(); + if(m_frequency_isSet){ + obj->insert("frequency", QJsonValue(frequency)); + } + if(m_power_relative_reference_isSet){ + obj->insert("powerRelativeReference", QJsonValue(power_relative_reference)); + } + if(m_power_absolute_reference_isSet){ + obj->insert("powerAbsoluteReference", QJsonValue(power_absolute_reference)); + } + + return obj; +} + +qint64 +SWGSpectrumCalibrationPoint::getFrequency() { + return frequency; +} +void +SWGSpectrumCalibrationPoint::setFrequency(qint64 frequency) { + this->frequency = frequency; + this->m_frequency_isSet = true; +} + +float +SWGSpectrumCalibrationPoint::getPowerRelativeReference() { + return power_relative_reference; +} +void +SWGSpectrumCalibrationPoint::setPowerRelativeReference(float power_relative_reference) { + this->power_relative_reference = power_relative_reference; + this->m_power_relative_reference_isSet = true; +} + +float +SWGSpectrumCalibrationPoint::getPowerAbsoluteReference() { + return power_absolute_reference; +} +void +SWGSpectrumCalibrationPoint::setPowerAbsoluteReference(float power_absolute_reference) { + this->power_absolute_reference = power_absolute_reference; + this->m_power_absolute_reference_isSet = true; +} + + +bool +SWGSpectrumCalibrationPoint::isSet(){ + bool isObjectUpdated = false; + do{ + if(m_frequency_isSet){ + isObjectUpdated = true; break; + } + if(m_power_relative_reference_isSet){ + isObjectUpdated = true; break; + } + if(m_power_absolute_reference_isSet){ + isObjectUpdated = true; break; + } + }while(false); + return isObjectUpdated; +} +} + diff --git a/swagger/sdrangel/code/qt5/client/SWGSpectrumCalibrationPoint.h b/swagger/sdrangel/code/qt5/client/SWGSpectrumCalibrationPoint.h new file mode 100644 index 000000000..7102f99e1 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGSpectrumCalibrationPoint.h @@ -0,0 +1,70 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 6.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/* + * SWGSpectrumCalibrationPoint.h + * + * Spectrum calibration point settings + */ + +#ifndef SWGSpectrumCalibrationPoint_H_ +#define SWGSpectrumCalibrationPoint_H_ + +#include + + + +#include "SWGObject.h" +#include "export.h" + +namespace SWGSDRangel { + +class SWG_API SWGSpectrumCalibrationPoint: public SWGObject { +public: + SWGSpectrumCalibrationPoint(); + SWGSpectrumCalibrationPoint(QString* json); + virtual ~SWGSpectrumCalibrationPoint(); + void init(); + void cleanup(); + + virtual QString asJson () override; + virtual QJsonObject* asJsonObject() override; + virtual void fromJsonObject(QJsonObject &json) override; + virtual SWGSpectrumCalibrationPoint* fromJson(QString &jsonString) override; + + qint64 getFrequency(); + void setFrequency(qint64 frequency); + + float getPowerRelativeReference(); + void setPowerRelativeReference(float power_relative_reference); + + float getPowerAbsoluteReference(); + void setPowerAbsoluteReference(float power_absolute_reference); + + + virtual bool isSet() override; + +private: + qint64 frequency; + bool m_frequency_isSet; + + float power_relative_reference; + bool m_power_relative_reference_isSet; + + float power_absolute_reference; + bool m_power_absolute_reference_isSet; + +}; + +} + +#endif /* SWGSpectrumCalibrationPoint_H_ */