mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-04 22:17:31 +00:00
Option to apply calibration and de-embedding while/after importing
This commit is contained in:
parent
f0669ab4c0
commit
7a4113cd6b
24 changed files with 1760 additions and 209 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include "deembeddingdialog.h"
|
||||
#include <QDebug>
|
||||
#include "ui_measurementdialog.h"
|
||||
#include "Traces/sparamtraceselector.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
@ -24,170 +25,49 @@ void Deembedding::measurementCompleted()
|
|||
measurementUI = nullptr;
|
||||
}
|
||||
|
||||
void Deembedding::setInitialTraceSelections()
|
||||
{
|
||||
// all checkboxes initially set to none
|
||||
measurementUI->cS11->blockSignals(true);
|
||||
measurementUI->cS12->blockSignals(true);
|
||||
measurementUI->cS21->blockSignals(true);
|
||||
measurementUI->cS22->blockSignals(true);
|
||||
measurementUI->cS11->clear();
|
||||
measurementUI->cS12->clear();
|
||||
measurementUI->cS21->clear();
|
||||
measurementUI->cS22->clear();
|
||||
measurementUI->cS11->addItem("None");
|
||||
measurementUI->cS12->addItem("None");
|
||||
measurementUI->cS21->addItem("None");
|
||||
measurementUI->cS22->addItem("None");
|
||||
// add applicable traces
|
||||
for(auto t : tm.getTraces()) {
|
||||
if(t->isReflection()) {
|
||||
measurementUI->cS11->addItem(t->name(), QVariant::fromValue<Trace*>(t));
|
||||
measurementUI->cS22->addItem(t->name(), QVariant::fromValue<Trace*>(t));
|
||||
} else {
|
||||
measurementUI->cS12->addItem(t->name(), QVariant::fromValue<Trace*>(t));
|
||||
measurementUI->cS21->addItem(t->name(), QVariant::fromValue<Trace*>(t));
|
||||
}
|
||||
}
|
||||
measurementUI->cS11->blockSignals(false);
|
||||
measurementUI->cS12->blockSignals(false);
|
||||
measurementUI->cS21->blockSignals(false);
|
||||
measurementUI->cS22->blockSignals(false);
|
||||
}
|
||||
|
||||
void Deembedding::traceSelectionChanged(QComboBox *w)
|
||||
{
|
||||
vector<QComboBox*> cbs;
|
||||
if (measurementUI->cS11->isVisible()) {
|
||||
cbs.push_back(measurementUI->cS11);
|
||||
}
|
||||
if (measurementUI->cS12->isVisible()) {
|
||||
cbs.push_back(measurementUI->cS12);
|
||||
}
|
||||
if (measurementUI->cS21->isVisible()) {
|
||||
cbs.push_back(measurementUI->cS21);
|
||||
}
|
||||
if (measurementUI->cS22->isVisible()) {
|
||||
cbs.push_back(measurementUI->cS22);
|
||||
}
|
||||
|
||||
// update available traces in combo boxes
|
||||
if(w->currentIndex() != 0 && points == 0) {
|
||||
// the first trace has been selected, extract frequency info
|
||||
Trace *t = qvariant_cast<Trace*>(w->itemData(w->currentIndex()));
|
||||
points = t->size();
|
||||
if(points > 0) {
|
||||
minFreq = t->minX();
|
||||
maxFreq = t->maxX();
|
||||
}
|
||||
// remove all trace options with incompatible frequencies
|
||||
for(auto c : cbs) {
|
||||
for(int i=1;i<c->count();i++) {
|
||||
Trace *t = qvariant_cast<Trace*>(c->itemData(i));
|
||||
if(t->size() != points || (points > 0 && (t->minX() != minFreq || t->maxX() != maxFreq))) {
|
||||
// this trace is not available anymore
|
||||
c->removeItem(i);
|
||||
// decrement to check the next index in the next loop iteration
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(w->currentIndex() == 0 && points > 0) {
|
||||
measurementUI->buttonBox->setEnabled(false);
|
||||
// Check if all trace selections are set for none
|
||||
for(auto c : cbs) {
|
||||
if(c->currentIndex() != 0) {
|
||||
// some trace is still selected, abort
|
||||
return;
|
||||
}
|
||||
}
|
||||
// all traces set for none
|
||||
points = 0;
|
||||
minFreq = 0;
|
||||
maxFreq = 0;
|
||||
setInitialTraceSelections();
|
||||
}
|
||||
bool allSelectionsValid = true;
|
||||
for(auto c : cbs) {
|
||||
if (c->currentIndex() == 0) {
|
||||
allSelectionsValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(allSelectionsValid) {
|
||||
measurementUI->buttonBox->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Deembedding::startMeasurementDialog(bool S11, bool S12, bool S21, bool S22)
|
||||
{
|
||||
measurements.clear();
|
||||
|
||||
points = 0;
|
||||
minFreq = 0.0;
|
||||
maxFreq = 0.0;
|
||||
|
||||
measurementDialog = new QDialog;
|
||||
auto ui = new Ui_DeembeddingMeasurementDialog;
|
||||
measurementUI = ui;
|
||||
ui->setupUi(measurementDialog);
|
||||
// disable not needed GUI elements
|
||||
|
||||
// add the trace selector
|
||||
set<unsigned int> skip;
|
||||
if(!S11) {
|
||||
ui->lS11->setVisible(false);
|
||||
ui->cS11->setVisible(false);
|
||||
skip.insert(0);
|
||||
}
|
||||
if(!S12) {
|
||||
ui->lS12->setVisible(false);
|
||||
ui->cS12->setVisible(false);
|
||||
skip.insert(1);
|
||||
}
|
||||
if(!S21) {
|
||||
ui->lS21->setVisible(false);
|
||||
ui->cS21->setVisible(false);
|
||||
skip.insert(2);
|
||||
}
|
||||
if(!S22) {
|
||||
ui->lS22->setVisible(false);
|
||||
ui->cS22->setVisible(false);
|
||||
skip.insert(3);
|
||||
}
|
||||
auto traceChooser = new SparamTraceSelector(tm, 2, false, skip);
|
||||
ui->horizontalLayout_2->insertWidget(0, traceChooser, 1);
|
||||
|
||||
connect(traceChooser, &SparamTraceSelector::selectionValid, ui->buttonBox, &QDialogButtonBox::setEnabled);
|
||||
|
||||
connect(ui->bMeasure, &QPushButton::clicked, [=](){
|
||||
ui->bMeasure->setEnabled(false);
|
||||
ui->cS11->setEnabled(false);
|
||||
ui->cS12->setEnabled(false);
|
||||
ui->cS21->setEnabled(false);
|
||||
ui->cS22->setEnabled(false);
|
||||
traceChooser->setEnabled(false);
|
||||
ui->buttonBox->setEnabled(false);
|
||||
measuring = true;
|
||||
});
|
||||
|
||||
connect(ui->cS11, qOverload<int>(&QComboBox::currentIndexChanged), [=](int){
|
||||
traceSelectionChanged(ui->cS11);
|
||||
});
|
||||
connect(ui->cS12, qOverload<int>(&QComboBox::currentIndexChanged), [=](int){
|
||||
traceSelectionChanged(ui->cS12);
|
||||
});
|
||||
connect(ui->cS21, qOverload<int>(&QComboBox::currentIndexChanged), [=](int){
|
||||
traceSelectionChanged(ui->cS21);
|
||||
});
|
||||
connect(ui->cS22, qOverload<int>(&QComboBox::currentIndexChanged), [=](int){
|
||||
traceSelectionChanged(ui->cS22);
|
||||
});
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, [=](){
|
||||
// create datapoints from individual traces
|
||||
measurements.clear();
|
||||
Trace *S11 = nullptr, *S12 = nullptr, *S21 = nullptr, *S22 = nullptr;
|
||||
if (ui->cS11->currentIndex() != 0) {
|
||||
S11 = qvariant_cast<Trace*>(ui->cS11->itemData(ui->cS11->currentIndex()));
|
||||
}
|
||||
if (ui->cS12->currentIndex() != 0) {
|
||||
S12 = qvariant_cast<Trace*>(ui->cS12->itemData(ui->cS12->currentIndex()));
|
||||
}
|
||||
if (ui->cS21->currentIndex() != 0) {
|
||||
S21 = qvariant_cast<Trace*>(ui->cS21->itemData(ui->cS21->currentIndex()));
|
||||
}
|
||||
if (ui->cS22->currentIndex() != 0) {
|
||||
S22 = qvariant_cast<Trace*>(ui->cS22->itemData(ui->cS22->currentIndex()));
|
||||
}
|
||||
for(unsigned int i=0;i<points;i++) {
|
||||
auto t = traceChooser->getTraces();
|
||||
auto S11 = t[0];
|
||||
auto S12 = t[1];
|
||||
auto S21 = t[2];
|
||||
auto S22 = t[3];
|
||||
for(unsigned int i=0;i<traceChooser->getPoints();i++) {
|
||||
Protocol::Datapoint p;
|
||||
p.pointNum = i;
|
||||
if(S11) {
|
||||
|
|
@ -219,15 +99,12 @@ void Deembedding::startMeasurementDialog(bool S11, bool S12, bool S21, bool S22)
|
|||
measurementCompleted();
|
||||
});
|
||||
|
||||
setInitialTraceSelections();
|
||||
|
||||
measurementDialog->show();
|
||||
}
|
||||
|
||||
Deembedding::Deembedding(TraceModel &tm)
|
||||
: tm(tm),
|
||||
measuring(false),
|
||||
points(0)
|
||||
measuring(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -268,12 +145,27 @@ void Deembedding::Deembed(Protocol::Datapoint &d)
|
|||
}
|
||||
}
|
||||
|
||||
void Deembedding::Deembed(Trace &S11, Trace &S12, Trace &S21, Trace &S22)
|
||||
{
|
||||
auto points = Trace::assembleDatapoints(S11, S12, S21, S22);
|
||||
if(points.size()) {
|
||||
// succeeded in assembling datapoints
|
||||
for(auto &p : points) {
|
||||
Deembed(p);
|
||||
}
|
||||
Trace::fillFromDatapoints(S11, S12, S21, S22, points);
|
||||
}
|
||||
}
|
||||
|
||||
void Deembedding::removeOption(unsigned int index)
|
||||
{
|
||||
if(index < options.size()) {
|
||||
delete options[index];
|
||||
options.erase(options.begin() + index);
|
||||
}
|
||||
if(options.size() == 0) {
|
||||
emit allOptionsCleared();
|
||||
}
|
||||
}
|
||||
|
||||
void Deembedding::addOption(DeembeddingOption *option)
|
||||
|
|
@ -290,6 +182,7 @@ void Deembedding::addOption(DeembeddingOption *option)
|
|||
measuringOption = option;
|
||||
startMeasurementDialog(S11, S12, S21, S22);
|
||||
});
|
||||
emit optionAdded();
|
||||
}
|
||||
|
||||
void Deembedding::swapOptions(unsigned int index)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ public:
|
|||
~Deembedding(){};
|
||||
|
||||
void Deembed(Protocol::Datapoint &d);
|
||||
void Deembed(Trace &S11, Trace &S12, Trace &S21, Trace &S22);
|
||||
|
||||
void removeOption(unsigned int index);
|
||||
void addOption(DeembeddingOption* option);
|
||||
|
|
@ -30,10 +31,10 @@ public slots:
|
|||
void configure();
|
||||
signals:
|
||||
void triggerMeasurement(bool S11 = true, bool S12 = true, bool S21 = true, bool S22 = true);
|
||||
void optionAdded();
|
||||
void allOptionsCleared();
|
||||
private:
|
||||
void measurementCompleted();
|
||||
void setInitialTraceSelections();
|
||||
void traceSelectionChanged(QComboBox *w);
|
||||
void startMeasurementDialog(bool S11, bool S12, bool S21, bool S22);
|
||||
std::vector<DeembeddingOption*> options;
|
||||
DeembeddingOption *measuringOption;
|
||||
|
|
@ -43,9 +44,6 @@ private:
|
|||
std::vector<Protocol::Datapoint> measurements;
|
||||
QDialog *measurementDialog;
|
||||
Ui_DeembeddingMeasurementDialog *measurementUI;
|
||||
// parameters of the selected traces for the measurement
|
||||
double minFreq, maxFreq;
|
||||
unsigned long points;
|
||||
|
||||
unsigned long sweepPoints;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
#include "manualdeembeddingdialog.h"
|
||||
#include "ui_manualdeembeddingdialog.h"
|
||||
#include "Traces/sparamtraceselector.h"
|
||||
|
||||
ManualDeembeddingDialog::ManualDeembeddingDialog(const TraceModel &model, Deembedding *deemb) :
|
||||
ui(new Ui::ManualDeembeddingDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
auto traceSelector = new SparamTraceSelector(model, 2);
|
||||
ui->verticalLayout->insertWidget(1, traceSelector, 1.0);
|
||||
ui->buttonBox->setEnabled(false);
|
||||
connect(traceSelector, &SparamTraceSelector::selectionValid, ui->buttonBox, &QDialogButtonBox::setEnabled);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, [=]() {
|
||||
auto t = traceSelector->getTraces();
|
||||
deemb->Deembed(*t[0], *t[1], *t[2], *t[3]);
|
||||
accept();
|
||||
});
|
||||
}
|
||||
|
||||
ManualDeembeddingDialog::~ManualDeembeddingDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef MANUALDEEMBEDDINGDIALOG_H
|
||||
#define MANUALDEEMBEDDINGDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "Traces/tracemodel.h"
|
||||
#include "deembedding.h"
|
||||
|
||||
namespace Ui {
|
||||
class ManualDeembeddingDialog;
|
||||
}
|
||||
|
||||
class ManualDeembeddingDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ManualDeembeddingDialog(const TraceModel &model, Deembedding *deemb);
|
||||
~ManualDeembeddingDialog();
|
||||
|
||||
private:
|
||||
Ui::ManualDeembeddingDialog *ui;
|
||||
};
|
||||
|
||||
#endif // MANUALDEEMBEDDINGDIALOG_H
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ManualDeembeddingDialog</class>
|
||||
<widget class="QDialog" name="ManualDeembeddingDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>508</width>
|
||||
<height>168</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Select the traces which contain the S parameters you want to de-embed:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ManualDeembeddingDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ManualDeembeddingDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
|
@ -60,51 +60,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,0">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lS11">
|
||||
<property name="text">
|
||||
<string>S11:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cS11"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lS12">
|
||||
<property name="text">
|
||||
<string>S12:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cS12"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lS21">
|
||||
<property name="text">
|
||||
<string>S21:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="cS21"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lS22">
|
||||
<property name="text">
|
||||
<string>S22:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="cS22"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0">
|
||||
<item>
|
||||
|
|
|
|||
91
Software/PC_Application/VNA/s2pImportOptions.ui
Normal file
91
Software/PC_Application/VNA/s2pImportOptions.ui
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>s2pImportOptions</class>
|
||||
<widget class="QDialog" name="s2pImportOptions">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>285</width>
|
||||
<height>178</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Import Options</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>You imported a two-port touchstone file, do you want to apply the currently active calibration or de-embed the data?</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="applyCal">
|
||||
<property name="text">
|
||||
<string>Apply Calibration</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="deembed">
|
||||
<property name="text">
|
||||
<string>De-embed imported traces</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>s2pImportOptions</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>s2pImportOptions</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
|
@ -5,11 +5,14 @@
|
|||
#include "Traces/tracetouchstoneexport.h"
|
||||
#include "Traces/tracecsvexport.h"
|
||||
#include "ui_tracewidget.h"
|
||||
#include "ui_s2pImportOptions.h"
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
TraceWidgetVNA::TraceWidgetVNA(TraceModel &model, QWidget *parent)
|
||||
: TraceWidget(model, parent)
|
||||
TraceWidgetVNA::TraceWidgetVNA(TraceModel &model, Calibration &cal, Deembedding &deembed, QWidget *parent)
|
||||
: TraceWidget(model, parent),
|
||||
cal(cal),
|
||||
deembed(deembed)
|
||||
{
|
||||
auto exportMenu = new QMenu();
|
||||
auto exportTouchstone = new QAction("Touchstone");
|
||||
|
|
@ -68,9 +71,34 @@ void TraceWidgetVNA::importDialog()
|
|||
i->show();
|
||||
if(filename.endsWith(".s2p")) {
|
||||
// potential candidate to process via calibration/de-embedding
|
||||
connect(i, &TraceImportDialog::importFinsished, [](const std::vector<Trace*> &traces) {
|
||||
connect(i, &TraceImportDialog::importFinsished, [=](const std::vector<Trace*> &traces) {
|
||||
if(traces.size() == 4) {
|
||||
// all traces imported, can calculate calibration/de-embedding
|
||||
bool calAvailable = cal.nPoints() > 0;
|
||||
bool deembedAvailable = deembed.getOptions().size() > 0;
|
||||
if(calAvailable || deembedAvailable) {
|
||||
// check if user wants to apply either one to the imported traces
|
||||
auto dialog = new QDialog();
|
||||
auto ui = new Ui::s2pImportOptions;
|
||||
ui->setupUi(dialog);
|
||||
ui->applyCal->setEnabled(calAvailable);
|
||||
ui->deembed->setEnabled(deembedAvailable);
|
||||
bool applyCal = false;
|
||||
bool applyDeembed = false;
|
||||
connect(ui->applyCal, &QCheckBox::toggled, [&](bool checked) {
|
||||
applyCal = checked;
|
||||
});
|
||||
connect(ui->deembed, &QCheckBox::toggled, [&](bool checked) {
|
||||
applyDeembed = checked;
|
||||
});
|
||||
dialog->exec();
|
||||
if(applyCal) {
|
||||
cal.correctTraces(*traces[0], *traces[1], *traces[2], *traces[3]);
|
||||
}
|
||||
if(applyDeembed) {
|
||||
deembed.Deembed(*traces[0], *traces[1], *traces[2], *traces[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,17 +2,22 @@
|
|||
#define TRACEWIDGETVNA_H
|
||||
|
||||
#include "Traces/tracewidget.h"
|
||||
#include "Calibration/calibration.h"
|
||||
#include "Deembedding/deembedding.h"
|
||||
|
||||
class TraceWidgetVNA : public TraceWidget
|
||||
{
|
||||
public:
|
||||
TraceWidgetVNA(TraceModel &model, QWidget *parent = nullptr);
|
||||
TraceWidgetVNA(TraceModel &model, Calibration &cal, Deembedding &deembed, QWidget *parent = nullptr);
|
||||
protected slots:
|
||||
virtual void exportDialog() override {};
|
||||
virtual void importDialog() override;
|
||||
|
||||
protected:
|
||||
virtual Trace::LiveParameter defaultParameter() override {return Trace::LiveParameter::S11;};
|
||||
// These can optionally be applied when importing an s2p file
|
||||
Calibration &cal;
|
||||
Deembedding &deembed;
|
||||
};
|
||||
|
||||
#endif // TRACEWIDGETVNA_H
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@
|
|||
#include <QErrorMessage>
|
||||
#include "CustomWidgets/informationbox.h"
|
||||
#include <QDebug>
|
||||
#include "Deembedding/manualdeembeddingdialog.h"
|
||||
#include "Calibration/manualcalibrationdialog.h"
|
||||
|
||||
VNA::VNA(AppWindow *window)
|
||||
: Mode(window, "Vector Network Analyzer"),
|
||||
|
|
@ -148,16 +150,51 @@ VNA::VNA(AppWindow *window)
|
|||
import->show();
|
||||
});
|
||||
|
||||
calMenu->addSeparator();
|
||||
auto calApplyToTraces = calMenu->addAction("Apply to traces...");
|
||||
calApplyToTraces->setEnabled(false);
|
||||
connect(calApplyToTraces, &QAction::triggered, [=]() {
|
||||
auto manualCalibration = new ManualCalibrationDialog(traceModel, &cal);
|
||||
manualCalibration->show();
|
||||
});
|
||||
|
||||
// portExtension.setCalkit(&cal.getCalibrationKit());
|
||||
|
||||
// De-embedding menu
|
||||
auto menuDeembed = new QMenu("De-embedding", window);
|
||||
window->menuBar()->insertMenu(window->getUi()->menuWindow->menuAction(), menuDeembed);
|
||||
auto confDeembed = menuDeembed->addAction("Setup...");
|
||||
connect(confDeembed, &QAction::triggered, &deembedding, &Deembedding::configure);
|
||||
|
||||
enableDeembeddingAction = menuDeembed->addAction("De-embed VNA samples");
|
||||
enableDeembeddingAction->setCheckable(true);
|
||||
enableDeembeddingAction->setEnabled(false);
|
||||
connect(enableDeembeddingAction, &QAction::toggled, this, &VNA::EnableDeembedding);
|
||||
|
||||
auto manualDeembed = menuDeembed->addAction("De-embed traces...");
|
||||
manualDeembed->setEnabled(false);
|
||||
connect(manualDeembed, &QAction::triggered, [=]() {
|
||||
auto manualDeembedding = new ManualDeembeddingDialog(traceModel, &deembedding);
|
||||
manualDeembedding->show();
|
||||
});
|
||||
|
||||
connect(&deembedding, &Deembedding::optionAdded, [=](){
|
||||
EnableDeembedding(true);
|
||||
enableDeembeddingAction->setEnabled(true);
|
||||
manualDeembed->setEnabled(true);
|
||||
});
|
||||
connect(&deembedding, &Deembedding::allOptionsCleared, [=](){
|
||||
EnableDeembedding(false);
|
||||
enableDeembeddingAction->setEnabled(false);
|
||||
manualDeembed->setEnabled(false);
|
||||
});
|
||||
|
||||
// Tools menu
|
||||
auto toolsMenu = new QMenu("Tools", window);
|
||||
window->menuBar()->insertMenu(window->getUi()->menuWindow->menuAction(), toolsMenu);
|
||||
actions.insert(toolsMenu->menuAction());
|
||||
auto impedanceMatching = toolsMenu->addAction("Impedance Matching");
|
||||
connect(impedanceMatching, &QAction::triggered, this, &VNA::StartImpedanceMatching);
|
||||
auto confDeembed = toolsMenu->addAction("De-embedding");
|
||||
connect(confDeembed, &QAction::triggered, &deembedding, &Deembedding::configure);
|
||||
|
||||
defaultCalMenu = new QMenu("Default Calibration", window);
|
||||
assignDefaultCal = defaultCalMenu->addAction("Assign...");
|
||||
|
|
@ -342,6 +379,7 @@ VNA::VNA(AppWindow *window)
|
|||
cbEnableCal->blockSignals(false);
|
||||
calImportTerms->setEnabled(false);
|
||||
calImportMeas->setEnabled(false);
|
||||
calApplyToTraces->setEnabled(false);
|
||||
saveCal->setEnabled(false);
|
||||
});
|
||||
connect(calDisable, &QAction::triggered, this, &VNA::DisableCalibration);
|
||||
|
|
@ -362,6 +400,7 @@ VNA::VNA(AppWindow *window)
|
|||
cbEnableCal->blockSignals(false);
|
||||
calImportTerms->setEnabled(true);
|
||||
calImportMeas->setEnabled(true);
|
||||
calApplyToTraces->setEnabled(true);
|
||||
saveCal->setEnabled(true);
|
||||
});
|
||||
|
||||
|
|
@ -378,7 +417,7 @@ VNA::VNA(AppWindow *window)
|
|||
markerModel = new TraceMarkerModel(traceModel, this);
|
||||
|
||||
auto tracesDock = new QDockWidget("Traces");
|
||||
tracesDock->setWidget(new TraceWidgetVNA(traceModel));
|
||||
tracesDock->setWidget(new TraceWidgetVNA(traceModel, cal, deembedding));
|
||||
window->addDockWidget(Qt::LeftDockWidgetArea, tracesDock);
|
||||
docks.insert(tracesDock);
|
||||
|
||||
|
|
@ -532,6 +571,7 @@ nlohmann::json VNA::toJSON()
|
|||
j["tiles"] = central->toJSON();
|
||||
j["markers"] = markerModel->toJSON();
|
||||
j["de-embedding"] = deembedding.toJSON();
|
||||
j["de-embedding_enabled"] = deembedding_active;
|
||||
return j;
|
||||
}
|
||||
|
||||
|
|
@ -548,6 +588,9 @@ void VNA::fromJSON(nlohmann::json j)
|
|||
}
|
||||
if(j.contains("de-embedding")) {
|
||||
deembedding.fromJSON(j["de-embedding"]);
|
||||
EnableDeembedding(j.value("de-embedding_enabled", true));
|
||||
} else {
|
||||
EnableDeembedding(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -576,7 +619,9 @@ void VNA::NewDatapoint(Protocol::Datapoint d)
|
|||
cal.correctMeasurement(d);
|
||||
}
|
||||
|
||||
deembedding.Deembed(d);
|
||||
if(deembedding_active) {
|
||||
deembedding.Deembed(d);
|
||||
}
|
||||
|
||||
traceModel.addVNAData(d, settings);
|
||||
emit dataChanged();
|
||||
|
|
@ -766,6 +811,7 @@ void VNA::DisableCalibration(bool force)
|
|||
{
|
||||
if(calValid || force) {
|
||||
calValid = false;
|
||||
cal.resetErrorTerms();
|
||||
emit CalibrationDisabled();
|
||||
}
|
||||
}
|
||||
|
|
@ -902,3 +948,11 @@ void VNA::UpdateCalWidget()
|
|||
calLabel->setStyleSheet(getCalStyle());
|
||||
calLabel->setToolTip(getCalToolTip());
|
||||
}
|
||||
|
||||
void VNA::EnableDeembedding(bool enable)
|
||||
{
|
||||
deembedding_active = enable;
|
||||
enableDeembeddingAction->blockSignals(true);
|
||||
enableDeembeddingAction->setChecked(enable);
|
||||
enableDeembeddingAction->blockSignals(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,9 @@ private:
|
|||
void StopSweep();
|
||||
void StartCalibrationDialog(Calibration::Type type = Calibration::Type::None);
|
||||
void UpdateCalWidget();
|
||||
|
||||
private slots:
|
||||
void EnableDeembedding(bool enable);
|
||||
private:
|
||||
Protocol::SweepSettings settings;
|
||||
unsigned int averages;
|
||||
TraceModel traceModel;
|
||||
|
|
@ -82,6 +84,8 @@ private:
|
|||
QAction *saveCal;
|
||||
|
||||
Deembedding deembedding;
|
||||
QAction *enableDeembeddingAction;
|
||||
bool deembedding_active;
|
||||
|
||||
// Status Labels
|
||||
QLabel *lAverages;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue