Merge branch 'mf_calkit'

This commit is contained in:
Jan Käberich 2021-12-01 23:21:24 +01:00
commit 0908cd7fbd
9 changed files with 1762 additions and 762 deletions

View File

@ -26,6 +26,7 @@ Calibration::Calibration()
measurements[Measurement::Line].datapoints = vector<Protocol::Datapoint>();
type = Type::None;
port1Standard = port2Standard = PortStandard::Male;
}
Calibration::Standard Calibration::getPort1Standard(Calibration::Measurement m)
@ -122,18 +123,24 @@ bool Calibration::constructErrorTerms(Calibration::Type type)
}
qDebug() << "Constructing error terms for" << TypeToString(type) << "calibration";
bool isTRL = type == Type::TRL;
double kit_minFreq = kit.minFreq(isTRL);
double kit_maxFreq = kit.maxFreq(isTRL);
if(minFreq < kit_minFreq || maxFreq > kit_maxFreq) {
bool uses_male = true;
bool uses_female = true;
if(!kit.checkIfValid(minFreq, maxFreq, isTRL, uses_male, uses_female)) {
// TODO adjust for male/female standards
// Calkit does not support complete calibration range
QString msg = QString("The calibration kit does not support the complete span.\n\n")
+ "The measured calibration data covers " + Unit::ToString(minFreq, "Hz", " kMG", 4) + " to " + Unit::ToString(maxFreq, "Hz", " kMG", 4)
+ ", however the calibration kit is only valid from " + Unit::ToString(kit_minFreq, "Hz", " kMG", 4) + " to " + Unit::ToString(kit_maxFreq, "Hz", " kMG", 4) + ".\n\n"
+ ", however the calibration kit does not support the whole frequency range.\n\n"
+ "Please adjust the calibration kit or the span and take the calibration measurements again.";
InformationBox::ShowError("Unable to perform calibration", msg);
qWarning() << msg;
return false;
}
// check calkit standards and adjust if necessary
if(!kit.hasSeparateMaleFemaleStandards()) {
port1Standard = PortStandard::Male;
port2Standard = PortStandard::Male;
}
switch(type) {
case Type::Port1SOL: constructPort1SOL(); break;
case Type::Port2SOL: constructPort2SOL(); break;
@ -181,7 +188,7 @@ void Calibration::construct12TermPoints()
auto S22_through = complex<double>(measurements[Measurement::Through].datapoints[i].real_S22, measurements[Measurement::Through].datapoints[i].imag_S22);
auto S12_through = complex<double>(measurements[Measurement::Through].datapoints[i].real_S12, measurements[Measurement::Through].datapoints[i].imag_S12);
auto actual = kit.toSOLT(p.frequency);
auto actual = kit.toSOLT(p.frequency, port1Standard == PortStandard::Male);
// Forward calibration
computeSOL(S11_short, S11_open, S11_load, p.fe00, p.fe11, p.fe10e01, actual.Open, actual.Short, actual.Load);
p.fe30 = S21_isolation;
@ -192,6 +199,7 @@ void Calibration::construct12TermPoints()
/ ((S11_through - p.fe00)*(actual.ThroughS22-p.fe11*deltaS)-deltaS*p.fe10e01);
p.fe10e32 = (S21_through - p.fe30)*(1.0 - p.fe11*actual.ThroughS11 - p.fe22*actual.ThroughS22 + p.fe11*p.fe22*deltaS) / actual.ThroughS21;
// Reverse calibration
actual = kit.toSOLT(p.frequency, port2Standard == PortStandard::Male);
computeSOL(S22_short, S22_open, S22_load, p.re33, p.re22, p.re23e32, actual.Open, actual.Short, actual.Load);
p.re03 = S12_isolation;
p.re11 = ((S22_through - p.re33)*(1.0 - p.re22 * actual.ThroughS22)-actual.ThroughS22*p.re23e32)
@ -212,7 +220,7 @@ void Calibration::constructPort1SOL()
auto S11_short = complex<double>(measurements[Measurement::Port1Short].datapoints[i].real_S11, measurements[Measurement::Port1Short].datapoints[i].imag_S11);
auto S11_load = complex<double>(measurements[Measurement::Port1Load].datapoints[i].real_S11, measurements[Measurement::Port1Load].datapoints[i].imag_S11);
// OSL port1
auto actual = kit.toSOLT(p.frequency);
auto actual = kit.toSOLT(p.frequency, port1Standard == PortStandard::Male);
// See page 13 of https://www.rfmentor.com/sites/default/files/NA_Error_Models_and_Cal_Methods.pdf
computeSOL(S11_short, S11_open, S11_load, p.fe00, p.fe11, p.fe10e01, actual.Open, actual.Short, actual.Load);
// All other calibration coefficients to ideal values
@ -240,7 +248,7 @@ void Calibration::constructPort2SOL()
auto S22_short = complex<double>(measurements[Measurement::Port2Short].datapoints[i].real_S22, measurements[Measurement::Port2Short].datapoints[i].imag_S22);
auto S22_load = complex<double>(measurements[Measurement::Port2Load].datapoints[i].real_S22, measurements[Measurement::Port2Load].datapoints[i].imag_S22);
// OSL port2
auto actual = kit.toSOLT(p.frequency);
auto actual = kit.toSOLT(p.frequency, port1Standard == PortStandard::Male);
// See page 19 of https://www.rfmentor.com/sites/default/files/NA_Error_Models_and_Cal_Methods.pdf
computeSOL(S22_short, S22_open, S22_load, p.re33, p.re22, p.re23e32, actual.Open, actual.Short, actual.Load);
// All other calibration coefficients to ideal values
@ -774,11 +782,23 @@ bool Calibration::openFromFile(QString filename)
}
try {
file >> *this;
nlohmann::json j;
file >> j;
fromJSON(j);
} catch(exception e) {
InformationBox::ShowError("File parsing error", e.what());
qWarning() << "Calibration file parsing failed: " << e.what();
return false;
// json parsing failed, probably using a legacy file format
try {
file.clear();
file.seekg(0);
file >> *this;
InformationBox::ShowMessage("Loading calibration file", "The file \"" + filename + "\" is stored in a deprecated"
" calibration format. Future versions of this application might not support"
" it anymore. Please save the calibration to update to the new format");
} catch(exception e) {
InformationBox::ShowError("File parsing error", e.what());
qWarning() << "Calibration file parsing failed: " << e.what();
return false;
}
}
this->currentCalFile = filename; // if all ok, remember this
@ -802,7 +822,7 @@ bool Calibration::saveToFile(QString filename)
auto calibration_file = filename + ".cal";
ofstream file;
file.open(calibration_file.toStdString());
file << *this;
file << setw(1) << toJSON();
auto calkit_file = filename + ".calkit";
qDebug() << "Saving associated calibration kit to file" << calkit_file;
@ -848,6 +868,95 @@ double Calibration::getMaxFreq(){
int Calibration::getNumPoints(){
return this->points.size();
}
nlohmann::json Calibration::toJSON()
{
nlohmann::json j;
nlohmann::json j_measurements;
for(auto m : measurements) {
if(m.second.datapoints.size() > 0) {
nlohmann::json j_measurement;
j_measurement["name"] = MeasurementToString(m.first).toStdString();
j_measurement["timestamp"] = m.second.timestamp.toSecsSinceEpoch();
nlohmann::json j_points;
for(auto p : m.second.datapoints) {
nlohmann::json j_point;
j_point["frequency"] = p.frequency;
j_point["S11_real"] = p.real_S11;
j_point["S11_imag"] = p.imag_S11;
j_point["S12_real"] = p.real_S12;
j_point["S12_imag"] = p.imag_S12;
j_point["S21_real"] = p.real_S21;
j_point["S21_imag"] = p.imag_S21;
j_point["S22_real"] = p.real_S22;
j_point["S22_imag"] = p.imag_S22;
j_points.push_back(j_point);
}
j_measurement["points"] = j_points;
j_measurements.push_back(j_measurement);
}
}
j["measurements"] = j_measurements;
j["type"] = TypeToString(getType()).toStdString();
j["port1StandardMale"] = port1Standard == PortStandard::Male;
j["port2StandardMale"] = port2Standard == PortStandard::Male;
return j;
}
void Calibration::fromJSON(nlohmann::json j)
{
clearMeasurements();
resetErrorTerms();
port1Standard = j.value("port1StandardMale", true) ? PortStandard::Male : PortStandard::Female;
port2Standard = j.value("port2StandardMale", true) ? PortStandard::Male : PortStandard::Female;
if(j.contains("measurements")) {
// grab measurements
for(auto j_m : j["measurements"]) {
if(!j_m.contains("name")) {
throw runtime_error("Measurement without name given");
}
auto m = MeasurementFromString(QString::fromStdString(j_m["name"]));
if(m == Measurement::Last) {
throw runtime_error("Measurement name unknown: "+std::string(j_m["name"]));
}
// get timestamp
measurements[m].timestamp = QDateTime::fromSecsSinceEpoch(j_m.value("timestamp", 0));
// extract points
if(!j_m.contains("points")) {
throw runtime_error("Measurement "+MeasurementToString(m).toStdString()+" does not contain any points");
}
int pointNum = 0;
for(auto j_p : j_m["points"]) {
Protocol::Datapoint p;
p.pointNum = pointNum++;
p.frequency = j_p.value("frequency", 0.0);
p.real_S11 = j_p.value("S11_real", 0.0);
p.imag_S11 = j_p.value("S11_imag", 0.0);
p.real_S12 = j_p.value("S12_real", 0.0);
p.imag_S12 = j_p.value("S12_imag", 0.0);
p.real_S21 = j_p.value("S21_real", 0.0);
p.imag_S21 = j_p.value("S21_imag", 0.0);
p.real_S22 = j_p.value("S22_real", 0.0);
p.imag_S22 = j_p.value("S22_imag", 0.0);
measurements[m].datapoints.push_back(p);
}
}
}
// got all measurements, construct calibration according to type
if(j.contains("type")) {
auto t = TypeFromString(QString::fromStdString(j["type"]));
if(t == Type::Last) {
throw runtime_error("Calibration type unknown: "+std::string(j["type"]));
}
if(calculationPossible(t)) {
constructErrorTerms(t);
} else {
throw runtime_error("Incomplete calibration data, the requested calibration could not be performed.");
}
}
}
QString Calibration::getCurrentCalibrationFile(){
return this->currentCalFile;
}
@ -911,6 +1020,9 @@ istream& operator >>(istream &in, Calibration &c)
}
}
}
// old file format did not contain port standard gender, set default
c.port1Standard = Calibration::PortStandard::Male;
c.port2Standard = Calibration::PortStandard::Male;
qDebug() << "Calibration file parsing complete";
return in;
}
@ -1017,6 +1129,26 @@ void Calibration::setCalibrationKit(const Calkit &value)
kit = value;
}
void Calibration::setPortStandard(int port, Calibration::PortStandard standard)
{
if(port == 1) {
port1Standard = standard;
} else if(port == 2) {
port2Standard = standard;
}
}
Calibration::PortStandard Calibration::getPortStandard(int port)
{
if(port == 1) {
return port1Standard;
} else if(port == 2) {
return port2Standard;
} else {
return PortStandard::Male;
}
}
Calibration::Type Calibration::getType() const
{
return type;

View File

@ -11,8 +11,9 @@
#include <iostream>
#include <iomanip>
#include <QDateTime>
#include <savable.h>
class Calibration
class Calibration : public Savable
{
public:
Calibration();
@ -108,6 +109,21 @@ public:
Calkit& getCalibrationKit();
void setCalibrationKit(const Calkit &value);
enum class PortStandard {
Male,
Female,
};
void setPortStandard(int port, PortStandard standard);
PortStandard getPortStandard(int port);
QString getCurrentCalibrationFile();
double getMinFreq();
double getMaxFreq();
int getNumPoints();
nlohmann::json toJSON() override;
void fromJSON(nlohmann::json j) override;
private:
void construct12TermPoints();
void constructPort1SOL();
@ -157,14 +173,9 @@ private:
Calkit kit;
QString descriptiveCalName();
private:
QString currentCalFile;
public:
QString getCurrentCalibrationFile();
double getMinFreq();
double getMaxFreq();
int getNumPoints();
PortStandard port1Standard, port2Standard;
};
#endif // CALIBRATION_H

View File

@ -26,11 +26,51 @@ CalibrationTraceDialog::CalibrationTraceDialog(Calibration *cal, double f_min, d
ui->tableView->setColumnWidth(3, 160);
UpdateCalibrationStatus();
connect(ui->port1Group, qOverload<int>(&QButtonGroup::buttonClicked), [=](){
if(ui->port1Male->isChecked()) {
cal->setPortStandard(1, Calibration::PortStandard::Male);
} else {
cal->setPortStandard(1, Calibration::PortStandard::Female);
}
UpdateCalibrationStatus();
});
connect(ui->port2Group, qOverload<int>(&QButtonGroup::buttonClicked), [=](){
if(ui->port2Male->isChecked()) {
cal->setPortStandard(2, Calibration::PortStandard::Male);
} else {
cal->setPortStandard(2, Calibration::PortStandard::Female);
}
UpdateCalibrationStatus();
});
// hide selector if calkit does not have separate male/female standards
if(!cal->getCalibrationKit().hasSeparateMaleFemaleStandards()) {
ui->port1Standards->hide();
ui->port2Standards->hide();
// default selection is male
ui->port1Male->click();
ui->port2Male->click();
} else {
// separate standards defined
if(cal->getPortStandard(1) == Calibration::PortStandard::Male) {
ui->port1Male->setChecked(true);
} else {
ui->port1Female->setChecked(true);
}
if(cal->getPortStandard(2) == Calibration::PortStandard::Male) {
ui->port2Male->setChecked(true);
} else {
ui->port2Female->setChecked(true);
}
}
// Check calibration kit span
if(type != Calibration::Type::None) {
auto kit = cal->getCalibrationKit();
auto isTRL = type == Calibration::Type::TRL;
if(kit.minFreq(isTRL) > f_min || kit.maxFreq(isTRL) < f_max) {
if(isTRL && (kit.minFreqTRL() > f_min || kit.maxFreqTRL() < f_max)) {
// TODO check SOLT frequency range depending on selected male/female kit
InformationBox::ShowMessage("Warning", "The calibration kit does not completely cover the currently selected span. "
"Applying a calibration will not be possible for any measurements taken with these settings.");
}

View File

@ -16,80 +16,151 @@
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QTableView" name="tableView">
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
<widget class="QGroupBox" name="port1Standards">
<property name="title">
<string>Port 1 Standards</string>
</property>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="port1Male">
<property name="text">
<string>Male</string>
</property>
<attribute name="buttonGroup">
<string notr="true">port1Group</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="port1Female">
<property name="text">
<string>Female</string>
</property>
<attribute name="buttonGroup">
<string notr="true">port1Group</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="bMeasure">
<property name="text">
<string>Measure</string>
</property>
<property name="icon">
<iconset theme="media-playback-start" resource="../icons.qrc">
<normaloff>:/icons/play.png</normaloff>:/icons/play.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bDelete">
<property name="text">
<string>Delete</string>
</property>
<property name="icon">
<iconset theme="edit-delete" resource="../icons.qrc">
<normaloff>:/icons/trash.png</normaloff>:/icons/trash.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="bApply">
<property name="text">
<string>Apply Calibration</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/ok.png</normaloff>:/icons/ok.png</iconset>
</property>
</widget>
</item>
</layout>
<widget class="QGroupBox" name="port2Standards">
<property name="title">
<string>Port 2 Standards</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="port2Male">
<property name="text">
<string>Male</string>
</property>
<attribute name="buttonGroup">
<string notr="true">port2Group</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="port2Female">
<property name="text">
<string>Female</string>
</property>
<attribute name="buttonGroup">
<string notr="true">port2Group</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTableView" name="tableView">
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderHighlightSections">
<bool>false</bool>
</attribute>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="bMeasure">
<property name="text">
<string>Measure</string>
</property>
<property name="icon">
<iconset theme="media-playback-start" resource="../icons.qrc">
<normaloff>:/icons/play.png</normaloff>:/icons/play.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bDelete">
<property name="text">
<string>Delete</string>
</property>
<property name="icon">
<iconset theme="edit-delete" resource="../icons.qrc">
<normaloff>:/icons/trash.png</normaloff>:/icons/trash.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="bApply">
<property name="text">
<string>Apply Calibration</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/ok.png</normaloff>:/icons/ok.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
@ -99,4 +170,8 @@
<include location="../icons.qrc"/>
</resources>
<connections/>
<buttongroups>
<buttongroup name="port1Group"/>
<buttongroup name="port2Group"/>
</buttongroups>
</ui>

View File

@ -14,9 +14,12 @@ using json = nlohmann::json;
using namespace std;
Calkit::Calkit()
: ts_open(nullptr),
ts_short(nullptr),
ts_load(nullptr),
: ts_open_m(nullptr),
ts_short_m(nullptr),
ts_load_m(nullptr),
ts_open_f(nullptr),
ts_short_f(nullptr),
ts_load_f(nullptr),
ts_through(nullptr),
ts_cached(false)
{
@ -128,39 +131,39 @@ Calkit Calkit::fromFile(QString filename)
// legacy file format, return to beginning of file
file.clear();
file.seekg(0);
c.SOLT.Open.useMeasurements = readLine(file).toInt();
c.SOLT.Short.useMeasurements = readLine(file).toInt();
c.SOLT.Load.useMeasurements = readLine(file).toInt();
c.SOLT.open_m.useMeasurements = readLine(file).toInt();
c.SOLT.short_m.useMeasurements = readLine(file).toInt();
c.SOLT.load_m.useMeasurements = readLine(file).toInt();
c.SOLT.Through.useMeasurements = readLine(file).toInt();
c.SOLT.Open.Z0 = readLine(file).toDouble();
c.SOLT.Open.delay = readLine(file).toDouble();
c.SOLT.Open.loss = readLine(file).toDouble();
c.SOLT.Open.C0 = readLine(file).toDouble();
c.SOLT.Open.C1 = readLine(file).toDouble();
c.SOLT.Open.C2 = readLine(file).toDouble();
c.SOLT.Open.C3 = readLine(file).toDouble();
c.SOLT.Short.Z0 = readLine(file).toDouble();
c.SOLT.Short.delay = readLine(file).toDouble();
c.SOLT.Short.loss = readLine(file).toDouble();
c.SOLT.Short.L0 = readLine(file).toDouble();
c.SOLT.Short.L1 = readLine(file).toDouble();
c.SOLT.Short.L2 = readLine(file).toDouble();
c.SOLT.Short.L3 = readLine(file).toDouble();
c.SOLT.Load.Z0 = readLine(file).toDouble();
c.SOLT.open_m.Z0 = readLine(file).toDouble();
c.SOLT.open_m.delay = readLine(file).toDouble();
c.SOLT.open_m.loss = readLine(file).toDouble();
c.SOLT.open_m.C0 = readLine(file).toDouble();
c.SOLT.open_m.C1 = readLine(file).toDouble();
c.SOLT.open_m.C2 = readLine(file).toDouble();
c.SOLT.open_m.C3 = readLine(file).toDouble();
c.SOLT.short_m.Z0 = readLine(file).toDouble();
c.SOLT.short_m.delay = readLine(file).toDouble();
c.SOLT.short_m.loss = readLine(file).toDouble();
c.SOLT.short_m.L0 = readLine(file).toDouble();
c.SOLT.short_m.L1 = readLine(file).toDouble();
c.SOLT.short_m.L2 = readLine(file).toDouble();
c.SOLT.short_m.L3 = readLine(file).toDouble();
c.SOLT.load_m.Z0 = readLine(file).toDouble();
c.SOLT.Through.Z0 = readLine(file).toDouble();
c.SOLT.Through.delay = readLine(file).toDouble();
c.SOLT.Through.loss = readLine(file).toDouble();
if(c.SOLT.Open.useMeasurements) {
c.SOLT.Open.file = readLine(file);
c.SOLT.Open.Sparam = readLine(file).toInt();
if(c.SOLT.open_m.useMeasurements) {
c.SOLT.open_m.file = readLine(file);
c.SOLT.open_m.Sparam = readLine(file).toInt();
}
if(c.SOLT.Short.useMeasurements) {
c.SOLT.Short.file = readLine(file);
c.SOLT.Short.Sparam = readLine(file).toInt();
if(c.SOLT.short_m.useMeasurements) {
c.SOLT.short_m.file = readLine(file);
c.SOLT.short_m.Sparam = readLine(file).toInt();
}
if(c.SOLT.Load.useMeasurements) {
c.SOLT.Load.file = readLine(file);
c.SOLT.Load.Sparam = readLine(file).toInt();
if(c.SOLT.load_m.useMeasurements) {
c.SOLT.load_m.file = readLine(file);
c.SOLT.load_m.Sparam = readLine(file).toInt();
}
if(c.SOLT.Through.useMeasurements) {
c.SOLT.Through.file = readLine(file);
@ -173,6 +176,8 @@ Calkit Calkit::fromFile(QString filename)
c.TRL.Line.minFreq = readLine(file).toDouble();
c.TRL.Line.maxFreq = readLine(file).toDouble();
c.SOLT.separate_male_female = false;
InformationBox::ShowMessage("Loading calkit file", "The file \"" + filename + "\" is stored in a deprecated"
" calibration kit format. Future versions of this application might not support"
" it anymore. Please save the calibration kit to update to the new format");
@ -199,7 +204,12 @@ void Calkit::edit(std::function<void (void)> done)
dialog->show();
}
class Calkit::SOLT Calkit::toSOLT(double frequency)
bool Calkit::hasSeparateMaleFemaleStandards()
{
return SOLT.separate_male_female;
}
class Calkit::SOLT Calkit::toSOLT(double frequency, bool male_standards)
{
auto addTransmissionLine = [](complex<double> termination_reflection, double offset_impedance, double offset_delay, double offset_loss, double frequency) -> complex<double> {
// nomenclature and formulas from https://loco.lab.asu.edu/loco-memos/edges_reports/report_20130807.pdf
@ -221,29 +231,36 @@ class Calkit::SOLT Calkit::toSOLT(double frequency)
return Gamma_i;
};
auto Load = male_standards ? SOLT.load_m : SOLT.load_f;
auto Short = male_standards ? SOLT.short_m : SOLT.short_f;
auto Open = male_standards ? SOLT.open_m : SOLT.open_f;
auto ts_load = male_standards ? ts_load_m : ts_load_f;
auto ts_short = male_standards ? ts_short_m : ts_short_f;
auto ts_open = male_standards ? ts_open_m : ts_open_f;
fillTouchstoneCache();
class SOLT ref;
if(SOLT.Load.useMeasurements) {
if(Load.useMeasurements) {
ref.Load = ts_load->interpolate(frequency).S[0];
} else {
auto imp_load = complex<double>(SOLT.Load.Z0, 0);
auto imp_load = complex<double>(Load.Z0, 0);
// Add parallel capacitor to impedance
if(SOLT.Load.Cparallel > 0) {
auto imp_C = complex<double>(0, -1.0 / (frequency * 2 * M_PI * SOLT.Load.Cparallel));
if(Load.Cparallel > 0) {
auto imp_C = complex<double>(0, -1.0 / (frequency * 2 * M_PI * Load.Cparallel));
imp_load = (imp_load * imp_C) / (imp_load + imp_C);
}
// add series inductor to impedance
auto imp_L = complex<double>(0, frequency * 2 * M_PI * SOLT.Load.Lseries);
auto imp_L = complex<double>(0, frequency * 2 * M_PI * Load.Lseries);
imp_load += imp_L;
ref.Load = (imp_load - complex<double>(50.0)) / (imp_load + complex<double>(50.0));
ref.Load = addTransmissionLine(ref.Load, SOLT.Load.Z0, SOLT.Load.delay*1e-12, 0, frequency);
ref.Load = addTransmissionLine(ref.Load, Load.Z0, Load.delay*1e-12, 0, frequency);
}
if(SOLT.Open.useMeasurements) {
if(Open.useMeasurements) {
ref.Open = ts_open->interpolate(frequency).S[0];
} else {
// calculate fringing capacitance for open
double Cfringing = SOLT.Open.C0 * 1e-15 + SOLT.Open.C1 * 1e-27 * frequency + SOLT.Open.C2 * 1e-36 * pow(frequency, 2) + SOLT.Open.C3 * 1e-45 * pow(frequency, 3);
double Cfringing = Open.C0 * 1e-15 + Open.C1 * 1e-27 * frequency + Open.C2 * 1e-36 * pow(frequency, 2) + Open.C3 * 1e-45 * pow(frequency, 3);
// convert to impedance
if (Cfringing == 0) {
// special case to avoid issues with infinity
@ -252,18 +269,18 @@ class Calkit::SOLT Calkit::toSOLT(double frequency)
auto imp_open = complex<double>(0, -1.0 / (frequency * 2 * M_PI * Cfringing));
ref.Open = (imp_open - complex<double>(50.0)) / (imp_open + complex<double>(50.0));
}
ref.Open = addTransmissionLine(ref.Open, SOLT.Open.Z0, SOLT.Open.delay*1e-12, SOLT.Open.loss*1e9, frequency);
ref.Open = addTransmissionLine(ref.Open, Open.Z0, Open.delay*1e-12, Open.loss*1e9, frequency);
}
if(SOLT.Short.useMeasurements) {
if(Short.useMeasurements) {
ref.Short = ts_short->interpolate(frequency).S[0];
} else {
// calculate inductance for short
double Lseries = SOLT.Short.L0 * 1e-12 + SOLT.Short.L1 * 1e-24 * frequency + SOLT.Short.L2 * 1e-33 * pow(frequency, 2) + SOLT.Short.L3 * 1e-42 * pow(frequency, 3);
double Lseries = Short.L0 * 1e-12 + Short.L1 * 1e-24 * frequency + Short.L2 * 1e-33 * pow(frequency, 2) + Short.L3 * 1e-42 * pow(frequency, 3);
// convert to impedance
auto imp_short = complex<double>(0, frequency * 2 * M_PI * Lseries);
ref.Short = (imp_short - complex<double>(50.0)) / (imp_short + complex<double>(50.0));
ref.Short = addTransmissionLine(ref.Short, SOLT.Short.Z0, SOLT.Short.delay*1e-12, SOLT.Short.loss*1e9, frequency);
ref.Short = addTransmissionLine(ref.Short, Short.Z0, Short.delay*1e-12, Short.loss*1e9, frequency);
}
if(SOLT.Through.useMeasurements) {
@ -300,47 +317,91 @@ class Calkit::TRL Calkit::toTRL(double)
return trl;
}
double Calkit::minFreq(bool trl)
double Calkit::minFreqTRL()
{
if(trl) {
return TRL.Line.minFreq;
} else {
fillTouchstoneCache();
double min = 0;
array<Touchstone*, 4> ts_list = {ts_open, ts_short, ts_load, ts_through};
// find the highest minimum frequency in all measurement files
for(auto ts : ts_list) {
if(!ts) {
// this calibration standard is defined by coefficients, no minimum frequency
continue;
}
if(ts->minFreq() > min) {
min = ts->minFreq();
}
}
return min;
}
return TRL.Line.minFreq;
}
double Calkit::maxFreq(bool trl)
double Calkit::maxFreqTRL()
{
if(trl) {
return TRL.Line.maxFreq;
return TRL.Line.maxFreq;
}
double Calkit::minFreqSOLT(bool male_standards)
{
fillTouchstoneCache();
double min = 0;
auto ts_load = male_standards ? ts_load_m : ts_load_f;
auto ts_short = male_standards ? ts_short_m : ts_short_f;
auto ts_open = male_standards ? ts_open_m : ts_open_f;
array<Touchstone*, 4> ts_list = {ts_open, ts_short, ts_load, ts_through};
// find the highest minimum frequency in all measurement files
for(auto ts : ts_list) {
if(!ts) {
// this calibration standard is defined by coefficients, no minimum frequency
continue;
}
if(ts->minFreq() > min) {
min = ts->minFreq();
}
}
return min;
}
double Calkit::maxFreqSOLT(bool male_standards)
{
fillTouchstoneCache();
double max = std::numeric_limits<double>::max();
auto ts_load = male_standards ? ts_load_m : ts_load_f;
auto ts_short = male_standards ? ts_short_m : ts_short_f;
auto ts_open = male_standards ? ts_open_m : ts_open_f;
array<Touchstone*, 4> ts_list = {ts_open, ts_short, ts_load, ts_through};
// find the highest minimum frequency in all measurement files
for(auto ts : ts_list) {
if(!ts) {
// this calibration standard is defined by coefficients, no minimum frequency
continue;
}
if(ts->maxFreq() < max) {
max = ts->maxFreq();
}
}
return max;
}
bool Calkit::checkIfValid(double min_freq, double max_freq, bool isTRL, bool include_male, bool include_female)
{
auto min_supported = std::numeric_limits<double>::min();
auto max_supported = std::numeric_limits<double>::max();
if(isTRL) {
min_supported = TRL.Line.minFreq;
max_supported = TRL.Line.maxFreq;
} else {
fillTouchstoneCache();
double max = std::numeric_limits<double>::max();
array<Touchstone*, 4> ts_list = {ts_open, ts_short, ts_load, ts_through};
// find the highest minimum frequency in all measurement files
for(auto ts : ts_list) {
if(!ts) {
// this calibration standard is defined by coefficients, no minimum frequency
continue;
if(include_male) {
auto min_male = minFreqSOLT(true);
auto max_male = maxFreqSOLT(true);
if(min_male > min_supported) {
min_supported = min_male;
}
if(ts->maxFreq() < max) {
max = ts->maxFreq();
if(max_male > max_supported) {
max_supported = max_male;
}
}
return max;
if(include_female) {
auto min_female = minFreqSOLT(false);
auto max_female = maxFreqSOLT(false);
if(min_female > min_supported) {
min_supported = min_female;
}
if(max_female > max_supported) {
max_supported = max_female;
}
}
}
if(min_supported <= min_freq && max_supported >= max_freq) {
return true;
} else {
return false;
}
}
@ -351,7 +412,7 @@ bool Calkit::isTRLReflectionShort() const
void Calkit::TransformPathsToRelative(QFileInfo d)
{
vector<QString*> filenames = {&SOLT.Short.file, &SOLT.Open.file, &SOLT.Load.file, &SOLT.Through.file};
vector<QString*> filenames = {&SOLT.short_m.file, &SOLT.open_m.file, &SOLT.load_m.file, &SOLT.short_f.file, &SOLT.open_f.file, &SOLT.load_f.file, &SOLT.Through.file};
for(auto f : filenames) {
if(f->isEmpty()) {
continue;
@ -366,7 +427,7 @@ void Calkit::TransformPathsToRelative(QFileInfo d)
void Calkit::TransformPathsToAbsolute(QFileInfo d)
{
vector<QString*> filenames = {&SOLT.Short.file, &SOLT.Open.file, &SOLT.Load.file, &SOLT.Through.file};
vector<QString*> filenames = {&SOLT.short_m.file, &SOLT.open_m.file, &SOLT.load_m.file, &SOLT.short_f.file, &SOLT.open_f.file, &SOLT.load_f.file, &SOLT.Through.file};
for(auto f : filenames) {
if(f->isEmpty()) {
continue;
@ -382,12 +443,18 @@ void Calkit::TransformPathsToAbsolute(QFileInfo d)
void Calkit::clearTouchstoneCache()
{
delete ts_open;
ts_open = nullptr;
delete ts_short;
ts_short = nullptr;
delete ts_load;
ts_load = nullptr;
delete ts_open_m;
ts_open_m = nullptr;
delete ts_short_m;
ts_short_m = nullptr;
delete ts_load_m;
ts_load_m = nullptr;
delete ts_open_f;
ts_open_f = nullptr;
delete ts_short_f;
ts_short_f = nullptr;
delete ts_load_f;
ts_load_f = nullptr;
delete ts_through;
ts_through = nullptr;
ts_cached = false;
@ -398,20 +465,35 @@ void Calkit::fillTouchstoneCache()
if(ts_cached) {
return;
}
if(SOLT.Open.useMeasurements) {
ts_open = new Touchstone(1);
*ts_open = Touchstone::fromFile(SOLT.Open.file.toStdString());
ts_open->reduceTo1Port(SOLT.Open.Sparam);
if(SOLT.open_m.useMeasurements) {
ts_open_m = new Touchstone(1);
*ts_open_m = Touchstone::fromFile(SOLT.open_m.file.toStdString());
ts_open_m->reduceTo1Port(SOLT.open_m.Sparam);
}
if(SOLT.Short.useMeasurements) {
ts_short = new Touchstone(1);
*ts_short = Touchstone::fromFile(SOLT.Short.file.toStdString());
ts_short->reduceTo1Port(SOLT.Short.Sparam);
if(SOLT.short_m.useMeasurements) {
ts_short_m = new Touchstone(1);
*ts_short_m = Touchstone::fromFile(SOLT.short_m.file.toStdString());
ts_short_m->reduceTo1Port(SOLT.short_m.Sparam);
}
if(SOLT.Load.useMeasurements) {
ts_load = new Touchstone(1);
*ts_load = Touchstone::fromFile(SOLT.Load.file.toStdString());
ts_load->reduceTo1Port(SOLT.Load.Sparam);
if(SOLT.load_m.useMeasurements) {
ts_load_m = new Touchstone(1);
*ts_load_m = Touchstone::fromFile(SOLT.load_m.file.toStdString());
ts_load_m->reduceTo1Port(SOLT.load_m.Sparam);
}
if(SOLT.open_f.useMeasurements) {
ts_open_f = new Touchstone(1);
*ts_open_f = Touchstone::fromFile(SOLT.open_f.file.toStdString());
ts_open_f->reduceTo1Port(SOLT.open_f.Sparam);
}
if(SOLT.short_f.useMeasurements) {
ts_short_f = new Touchstone(1);
*ts_short_f = Touchstone::fromFile(SOLT.short_f.file.toStdString());
ts_short_f->reduceTo1Port(SOLT.short_f.Sparam);
}
if(SOLT.load_f.useMeasurements) {
ts_load_f = new Touchstone(1);
*ts_load_f = Touchstone::fromFile(SOLT.load_f.file.toStdString());
ts_load_f->reduceTo1Port(SOLT.load_f.Sparam);
}
if(SOLT.Through.useMeasurements) {
ts_through = new Touchstone(2);

View File

@ -41,10 +41,14 @@ public:
void toFile(QString filename);
static Calkit fromFile(QString filename);
void edit(std::function<void(void)> done = nullptr);
SOLT toSOLT(double frequency);
bool hasSeparateMaleFemaleStandards();
SOLT toSOLT(double frequency, bool male_standards = true);
TRL toTRL(double frequency);
double minFreq(bool trl = false);
double maxFreq(bool trl = false);
double minFreqTRL();
double maxFreqTRL();
double minFreqSOLT(bool male_standards = true);
double maxFreqSOLT(bool male_standards = true);
bool checkIfValid(double min_freq, double max_freq, bool isTRL, bool include_male, bool include_female);
bool isTRLReflectionShort() const;
private:
@ -54,30 +58,34 @@ private:
QString manufacturer, serialnumber, description;
// SOLT standard definitions
struct {
struct {
using Open = struct {
double Z0, delay, loss, C0, C1, C2, C3;
QString file;
bool useMeasurements;
int Sparam;
} Open;
struct {
};
Open open_m, open_f;
using Short = struct {
double Z0, delay, loss, L0, L1, L2, L3;
QString file;
bool useMeasurements;
int Sparam;
} Short;
struct {
};
Short short_m, short_f;
using Load = struct {
double Z0, delay, Cparallel, Lseries;
QString file;
bool useMeasurements;
int Sparam;
} Load;
};
Load load_m, load_f;
struct {
double Z0, delay, loss;
QString file;
bool useMeasurements;
int Sparam1, Sparam2;
} Through;
bool separate_male_female;
} SOLT;
struct {
struct {
@ -92,7 +100,9 @@ private:
} TRL;
bool startDialogWithSOLT;
Touchstone *ts_open, *ts_short, *ts_load, *ts_through;
Touchstone *ts_open_m, *ts_short_m, *ts_load_m;
Touchstone *ts_open_f, *ts_short_f, *ts_load_f;
Touchstone *ts_through;
bool ts_cached;
using JSONDescription = struct _jsondescr {
@ -100,40 +110,67 @@ private:
QString name;
QVariant def;
};
const std::array<JSONDescription, 43> json_descr = {{
const std::array<JSONDescription, 71> json_descr = {{
{&manufacturer, "Manufacturer", ""},
{&serialnumber, "Serialnumber", ""},
{&description, "Description", ""},
{&SOLT.Open.Z0, "SOLT/Open/Param/Z0", 50.0},
{&SOLT.Open.delay, "SOLT/Open/Param/Delay", 0.0},
{&SOLT.Open.loss, "SOLT/Open/Param/Loss", 0.0},
{&SOLT.Open.C0, "SOLT/Open/Param/C0", 0.0},
{&SOLT.Open.C1, "SOLT/Open/Param/C1", 0.0},
{&SOLT.Open.C2, "SOLT/Open/Param/C2", 0.0},
{&SOLT.Open.C3, "SOLT/Open/Param/C3", 0.0},
{&SOLT.Open.useMeasurements, "SOLT/Open/Measurements/Use", false},
{&SOLT.Open.file, "SOLT/Open/Measurements/File", ""},
{&SOLT.Open.Sparam, "SOLT/Open/Measurements/Port", 0},
{&SOLT.open_m.Z0, "SOLT/Open/Param/Z0", 50.0},
{&SOLT.open_m.delay, "SOLT/Open/Param/Delay", 0.0},
{&SOLT.open_m.loss, "SOLT/Open/Param/Loss", 0.0},
{&SOLT.open_m.C0, "SOLT/Open/Param/C0", 0.0},
{&SOLT.open_m.C1, "SOLT/Open/Param/C1", 0.0},
{&SOLT.open_m.C2, "SOLT/Open/Param/C2", 0.0},
{&SOLT.open_m.C3, "SOLT/Open/Param/C3", 0.0},
{&SOLT.open_m.useMeasurements, "SOLT/Open/Measurements/Use", false},
{&SOLT.open_m.file, "SOLT/Open/Measurements/File", ""},
{&SOLT.open_m.Sparam, "SOLT/Open/Measurements/Port", 0},
{&SOLT.open_f.Z0, "SOLT/Open/Param/Z0_Female", 50.0},
{&SOLT.open_f.delay, "SOLT/Open/Param/Delay_Female", 0.0},
{&SOLT.open_f.loss, "SOLT/Open/Param/Loss_Female", 0.0},
{&SOLT.open_f.C0, "SOLT/Open/Param/C0_Female", 0.0},
{&SOLT.open_f.C1, "SOLT/Open/Param/C1_Female", 0.0},
{&SOLT.open_f.C2, "SOLT/Open/Param/C2_Female", 0.0},
{&SOLT.open_f.C3, "SOLT/Open/Param/C3_Female", 0.0},
{&SOLT.open_f.useMeasurements, "SOLT/Open/Measurements/Use_Female", false},
{&SOLT.open_f.file, "SOLT/Open/Measurements/File_Female", ""},
{&SOLT.open_f.Sparam, "SOLT/Open/Measurements/Port_Female", 0},
{&SOLT.Short.Z0, "SOLT/Short/Param/Z0", 50.0},
{&SOLT.Short.delay, "SOLT/Short/Param/Delay", 0.0},
{&SOLT.Short.loss, "SOLT/Short/Param/Loss", 0.0},
{&SOLT.Short.L0, "SOLT/Short/Param/L0", 0.0},
{&SOLT.Short.L1, "SOLT/Short/Param/L1", 0.0},
{&SOLT.Short.L2, "SOLT/Short/Param/L2", 0.0},
{&SOLT.Short.L3, "SOLT/Short/Param/L3", 0.0},
{&SOLT.Short.useMeasurements, "SOLT/Short/Measurements/Use", false},
{&SOLT.Short.file, "SOLT/Short/Measurements/File", ""},
{&SOLT.Short.Sparam, "SOLT/Short/Measurements/Port", 0},
{&SOLT.short_m.Z0, "SOLT/Short/Param/Z0", 50.0},
{&SOLT.short_m.delay, "SOLT/Short/Param/Delay", 0.0},
{&SOLT.short_m.loss, "SOLT/Short/Param/Loss", 0.0},
{&SOLT.short_m.L0, "SOLT/Short/Param/L0", 0.0},
{&SOLT.short_m.L1, "SOLT/Short/Param/L1", 0.0},
{&SOLT.short_m.L2, "SOLT/Short/Param/L2", 0.0},
{&SOLT.short_m.L3, "SOLT/Short/Param/L3", 0.0},
{&SOLT.short_m.useMeasurements, "SOLT/Short/Measurements/Use", false},
{&SOLT.short_m.file, "SOLT/Short/Measurements/File", ""},
{&SOLT.short_m.Sparam, "SOLT/Short/Measurements/Port", 0},
{&SOLT.short_f.Z0, "SOLT/Short/Param/Z0_Female", 50.0},
{&SOLT.short_f.delay, "SOLT/Short/Param/Delay_Female", 0.0},
{&SOLT.short_f.loss, "SOLT/Short/Param/Loss_Female", 0.0},
{&SOLT.short_f.L0, "SOLT/Short/Param/L0_Female", 0.0},
{&SOLT.short_f.L1, "SOLT/Short/Param/L1_Female", 0.0},
{&SOLT.short_f.L2, "SOLT/Short/Param/L2_Female", 0.0},
{&SOLT.short_f.L3, "SOLT/Short/Param/L3_Female", 0.0},
{&SOLT.short_f.useMeasurements, "SOLT/Short/Measurements/Use_Female", false},
{&SOLT.short_f.file, "SOLT/Short/Measurements/File_Female", ""},
{&SOLT.short_f.Sparam, "SOLT/Short/Measurements/Port_Female", 0},
{&SOLT.Load.Z0, "SOLT/Load/Param/Z0", 50.0},
{&SOLT.Load.delay, "SOLT/Load/Param/Delay", 0.0},
{&SOLT.Load.Cparallel, "SOLT/Load/Param/C", 0.0},
{&SOLT.Load.Lseries, "SOLT/Load/Param/L", 0.0},
{&SOLT.Load.useMeasurements, "SOLT/Load/Measurements/Use", false},
{&SOLT.Load.file, "SOLT/Load/Measurements/File", ""},
{&SOLT.Load.Sparam, "SOLT/Load/Measurements/Port", 0},
{&SOLT.load_m.Z0, "SOLT/Load/Param/Z0", 50.0},
{&SOLT.load_m.delay, "SOLT/Load/Param/Delay", 0.0},
{&SOLT.load_m.Cparallel, "SOLT/Load/Param/C", 0.0},
{&SOLT.load_m.Lseries, "SOLT/Load/Param/L", 0.0},
{&SOLT.load_m.useMeasurements, "SOLT/Load/Measurements/Use", false},
{&SOLT.load_m.file, "SOLT/Load/Measurements/File", ""},
{&SOLT.load_m.Sparam, "SOLT/Load/Measurements/Port", 0},
{&SOLT.load_f.Z0, "SOLT/Load/Param/Z0_Female", 50.0},
{&SOLT.load_f.delay, "SOLT/Load/Param/Delay_Female", 0.0},
{&SOLT.load_f.Cparallel, "SOLT/Load/Param/C_Female", 0.0},
{&SOLT.load_f.Lseries, "SOLT/Load/Param/L_Female", 0.0},
{&SOLT.load_f.useMeasurements, "SOLT/Load/Measurements/Use_Female", false},
{&SOLT.load_f.file, "SOLT/Load/Measurements/File_Female", ""},
{&SOLT.load_f.Sparam, "SOLT/Load/Measurements/Port_Female", 0},
{&SOLT.Through.Z0, "SOLT/Through/Param/Z0", 50.0},
{&SOLT.Through.delay, "SOLT/Through/Param/Delay", 0.0},
@ -143,6 +180,8 @@ private:
{&SOLT.Through.Sparam1, "SOLT/Through/Measurements/Port1", 0},
{&SOLT.Through.Sparam2, "SOLT/Through/Measurements/Port2", 1},
{&SOLT.separate_male_female, "SOLT/SeparateMaleFemale", false},
{&TRL.Through.Z0, "TRL/Through/Z0", 50.0},
{&TRL.Reflection.isShort, "TRL/Reflect/isShort", false},
{&TRL.Line.delay, "TRL/Line/Delay", 74.0},

View File

@ -47,6 +47,29 @@ CalkitDialog::CalkitDialog(Calkit &c, QWidget *parent) :
ui->load_parC->setPrefixes("fpnum ");
ui->load_serL->setUnit("H");
ui->load_serL->setPrefixes("fpnum ");
// Same setup for female standards
ui->OpenType_f->setId(ui->open_coefficients_f, 0);
ui->OpenType_f->setId(ui->open_measurement_f, 1);
ui->ShortType_f->setId(ui->short_coefficients_f, 0);
ui->ShortType_f->setId(ui->short_measurement_f, 1);
ui->LoadType_f->setId(ui->load_coefficients_f, 0);
ui->LoadType_f->setId(ui->load_measurement_f, 1);
ui->open_touchstone_f->setPorts(1);
ui->short_touchstone_f->setPorts(1);
ui->load_touchstone_f->setPorts(1);
ui->short_Z0_f->setUnit("Ω");
ui->open_Z0_f->setUnit("Ω");
ui->load_Z0_f->setUnit("Ω");
ui->load_parC_f->setUnit("F");
ui->load_parC_f->setPrefixes("fpnum ");
ui->load_serL_f->setUnit("H");
ui->load_serL_f->setPrefixes("fpnum ");
ui->through_Z0->setUnit("Ω");
ui->TRL_through_Z0->setUnit("Ω");
@ -59,6 +82,24 @@ CalkitDialog::CalkitDialog(Calkit &c, QWidget *parent) :
editKit.clearTouchstoneCache();
ownKit = editKit;
connect(ui->cbStandardDefinition, qOverload<int>(&QComboBox::currentIndexChanged), [=](int index){
if (index == 0) {
// common definition, hide tab bars, set all to male tab
ui->mf_short->setCurrentIndex(0);
ui->mf_short->tabBar()->hide();
ui->mf_open->setCurrentIndex(0);
ui->mf_open->tabBar()->hide();
ui->mf_load->setCurrentIndex(0);
ui->mf_load->tabBar()->hide();
} else {
// separate definitions for male/female standards
ui->mf_short->tabBar()->show();
ui->mf_open->tabBar()->show();
ui->mf_load->tabBar()->show();
}
});
updateEntries();
connect(ui->TRL_line_min, &SIUnitEdit::valueChanged, [=](double newval){
@ -85,6 +126,15 @@ CalkitDialog::CalkitDialog(Calkit &c, QWidget *parent) :
if(ui->load_measurement->isChecked() && !ui->load_touchstone->getStatus()) {
ok = false;
}
if(ui->open_measurement_f->isChecked() && !ui->open_touchstone_f->getStatus()) {
ok = false;
}
if(ui->short_measurement_f->isChecked() && !ui->short_touchstone_f->getStatus()) {
ok = false;
}
if(ui->load_measurement_f->isChecked() && !ui->load_touchstone_f->getStatus()) {
ok = false;
}
if(ui->through_measurement->isChecked() && !ui->through_touchstone->getStatus()) {
ok = false;
}
@ -95,6 +145,9 @@ CalkitDialog::CalkitDialog(Calkit &c, QWidget *parent) :
connect(ui->open_touchstone, &TouchstoneImport::statusChanged, UpdateStatus);
connect(ui->short_touchstone, &TouchstoneImport::statusChanged, UpdateStatus);
connect(ui->load_touchstone, &TouchstoneImport::statusChanged, UpdateStatus);
connect(ui->open_touchstone_f, &TouchstoneImport::statusChanged, UpdateStatus);
connect(ui->short_touchstone_f, &TouchstoneImport::statusChanged, UpdateStatus);
connect(ui->load_touchstone_f, &TouchstoneImport::statusChanged, UpdateStatus);
connect(ui->through_touchstone, &TouchstoneImport::statusChanged, UpdateStatus);
connect(ui->OpenType, qOverload<int>(&QButtonGroup::buttonClicked), [=](int) {
@ -106,6 +159,15 @@ CalkitDialog::CalkitDialog(Calkit &c, QWidget *parent) :
connect(ui->LoadType, qOverload<int>(&QButtonGroup::buttonClicked), [=](int) {
UpdateStatus();
});
connect(ui->OpenType_f, qOverload<int>(&QButtonGroup::buttonClicked), [=](int) {
UpdateStatus();
});
connect(ui->ShortType_f, qOverload<int>(&QButtonGroup::buttonClicked), [=](int) {
UpdateStatus();
});
connect(ui->LoadType_f, qOverload<int>(&QButtonGroup::buttonClicked), [=](int) {
UpdateStatus();
});
connect(ui->ThroughType, qOverload<int>(&QButtonGroup::buttonClicked), [=](int) {
UpdateStatus();
});
@ -152,49 +214,83 @@ void CalkitDialog::parseEntries()
ownKit.description = ui->description->toPlainText();
// type
ownKit.SOLT.Open.useMeasurements = ui->open_measurement->isChecked();
ownKit.SOLT.Short.useMeasurements = ui->short_measurement->isChecked();
ownKit.SOLT.Load.useMeasurements = ui->load_measurement->isChecked();
ownKit.SOLT.open_m.useMeasurements = ui->open_measurement->isChecked();
ownKit.SOLT.short_m.useMeasurements = ui->short_measurement->isChecked();
ownKit.SOLT.load_m.useMeasurements = ui->load_measurement->isChecked();
ownKit.SOLT.open_f.useMeasurements = ui->open_measurement_f->isChecked();
ownKit.SOLT.short_f.useMeasurements = ui->short_measurement_f->isChecked();
ownKit.SOLT.load_f.useMeasurements = ui->load_measurement_f->isChecked();
ownKit.SOLT.Through.useMeasurements = ui->through_measurement->isChecked();
// coefficients
ownKit.SOLT.Open.Z0 = ui->open_Z0->value();
ownKit.SOLT.Open.delay = ui->open_delay->value();
ownKit.SOLT.Open.loss = ui->open_loss->value();
ownKit.SOLT.Open.C0 = ui->open_C0->value();
ownKit.SOLT.Open.C1 = ui->open_C1->value();
ownKit.SOLT.Open.C2 = ui->open_C2->value();
ownKit.SOLT.Open.C3 = ui->open_C3->value();
ownKit.SOLT.open_m.Z0 = ui->open_Z0->value();
ownKit.SOLT.open_m.delay = ui->open_delay->value();
ownKit.SOLT.open_m.loss = ui->open_loss->value();
ownKit.SOLT.open_m.C0 = ui->open_C0->value();
ownKit.SOLT.open_m.C1 = ui->open_C1->value();
ownKit.SOLT.open_m.C2 = ui->open_C2->value();
ownKit.SOLT.open_m.C3 = ui->open_C3->value();
ownKit.SOLT.Short.Z0 = ui->short_Z0->value();
ownKit.SOLT.Short.delay = ui->short_delay->value();
ownKit.SOLT.Short.loss = ui->short_loss->value();
ownKit.SOLT.Short.L0 = ui->short_L0->value();
ownKit.SOLT.Short.L1 = ui->short_L1->value();
ownKit.SOLT.Short.L2 = ui->short_L2->value();
ownKit.SOLT.Short.L3 = ui->short_L3->value();
ownKit.SOLT.short_m.Z0 = ui->short_Z0->value();
ownKit.SOLT.short_m.delay = ui->short_delay->value();
ownKit.SOLT.short_m.loss = ui->short_loss->value();
ownKit.SOLT.short_m.L0 = ui->short_L0->value();
ownKit.SOLT.short_m.L1 = ui->short_L1->value();
ownKit.SOLT.short_m.L2 = ui->short_L2->value();
ownKit.SOLT.short_m.L3 = ui->short_L3->value();
ownKit.SOLT.Load.Z0 = ui->load_Z0->value();
ownKit.SOLT.Load.delay = ui->load_delay->value();
ownKit.SOLT.Load.Cparallel = ui->load_parC->value();
ownKit.SOLT.Load.Lseries = ui->load_serL->value();
ownKit.SOLT.load_m.Z0 = ui->load_Z0->value();
ownKit.SOLT.load_m.delay = ui->load_delay->value();
ownKit.SOLT.load_m.Cparallel = ui->load_parC->value();
ownKit.SOLT.load_m.Lseries = ui->load_serL->value();
ownKit.SOLT.open_f.Z0 = ui->open_Z0_f->value();
ownKit.SOLT.open_f.delay = ui->open_delay_f->value();
ownKit.SOLT.open_f.loss = ui->open_loss_f->value();
ownKit.SOLT.open_f.C0 = ui->open_C0_f->value();
ownKit.SOLT.open_f.C1 = ui->open_C1_f->value();
ownKit.SOLT.open_f.C2 = ui->open_C2_f->value();
ownKit.SOLT.open_f.C3 = ui->open_C3_f->value();
ownKit.SOLT.short_f.Z0 = ui->short_Z0_f->value();
ownKit.SOLT.short_f.delay = ui->short_delay_f->value();
ownKit.SOLT.short_f.loss = ui->short_loss_f->value();
ownKit.SOLT.short_f.L0 = ui->short_L0_f->value();
ownKit.SOLT.short_f.L1 = ui->short_L1_f->value();
ownKit.SOLT.short_f.L2 = ui->short_L2_f->value();
ownKit.SOLT.short_f.L3 = ui->short_L3_f->value();
ownKit.SOLT.load_f.Z0 = ui->load_Z0_f->value();
ownKit.SOLT.load_f.delay = ui->load_delay_f->value();
ownKit.SOLT.load_f.Cparallel = ui->load_parC_f->value();
ownKit.SOLT.load_f.Lseries = ui->load_serL_f->value();
ownKit.SOLT.Through.Z0 = ui->through_Z0->value();
ownKit.SOLT.Through.delay = ui->through_delay->value();
ownKit.SOLT.Through.loss = ui->through_loss->value();
ownKit.SOLT.separate_male_female = ui->cbStandardDefinition->currentIndex() == 1;
// file
ownKit.SOLT.Open.file = ui->open_touchstone->getFilename();
ownKit.SOLT.Short.file = ui->short_touchstone->getFilename();
ownKit.SOLT.Load.file = ui->load_touchstone->getFilename();
ownKit.SOLT.open_m.file = ui->open_touchstone->getFilename();
ownKit.SOLT.short_m.file = ui->short_touchstone->getFilename();
ownKit.SOLT.load_m.file = ui->load_touchstone->getFilename();
ownKit.SOLT.Through.file = ui->through_touchstone->getFilename();
ownKit.SOLT.Open.Sparam = ui->open_touchstone->getPorts()[0];
ownKit.SOLT.Short.Sparam = ui->short_touchstone->getPorts()[0];
ownKit.SOLT.Load.Sparam = ui->load_touchstone->getPorts()[0];
ownKit.SOLT.open_m.Sparam = ui->open_touchstone->getPorts()[0];
ownKit.SOLT.short_m.Sparam = ui->short_touchstone->getPorts()[0];
ownKit.SOLT.load_m.Sparam = ui->load_touchstone->getPorts()[0];
ownKit.SOLT.Through.Sparam1 = ui->through_touchstone->getPorts()[0];
ownKit.SOLT.Through.Sparam2 = ui->through_touchstone->getPorts()[1];
ownKit.SOLT.open_f.file = ui->open_touchstone_f->getFilename();
ownKit.SOLT.short_f.file = ui->short_touchstone_f->getFilename();
ownKit.SOLT.load_f.file = ui->load_touchstone_f->getFilename();
ownKit.SOLT.open_f.Sparam = ui->open_touchstone_f->getPorts()[0];
ownKit.SOLT.short_f.Sparam = ui->short_touchstone_f->getPorts()[0];
ownKit.SOLT.load_f.Sparam = ui->load_touchstone_f->getPorts()[0];
// TRL
ownKit.TRL.Through.Z0 = ui->TRL_through_Z0->value();
ownKit.TRL.Reflection.isShort = ui->TRL_R_short->isChecked();
@ -212,70 +308,124 @@ void CalkitDialog::updateEntries()
ui->description->setPlainText(ownKit.description);
// Coefficients
ui->open_Z0->setValueQuiet(ownKit.SOLT.Open.Z0);
ui->open_delay->setValueQuiet(ownKit.SOLT.Open.delay);
ui->open_loss->setValueQuiet(ownKit.SOLT.Open.loss);
ui->open_C0->setValueQuiet(ownKit.SOLT.Open.C0);
ui->open_C1->setValueQuiet(ownKit.SOLT.Open.C1);
ui->open_C2->setValueQuiet(ownKit.SOLT.Open.C2);
ui->open_C3->setValueQuiet(ownKit.SOLT.Open.C3);
ui->open_Z0->setValueQuiet(ownKit.SOLT.open_m.Z0);
ui->open_delay->setValueQuiet(ownKit.SOLT.open_m.delay);
ui->open_loss->setValueQuiet(ownKit.SOLT.open_m.loss);
ui->open_C0->setValueQuiet(ownKit.SOLT.open_m.C0);
ui->open_C1->setValueQuiet(ownKit.SOLT.open_m.C1);
ui->open_C2->setValueQuiet(ownKit.SOLT.open_m.C2);
ui->open_C3->setValueQuiet(ownKit.SOLT.open_m.C3);
ui->short_Z0->setValueQuiet(ownKit.SOLT.Short.Z0);
ui->short_delay->setValueQuiet(ownKit.SOLT.Short.delay);
ui->short_loss->setValueQuiet(ownKit.SOLT.Short.loss);
ui->short_L0->setValueQuiet(ownKit.SOLT.Short.L0);
ui->short_L1->setValueQuiet(ownKit.SOLT.Short.L1);
ui->short_L2->setValueQuiet(ownKit.SOLT.Short.L2);
ui->short_L3->setValueQuiet(ownKit.SOLT.Short.L3);
ui->short_Z0->setValueQuiet(ownKit.SOLT.short_m.Z0);
ui->short_delay->setValueQuiet(ownKit.SOLT.short_m.delay);
ui->short_loss->setValueQuiet(ownKit.SOLT.short_m.loss);
ui->short_L0->setValueQuiet(ownKit.SOLT.short_m.L0);
ui->short_L1->setValueQuiet(ownKit.SOLT.short_m.L1);
ui->short_L2->setValueQuiet(ownKit.SOLT.short_m.L2);
ui->short_L3->setValueQuiet(ownKit.SOLT.short_m.L3);
ui->load_Z0->setValueQuiet(ownKit.SOLT.Load.Z0);
ui->load_delay->setValueQuiet(ownKit.SOLT.Load.delay);
ui->load_parC->setValueQuiet(ownKit.SOLT.Load.Cparallel);
ui->load_serL->setValueQuiet(ownKit.SOLT.Load.Lseries);
ui->load_Z0->setValueQuiet(ownKit.SOLT.load_m.Z0);
ui->load_delay->setValueQuiet(ownKit.SOLT.load_m.delay);
ui->load_parC->setValueQuiet(ownKit.SOLT.load_m.Cparallel);
ui->load_serL->setValueQuiet(ownKit.SOLT.load_m.Lseries);
ui->open_Z0_f->setValueQuiet(ownKit.SOLT.open_f.Z0);
ui->open_delay_f->setValueQuiet(ownKit.SOLT.open_f.delay);
ui->open_loss_f->setValueQuiet(ownKit.SOLT.open_f.loss);
ui->open_C0_f->setValueQuiet(ownKit.SOLT.open_f.C0);
ui->open_C1_f->setValueQuiet(ownKit.SOLT.open_f.C1);
ui->open_C2_f->setValueQuiet(ownKit.SOLT.open_f.C2);
ui->open_C3_f->setValueQuiet(ownKit.SOLT.open_f.C3);
ui->short_Z0_f->setValueQuiet(ownKit.SOLT.short_f.Z0);
ui->short_delay_f->setValueQuiet(ownKit.SOLT.short_f.delay);
ui->short_loss_f->setValueQuiet(ownKit.SOLT.short_f.loss);
ui->short_L0_f->setValueQuiet(ownKit.SOLT.short_f.L0);
ui->short_L1_f->setValueQuiet(ownKit.SOLT.short_f.L1);
ui->short_L2_f->setValueQuiet(ownKit.SOLT.short_f.L2);
ui->short_L3_f->setValueQuiet(ownKit.SOLT.short_f.L3);
ui->load_Z0_f->setValueQuiet(ownKit.SOLT.load_f.Z0);
ui->load_delay_f->setValueQuiet(ownKit.SOLT.load_f.delay);
ui->load_parC_f->setValueQuiet(ownKit.SOLT.load_f.Cparallel);
ui->load_serL_f->setValueQuiet(ownKit.SOLT.load_f.Lseries);
ui->through_Z0->setValueQuiet(ownKit.SOLT.Through.Z0);
ui->through_delay->setValueQuiet(ownKit.SOLT.Through.delay);
ui->through_loss->setValueQuiet(ownKit.SOLT.Through.loss);
// Measurements
ui->open_touchstone->setFile(ownKit.SOLT.Open.file);
ui->open_touchstone->selectPort(0, ownKit.SOLT.Open.Sparam);
ui->open_touchstone->setFile(ownKit.SOLT.open_m.file);
ui->open_touchstone->selectPort(0, ownKit.SOLT.open_m.Sparam);
ui->short_touchstone->setFile(ownKit.SOLT.Short.file);
ui->short_touchstone->selectPort(0, ownKit.SOLT.Short.Sparam);
ui->short_touchstone->setFile(ownKit.SOLT.short_m.file);
ui->short_touchstone->selectPort(0, ownKit.SOLT.short_m.Sparam);
ui->load_touchstone->setFile(ownKit.SOLT.Load.file);
ui->load_touchstone->selectPort(0, ownKit.SOLT.Load.Sparam);
ui->load_touchstone->setFile(ownKit.SOLT.load_m.file);
ui->load_touchstone->selectPort(0, ownKit.SOLT.load_m.Sparam);
ui->open_touchstone_f->setFile(ownKit.SOLT.open_f.file);
ui->open_touchstone_f->selectPort(0, ownKit.SOLT.open_f.Sparam);
ui->short_touchstone_f->setFile(ownKit.SOLT.short_f.file);
ui->short_touchstone_f->selectPort(0, ownKit.SOLT.short_f.Sparam);
ui->load_touchstone_f->setFile(ownKit.SOLT.load_f.file);
ui->load_touchstone_f->selectPort(0, ownKit.SOLT.load_f.Sparam);
ui->through_touchstone->setFile(ownKit.SOLT.Through.file);
ui->through_touchstone->selectPort(0, ownKit.SOLT.Through.Sparam1);
ui->through_touchstone->selectPort(1, ownKit.SOLT.Through.Sparam2);
// Type
if (ownKit.SOLT.Open.useMeasurements) {
if (ownKit.SOLT.open_m.useMeasurements) {
ui->open_measurement->click();
} else {
ui->open_coefficients->click();
}
if (ownKit.SOLT.Short.useMeasurements) {
if (ownKit.SOLT.short_m.useMeasurements) {
ui->short_measurement->click();
} else {
ui->short_coefficients->click();
}
if (ownKit.SOLT.Load.useMeasurements) {
if (ownKit.SOLT.load_m.useMeasurements) {
ui->load_measurement->click();
} else {
ui->load_coefficients->click();
}
if (ownKit.SOLT.open_f.useMeasurements) {
ui->open_measurement_f->click();
} else {
ui->open_coefficients_f->click();
}
if (ownKit.SOLT.short_f.useMeasurements) {
ui->short_measurement_f->click();
} else {
ui->short_coefficients_f->click();
}
if (ownKit.SOLT.load_f.useMeasurements) {
ui->load_measurement_f->click();
} else {
ui->load_coefficients_f->click();
}
if (ownKit.SOLT.Through.useMeasurements) {
ui->through_measurement->click();
} else {
ui->through_coefficients->click();
}
if (ownKit.SOLT.separate_male_female) {
ui->cbStandardDefinition->setCurrentIndex(1);
} else {
ui->cbStandardDefinition->setCurrentIndex(0);
}
// TRL
ui->TRL_through_Z0->setValueQuiet(ownKit.TRL.Through.Z0);
if(ownKit.TRL.Reflection.isShort) {

File diff suppressed because it is too large Load Diff