LibreVNADriver specific actions

This commit is contained in:
Jan Käberich 2023-01-25 23:07:33 +01:00
parent cde564299c
commit 80c5fc0ff6
34 changed files with 551 additions and 461 deletions

View File

@ -1730,7 +1730,6 @@ void Calibration::addMeasurements(std::set<CalibrationMeasurement::Base *> m, co
meas->addPoint(data);
}
unsavedChanges = true;
// TODO
if(DeviceDriver::getActiveDriver()) {
validDevice = DeviceDriver::getActiveDriver()->getSerial();
}

View File

@ -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<points.size();i++) {
auto p = points[i];
Protocol::PacketInfo info;
@ -256,7 +262,7 @@ void AmplitudeCalDialog::RemoveAllPoints()
bool AmplitudeCalDialog::AddPoint(AmplitudeCalDialog::CorrectionPoint &p)
{
if (points.size() >= 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;

View File

@ -1,11 +1,12 @@
#ifndef AMPLITUDECALDIALOG_H
#define AMPLITUDECALDIALOG_H
#include "mode.h"
#include "modehandler.h"
#include "Device/device.h"
#include "librevnadriver.h"
#include <deque>
#include <QDialog>
#include <QAbstractTableModel>
#include <QProgressBar>
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<CorrectionPoint> 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<CorrectionPoint> points;

View File

@ -6,7 +6,7 @@
#include <QFileDialog>
#include <QStyle>
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::ConnectionType>(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);
}

View File

@ -1,7 +1,7 @@
#ifndef FIRMWAREUPDATEDIALOG_H
#define FIRMWAREUPDATEDIALOG_H
#include "device.h"
#include "librevnadriver.h"
#include <QDialog>
#include <QFile>
@ -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;

View File

@ -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;
}

View File

@ -1,9 +1,7 @@
#ifndef FREQUENCYCALDIALOG_H
#define FREQUENCYCALDIALOG_H
#include "Device/device.h"
#include "modehandler.h"
#include "mode.h"
#include "librevnadriver.h"
#include <QDialog>
@ -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

View File

@ -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<DeviceDriver::Flag> LibreVNADriver::getFlags()
@ -136,24 +192,6 @@ QString LibreVNADriver::getStatus()
return ret;
}
std::vector<Savable::SettingDescription> LibreVNADriver::driverSpecificSettings()
{
std::vector<Savable::SettingDescription> 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<QAction *> LibreVNADriver::driverSpecificActions()
{
// TODO
return std::vector<QAction*>();
}
QStringList LibreVNADriver::availableVNAMeasurements()
{
QStringList ret;
@ -229,6 +267,7 @@ bool LibreVNADriver::setSA(const DeviceDriver::SASettings &s, std::function<void
if(!supports(Feature::SA)) {
return false;
}
zerospan = s.freqStart == s.freqStop;
Protocol::PacketInfo p = {};
@ -260,6 +299,33 @@ bool LibreVNADriver::setSA(const DeviceDriver::SASettings &s, std::function<void
p.spectrumSettings.trackingGeneratorPort = s.trackingPort;
p.spectrumSettings.syncMode = 0;
p.spectrumSettings.syncMaster = 0;
if(p.spectrumSettings.trackingGenerator && p.spectrumSettings.f_stop >= 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<void(TransmissionResult)> cb)
{
Protocol::PacketInfo p;

View File

@ -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<Savable::SettingDescription> driverSpecificSettings() override;
/**
* @brief Return driver specific actions.
*
* The returned actions will be appended to the device menu.
*
* @return List of actions
*/
virtual std::vector<QAction*> 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<void(TransmissionResult)> cb = nullptr, unsigned int timeout = 500) = 0;
bool sendWithoutPayload(Protocol::PacketType type, std::function<void(TransmissionResult)> 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<void(TransmissionResult)> 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;

View File

@ -1,7 +1,7 @@
#include "librevnausbdriver.h"
#include "CustomWidgets/informationbox.h"
#include "deviceusblog.h"
#include "../deviceusblog.h"
#include <QTimer>
@ -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::ConnectionType>(Qt::QueuedConnection | Qt::UniqueConnection));
connect(this, &LibreVNAUSBDriver::receivedPacket, this, &LibreVNAUSBDriver::handleReceivedPacket, static_cast<Qt::ConnectionType>(Qt::QueuedConnection | Qt::UniqueConnection));
transmissionTimer.setSingleShot(true);
transmissionActive = false;
@ -251,8 +251,8 @@ void LibreVNAUSBDriver::disconnect()
void LibreVNAUSBDriver::registerTypes()
{
qRegisterMetaType<Protocol::PacketInfo>("LibreVNAUSBPacket");
qRegisterMetaType<TransmissionResult>("LibreVNAUSBResult");
qDebug() << "Registering meta type: " << qRegisterMetaType<Protocol::PacketInfo>();
qDebug() << "Registering meta type: " << qRegisterMetaType<TransmissionResult>();
}
void LibreVNAUSBDriver::ReceivedData()

View File

@ -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);
}

View File

@ -1,7 +1,7 @@
#ifndef MANUALCONTROLDIALOG_H
#define MANUALCONTROLDIALOG_H
#include "device.h"
#include "librevnadriver.h"
#include <QDialog>
#include <complex>
@ -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<double> port1referenced;
std::complex<double> port2referenced;
};

View File

@ -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();
}
}

