From 80c5fc0ff62abb390f12e6be72935cc65716cfd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Wed, 25 Jan 2023 23:07:33 +0100 Subject: [PATCH] LibreVNADriver specific actions --- .../LibreVNA-GUI/Calibration/calibration.cpp | 1 - .../LibreVNA}/addamplitudepointsdialog.ui | 0 .../LibreVNA}/amplitudecaldialog.cpp | 58 ++- .../LibreVNA}/amplitudecaldialog.h | 21 +- .../LibreVNA}/amplitudecaldialog.ui | 0 .../LibreVNA}/automaticamplitudedialog.ui | 0 .../{ => LibreVNA}/firmwareupdatedialog.cpp | 37 +- .../{ => LibreVNA}/firmwareupdatedialog.h | 6 +- .../{ => LibreVNA}/firmwareupdatedialog.ui | 0 .../LibreVNA}/frequencycaldialog.cpp | 18 +- .../LibreVNA}/frequencycaldialog.h | 8 +- .../LibreVNA}/frequencycaldialog.ui | 0 .../Device/{ => LibreVNA}/librevnadriver.cpp | 126 ++++- .../Device/{ => LibreVNA}/librevnadriver.h | 37 +- .../{ => LibreVNA}/librevnausbdriver.cpp | 12 +- .../Device/{ => LibreVNA}/librevnausbdriver.h | 0 .../{ => LibreVNA}/manualcontroldialog.cpp | 18 +- .../{ => LibreVNA}/manualcontroldialog.h | 6 +- .../{ => LibreVNA}/manualcontroldialog.ui | 0 .../LibreVNA}/receivercaldialog.cpp | 8 +- .../LibreVNA}/receivercaldialog.h | 3 +- .../LibreVNA}/sourcecaldialog.cpp | 4 +- .../LibreVNA}/sourcecaldialog.h | 3 +- .../LibreVNA-GUI/Device/device.h | 2 +- .../LibreVNA-GUI/Device/devicedriver.cpp | 7 + .../LibreVNA-GUI/Device/devicedriver.h | 23 +- .../LibreVNA-GUI/LibreVNA-GUI.pro | 44 +- .../SpectrumAnalyzer/spectrumanalyzer.cpp | 28 - .../PC_Application/LibreVNA-GUI/VNA/vna.cpp | 2 - .../PC_Application/LibreVNA-GUI/appwindow.cpp | 483 +++++++++--------- .../PC_Application/LibreVNA-GUI/appwindow.h | 6 +- Software/PC_Application/LibreVNA-GUI/main.ui | 6 - .../PC_Application/LibreVNA-GUI/preferences.h | 1 + .../LibreVNA-Test/LibreVNA-Test.pro | 44 +- 34 files changed, 551 insertions(+), 461 deletions(-) rename Software/PC_Application/LibreVNA-GUI/{Calibration => Device/LibreVNA}/addamplitudepointsdialog.ui (100%) rename Software/PC_Application/LibreVNA-GUI/{Calibration => Device/LibreVNA}/amplitudecaldialog.cpp (91%) rename Software/PC_Application/LibreVNA-GUI/{Calibration => Device/LibreVNA}/amplitudecaldialog.h (87%) rename Software/PC_Application/LibreVNA-GUI/{Calibration => Device/LibreVNA}/amplitudecaldialog.ui (100%) rename Software/PC_Application/LibreVNA-GUI/{Calibration => Device/LibreVNA}/automaticamplitudedialog.ui (100%) rename Software/PC_Application/LibreVNA-GUI/Device/{ => LibreVNA}/firmwareupdatedialog.cpp (80%) rename Software/PC_Application/LibreVNA-GUI/Device/{ => LibreVNA}/firmwareupdatedialog.h (92%) rename Software/PC_Application/LibreVNA-GUI/Device/{ => LibreVNA}/firmwareupdatedialog.ui (100%) rename Software/PC_Application/LibreVNA-GUI/{Calibration => Device/LibreVNA}/frequencycaldialog.cpp (60%) rename Software/PC_Application/LibreVNA-GUI/{Calibration => Device/LibreVNA}/frequencycaldialog.h (61%) rename Software/PC_Application/LibreVNA-GUI/{Calibration => Device/LibreVNA}/frequencycaldialog.ui (100%) rename Software/PC_Application/LibreVNA-GUI/Device/{ => LibreVNA}/librevnadriver.cpp (74%) rename Software/PC_Application/LibreVNA-GUI/Device/{ => LibreVNA}/librevnadriver.h (84%) rename Software/PC_Application/LibreVNA-GUI/Device/{ => LibreVNA}/librevnausbdriver.cpp (96%) rename Software/PC_Application/LibreVNA-GUI/Device/{ => LibreVNA}/librevnausbdriver.h (100%) rename Software/PC_Application/LibreVNA-GUI/Device/{ => LibreVNA}/manualcontroldialog.cpp (96%) rename Software/PC_Application/LibreVNA-GUI/Device/{ => LibreVNA}/manualcontroldialog.h (95%) rename Software/PC_Application/LibreVNA-GUI/Device/{ => LibreVNA}/manualcontroldialog.ui (100%) rename Software/PC_Application/LibreVNA-GUI/{Calibration => Device/LibreVNA}/receivercaldialog.cpp (91%) rename Software/PC_Application/LibreVNA-GUI/{Calibration => Device/LibreVNA}/receivercaldialog.h (87%) rename Software/PC_Application/LibreVNA-GUI/{Calibration => Device/LibreVNA}/sourcecaldialog.cpp (92%) rename Software/PC_Application/LibreVNA-GUI/{Calibration => Device/LibreVNA}/sourcecaldialog.h (88%) diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp b/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp index c58e0a8..19aece6 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp @@ -1730,7 +1730,6 @@ void Calibration::addMeasurements(std::set m, co meas->addPoint(data); } unsavedChanges = true; - // TODO if(DeviceDriver::getActiveDriver()) { validDevice = DeviceDriver::getActiveDriver()->getSerial(); } diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/addamplitudepointsdialog.ui b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/addamplitudepointsdialog.ui similarity index 100% rename from Software/PC_Application/LibreVNA-GUI/Calibration/addamplitudepointsdialog.ui rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/addamplitudepointsdialog.ui diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/amplitudecaldialog.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.cpp similarity index 91% rename from Software/PC_Application/LibreVNA-GUI/Calibration/amplitudecaldialog.cpp rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.cpp index 418dca7..20b40fa 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/amplitudecaldialog.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.cpp @@ -18,18 +18,16 @@ using namespace std; using namespace nlohmann; -AmplitudeCalDialog::AmplitudeCalDialog(Device *dev, ModeHandler *handler, QWidget *parent) : +AmplitudeCalDialog::AmplitudeCalDialog(LibreVNADriver *dev, QWidget *parent) : QDialog(parent), ui(new Ui::AmplitudeCalDialog), dev(dev), - modeHandler(handler), model(this), edited(false), mode(CalibrationMode::BothPorts) { - activeMode = modeHandler->getActiveMode(); - modeHandler->deactivate(activeMode); - dev->SetIdle(); + setAttribute(Qt::WA_DeleteOnClose); + emit dev->acquireControl(); ui->setupUi(this); ui->view->setModel(&model); ui->view->setColumnWidth(AmplitudeModel::ColIndexFreq, 100); @@ -134,13 +132,21 @@ AmplitudeCalDialog::AmplitudeCalDialog(Device *dev, ModeHandler *handler, QWidge }); connect(ui->automatic, &QPushButton::clicked, this, &AmplitudeCalDialog::AutomaticMeasurementDialog); - connect(dev, &Device::SpectrumResultReceived, this, &AmplitudeCalDialog::ReceivedMeasurement, Qt::QueuedConnection); + connect(this, &AmplitudeCalDialog::SpectrumResultReceived, this, &AmplitudeCalDialog::ReceivedMeasurement); + + connect(dev, &LibreVNADriver::receivedPacket, this, [=](const Protocol::PacketInfo &p){ + if(p.type == Protocol::PacketType::SpectrumAnalyzerResult) { + emit SpectrumResultReceived(p.spectrumResult); + } else if(p.type == Protocol::PacketType::SourceCalPoint || p.type == Protocol::PacketType::ReceiverCalPoint) { + emit AmplitudeCorrectionPointReceived(p.amplitudePoint); + } + }, Qt::QueuedConnection); } AmplitudeCalDialog::~AmplitudeCalDialog() { + emit dev->releaseControl(); delete ui; - modeHandler->activate(activeMode); } void AmplitudeCalDialog::reject() @@ -200,7 +206,7 @@ void AmplitudeCalDialog::ReceivedPoint(Protocol::AmplitudeCorrectionPoint p) emit pointsUpdated(); if(p.pointNum == p.totalPoints - 1) { // this was the last point - disconnect(dev, &Device::AmplitudeCorrectionPointReceived, this, nullptr); + disconnect(this, &AmplitudeCalDialog::AmplitudeCorrectionPointReceived, this, nullptr); ui->load->setEnabled(true); } } @@ -208,18 +214,18 @@ void AmplitudeCalDialog::ReceivedPoint(Protocol::AmplitudeCorrectionPoint p) void AmplitudeCalDialog::LoadFromDevice() { ui->load->setEnabled(false); - dev->SetIdle(); + dev->setIdle(); RemoveAllPoints(); // qDebug() << "Asking for amplitude calibration"; - connect(dev, &Device::AmplitudeCorrectionPointReceived, this, &AmplitudeCalDialog::ReceivedPoint, Qt::QueuedConnection); - dev->SendCommandWithoutPayload(requestCommand()); + connect(this, &AmplitudeCalDialog::AmplitudeCorrectionPointReceived, this, &AmplitudeCalDialog::ReceivedPoint, Qt::QueuedConnection); + dev->sendWithoutPayload(requestCommand()); edited = false; UpdateSaveButton(); } void AmplitudeCalDialog::SaveToDevice() { - dev->SetIdle(); + dev->setIdle(); for(unsigned int i=0;i= Device::Info(dev).limits_maxAmplitudePoints) { + if (points.size() >= dev->getMaxAmplitudePoints()) { // already at limit return false; } @@ -302,8 +308,8 @@ void AmplitudeCalDialog::AddPointDialog() ui->stopFreq->setUnit("Hz"); ui->stopFreq->setPrefixes(" kMG"); ui->frequency->setValue(1000000000.0); - ui->startFreq->setValue(Device::Info(dev).limits_minFreq); - ui->stopFreq->setValue(Device::Info(dev).limits_maxFreq); + ui->startFreq->setValue(dev->getInfo().Limits.SA.minFreq); + ui->stopFreq->setValue(dev->getInfo().Limits.SA.maxFreq); connect(ui->singlePoint, &QRadioButton::toggled, [=](bool single) { ui->stopFreq->setEnabled(!single); ui->startFreq->setEnabled(!single); @@ -342,7 +348,7 @@ void AmplitudeCalDialog::AddPointDialog() delete d; }); - dev->SendCommandWithoutPayload(requestCommand()); + dev->sendWithoutPayload(requestCommand()); if(AppWindow::showGUI()) { d->show(); @@ -377,14 +383,14 @@ void AmplitudeCalDialog::AutomaticMeasurementDialog() connect(automatic.dialog, &QDialog::rejected, ui->abort, &QPushButton::click); connect(ui->abort, &QPushButton::clicked, [=](){ // aborted, clean up - disconnect(dev, &Device::SpectrumResultReceived, this, &AmplitudeCalDialog::ReceivedAutomaticMeasurementResult); - dev->SetIdle(); + disconnect(this, &AmplitudeCalDialog::SpectrumResultReceived, this, &AmplitudeCalDialog::ReceivedAutomaticMeasurementResult); + dev->setIdle(); delete ui; delete automatic.dialog; }); - dev->SetIdle(); - connect(dev, &Device::AmplitudeCorrectionPointReceived, this, [this, ui, otherCal](Protocol::AmplitudeCorrectionPoint p) { + dev->setIdle(); + connect(this, &AmplitudeCalDialog::AmplitudeCorrectionPointReceived, this, [this, ui, otherCal](Protocol::AmplitudeCorrectionPoint p) { CorrectionPoint c; c.frequency = p.freq * 10.0; c.correctionPort1 = p.port1; @@ -398,14 +404,14 @@ void AmplitudeCalDialog::AutomaticMeasurementDialog() ui->progress->setValue(0); ui->status->setText(otherCal + " Calibration contains " +QString::number(p.totalPoints)+" points, ready to start measurement"); ui->start->setEnabled(true); - disconnect(dev, &Device::AmplitudeCorrectionPointReceived, this, nullptr); + disconnect(this, &AmplitudeCalDialog::AmplitudeCorrectionPointReceived, this, nullptr); qDebug() << "Received" << p.totalPoints << "points for automatic calibration"; } }, Qt::QueuedConnection); // request points of otherCal // switch between source/receiver calibration auto request = automatic.isSourceCal ? Protocol::PacketType::RequestReceiverCal : Protocol::PacketType::RequestSourceCal; - dev->SendCommandWithoutPayload(request); + dev->sendWithoutPayload(request); connect(ui->start, &QPushButton::clicked, [=](){ // remove any exising points in own calibration and copy points from other calibration @@ -414,7 +420,7 @@ void AmplitudeCalDialog::AutomaticMeasurementDialog() AddPoint(p.frequency); } // intialize measurement state machine - connect(dev, &Device::SpectrumResultReceived, this, &AmplitudeCalDialog::ReceivedAutomaticMeasurementResult, Qt::QueuedConnection); + connect(this, &AmplitudeCalDialog::SpectrumResultReceived, this, &AmplitudeCalDialog::ReceivedAutomaticMeasurementResult, Qt::QueuedConnection); automatic.measuringPort2 = false; automatic.measuringCount = 0; ui->status->setText("Taking measurements..."); @@ -426,9 +432,8 @@ void AmplitudeCalDialog::AutomaticMeasurementDialog() } } -void AmplitudeCalDialog::ReceivedMeasurement(Device *dev, Protocol::SpectrumAnalyzerResult res) +void AmplitudeCalDialog::ReceivedMeasurement(Protocol::SpectrumAnalyzerResult res) { - Q_UNUSED(dev) MeasurementResult m = {.port1 = Util::SparamTodB(res.port1), .port2 = Util::SparamTodB(res.port2)}; sweepMeasurements.push_back(m); if(res.pointNum == automaticSweepPoints - 1) { @@ -533,9 +538,8 @@ void AmplitudeCalDialog::SetupNextAutomaticPoint(bool isSourceCal) sweepMeasurements.reserve(automaticSweepPoints); } -void AmplitudeCalDialog::ReceivedAutomaticMeasurementResult(Device *dev, Protocol::SpectrumAnalyzerResult res) +void AmplitudeCalDialog::ReceivedAutomaticMeasurementResult(Protocol::SpectrumAnalyzerResult res) { - Q_UNUSED(dev) if(res.pointNum != automaticSweepPoints - 1) { // ignore everything except end of sweep return; diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/amplitudecaldialog.h b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.h similarity index 87% rename from Software/PC_Application/LibreVNA-GUI/Calibration/amplitudecaldialog.h rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.h index fc1d48e..d2adebe 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/amplitudecaldialog.h +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.h @@ -1,11 +1,12 @@ #ifndef AMPLITUDECALDIALOG_H #define AMPLITUDECALDIALOG_H -#include "mode.h" -#include "modehandler.h" -#include "Device/device.h" +#include "librevnadriver.h" +#include #include +#include +#include namespace Ui { class AmplitudeCalDialog; @@ -15,7 +16,7 @@ class AmplitudeCalDialog; class AmplitudeModel : public QAbstractTableModel { - friend AmplitudeCalDialog; + friend class AmplitudeCalDialog; Q_OBJECT public: AmplitudeModel(AmplitudeCalDialog *c); @@ -43,7 +44,7 @@ class AmplitudeCalDialog : public QDialog Q_OBJECT public: - explicit AmplitudeCalDialog(Device *dev, ModeHandler *handler, QWidget *parent = nullptr); + explicit AmplitudeCalDialog(LibreVNADriver *dev, QWidget *parent = nullptr); ~AmplitudeCalDialog(); void reject() override; @@ -78,16 +79,18 @@ protected slots: bool AddPoint(double frequency); void AddPointDialog(); void AutomaticMeasurementDialog(); - void ReceivedMeasurement(Device *dev, Protocol::SpectrumAnalyzerResult res); signals: void pointsUpdated(); void newPointCreated(CorrectionPoint& p); + void AmplitudeCorrectionPointReceived(Protocol::AmplitudeCorrectionPoint p); + void SpectrumResultReceived(Protocol::SpectrumAnalyzerResult res); protected: static constexpr double excitationAmplitude = -20.0; static constexpr int automaticSweepPoints = 31; static constexpr int averages = 3; static constexpr int automaticSettling = 1; + void ReceivedMeasurement(Protocol::SpectrumAnalyzerResult res); bool ConfirmActionIfEdited(); void UpdateSaveButton(); virtual Protocol::PacketType requestCommand() = 0; @@ -100,15 +103,13 @@ protected: virtual void UpdateAmplitude(CorrectionPoint& point) = 0; std::vector points; Ui::AmplitudeCalDialog *ui; - Device *dev; - Mode *activeMode; - ModeHandler *modeHandler; + LibreVNADriver *dev; AmplitudeModel model; bool edited; CalibrationMode mode; void SetupNextAutomaticPoint(bool isSourceCal); - void ReceivedAutomaticMeasurementResult(Device *dev, Protocol::SpectrumAnalyzerResult res); + void ReceivedAutomaticMeasurementResult(Protocol::SpectrumAnalyzerResult res); struct { QDialog *dialog; std::vector points; diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/amplitudecaldialog.ui b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.ui similarity index 100% rename from Software/PC_Application/LibreVNA-GUI/Calibration/amplitudecaldialog.ui rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.ui diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/automaticamplitudedialog.ui b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/automaticamplitudedialog.ui similarity index 100% rename from Software/PC_Application/LibreVNA-GUI/Calibration/automaticamplitudedialog.ui rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/automaticamplitudedialog.ui diff --git a/Software/PC_Application/LibreVNA-GUI/Device/firmwareupdatedialog.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.cpp similarity index 80% rename from Software/PC_Application/LibreVNA-GUI/Device/firmwareupdatedialog.cpp rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.cpp index 3b16e8c..042cd9a 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/firmwareupdatedialog.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.cpp @@ -6,7 +6,7 @@ #include #include -FirmwareUpdateDialog::FirmwareUpdateDialog(Device *dev, QWidget *parent) : +FirmwareUpdateDialog::FirmwareUpdateDialog(LibreVNADriver *dev, QWidget *parent) : QDialog(parent), ui(new Ui::FirmwareUpdateDialog), dev(dev), @@ -15,6 +15,8 @@ FirmwareUpdateDialog::FirmwareUpdateDialog(Device *dev, QWidget *parent) : state(State::Idle), transferredBytes(0) { + dev->acquireControl(); + setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); ui->bFile->setIcon(this->style()->standardPixmap(QStyle::SP_FileDialogStart)); ui->bStart->setIcon(this->style()->standardPixmap(QStyle::SP_MediaPlay)); @@ -23,6 +25,7 @@ FirmwareUpdateDialog::FirmwareUpdateDialog(Device *dev, QWidget *parent) : FirmwareUpdateDialog::~FirmwareUpdateDialog() { + dev->releaseControl(); delete ui; } @@ -62,10 +65,15 @@ void FirmwareUpdateDialog::on_bStart_clicked() } file->seek(0); state = State::ErasingFLASH; - connect(dev, &Device::AckReceived, this, &FirmwareUpdateDialog::receivedAck, Qt::QueuedConnection); - connect(dev, &Device::NackReceived, this, &FirmwareUpdateDialog::receivedNack, Qt::QueuedConnection); + connect(dev, &LibreVNADriver::receivedAnswer, this, [=](const LibreVNADriver::TransmissionResult &res) { + if(res == LibreVNADriver::TransmissionResult::Ack) { + receivedAck(); + } else if(res == LibreVNADriver::TransmissionResult::Nack) { + receivedNack(); + } + }, static_cast(Qt::QueuedConnection | Qt::UniqueConnection)); addStatus("Erasing device memory..."); - dev->SendCommandWithoutPayload(Protocol::PacketType::ClearFlash); + dev->sendWithoutPayload(Protocol::PacketType::ClearFlash); timer.setSingleShot(true); timer.start(20000); } @@ -78,8 +86,6 @@ void FirmwareUpdateDialog::addStatus(QString line) void FirmwareUpdateDialog::abortWithError(QString error) { timer.stop(); - disconnect(dev, &Device::AckReceived, this, &FirmwareUpdateDialog::receivedAck); - disconnect(dev, &Device::NackReceived, this, &FirmwareUpdateDialog::receivedNack); QTextCharFormat tf; tf = ui->status->currentCharFormat(); @@ -97,7 +103,7 @@ void FirmwareUpdateDialog::timerCallback() switch(state) { case State::WaitingForReboot: { // Currently waiting for the reboot, check device list - auto devices = Device::GetDevices(); + auto devices = dev->GetAvailableDevices(); if(devices.find(serialnumber) != devices.end()) { // the device rebooted and is available again addStatus("...device enumerated, update complete"); @@ -109,7 +115,7 @@ void FirmwareUpdateDialog::timerCallback() case State::WaitBeforeInitializing: // Device had enough time to initialize, indicate that rebooted device is ready timer.stop(); - emit DeviceRebooted(serialnumber); + dev->connectDevice(serialnumber); delete this; break; default: @@ -139,7 +145,7 @@ void FirmwareUpdateDialog::receivedAck() // complete file transferred addStatus("Triggering device update..."); state = State::TriggeringUpdate; - dev->SendCommandWithoutPayload(Protocol::PacketType::PerformFirmwareUpdate); + dev->sendWithoutPayload(Protocol::PacketType::PerformFirmwareUpdate); timer.start(5000); } else { sendNextFirmwareChunk(); @@ -148,8 +154,8 @@ void FirmwareUpdateDialog::receivedAck() break; case State::TriggeringUpdate: addStatus("Rebooting device..."); - serialnumber = dev->serial(); - emit DeviceRebooting(); + serialnumber = dev->getSerial(); + dev->disconnectDevice(); state = State::WaitingForReboot; timer.setSingleShot(false); timer.start(2000); @@ -174,8 +180,9 @@ void FirmwareUpdateDialog::receivedNack() void FirmwareUpdateDialog::sendNextFirmwareChunk() { - Protocol::FirmwarePacket fw; - fw.address = transferredBytes; - file->read((char*) &fw.data, PacketConstants::FW_CHUNK_SIZE); - dev->SendFirmwareChunk(fw); + Protocol::PacketInfo p; + p.type = Protocol::PacketType::FirmwarePacket; + p.firmware.address = transferredBytes; + file->read((char*) &p.firmware.data, PacketConstants::FW_CHUNK_SIZE); + dev->SendPacket(p); } diff --git a/Software/PC_Application/LibreVNA-GUI/Device/firmwareupdatedialog.h b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.h similarity index 92% rename from Software/PC_Application/LibreVNA-GUI/Device/firmwareupdatedialog.h rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.h index b0322d3..ebcd459 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/firmwareupdatedialog.h +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.h @@ -1,7 +1,7 @@ #ifndef FIRMWAREUPDATEDIALOG_H #define FIRMWAREUPDATEDIALOG_H -#include "device.h" +#include "librevnadriver.h" #include #include @@ -23,7 +23,7 @@ public: * - If the update fails during device reboot, the device pointer is set to zero and the device deleted * - If the update succeeds, the device pointer will be set to the new device instance */ - explicit FirmwareUpdateDialog(Device *dev, QWidget *parent = nullptr); + explicit FirmwareUpdateDialog(LibreVNADriver *dev, QWidget *parent = nullptr); ~FirmwareUpdateDialog(); signals: @@ -42,7 +42,7 @@ private: void abortWithError(QString error); void sendNextFirmwareChunk(); Ui::FirmwareUpdateDialog *ui; - Device *dev; + LibreVNADriver *dev; QFile *file; QTimer timer; diff --git a/Software/PC_Application/LibreVNA-GUI/Device/firmwareupdatedialog.ui b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.ui similarity index 100% rename from Software/PC_Application/LibreVNA-GUI/Device/firmwareupdatedialog.ui rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.ui diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/frequencycaldialog.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.cpp similarity index 60% rename from Software/PC_Application/LibreVNA-GUI/Calibration/frequencycaldialog.cpp rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.cpp index 8f37a72..40165d0 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/frequencycaldialog.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.cpp @@ -2,18 +2,24 @@ #include "ui_frequencycaldialog.h" -FrequencyCalDialog::FrequencyCalDialog(Device *dev, ModeHandler *handler, QWidget *parent) : +FrequencyCalDialog::FrequencyCalDialog(LibreVNADriver *dev, QWidget *parent) : QDialog(parent), ui(new Ui::FrequencyCalDialog), dev(dev) { + emit dev->acquireControl(); + setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); ui->ppm->setUnit("ppm"); ui->ppm->setPrefixes(" "); ui->ppm->setPrecision(4); ui->ppm->setValue(0.0); - connect(dev, &Device::FrequencyCorrectionReceived, ui->ppm, &SIUnitEdit::setValueQuiet, Qt::QueuedConnection); + connect(dev, &LibreVNADriver::receivedPacket, this, [=](const Protocol::PacketInfo &p){ + if(p.type == Protocol::PacketType::FrequencyCorrection) { + ui->ppm->setValueQuiet(p.frequencyCorrection.ppm); + } + }, Qt::QueuedConnection); connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(ui->buttonBox, &QDialogButtonBox::accepted, [=](){ // get value and transfer to device @@ -21,20 +27,16 @@ FrequencyCalDialog::FrequencyCalDialog(Device *dev, ModeHandler *handler, QWidg p.type = Protocol::PacketType::FrequencyCorrection; p.frequencyCorrection.ppm = ui->ppm->value(); dev->SendPacket(p); - // force restart of current mode for setting to take effect - auto activeMode = handler->getActiveMode(); - handler->deactivate(activeMode); - handler->activate(activeMode); accept(); delete this; }); // request setting from device - dev->SendCommandWithoutPayload(Protocol::PacketType::RequestFrequencyCorrection); + dev->sendWithoutPayload(Protocol::PacketType::RequestFrequencyCorrection); } - FrequencyCalDialog::~FrequencyCalDialog() { + emit dev->releaseControl(); delete ui; } diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/frequencycaldialog.h b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.h similarity index 61% rename from Software/PC_Application/LibreVNA-GUI/Calibration/frequencycaldialog.h rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.h index 9ddf4e9..24e6077 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/frequencycaldialog.h +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.h @@ -1,9 +1,7 @@ #ifndef FREQUENCYCALDIALOG_H #define FREQUENCYCALDIALOG_H -#include "Device/device.h" -#include "modehandler.h" -#include "mode.h" +#include "librevnadriver.h" #include @@ -16,12 +14,12 @@ class FrequencyCalDialog : public QDialog Q_OBJECT public: - explicit FrequencyCalDialog(Device *dev, ModeHandler *handler, QWidget *parent = nullptr); + explicit FrequencyCalDialog(LibreVNADriver *dev, QWidget *parent = nullptr); ~FrequencyCalDialog(); private: Ui::FrequencyCalDialog *ui; - Device *dev; + LibreVNADriver *dev; }; #endif // FREQUENCYCALDIALOG_H diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/frequencycaldialog.ui b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.ui similarity index 100% rename from Software/PC_Application/LibreVNA-GUI/Calibration/frequencycaldialog.ui rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.ui diff --git a/Software/PC_Application/LibreVNA-GUI/Device/librevnadriver.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp similarity index 74% rename from Software/PC_Application/LibreVNA-GUI/Device/librevnadriver.cpp rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp index db1cb42..c41fd15 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/librevnadriver.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp @@ -1,5 +1,14 @@ #include "librevnadriver.h" +#include "manualcontroldialog.h" +#include "firmwareupdatedialog.h" +#include "frequencycaldialog.h" +#include "sourcecaldialog.h" +#include "receivercaldialog.h" + +#include "unit.h" +#include "CustomWidgets/informationbox.h" + using namespace std; class Reference @@ -97,6 +106,53 @@ LibreVNADriver::LibreVNADriver() connected = false; skipOwnPacketHandling = false; SApoints = 0; + + auto manual = new QAction("Manual Control"); + connect(manual, &QAction::triggered, this, [=](){ + auto d = new ManualControlDialog(*this); + d->show(); + }); + specificActions.push_back(manual); + + auto update = new QAction("Firmware Update"); + connect(update, &QAction::triggered, this, [=](){ + auto d = new FirmwareUpdateDialog(this); + d->show(); + }); + specificActions.push_back(update); + + auto sep = new QAction(); + sep->setSeparator(true); + specificActions.push_back(sep); + + auto srccal = new QAction("Source Calibration"); + connect(srccal, &QAction::triggered, this, [=](){ + auto d = new SourceCalDialog(this); + d->show(); + }); + specificActions.push_back(srccal); + + auto recvcal = new QAction("Receiver Calibration"); + connect(recvcal, &QAction::triggered, this, [=](){ + auto d = new ReceiverCalDialog(this); + d->show(); + }); + specificActions.push_back(recvcal); + + auto freqcal = new QAction("Frequency Calibration"); + connect(freqcal, &QAction::triggered, this, [=](){ + auto d = new FrequencyCalDialog(this); + d->show(); + }); + specificActions.push_back(freqcal); + + specificSettings.push_back(Savable::SettingDescription(&captureRawReceiverValues, "captureRawReceiverValues", false)); + specificSettings.push_back(Savable::SettingDescription(&harmonicMixing, "harmonicMixing", false)); + specificSettings.push_back(Savable::SettingDescription(&SASignalID, "signalID", true)); + specificSettings.push_back(Savable::SettingDescription(&VNASuppressInvalidPeaks, "suppressInvalidPeaks", true)); + specificSettings.push_back(Savable::SettingDescription(&VNAAdjustPowerLevel, "adjustPowerLevel", false)); + specificSettings.push_back(Savable::SettingDescription(&SAUseDFT, "useDFT", true)); + specificSettings.push_back(Savable::SettingDescription(&SARBWLimitForDFT, "RBWlimitDFT", 3000)); } std::set LibreVNADriver::getFlags() @@ -136,24 +192,6 @@ QString LibreVNADriver::getStatus() return ret; } -std::vector LibreVNADriver::driverSpecificSettings() -{ - std::vector ret; - ret.push_back(Savable::SettingDescription(&captureRawReceiverValues, "captureRawReceiverValues", false)); - ret.push_back(Savable::SettingDescription(&SASignalID, "signalID", true)); - ret.push_back(Savable::SettingDescription(&VNASuppressInvalidPeaks, "suppressInvalidPeaks", true)); - ret.push_back(Savable::SettingDescription(&VNAAdjustPowerLevel, "adjustPowerLevel", false)); - ret.push_back(Savable::SettingDescription(&SAUseDFT, "useDFT", true)); - ret.push_back(Savable::SettingDescription(&SARBWLimitForDFT, "RBWlimitDFT", 3000)); - return ret; -} - -std::vector LibreVNADriver::driverSpecificActions() -{ - // TODO - return std::vector(); -} - QStringList LibreVNADriver::availableVNAMeasurements() { QStringList ret; @@ -229,6 +267,7 @@ bool LibreVNADriver::setSA(const DeviceDriver::SASettings &s, std::function= 25000000) { + // Check point spacing. + // The highband PLL used as the tracking generator is not able to reach every frequency exactly. This + // could lead to sharp drops in the spectrum at certain frequencies. If the span is wide enough with + // respect to the point number, it is ensured that every displayed point has at least one sample with + // a reachable PLL frequency in it. Display a warning message if this is not the case with the current + // settings. + auto pointSpacing = (p.spectrumSettings.f_stop - p.spectrumSettings.f_start) / (p.spectrumSettings.pointNum - 1); + // The frequency resolution of the PLL is frequency dependent (due to PLL divider). + // This code assumes some knowledge of the actual hardware and probably should be moved + // onto the device at some point + double minSpacing = 25000; + auto stop = p.spectrumSettings.f_stop; + while(stop <= 3000000000) { + minSpacing /= 2; + stop *= 2; + } + if(pointSpacing < minSpacing) { + auto requiredMinSpan = minSpacing * (p.spectrumSettings.pointNum - 1); + auto message = QString() + "Due to PLL limitations, the tracking generator can not reach every frequency exactly. " + "With your current span, this could result in the signal not being detected at some bands. A minimum" + " span of " + Unit::ToString(requiredMinSpan, "Hz", " kMG") + " is recommended at this stop frequency."; + InformationBox::ShowMessage("Warning", message, "TrackingGeneratorSpanTooSmallWarning"); + } + } + return SendPacket(p, [=](TransmissionResult r){ if(cb) { cb(r == TransmissionResult::Ack); @@ -364,7 +430,18 @@ void LibreVNADriver::handleReceivedPacket(const Protocol::PacketInfo &packet) switch(packet.type) { case Protocol::PacketType::DeviceInfo: - // TODO check protocol version + // Check protocol version + if(packet.info.ProtocolVersion != Protocol::Version) { + auto ret = InformationBox::AskQuestion("Warning", + "The device reports a different protocol" + "version (" + QString::number(packet.info.ProtocolVersion) + ") than expected (" + QString::number(Protocol::Version) + ").\n" + "A firmware update is strongly recommended. Do you want to update now?", false); + if (ret) { + auto d = new FirmwareUpdateDialog(this); + d->show(); + } + } + info.firmware_version = QString::number(packet.info.FW_major)+"."+QString::number(packet.info.FW_minor)+"."+QString::number(packet.info.FW_patch); info.hardware_version = QString::number(packet.info.hardware_version)+QString(packet.info.HW_Revision); info.supportedFeatures = { @@ -375,7 +452,7 @@ void LibreVNADriver::handleReceivedPacket(const Protocol::PacketInfo &packet) }; info.Limits.VNA.ports = 2; info.Limits.VNA.minFreq = packet.info.limits_minFreq; - info.Limits.VNA.maxFreq = packet.info.limits_maxFreq; // TODO check if harmonic mixing is enabled + info.Limits.VNA.maxFreq = harmonicMixing ? packet.info.limits_maxFreqHarmonic : packet.info.limits_maxFreq; info.Limits.VNA.maxPoints = packet.info.limits_maxPoints; info.Limits.VNA.minIFBW = packet.info.limits_minIFBW; info.Limits.VNA.maxIFBW = packet.info.limits_maxIFBW; @@ -395,6 +472,8 @@ void LibreVNADriver::handleReceivedPacket(const Protocol::PacketInfo &packet) info.Limits.SA.maxRBW = packet.info.limits_maxRBW; info.Limits.SA.mindBm = (double) packet.info.limits_cdbm_min / 100; info.Limits.SA.maxdBm = (double) packet.info.limits_cdbm_max / 100; + + limits_maxAmplitudePoints = packet.info.limits_maxAmplitudePoints; emit InfoUpdated(); break; case Protocol::PacketType::DeviceStatusV1: @@ -449,9 +528,16 @@ void LibreVNADriver::handleReceivedPacket(const Protocol::PacketInfo &packet) emit SAmeasurementReceived(m); } break; + default: + break; } } +int LibreVNADriver::getMaxAmplitudePoints() const +{ + return limits_maxAmplitudePoints; +} + bool LibreVNADriver::sendWithoutPayload(Protocol::PacketType type, std::function cb) { Protocol::PacketInfo p; diff --git a/Software/PC_Application/LibreVNA-GUI/Device/librevnadriver.h b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.h similarity index 84% rename from Software/PC_Application/LibreVNA-GUI/Device/librevnadriver.h rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.h index d4c661c..c92e04e 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/librevnadriver.h +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.h @@ -1,7 +1,7 @@ #ifndef LIBREVNADRIVER_H #define LIBREVNADRIVER_H -#include "devicedriver.h" +#include "../devicedriver.h" #include "../../VNA_embedded/Application/Communication/Protocol.hpp" @@ -55,32 +55,6 @@ public: */ virtual QString getStatus() override; - /** - * @brief Returns the driver specific settings - * - * The settings are returned as a map. - * Key: user-readable setting name - * Value: SettingDescription, consisting of: - * - var: Pointer to the setting variable (should be a private member of the derived class) - * - name: Arbitrary string used to persistently store this setting (never visible to the user) - * - def: Default value of the setting - * - * These settings will be persistent across reboots. For each device driver, a section within the preferences - * will be created where these settings can be changed. - * - * @return Map of driver specific settings - */ - virtual std::vector driverSpecificSettings() override; - - /** - * @brief Return driver specific actions. - * - * The returned actions will be appended to the device menu. - * - * @return List of actions - */ - virtual std::vector driverSpecificActions() override; - /** * @brief Names of available measurements. * @@ -173,20 +147,22 @@ signals: void passOnReceivedPacket(const Protocol::PacketInfo& packet); public: virtual bool SendPacket(const Protocol::PacketInfo& packet, std::function cb = nullptr, unsigned int timeout = 500) = 0; + bool sendWithoutPayload(Protocol::PacketType type, std::function cb = nullptr); + + int getMaxAmplitudePoints() const; -protected: signals: - void receivedAnswer(TransmissionResult result); + void receivedAnswer(const LibreVNADriver::TransmissionResult &result); void receivedPacket(const Protocol::PacketInfo& packet); protected slots: void handleReceivedPacket(const Protocol::PacketInfo& packet); protected: - bool sendWithoutPayload(Protocol::PacketType type, std::function cb = nullptr); bool connected; QString serial; Info info; + int limits_maxAmplitudePoints; Protocol::DeviceStatusV1 lastStatus; @@ -198,6 +174,7 @@ protected: // Driver specific settings bool captureRawReceiverValues; + bool harmonicMixing; bool SASignalID; bool SAUseDFT; double SARBWLimitForDFT; diff --git a/Software/PC_Application/LibreVNA-GUI/Device/librevnausbdriver.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.cpp similarity index 96% rename from Software/PC_Application/LibreVNA-GUI/Device/librevnausbdriver.cpp rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.cpp index eb3aa6d..be2a91f 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/librevnausbdriver.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.cpp @@ -1,7 +1,7 @@ #include "librevnausbdriver.h" #include "CustomWidgets/informationbox.h" -#include "deviceusblog.h" +#include "../deviceusblog.h" #include @@ -211,9 +211,9 @@ bool LibreVNAUSBDriver::connectTo(QString serial) connect(dataBuffer, &USBInBuffer::DataReceived, this, &LibreVNAUSBDriver::ReceivedData, Qt::DirectConnection); connect(dataBuffer, &USBInBuffer::TransferError, this, &LibreVNAUSBDriver::ConnectionLost); connect(logBuffer, &USBInBuffer::DataReceived, this, &LibreVNAUSBDriver::ReceivedLog, Qt::DirectConnection); - connect(&transmissionTimer, &QTimer::timeout, this, &LibreVNAUSBDriver::transmissionTimeout); - connect(this, &LibreVNAUSBDriver::receivedAnswer, this, &LibreVNAUSBDriver::transmissionFinished, Qt::QueuedConnection); - connect(this, &LibreVNAUSBDriver::receivedPacket, this, &LibreVNAUSBDriver::handleReceivedPacket, Qt::QueuedConnection); + connect(&transmissionTimer, &QTimer::timeout, this, &LibreVNAUSBDriver::transmissionTimeout, Qt::UniqueConnection); + connect(this, &LibreVNAUSBDriver::receivedAnswer, this, &LibreVNAUSBDriver::transmissionFinished, static_cast(Qt::QueuedConnection | Qt::UniqueConnection)); + connect(this, &LibreVNAUSBDriver::receivedPacket, this, &LibreVNAUSBDriver::handleReceivedPacket, static_cast(Qt::QueuedConnection | Qt::UniqueConnection)); transmissionTimer.setSingleShot(true); transmissionActive = false; @@ -251,8 +251,8 @@ void LibreVNAUSBDriver::disconnect() void LibreVNAUSBDriver::registerTypes() { - qRegisterMetaType("LibreVNAUSBPacket"); - qRegisterMetaType("LibreVNAUSBResult"); + qDebug() << "Registering meta type: " << qRegisterMetaType(); + qDebug() << "Registering meta type: " << qRegisterMetaType(); } void LibreVNAUSBDriver::ReceivedData() diff --git a/Software/PC_Application/LibreVNA-GUI/Device/librevnausbdriver.h b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.h similarity index 100% rename from Software/PC_Application/LibreVNA-GUI/Device/librevnausbdriver.h rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.h diff --git a/Software/PC_Application/LibreVNA-GUI/Device/manualcontroldialog.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialog.cpp similarity index 96% rename from Software/PC_Application/LibreVNA-GUI/Device/manualcontroldialog.cpp rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialog.cpp index d9e31b6..e9d97a0 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/manualcontroldialog.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialog.cpp @@ -11,12 +11,15 @@ using namespace std; -ManualControlDialog::ManualControlDialog(Device &dev, QWidget *parent) : +ManualControlDialog::ManualControlDialog(LibreVNADriver &dev, QWidget *parent) : QDialog(parent), ui(new Ui::ManualControlDialog), dev(dev) { ui->setupUi(this); + setAttribute(Qt::WA_DeleteOnClose); + + emit dev.acquireControl(); ui->SourceLowFrequency->setUnit("Hz"); ui->SourceLowFrequency->setPrefixes(" kM"); @@ -148,7 +151,11 @@ ManualControlDialog::ManualControlDialog(Device &dev, QWidget *parent) : MakeReadOnly(ui->refmag); MakeReadOnly(ui->refphase); - connect(&dev, &Device::ManualStatusReceived, this, &ManualControlDialog::NewStatus, Qt::QueuedConnection); + connect(&dev, &LibreVNADriver::receivedPacket, this, [=](const Protocol::PacketInfo &p){ + if(p.type == Protocol::PacketType::ManualStatusV1) { + NewStatus(p.manualStatusV1); + } + }, Qt::QueuedConnection); connect(ui->SourceCE, &QCheckBox::toggled, [=](bool) { UpdateDevice(); }); connect(ui->SourceRFEN, &QCheckBox::toggled, [=](bool) { UpdateDevice(); }); @@ -184,6 +191,7 @@ ManualControlDialog::ManualControlDialog(Device &dev, QWidget *parent) : ManualControlDialog::~ManualControlDialog() { + emit dev.releaseControl(); delete ui; } @@ -616,7 +624,9 @@ void ManualControlDialog::NewStatus(Protocol::ManualStatusV1 status) void ManualControlDialog::UpdateDevice() { - Protocol::ManualControlV1 m; + Protocol::PacketInfo p; + p.type = Protocol::PacketType::ManualControlV1; + Protocol::ManualControlV1 &m = p.manual; // Source highband m.SourceHighCE = ui->SourceCE->isChecked(); m.SourceHighRFEN = ui->SourceRFEN->isChecked(); @@ -648,5 +658,5 @@ void ManualControlDialog::UpdateDevice() qDebug() << "Updating manual control state"; - dev.SetManual(m); + dev.SendPacket(p); } diff --git a/Software/PC_Application/LibreVNA-GUI/Device/manualcontroldialog.h b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialog.h similarity index 95% rename from Software/PC_Application/LibreVNA-GUI/Device/manualcontroldialog.h rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialog.h index 553d549..cbd9643 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/manualcontroldialog.h +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialog.h @@ -1,7 +1,7 @@ #ifndef MANUALCONTROLDIALOG_H #define MANUALCONTROLDIALOG_H -#include "device.h" +#include "librevnadriver.h" #include #include @@ -15,7 +15,7 @@ class ManualControlDialog : public QDialog Q_OBJECT public: - explicit ManualControlDialog(Device &dev, QWidget *parent = nullptr); + explicit ManualControlDialog(LibreVNADriver &dev, QWidget *parent = nullptr); ~ManualControlDialog(); void setHighSourceChipEnable(bool enable); @@ -108,7 +108,7 @@ public slots: private: void UpdateDevice(); Ui::ManualControlDialog *ui; - Device &dev; + LibreVNADriver &dev; std::complex port1referenced; std::complex port2referenced; }; diff --git a/Software/PC_Application/LibreVNA-GUI/Device/manualcontroldialog.ui b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialog.ui similarity index 100% rename from Software/PC_Application/LibreVNA-GUI/Device/manualcontroldialog.ui rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialog.ui diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/receivercaldialog.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/receivercaldialog.cpp similarity index 91% rename from Software/PC_Application/LibreVNA-GUI/Calibration/receivercaldialog.cpp rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/receivercaldialog.cpp index bd64cfe..2f6a46f 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/receivercaldialog.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/receivercaldialog.cpp @@ -1,7 +1,7 @@ #include "receivercaldialog.h" -ReceiverCalDialog::ReceiverCalDialog(Device *dev, ModeHandler *handler) - : AmplitudeCalDialog(dev, handler) +ReceiverCalDialog::ReceiverCalDialog(LibreVNADriver *dev) + : AmplitudeCalDialog(dev) { setWindowTitle("Receiver Calibration Dialog"); LoadFromDevice(); @@ -17,7 +17,7 @@ void ReceiverCalDialog::SelectedPoint(double frequency, bool) // setup 3 points centered around the measurement frequency (zero span not supported yet) p.spectrumSettings.f_stop = frequency + 1.0; p.spectrumSettings.f_start = frequency - 1.0; - p.spectrumSettings.pointNum = 3; + p.spectrumSettings.pointNum = automaticSweepPoints; p.spectrumSettings.Detector = 0; p.spectrumSettings.SignalID = 1; p.spectrumSettings.WindowType = 3; @@ -25,7 +25,7 @@ void ReceiverCalDialog::SelectedPoint(double frequency, bool) dev->SendPacket(p); } else { // invalid frequency, disable - dev->SetIdle(); + dev->setIdle(); } } diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/receivercaldialog.h b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/receivercaldialog.h similarity index 87% rename from Software/PC_Application/LibreVNA-GUI/Calibration/receivercaldialog.h rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/receivercaldialog.h index 28fecf4..d84ac59 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/receivercaldialog.h +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/receivercaldialog.h @@ -2,13 +2,12 @@ #define RECEIVERCALDIALOG_H #include "amplitudecaldialog.h" -#include "modehandler.h" class ReceiverCalDialog : public AmplitudeCalDialog { Q_OBJECT public: - ReceiverCalDialog(Device *dev, ModeHandler *handler); + ReceiverCalDialog(LibreVNADriver *dev); protected: Protocol::PacketType requestCommand() override { return Protocol::PacketType::RequestReceiverCal; } Protocol::PacketType pointType() override { return Protocol::PacketType::ReceiverCalPoint; } diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/sourcecaldialog.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/sourcecaldialog.cpp similarity index 92% rename from Software/PC_Application/LibreVNA-GUI/Calibration/sourcecaldialog.cpp rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/sourcecaldialog.cpp index c511920..f40ea1f 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/sourcecaldialog.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/sourcecaldialog.cpp @@ -2,8 +2,8 @@ #include -SourceCalDialog::SourceCalDialog(Device *dev, ModeHandler *handler) - : AmplitudeCalDialog(dev, handler) +SourceCalDialog::SourceCalDialog(LibreVNADriver *dev) + : AmplitudeCalDialog(dev) { setWindowTitle("Source Calibration Dialog"); LoadFromDevice(); diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/sourcecaldialog.h b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/sourcecaldialog.h similarity index 88% rename from Software/PC_Application/LibreVNA-GUI/Calibration/sourcecaldialog.h rename to Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/sourcecaldialog.h index f343e3b..1dc6c52 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/sourcecaldialog.h +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/sourcecaldialog.h @@ -2,7 +2,6 @@ #define SOURCECALDIALOG_H #include "amplitudecaldialog.h" -#include "modehandler.h" #include @@ -10,7 +9,7 @@ class SourceCalDialog : public AmplitudeCalDialog { Q_OBJECT public: - SourceCalDialog(Device *dev, ModeHandler *handler); + SourceCalDialog(LibreVNADriver *dev); protected: Protocol::PacketType requestCommand() override { return Protocol::PacketType::RequestSourceCal; } Protocol::PacketType pointType() override { return Protocol::PacketType::SourceCalPoint; } diff --git a/Software/PC_Application/LibreVNA-GUI/Device/device.h b/Software/PC_Application/LibreVNA-GUI/Device/device.h index b59acee..5bddb27 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/device.h +++ b/Software/PC_Application/LibreVNA-GUI/Device/device.h @@ -3,7 +3,7 @@ #include "../../VNA_embedded/Application/Communication/Protocol.hpp" -#include "librevnausbdriver.h" +#include "LibreVNA/librevnausbdriver.h" #include #include diff --git a/Software/PC_Application/LibreVNA-GUI/Device/devicedriver.cpp b/Software/PC_Application/LibreVNA-GUI/Device/devicedriver.cpp index 265c13d..d25a286 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/devicedriver.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/devicedriver.cpp @@ -2,6 +2,13 @@ DeviceDriver *DeviceDriver::activeDriver = nullptr; +DeviceDriver::~DeviceDriver() +{ + for(auto a : specificActions) { + delete a; + } +} + bool DeviceDriver::connectDevice(QString serial) { if(activeDriver && activeDriver != this) { diff --git a/Software/PC_Application/LibreVNA-GUI/Device/devicedriver.h b/Software/PC_Application/LibreVNA-GUI/Device/devicedriver.h index 43df4b0..cf67627 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/devicedriver.h +++ b/Software/PC_Application/LibreVNA-GUI/Device/devicedriver.h @@ -8,7 +8,7 @@ * - Derive from this class * - Implement all pure virtual functions * - Implement the virtual functions if the device supports the specific function - * - TODO register the driver during application start + * - register the driver during application start */ #include "Tools/parameters.h" @@ -25,7 +25,7 @@ class DeviceDriver : public QObject Q_OBJECT public: DeviceDriver() {} - virtual ~DeviceDriver() {} + virtual ~DeviceDriver(); /** * @brief Returns the driver name. It must be unique across all implemented drivers and is used to identify the driver @@ -201,7 +201,7 @@ public: * * @return Map of driver specific settings */ - virtual std::vector driverSpecificSettings() {return std::vector();} + std::vector driverSpecificSettings() {return specificSettings;} /** * @brief Return driver specific actions. @@ -210,7 +210,7 @@ public: * * @return List of actions */ - virtual std::vector driverSpecificActions() {return std::vector();} + std::vector driverSpecificActions() {return specificActions;} class VNASettings { public: @@ -456,12 +456,27 @@ signals: */ void LogLineReceived(QString line); + /** + * @brief Emit this signal whenever the device driver wants complete control over the device. Once emitted, no other part of the application + * will try to communicate until releaseControl() is emitted + */ + void acquireControl(); + + /** + * @brief Emit this signal whenever the device driver wants to return control to the application. + */ + void releaseControl(); + public: bool connectDevice(QString serial); void disconnectDevice(); static DeviceDriver* getActiveDriver() {return activeDriver;} static unsigned int SApoints(); +protected: + std::vector specificActions; + std::vector specificSettings; + private: static DeviceDriver *activeDriver; }; diff --git a/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro b/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro index 1633480..a9160f3 100644 --- a/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro +++ b/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro @@ -4,16 +4,12 @@ HEADERS += \ Calibration/LibreCAL/caldevice.h \ Calibration/LibreCAL/librecaldialog.h \ Calibration/LibreCAL/usbdevice.h \ - Calibration/amplitudecaldialog.h \ Calibration/calibration.h \ Calibration/calibrationmeasurement.h \ Calibration/calkit.h \ Calibration/calkitdialog.h \ Calibration/calstandard.h \ - Calibration/frequencycaldialog.h \ Calibration/manualcalibrationdialog.h \ - Calibration/receivercaldialog.h \ - Calibration/sourcecaldialog.h \ CustomWidgets/colorpickerbutton.h \ CustomWidgets/csvimport.h \ CustomWidgets/informationbox.h \ @@ -23,6 +19,14 @@ HEADERS += \ CustomWidgets/toggleswitch.h \ CustomWidgets/touchstoneimport.h \ CustomWidgets/tracesetselector.h \ + Device/LibreVNA/amplitudecaldialog.h \ + Device/LibreVNA/firmwareupdatedialog.h \ + Device/LibreVNA/frequencycaldialog.h \ + Device/LibreVNA/librevnadriver.h \ + Device/LibreVNA/librevnausbdriver.h \ + Device/LibreVNA/manualcontroldialog.h \ + Device/LibreVNA/receivercaldialog.h \ + Device/LibreVNA/sourcecaldialog.h \ Device/compounddevice.h \ Device/compounddeviceeditdialog.h \ Device/device.h \ @@ -30,10 +34,6 @@ HEADERS += \ Device/devicelog.h \ Device/deviceusblog.h \ Device/deviceusblogview.h \ - Device/firmwareupdatedialog.h \ - Device/librevnadriver.h \ - Device/librevnausbdriver.h \ - Device/manualcontroldialog.h \ Device/virtualdevice.h \ Generator/generator.h \ Generator/signalgenwidget.h \ @@ -155,16 +155,12 @@ SOURCES += \ Calibration/LibreCAL/caldevice.cpp \ Calibration/LibreCAL/librecaldialog.cpp \ Calibration/LibreCAL/usbdevice.cpp \ - Calibration/amplitudecaldialog.cpp \ Calibration/calibration.cpp \ Calibration/calibrationmeasurement.cpp \ Calibration/calkit.cpp \ Calibration/calkitdialog.cpp \ Calibration/calstandard.cpp \ - Calibration/frequencycaldialog.cpp \ Calibration/manualcalibrationdialog.cpp \ - Calibration/receivercaldialog.cpp \ - Calibration/sourcecaldialog.cpp \ CustomWidgets/colorpickerbutton.cpp \ CustomWidgets/csvimport.cpp \ CustomWidgets/informationbox.cpp \ @@ -174,6 +170,14 @@ SOURCES += \ CustomWidgets/toggleswitch.cpp \ CustomWidgets/touchstoneimport.cpp \ CustomWidgets/tracesetselector.cpp \ + Device/LibreVNA/amplitudecaldialog.cpp \ + Device/LibreVNA/firmwareupdatedialog.cpp \ + Device/LibreVNA/frequencycaldialog.cpp \ + Device/LibreVNA/librevnadriver.cpp \ + Device/LibreVNA/librevnausbdriver.cpp \ + Device/LibreVNA/manualcontroldialog.cpp \ + Device/LibreVNA/receivercaldialog.cpp \ + Device/LibreVNA/sourcecaldialog.cpp \ Device/compounddevice.cpp \ Device/compounddeviceeditdialog.cpp \ Device/device.cpp \ @@ -181,10 +185,6 @@ SOURCES += \ Device/devicelog.cpp \ Device/deviceusblog.cpp \ Device/deviceusblogview.cpp \ - Device/firmwareupdatedialog.cpp \ - Device/librevnadriver.cpp \ - Device/librevnausbdriver.cpp \ - Device/manualcontroldialog.cpp \ Device/virtualdevice.cpp \ Generator/generator.cpp \ Generator/signalgenwidget.cpp \ @@ -304,22 +304,22 @@ FORMS += \ Calibration/CalStandardShortEditDialog.ui \ Calibration/CalStandardThroughEditDialog.ui \ Calibration/LibreCAL/librecaldialog.ui \ - Calibration/addamplitudepointsdialog.ui \ - Calibration/amplitudecaldialog.ui \ - Calibration/automaticamplitudedialog.ui \ Calibration/calibrationdialogui.ui \ Calibration/calkitdialog.ui \ - Calibration/frequencycaldialog.ui \ Calibration/manualcalibrationdialog.ui \ CustomWidgets/csvimport.ui \ CustomWidgets/jsonpickerdialog.ui \ CustomWidgets/tilewidget.ui \ CustomWidgets/touchstoneimport.ui \ + Device/LibreVNA/addamplitudepointsdialog.ui \ + Device/LibreVNA/amplitudecaldialog.ui \ + Device/LibreVNA/automaticamplitudedialog.ui \ + Device/LibreVNA/firmwareupdatedialog.ui \ + Device/LibreVNA/frequencycaldialog.ui \ + Device/LibreVNA/manualcontroldialog.ui \ Device/compounddeviceeditdialog.ui \ Device/devicelog.ui \ Device/deviceusblogview.ui \ - Device/firmwareupdatedialog.ui \ - Device/manualcontroldialog.ui \ Generator/signalgenwidget.ui \ Tools/impedancematchdialog.ui \ Tools/mixedmodeconversion.ui \ diff --git a/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp b/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp index a495ad5..4f2c698 100644 --- a/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp +++ b/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp @@ -2,7 +2,6 @@ #include "unit.h" #include "CustomWidgets/toggleswitch.h" -#include "Device/manualcontroldialog.h" #include "Traces/tracemodel.h" #include "tracewidgetsa.h" #include "Traces/tracesmithchart.h" @@ -823,33 +822,6 @@ void SpectrumAnalyzer::ConfigureDevice() if(running) { changingSettings = true; - // TODO move into libreVNA driver -// if(settings.trackingGenerator && settings.freqStop >= 25000000) { -// // Check point spacing. -// // The highband PLL used as the tracking generator is not able to reach every frequency exactly. This -// // could lead to sharp drops in the spectrum at certain frequencies. If the span is wide enough with -// // respect to the point number, it is ensured that every displayed point has at least one sample with -// // a reachable PLL frequency in it. Display a warning message if this is not the case with the current -// // settings. -// auto pointSpacing = (settings.freqStop - settings.freqStart) / (settings.points - 1); -// // The frequency resolution of the PLL is frequency dependent (due to PLL divider). -// // This code assumes some knowledge of the actual hardware and probably should be moved -// // onto the device at some point -// double minSpacing = 25000; -// auto stop = settings.freqStop; -// while(stop <= 3000000000) { -// minSpacing /= 2; -// stop *= 2; -// } -// if(pointSpacing < minSpacing) { -// auto requiredMinSpan = minSpacing * (settings.points - 1); -// auto message = QString() + "Due to PLL limitations, the tracking generator can not reach every frequency exactly. " -// "With your current span, this could result in the signal not being detected at some bands. A minimum" -// " span of " + Unit::ToString(requiredMinSpan, "Hz", " kMG") + " is recommended at this stop frequency."; -// InformationBox::ShowMessage("Warning", message, "TrackingGeneratorSpanTooSmallWarning"); -// } -// } - if(window->getDevice() && isActive) { window->getDevice()->setSA(settings, [=](bool){ // device received command diff --git a/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp b/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp index 784db25..f5c39ed 100644 --- a/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp +++ b/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp @@ -2,7 +2,6 @@ #include "unit.h" #include "CustomWidgets/toggleswitch.h" -#include "Device/manualcontroldialog.h" #include "Traces/tracemodel.h" #include "tracewidgetvna.h" #include "Traces/tracesmithchart.h" @@ -14,7 +13,6 @@ #include "Tools/impedancematchdialog.h" #include "Tools/mixedmodeconversion.h" #include "ui_main.h" -#include "Device/firmwareupdatedialog.h" #include "preferences.h" #include "Generator/signalgenwidget.h" #include "CustomWidgets/informationbox.h" diff --git a/Software/PC_Application/LibreVNA-GUI/appwindow.cpp b/Software/PC_Application/LibreVNA-GUI/appwindow.cpp index 280a384..dcaa803 100644 --- a/Software/PC_Application/LibreVNA-GUI/appwindow.cpp +++ b/Software/PC_Application/LibreVNA-GUI/appwindow.cpp @@ -2,7 +2,6 @@ #include "unit.h" #include "CustomWidgets/toggleswitch.h" -#include "Device/manualcontroldialog.h" #include "Device/deviceusblogview.h" #include "Traces/tracemodel.h" #include "Traces/tracewidget.h" @@ -14,15 +13,11 @@ #include "Traces/Marker/markerwidget.h" #include "Tools/impedancematchdialog.h" #include "ui_main.h" -#include "Device/firmwareupdatedialog.h" #include "preferences.h" #include "Generator/signalgenwidget.h" #include "VNA/vna.h" #include "Generator/generator.h" #include "SpectrumAnalyzer/spectrumanalyzer.h" -#include "Calibration/sourcecaldialog.h" -#include "Calibration/receivercaldialog.h" -#include "Calibration/frequencycaldialog.h" #include "CustomWidgets/jsonpickerdialog.h" #include "CustomWidgets/informationbox.h" #include "Util/app_common.h" @@ -30,7 +25,7 @@ #include "mode.h" #include "modehandler.h" #include "modewindow.h" -#include "Device/librevnausbdriver.h" +#include "Device/LibreVNA/librevnausbdriver.h" #include #include @@ -75,7 +70,6 @@ static bool noGUIset = false; AppWindow::AppWindow(QWidget *parent) : QMainWindow(parent) , deviceActionGroup(new QActionGroup(this)) - , manual(nullptr) , ui(new Ui::MainWindow) , server(nullptr) , appVersion(APP_VERSION) @@ -326,15 +320,15 @@ void AppWindow::closeEvent(QCloseEvent *event) device->disconnectDevice(); device = nullptr; } - for(auto driver : deviceDrivers) { - delete driver; - } delete modeHandler; modeHandler = nullptr; pref.store(); for(auto driver : deviceDrivers) { Preferences::getInstance().store(driver->driverSpecificSettings()); } + for(auto driver : deviceDrivers) { + delete driver; + } QMainWindow::closeEvent(event); } @@ -375,8 +369,31 @@ bool AppWindow::ConnectToDevice(QString serial, DeviceDriver *driver) connect(device, &DeviceDriver::LogLineReceived, &deviceLog, &DeviceLog::addLine); connect(device, &DeviceDriver::ConnectionLost, this, &AppWindow::DeviceConnectionLost); connect(device, &DeviceDriver::StatusUpdated, this, &AppWindow::DeviceStatusUpdated); + connect(device, &DeviceDriver::releaseControl, [=](){ + if(lastActiveMode) { + modeHandler->activate(lastActiveMode); + } + }); + connect(device, &DeviceDriver::acquireControl, [=](){ + lastActiveMode = modeHandler->getActiveMode(); + modeHandler->deactivate(lastActiveMode); + }); // connect(vdevice, &VirtualDevice::NeedsFirmwareUpdate, this, &AppWindow::DeviceNeedsUpdate); ui->actionDisconnect->setEnabled(true); + // find correct position to add device specific actions at + QAction *before = nullptr; + for(int i=0;imenuDevice->actions().size();i++) { + auto comp = ui->menuDevice->actions()[i]; + if(comp == ui->actionDisconnect) { + if(i + 2 < ui->menuDevice->actions().size()) { + before = ui->menuDevice->actions()[i+2]; + } + break; + } + } + for(auto a : device->driverSpecificActions()) { + ui->menuDevice->insertAction(before, a); + } // if(!vdevice->isCompoundDevice()) { // ui->actionManual_Control->setEnabled(true); // ui->actionFirmware_Update->setEnabled(true); @@ -419,6 +436,9 @@ bool AppWindow::ConnectToDevice(QString serial, DeviceDriver *driver) void AppWindow::DisconnectDevice() { if(device) { + for(auto a : device->driverSpecificActions()) { + ui->menuDevice->removeAction(a); + } device->disconnectDevice(); device = nullptr; } @@ -701,232 +721,233 @@ void AppWindow::SetupSCPI() return QString::number(DeviceDriver::getInfo(getDevice()).Limits.VNA.maxFreq); })); - auto scpi_manual = new SCPINode("MANual"); - scpi_manual->add(new SCPICommand("STArt",[=](QStringList) -> QString { -// StartManualControl(); - return SCPI::getResultName(SCPI::Result::Empty); - }, nullptr)); - scpi_manual->add(new SCPICommand("STOp",[=](QStringList) -> QString { - manual->close(); - delete manual; - return SCPI::getResultName(SCPI::Result::Empty); - }, nullptr)); + // TODO +// auto scpi_manual = new SCPINode("MANual"); +// scpi_manual->add(new SCPICommand("STArt",[=](QStringList) -> QString { +//// StartManualControl(); +// return SCPI::getResultName(SCPI::Result::Empty); +// }, nullptr)); +// scpi_manual->add(new SCPICommand("STOp",[=](QStringList) -> QString { +// manual->close(); +// delete manual; +// return SCPI::getResultName(SCPI::Result::Empty); +// }, nullptr)); +// +// auto addBooleanManualSetting = [=](QString cmd, void(ManualControlDialog::*set)(bool), bool(ManualControlDialog::*get)(void)) { +// scpi_manual->add(new SCPICommand(cmd, [=](QStringList params) -> QString { +// bool enable; +// if(!manual || !SCPI::paramToBool(params, 0, enable)) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// auto set_fn = std::bind(set, manual, std::placeholders::_1); +// set_fn(enable); +// return SCPI::getResultName(SCPI::Result::Empty); +// }, [=](QStringList) -> QString { +// if(!manual) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// auto get_fn = std::bind(get, manual); +// return get_fn() ? SCPI::getResultName(SCPI::Result::True) : SCPI::getResultName(SCPI::Result::False); +// })); +// }; - auto addBooleanManualSetting = [=](QString cmd, void(ManualControlDialog::*set)(bool), bool(ManualControlDialog::*get)(void)) { - scpi_manual->add(new SCPICommand(cmd, [=](QStringList params) -> QString { - bool enable; - if(!manual || !SCPI::paramToBool(params, 0, enable)) { - return SCPI::getResultName(SCPI::Result::Error); - } - auto set_fn = std::bind(set, manual, std::placeholders::_1); - set_fn(enable); - return SCPI::getResultName(SCPI::Result::Empty); - }, [=](QStringList) -> QString { - if(!manual) { - return SCPI::getResultName(SCPI::Result::Error); - } - auto get_fn = std::bind(get, manual); - return get_fn() ? SCPI::getResultName(SCPI::Result::True) : SCPI::getResultName(SCPI::Result::False); - })); - }; +// auto addDoubleManualSetting = [=](QString cmd, void(ManualControlDialog::*set)(double), double(ManualControlDialog::*get)(void)) { +// scpi_manual->add(new SCPICommand(cmd, [=](QStringList params) -> QString { +// double value; +// if(!manual || !SCPI::paramToDouble(params, 0, value)) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// auto set_fn = std::bind(set, manual, std::placeholders::_1); +// set_fn(value); +// return SCPI::getResultName(SCPI::Result::Empty); +// }, [=](QStringList) -> QString { +// if(!manual) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// auto get_fn = std::bind(get, manual); +// return QString::number(get_fn()); +// })); +// }; +// auto addIntegerManualSetting = [=](QString cmd, void(ManualControlDialog::*set)(int), int(ManualControlDialog::*get)(void)) { +// scpi_manual->add(new SCPICommand(cmd, [=](QStringList params) -> QString { +// double value; +// if(!manual || !SCPI::paramToDouble(params, 0, value)) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// auto set_fn = std::bind(set, manual, std::placeholders::_1); +// set_fn(value); +// return SCPI::getResultName(SCPI::Result::Empty); +// }, [=](QStringList) -> QString { +// if(!manual) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// auto get_fn = std::bind(get, manual); +// return QString::number(get_fn()); +// })); +// }; +// auto addIntegerManualSettingWithReturnValue = [=](QString cmd, bool(ManualControlDialog::*set)(int), int(ManualControlDialog::*get)(void)) { +// scpi_manual->add(new SCPICommand(cmd, [=](QStringList params) -> QString { +// double value; +// if(!manual || !SCPI::paramToDouble(params, 0, value)) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// auto set_fn = std::bind(set, manual, std::placeholders::_1); +// if(set_fn(value)) { +// return SCPI::getResultName(SCPI::Result::Empty); +// } else { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// }, [=](QStringList) -> QString { +// if(!manual) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// auto get_fn = std::bind(get, manual); +// return QString::number(get_fn()); +// })); +// }; +// auto addIntegerManualQuery = [=](QString cmd, int(ManualControlDialog::*get)(void)) { +// scpi_manual->add(new SCPICommand(cmd, nullptr, [=](QStringList) -> QString { +// if(!manual) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// auto get_fn = std::bind(get, manual); +// return QString::number(get_fn()); +// })); +// }; +// auto addDoubleManualQuery = [=](QString cmd, double(ManualControlDialog::*get)(void)) { +// scpi_manual->add(new SCPICommand(cmd, nullptr, [=](QStringList) -> QString { +// if(!manual) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// auto get_fn = std::bind(get, manual); +// return QString::number(get_fn()); +// })); +// }; +// auto addBooleanManualQuery = [=](QString cmd, bool(ManualControlDialog::*get)(void)) { +// scpi_manual->add(new SCPICommand(cmd, nullptr, [=](QStringList) -> QString { +// if(!manual) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// auto get_fn = std::bind(get, manual); +// return get_fn() ? SCPI::getResultName(SCPI::Result::True) : SCPI::getResultName(SCPI::Result::False); +// })); +// }; +// auto addComplexManualQuery = [=](QString cmd, std::complex(ManualControlDialog::*get)(void)) { +// scpi_manual->add(new SCPICommand(cmd, nullptr, [=](QStringList) -> QString { +// if(!manual) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// auto get_fn = std::bind(get, manual); +// auto res = get_fn(); +// return QString::number(res.real())+","+QString::number(res.imag()); +// })); +// }; - auto addDoubleManualSetting = [=](QString cmd, void(ManualControlDialog::*set)(double), double(ManualControlDialog::*get)(void)) { - scpi_manual->add(new SCPICommand(cmd, [=](QStringList params) -> QString { - double value; - if(!manual || !SCPI::paramToDouble(params, 0, value)) { - return SCPI::getResultName(SCPI::Result::Error); - } - auto set_fn = std::bind(set, manual, std::placeholders::_1); - set_fn(value); - return SCPI::getResultName(SCPI::Result::Empty); - }, [=](QStringList) -> QString { - if(!manual) { - return SCPI::getResultName(SCPI::Result::Error); - } - auto get_fn = std::bind(get, manual); - return QString::number(get_fn()); - })); - }; - auto addIntegerManualSetting = [=](QString cmd, void(ManualControlDialog::*set)(int), int(ManualControlDialog::*get)(void)) { - scpi_manual->add(new SCPICommand(cmd, [=](QStringList params) -> QString { - double value; - if(!manual || !SCPI::paramToDouble(params, 0, value)) { - return SCPI::getResultName(SCPI::Result::Error); - } - auto set_fn = std::bind(set, manual, std::placeholders::_1); - set_fn(value); - return SCPI::getResultName(SCPI::Result::Empty); - }, [=](QStringList) -> QString { - if(!manual) { - return SCPI::getResultName(SCPI::Result::Error); - } - auto get_fn = std::bind(get, manual); - return QString::number(get_fn()); - })); - }; - auto addIntegerManualSettingWithReturnValue = [=](QString cmd, bool(ManualControlDialog::*set)(int), int(ManualControlDialog::*get)(void)) { - scpi_manual->add(new SCPICommand(cmd, [=](QStringList params) -> QString { - double value; - if(!manual || !SCPI::paramToDouble(params, 0, value)) { - return SCPI::getResultName(SCPI::Result::Error); - } - auto set_fn = std::bind(set, manual, std::placeholders::_1); - if(set_fn(value)) { - return SCPI::getResultName(SCPI::Result::Empty); - } else { - return SCPI::getResultName(SCPI::Result::Error); - } - }, [=](QStringList) -> QString { - if(!manual) { - return SCPI::getResultName(SCPI::Result::Error); - } - auto get_fn = std::bind(get, manual); - return QString::number(get_fn()); - })); - }; - auto addIntegerManualQuery = [=](QString cmd, int(ManualControlDialog::*get)(void)) { - scpi_manual->add(new SCPICommand(cmd, nullptr, [=](QStringList) -> QString { - if(!manual) { - return SCPI::getResultName(SCPI::Result::Error); - } - auto get_fn = std::bind(get, manual); - return QString::number(get_fn()); - })); - }; - auto addDoubleManualQuery = [=](QString cmd, double(ManualControlDialog::*get)(void)) { - scpi_manual->add(new SCPICommand(cmd, nullptr, [=](QStringList) -> QString { - if(!manual) { - return SCPI::getResultName(SCPI::Result::Error); - } - auto get_fn = std::bind(get, manual); - return QString::number(get_fn()); - })); - }; - auto addBooleanManualQuery = [=](QString cmd, bool(ManualControlDialog::*get)(void)) { - scpi_manual->add(new SCPICommand(cmd, nullptr, [=](QStringList) -> QString { - if(!manual) { - return SCPI::getResultName(SCPI::Result::Error); - } - auto get_fn = std::bind(get, manual); - return get_fn() ? SCPI::getResultName(SCPI::Result::True) : SCPI::getResultName(SCPI::Result::False); - })); - }; - auto addComplexManualQuery = [=](QString cmd, std::complex(ManualControlDialog::*get)(void)) { - scpi_manual->add(new SCPICommand(cmd, nullptr, [=](QStringList) -> QString { - if(!manual) { - return SCPI::getResultName(SCPI::Result::Error); - } - auto get_fn = std::bind(get, manual); - auto res = get_fn(); - return QString::number(res.real())+","+QString::number(res.imag()); - })); - }; +// addBooleanManualSetting("HSRC_CE", &ManualControlDialog::setHighSourceChipEnable, &ManualControlDialog::getHighSourceChipEnable); +// addBooleanManualSetting("HSRC_RFEN", &ManualControlDialog::setHighSourceRFEnable, &ManualControlDialog::getHighSourceRFEnable); +// addBooleanManualQuery("HSRC_LOCKed", &ManualControlDialog::getHighSourceLocked); +// addIntegerManualSettingWithReturnValue("HSRC_PWR", &ManualControlDialog::setHighSourcePower, &ManualControlDialog::getHighSourcePower); +// addDoubleManualSetting("HSRC_FREQ", &ManualControlDialog::setHighSourceFrequency, &ManualControlDialog::getHighSourceFrequency); +// scpi_manual->add(new SCPICommand("HSRC_LPF", [=](QStringList params) -> QString { +// long value; +// if(!manual || !SCPI::paramToLong(params, 0, value)) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// switch(value) { +// case 947: +// manual->setHighSourceLPF(ManualControlDialog::LPF::M947); +// break; +// case 1880: +// manual->setHighSourceLPF(ManualControlDialog::LPF::M1880); +// break; +// case 3500: +// manual->setHighSourceLPF(ManualControlDialog::LPF::M3500); +// break; +// case 0: +// manual->setHighSourceLPF(ManualControlDialog::LPF::None); +// break; +// default: +// return SCPI::getResultName(SCPI::Result::Error); +// } +// return SCPI::getResultName(SCPI::Result::Empty); +// }, [=](QStringList) -> QString { +// if(!manual) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// auto lpf = manual->getHighSourceLPF(); +// switch(lpf) { +// case ManualControlDialog::LPF::M947: return "947"; +// case ManualControlDialog::LPF::M1880: return "1880"; +// case ManualControlDialog::LPF::M3500: return "3500"; +// case ManualControlDialog::LPF::None: return "0"; +// default: return SCPI::getResultName(SCPI::Result::Error); +// } +// })); +// addBooleanManualSetting("LSRC_EN", &ManualControlDialog::setLowSourceEnable, &ManualControlDialog::getLowSourceEnable); +// addIntegerManualSettingWithReturnValue("LSRC_PWR", &ManualControlDialog::setLowSourcePower, &ManualControlDialog::getLowSourcePower); +// addDoubleManualSetting("LSRC_FREQ", &ManualControlDialog::setLowSourceFrequency, &ManualControlDialog::getLowSourceFrequency); +// addBooleanManualSetting("BAND_SW", &ManualControlDialog::setHighband, &ManualControlDialog::getHighband); +// addDoubleManualSetting("ATTenuator", &ManualControlDialog::setAttenuator, &ManualControlDialog::getAttenuator); +// addBooleanManualSetting("AMP_EN", &ManualControlDialog::setAmplifierEnable, &ManualControlDialog::getAmplifierEnable); +// addIntegerManualSettingWithReturnValue("PORT_SW", &ManualControlDialog::setPortSwitch, &ManualControlDialog::getPortSwitch); +// addBooleanManualSetting("LO1_CE", &ManualControlDialog::setLO1ChipEnable, &ManualControlDialog::getLO1ChipEnable); +// addBooleanManualSetting("LO1_RFEN", &ManualControlDialog::setLO1RFEnable, &ManualControlDialog::getLO1RFEnable); +// addBooleanManualQuery("LO1_LOCKed", &ManualControlDialog::getLO1Locked); +// addDoubleManualSetting("LO1_FREQ", &ManualControlDialog::setLO1Frequency, &ManualControlDialog::getLO1Frequency); +// addDoubleManualSetting("IF1_FREQ", &ManualControlDialog::setIF1Frequency, &ManualControlDialog::getIF1Frequency); +// addBooleanManualSetting("LO2_EN", &ManualControlDialog::setLO2Enable, &ManualControlDialog::getLO2Enable); +// addDoubleManualSetting("LO2_FREQ", &ManualControlDialog::setLO2Frequency, &ManualControlDialog::getLO2Frequency); +// addDoubleManualSetting("IF2_FREQ", &ManualControlDialog::setIF2Frequency, &ManualControlDialog::getIF2Frequency); +// addBooleanManualSetting("PORT1_EN", &ManualControlDialog::setPort1Enable, &ManualControlDialog::getPort1Enable); +// addBooleanManualSetting("PORT2_EN", &ManualControlDialog::setPort2Enable, &ManualControlDialog::getPort2Enable); +// addBooleanManualSetting("REF_EN", &ManualControlDialog::setRefEnable, &ManualControlDialog::getRefEnable); +// addIntegerManualSetting("SAMPLES", &ManualControlDialog::setNumSamples, &ManualControlDialog::getNumSamples); +// scpi_manual->add(new SCPICommand("WINdow", [=](QStringList params) -> QString { +// if(!manual || params.size() < 1) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// if (params[0] == "NONE") { +// manual->setWindow(ManualControlDialog::Window::None); +// } else if(params[0] == "KAISER") { +// manual->setWindow(ManualControlDialog::Window::Kaiser); +// } else if(params[0] == "HANN") { +// manual->setWindow(ManualControlDialog::Window::Hann); +// } else if(params[0] == "FLATTOP") { +// manual->setWindow(ManualControlDialog::Window::FlatTop); +// } else { +// return "INVALID WINDOW"; +// } +// return SCPI::getResultName(SCPI::Result::Empty); +// }, [=](QStringList) -> QString { +// if(!manual) { +// return SCPI::getResultName(SCPI::Result::Error); +// } +// switch((ManualControlDialog::Window) manual->getWindow()) { +// case ManualControlDialog::Window::None: return "NONE"; +// case ManualControlDialog::Window::Kaiser: return "KAISER"; +// case ManualControlDialog::Window::Hann: return "HANN"; +// case ManualControlDialog::Window::FlatTop: return "FLATTOP"; +// default: return SCPI::getResultName(SCPI::Result::Error); +// } +// })); +// addIntegerManualQuery("PORT1_MIN", &ManualControlDialog::getPort1MinADC); +// addIntegerManualQuery("PORT1_MAX", &ManualControlDialog::getPort1MaxADC); +// addDoubleManualQuery("PORT1_MAG", &ManualControlDialog::getPort1Magnitude); +// addDoubleManualQuery("PORT1_PHAse", &ManualControlDialog::getPort1Phase); +// addComplexManualQuery("PORT1_REFerenced", &ManualControlDialog::getPort1Referenced); - addBooleanManualSetting("HSRC_CE", &ManualControlDialog::setHighSourceChipEnable, &ManualControlDialog::getHighSourceChipEnable); - addBooleanManualSetting("HSRC_RFEN", &ManualControlDialog::setHighSourceRFEnable, &ManualControlDialog::getHighSourceRFEnable); - addBooleanManualQuery("HSRC_LOCKed", &ManualControlDialog::getHighSourceLocked); - addIntegerManualSettingWithReturnValue("HSRC_PWR", &ManualControlDialog::setHighSourcePower, &ManualControlDialog::getHighSourcePower); - addDoubleManualSetting("HSRC_FREQ", &ManualControlDialog::setHighSourceFrequency, &ManualControlDialog::getHighSourceFrequency); - scpi_manual->add(new SCPICommand("HSRC_LPF", [=](QStringList params) -> QString { - long value; - if(!manual || !SCPI::paramToLong(params, 0, value)) { - return SCPI::getResultName(SCPI::Result::Error); - } - switch(value) { - case 947: - manual->setHighSourceLPF(ManualControlDialog::LPF::M947); - break; - case 1880: - manual->setHighSourceLPF(ManualControlDialog::LPF::M1880); - break; - case 3500: - manual->setHighSourceLPF(ManualControlDialog::LPF::M3500); - break; - case 0: - manual->setHighSourceLPF(ManualControlDialog::LPF::None); - break; - default: - return SCPI::getResultName(SCPI::Result::Error); - } - return SCPI::getResultName(SCPI::Result::Empty); - }, [=](QStringList) -> QString { - if(!manual) { - return SCPI::getResultName(SCPI::Result::Error); - } - auto lpf = manual->getHighSourceLPF(); - switch(lpf) { - case ManualControlDialog::LPF::M947: return "947"; - case ManualControlDialog::LPF::M1880: return "1880"; - case ManualControlDialog::LPF::M3500: return "3500"; - case ManualControlDialog::LPF::None: return "0"; - default: return SCPI::getResultName(SCPI::Result::Error); - } - })); - addBooleanManualSetting("LSRC_EN", &ManualControlDialog::setLowSourceEnable, &ManualControlDialog::getLowSourceEnable); - addIntegerManualSettingWithReturnValue("LSRC_PWR", &ManualControlDialog::setLowSourcePower, &ManualControlDialog::getLowSourcePower); - addDoubleManualSetting("LSRC_FREQ", &ManualControlDialog::setLowSourceFrequency, &ManualControlDialog::getLowSourceFrequency); - addBooleanManualSetting("BAND_SW", &ManualControlDialog::setHighband, &ManualControlDialog::getHighband); - addDoubleManualSetting("ATTenuator", &ManualControlDialog::setAttenuator, &ManualControlDialog::getAttenuator); - addBooleanManualSetting("AMP_EN", &ManualControlDialog::setAmplifierEnable, &ManualControlDialog::getAmplifierEnable); - addIntegerManualSettingWithReturnValue("PORT_SW", &ManualControlDialog::setPortSwitch, &ManualControlDialog::getPortSwitch); - addBooleanManualSetting("LO1_CE", &ManualControlDialog::setLO1ChipEnable, &ManualControlDialog::getLO1ChipEnable); - addBooleanManualSetting("LO1_RFEN", &ManualControlDialog::setLO1RFEnable, &ManualControlDialog::getLO1RFEnable); - addBooleanManualQuery("LO1_LOCKed", &ManualControlDialog::getLO1Locked); - addDoubleManualSetting("LO1_FREQ", &ManualControlDialog::setLO1Frequency, &ManualControlDialog::getLO1Frequency); - addDoubleManualSetting("IF1_FREQ", &ManualControlDialog::setIF1Frequency, &ManualControlDialog::getIF1Frequency); - addBooleanManualSetting("LO2_EN", &ManualControlDialog::setLO2Enable, &ManualControlDialog::getLO2Enable); - addDoubleManualSetting("LO2_FREQ", &ManualControlDialog::setLO2Frequency, &ManualControlDialog::getLO2Frequency); - addDoubleManualSetting("IF2_FREQ", &ManualControlDialog::setIF2Frequency, &ManualControlDialog::getIF2Frequency); - addBooleanManualSetting("PORT1_EN", &ManualControlDialog::setPort1Enable, &ManualControlDialog::getPort1Enable); - addBooleanManualSetting("PORT2_EN", &ManualControlDialog::setPort2Enable, &ManualControlDialog::getPort2Enable); - addBooleanManualSetting("REF_EN", &ManualControlDialog::setRefEnable, &ManualControlDialog::getRefEnable); - addIntegerManualSetting("SAMPLES", &ManualControlDialog::setNumSamples, &ManualControlDialog::getNumSamples); - scpi_manual->add(new SCPICommand("WINdow", [=](QStringList params) -> QString { - if(!manual || params.size() < 1) { - return SCPI::getResultName(SCPI::Result::Error); - } - if (params[0] == "NONE") { - manual->setWindow(ManualControlDialog::Window::None); - } else if(params[0] == "KAISER") { - manual->setWindow(ManualControlDialog::Window::Kaiser); - } else if(params[0] == "HANN") { - manual->setWindow(ManualControlDialog::Window::Hann); - } else if(params[0] == "FLATTOP") { - manual->setWindow(ManualControlDialog::Window::FlatTop); - } else { - return "INVALID WINDOW"; - } - return SCPI::getResultName(SCPI::Result::Empty); - }, [=](QStringList) -> QString { - if(!manual) { - return SCPI::getResultName(SCPI::Result::Error); - } - switch((ManualControlDialog::Window) manual->getWindow()) { - case ManualControlDialog::Window::None: return "NONE"; - case ManualControlDialog::Window::Kaiser: return "KAISER"; - case ManualControlDialog::Window::Hann: return "HANN"; - case ManualControlDialog::Window::FlatTop: return "FLATTOP"; - default: return SCPI::getResultName(SCPI::Result::Error); - } - })); - addIntegerManualQuery("PORT1_MIN", &ManualControlDialog::getPort1MinADC); - addIntegerManualQuery("PORT1_MAX", &ManualControlDialog::getPort1MaxADC); - addDoubleManualQuery("PORT1_MAG", &ManualControlDialog::getPort1Magnitude); - addDoubleManualQuery("PORT1_PHAse", &ManualControlDialog::getPort1Phase); - addComplexManualQuery("PORT1_REFerenced", &ManualControlDialog::getPort1Referenced); +// addIntegerManualQuery("PORT2_MIN", &ManualControlDialog::getPort2MinADC); +// addIntegerManualQuery("PORT2_MAX", &ManualControlDialog::getPort2MaxADC); +// addDoubleManualQuery("PORT2_MAG", &ManualControlDialog::getPort2Magnitude); +// addDoubleManualQuery("PORT2_PHAse", &ManualControlDialog::getPort2Phase); +// addComplexManualQuery("PORT2_REFerenced", &ManualControlDialog::getPort2Referenced); - addIntegerManualQuery("PORT2_MIN", &ManualControlDialog::getPort2MinADC); - addIntegerManualQuery("PORT2_MAX", &ManualControlDialog::getPort2MaxADC); - addDoubleManualQuery("PORT2_MAG", &ManualControlDialog::getPort2Magnitude); - addDoubleManualQuery("PORT2_PHAse", &ManualControlDialog::getPort2Phase); - addComplexManualQuery("PORT2_REFerenced", &ManualControlDialog::getPort2Referenced); +// addIntegerManualQuery("REF_MIN", &ManualControlDialog::getRefMinADC); +// addIntegerManualQuery("REF_MAX", &ManualControlDialog::getRefMaxADC); +// addDoubleManualQuery("REF_MAG", &ManualControlDialog::getRefMagnitude); +// addDoubleManualQuery("REF_PHAse", &ManualControlDialog::getRefPhase); - addIntegerManualQuery("REF_MIN", &ManualControlDialog::getRefMinADC); - addIntegerManualQuery("REF_MAX", &ManualControlDialog::getRefMaxADC); - addDoubleManualQuery("REF_MAG", &ManualControlDialog::getRefMagnitude); - addDoubleManualQuery("REF_PHAse", &ManualControlDialog::getRefPhase); - - scpi.add(scpi_manual); +// scpi.add(scpi_manual); } void AppWindow::StartTCPServer(int port) diff --git a/Software/PC_Application/LibreVNA-GUI/appwindow.h b/Software/PC_Application/LibreVNA-GUI/appwindow.h index de63452..64e5016 100644 --- a/Software/PC_Application/LibreVNA-GUI/appwindow.h +++ b/Software/PC_Application/LibreVNA-GUI/appwindow.h @@ -10,8 +10,8 @@ #include "preferences.h" #include "scpi.h" #include "tcpserver.h" -#include "Device/manualcontroldialog.h" #include "Device/devicedriver.h" +//#include "modehandler.h" #include #include @@ -32,6 +32,7 @@ class VNA; class Generator; class SpectrumAnalyzer; class ModeHandler; +class Mode; class AppWindow : public QMainWindow { @@ -105,6 +106,7 @@ private: } toolbars; ModeHandler *modeHandler; + Mode *lastActiveMode; // VirtualDevice *vdevice; std::vector deviceDrivers; @@ -128,8 +130,6 @@ private: QString deviceSerial; QActionGroup *deviceActionGroup; - ManualControlDialog *manual; - // Status bar widgets QLabel lConnectionStatus; QLabel lDeviceInfo; diff --git a/Software/PC_Application/LibreVNA-GUI/main.ui b/Software/PC_Application/LibreVNA-GUI/main.ui index 0660b53..1d982b6 100644 --- a/Software/PC_Application/LibreVNA-GUI/main.ui +++ b/Software/PC_Application/LibreVNA-GUI/main.ui @@ -49,12 +49,6 @@ - - - - - - diff --git a/Software/PC_Application/LibreVNA-GUI/preferences.h b/Software/PC_Application/LibreVNA-GUI/preferences.h index 68e8171..c701664 100644 --- a/Software/PC_Application/LibreVNA-GUI/preferences.h +++ b/Software/PC_Application/LibreVNA-GUI/preferences.h @@ -184,6 +184,7 @@ private: TCPoverride(false) {} static Preferences instance; + // TODO remove settings that have been moved to LibreVNADriver const std::vector descr = {{ {&Startup.ConnectToFirstDevice, "Startup.ConnectToFirstDevice", true}, {&Startup.RememberSweepSettings, "Startup.RememberSweepSettings", false}, diff --git a/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro b/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro index f131c66..d73198d 100644 --- a/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro +++ b/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro @@ -10,16 +10,12 @@ SOURCES += \ ../LibreVNA-GUI/Calibration/LibreCAL/caldevice.cpp \ ../LibreVNA-GUI/Calibration/LibreCAL/librecaldialog.cpp \ ../LibreVNA-GUI/Calibration/LibreCAL/usbdevice.cpp \ - ../LibreVNA-GUI/Calibration/amplitudecaldialog.cpp \ ../LibreVNA-GUI/Calibration/calibration.cpp \ ../LibreVNA-GUI/Calibration/calibrationmeasurement.cpp \ ../LibreVNA-GUI/Calibration/calkit.cpp \ ../LibreVNA-GUI/Calibration/calkitdialog.cpp \ ../LibreVNA-GUI/Calibration/calstandard.cpp \ - ../LibreVNA-GUI/Calibration/frequencycaldialog.cpp \ ../LibreVNA-GUI/Calibration/manualcalibrationdialog.cpp \ - ../LibreVNA-GUI/Calibration/receivercaldialog.cpp \ - ../LibreVNA-GUI/Calibration/sourcecaldialog.cpp \ ../LibreVNA-GUI/CustomWidgets/colorpickerbutton.cpp \ ../LibreVNA-GUI/CustomWidgets/csvimport.cpp \ ../LibreVNA-GUI/CustomWidgets/informationbox.cpp \ @@ -29,6 +25,14 @@ SOURCES += \ ../LibreVNA-GUI/CustomWidgets/toggleswitch.cpp \ ../LibreVNA-GUI/CustomWidgets/touchstoneimport.cpp \ ../LibreVNA-GUI/CustomWidgets/tracesetselector.cpp \ + ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.cpp \ + ../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.cpp \ + ../LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.cpp \ + ../LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp \ + ../LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.cpp \ + ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialog.cpp \ + ../LibreVNA-GUI/Device/LibreVNA/receivercaldialog.cpp \ + ../LibreVNA-GUI/Device/LibreVNA/sourcecaldialog.cpp \ ../LibreVNA-GUI/Device/compounddevice.cpp \ ../LibreVNA-GUI/Device/compounddeviceeditdialog.cpp \ ../LibreVNA-GUI/Device/device.cpp \ @@ -36,10 +40,6 @@ SOURCES += \ ../LibreVNA-GUI/Device/devicelog.cpp \ ../LibreVNA-GUI/Device/deviceusblog.cpp \ ../LibreVNA-GUI/Device/deviceusblogview.cpp \ - ../LibreVNA-GUI/Device/firmwareupdatedialog.cpp \ - ../LibreVNA-GUI/Device/librevnadriver.cpp \ - ../LibreVNA-GUI/Device/librevnausbdriver.cpp \ - ../LibreVNA-GUI/Device/manualcontroldialog.cpp \ ../LibreVNA-GUI/Device/virtualdevice.cpp \ ../LibreVNA-GUI/Generator/generator.cpp \ ../LibreVNA-GUI/Generator/signalgenwidget.cpp \ @@ -180,16 +180,12 @@ HEADERS += \ ../LibreVNA-GUI/Calibration/LibreCAL/caldevice.h \ ../LibreVNA-GUI/Calibration/LibreCAL/librecaldialog.h \ ../LibreVNA-GUI/Calibration/LibreCAL/usbdevice.h \ - ../LibreVNA-GUI/Calibration/amplitudecaldialog.h \ ../LibreVNA-GUI/Calibration/calibration.h \ ../LibreVNA-GUI/Calibration/calibrationmeasurement.h \ ../LibreVNA-GUI/Calibration/calkit.h \ ../LibreVNA-GUI/Calibration/calkitdialog.h \ ../LibreVNA-GUI/Calibration/calstandard.h \ - ../LibreVNA-GUI/Calibration/frequencycaldialog.h \ ../LibreVNA-GUI/Calibration/manualcalibrationdialog.h \ - ../LibreVNA-GUI/Calibration/receivercaldialog.h \ - ../LibreVNA-GUI/Calibration/sourcecaldialog.h \ ../LibreVNA-GUI/CustomWidgets/colorpickerbutton.h \ ../LibreVNA-GUI/CustomWidgets/csvimport.h \ ../LibreVNA-GUI/CustomWidgets/informationbox.h \ @@ -199,6 +195,14 @@ HEADERS += \ ../LibreVNA-GUI/CustomWidgets/toggleswitch.h \ ../LibreVNA-GUI/CustomWidgets/touchstoneimport.h \ ../LibreVNA-GUI/CustomWidgets/tracesetselector.h \ + ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.h \ + ../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.h \ + ../LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.h \ + ../LibreVNA-GUI/Device/LibreVNA/librevnadriver.h \ + ../LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.h \ + ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialog.h \ + ../LibreVNA-GUI/Device/LibreVNA/receivercaldialog.h \ + ../LibreVNA-GUI/Device/LibreVNA/sourcecaldialog.h \ ../LibreVNA-GUI/Device/compounddevice.h \ ../LibreVNA-GUI/Device/compounddeviceeditdialog.h \ ../LibreVNA-GUI/Device/device.h \ @@ -206,10 +210,6 @@ HEADERS += \ ../LibreVNA-GUI/Device/devicelog.h \ ../LibreVNA-GUI/Device/deviceusblog.h \ ../LibreVNA-GUI/Device/deviceusblogview.h \ - ../LibreVNA-GUI/Device/firmwareupdatedialog.h \ - ../LibreVNA-GUI/Device/librevnadriver.h \ - ../LibreVNA-GUI/Device/librevnausbdriver.h \ - ../LibreVNA-GUI/Device/manualcontroldialog.h \ ../LibreVNA-GUI/Device/virtualdevice.h \ ../LibreVNA-GUI/Generator/generator.h \ ../LibreVNA-GUI/Generator/signalgenwidget.h \ @@ -340,22 +340,22 @@ FORMS += \ ../LibreVNA-GUI/Calibration/CalStandardShortEditDialog.ui \ ../LibreVNA-GUI/Calibration/CalStandardThroughEditDialog.ui \ ../LibreVNA-GUI/Calibration/LibreCAL/librecaldialog.ui \ - ../LibreVNA-GUI/Calibration/addamplitudepointsdialog.ui \ - ../LibreVNA-GUI/Calibration/amplitudecaldialog.ui \ - ../LibreVNA-GUI/Calibration/automaticamplitudedialog.ui \ ../LibreVNA-GUI/Calibration/calibrationdialogui.ui \ ../LibreVNA-GUI/Calibration/calkitdialog.ui \ - ../LibreVNA-GUI/Calibration/frequencycaldialog.ui \ ../LibreVNA-GUI/Calibration/manualcalibrationdialog.ui \ ../LibreVNA-GUI/CustomWidgets/csvimport.ui \ ../LibreVNA-GUI/CustomWidgets/jsonpickerdialog.ui \ ../LibreVNA-GUI/CustomWidgets/tilewidget.ui \ ../LibreVNA-GUI/CustomWidgets/touchstoneimport.ui \ + ../LibreVNA-GUI/Device/LibreVNA/addamplitudepointsdialog.ui \ + ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.ui \ + ../LibreVNA-GUI/Device/LibreVNA/automaticamplitudedialog.ui \ + ../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.ui \ + ../LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.ui \ + ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialog.ui \ ../LibreVNA-GUI/Device/compounddeviceeditdialog.ui \ ../LibreVNA-GUI/Device/devicelog.ui \ ../LibreVNA-GUI/Device/deviceusblogview.ui \ - ../LibreVNA-GUI/Device/firmwareupdatedialog.ui \ - ../LibreVNA-GUI/Device/manualcontroldialog.ui \ ../LibreVNA-GUI/Generator/signalgenwidget.ui \ ../LibreVNA-GUI/Tools/impedancematchdialog.ui \ ../LibreVNA-GUI/Tools/mixedmodeconversion.ui \