View File

@ -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; }

View File

@ -2,8 +2,8 @@
#include <QDebug>
SourceCalDialog::SourceCalDialog(Device *dev, ModeHandler *handler)
: AmplitudeCalDialog(dev, handler)
SourceCalDialog::SourceCalDialog(LibreVNADriver *dev)
: AmplitudeCalDialog(dev)
{
setWindowTitle("Source Calibration Dialog");
LoadFromDevice();

View File

@ -2,7 +2,6 @@
#define SOURCECALDIALOG_H
#include "amplitudecaldialog.h"
#include "modehandler.h"
#include <QObject>
@ -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; }

View File

@ -3,7 +3,7 @@
#include "../../VNA_embedded/Application/Communication/Protocol.hpp"
#include "librevnausbdriver.h"
#include "LibreVNA/librevnausbdriver.h"
#include <functional>
#include <libusb-1.0/libusb.h>

View File

@ -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) {

View File

@ -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<Savable::SettingDescription> driverSpecificSettings() {return std::vector<Savable::SettingDescription>();}
std::vector<Savable::SettingDescription> driverSpecificSettings() {return specificSettings;}
/**
* @brief Return driver specific actions.
@ -210,7 +210,7 @@ public:
*
* @return List of actions
*/
virtual std::vector<QAction*> driverSpecificActions() {return std::vector<QAction*>();}
std::vector<QAction*> 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<QAction*> specificActions;
std::vector<Savable::SettingDescription> specificSettings;
private:
static DeviceDriver *activeDriver;
};

View File

@ -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 \

View File

@ -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

View File

@ -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"

View File

@ -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 <QDockWidget>
#include <QDesktopWidget>
@ -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;i<ui->menuDevice->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<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);
// 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<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);
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)

View File

@ -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 <QWidget>
#include <QMainWindow>
@ -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<DeviceDriver*> deviceDrivers;
@ -128,8 +130,6 @@ private:
QString deviceSerial;
QActionGroup *deviceActionGroup;
ManualControlDialog *manual;
// Status bar widgets
QLabel lConnectionStatus;
QLabel lDeviceInfo;

View File

@ -49,12 +49,6 @@
<addaction name="menuConnect_to"/>
<addaction name="actionDisconnect"/>
<addaction name="separator"/>
<addaction name="actionManual_Control"/>
<addaction name="actionFirmware_Update"/>
<addaction name="separator"/>
<addaction name="actionSource_Calibration"/>
<addaction name="actionReceiver_Calibration"/>
<addaction name="actionFrequency_Calibration"/>
<addaction name="separator"/>
<addaction name="actionUSB_log"/>
</widget>

View File

@ -184,6 +184,7 @@ private:
TCPoverride(false) {}
static Preferences instance;
// TODO remove settings that have been moved to LibreVNADriver
const std::vector<Savable::SettingDescription> descr = {{
{&Startup.ConnectToFirstDevice, "Startup.ConnectToFirstDevice", true},
{&Startup.RememberSweepSettings, "Startup.RememberSweepSettings", false},

View File

@ -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 \