From 45cf2200b8c6d463adc31dff015c2f59e44b5521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Sat, 4 Dec 2021 21:16:45 +0100 Subject: [PATCH] Show gender of required standard in additional column --- .../Calibration/calibration.cpp | 19 ++++++ .../PC_Application/Calibration/calibration.h | 13 +++- .../Calibration/calibrationtracedialog.cpp | 9 ++- .../Calibration/measurementmodel.cpp | 66 ++++++++++++++----- .../Calibration/measurementmodel.h | 17 +++-- 5 files changed, 95 insertions(+), 29 deletions(-) diff --git a/Software/PC_Application/Calibration/calibration.cpp b/Software/PC_Application/Calibration/calibration.cpp index 75d460d..bf0710e 100644 --- a/Software/PC_Application/Calibration/calibration.cpp +++ b/Software/PC_Application/Calibration/calibration.cpp @@ -218,6 +218,9 @@ void Calibration::construct12TermPoints() p.re11 = ((S22_through - p.re33)*(1.0 - p.re22 * actual.ThroughS22)-actual.ThroughS22*p.re23e32) / ((S22_through - p.re33)*(actual.ThroughS11-p.re22*deltaS)-deltaS*p.re23e32); p.re23e01 = (S12_through - p.re03)*(1.0 - p.re11*actual.ThroughS11 - p.re22*actual.ThroughS22 + p.re11*p.re22*deltaS) / actual.ThroughS12; + + + points.push_back(p); } } @@ -237,6 +240,7 @@ void Calibration::constructPort1SOL() // 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 + p.fex = 0.0; p.fe30 = 0.0; p.fe22 = 0.0; p.fe10e32 = 1.0; @@ -244,6 +248,7 @@ void Calibration::constructPort1SOL() p.re22 = 0.0; p.re23e32 = 1.0; p.re03 = 0.0; + p.rex = 0.0; p.re11 = 0.0; p.re23e01 = 1.0; points.push_back(p); @@ -265,6 +270,7 @@ void Calibration::constructPort2SOL() // 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 + p.fex = 0.0; p.fe30 = 0.0; p.fe22 = 0.0; p.fe10e32 = 1.0; @@ -272,6 +278,7 @@ void Calibration::constructPort2SOL() p.fe11 = 0.0; p.fe10e01 = 1.0; p.re03 = 0.0; + p.rex = 0.0; p.re11 = 0.0; p.re23e01 = 1.0; points.push_back(p); @@ -292,11 +299,13 @@ void Calibration::constructTransmissionNormalization() p.re23e01 = S12_through / actual.ThroughS12; // All other calibration coefficients to ideal values p.fe30 = 0.0; + p.fex = 0.0; p.fe22 = 0.0; p.fe00 = 0.0; p.fe11 = 0.0; p.fe10e01 = 1.0; p.re03 = 0.0; + p.rex = 0.0; p.re11 = 0.0; p.re33 = 0.0; p.re22 = 0.0; @@ -396,6 +405,7 @@ void Calibration::constructTRL() p.fe10e32 = S_B.m21; // no isolation measurement available p.fe30 = 0.0; + p.fex = 0.0; // Reverse coefficients, normalize for S12 = 1.0 // => det(T)/T22 = 1.0 @@ -416,6 +426,7 @@ void Calibration::constructTRL() p.re33 = S_B.m22; // no isolation measurement available p.re03 = 0.0; + p.rex = 0.0; points.push_back(p); } @@ -1117,7 +1128,9 @@ Calibration::Point Calibration::getCalibrationPoint(Protocol::Datapoint &d) ret.fe11 = low->fe11 * (1 - alpha) + high->fe11 * alpha; ret.fe22 = low->fe22 * (1 - alpha) + high->fe22 * alpha; ret.fe30 = low->fe30 * (1 - alpha) + high->fe30 * alpha; + ret.fex = low->fex * (1 - alpha) + high->fex * alpha; ret.re03 = low->re03 * (1 - alpha) + high->re03 * alpha; + ret.rex = low->rex * (1 - alpha) + high->rex * alpha; ret.re11 = low->re11 * (1 - alpha) + high->re11 * alpha; ret.re22 = low->re22 * (1 - alpha) + high->re22 * alpha; ret.re33 = low->re33 * (1 - alpha) + high->re33 * alpha; @@ -1141,6 +1154,12 @@ void Calibration::computeSOL(std::complex s_m, std::complex o_m, tracking = directivity * match - delta; } +void Calibration::computeIsolation(std::complex x0_m, std::complex x1_m, std::complex reverse_match, std::complex reverse_tracking, std::complex reverse_directivity, std::complex x0, std::complex x1, std::complex &internal_isolation, std::complex &external_isolation) +{ + external_isolation = (x1_m - x0_m)*(1.0 - reverse_match * (x1 - x0) + x1*x0*reverse_match*reverse_match) / (reverse_tracking * (x1 - x0)); + internal_isolation = x0_m - external_isolation*(reverse_directivity + reverse_tracking*x0 / (1.0 - x0*reverse_match)); +} + std::complex Calibration::correctSOL(std::complex measured, std::complex directivity, std::complex match, std::complex tracking) { return (measured - directivity) / (measured * match - directivity * match + tracking); diff --git a/Software/PC_Application/Calibration/calibration.h b/Software/PC_Application/Calibration/calibration.h index f3f2717..fba9643 100644 --- a/Software/PC_Application/Calibration/calibration.h +++ b/Software/PC_Application/Calibration/calibration.h @@ -138,9 +138,9 @@ private: public: double frequency; // Forward error terms - std::complex fe00, fe11, fe10e01, fe10e32, fe22, fe30; + std::complex fe00, fe11, fe10e01, fe10e32, fe22, fe30, fex; // Reverse error terms - std::complex re33, re11, re23e32, re23e01, re22, re03; + std::complex re33, re11, re23e32, re23e01, re22, re03, rex; }; Point getCalibrationPoint(Protocol::Datapoint &d); /* @@ -158,6 +158,15 @@ private: std::complex o_c = std::complex(1.0, 0), std::complex s_c = std::complex(-1.0, 0), std::complex l_c = std::complex(0, 0)); + void computeIsolation(std::complex x0_m, + std::complex x1_m, + std::complex reverse_match, + std::complex reverse_tracking, + std::complex reverse_directivity, + std::complex x0, + std::complex x1, + std::complex &internal_isolation, + std::complex &external_isolation); std::complex correctSOL(std::complex measured, std::complex directivity, std::complex match, diff --git a/Software/PC_Application/Calibration/calibrationtracedialog.cpp b/Software/PC_Application/Calibration/calibrationtracedialog.cpp index 55c2f08..db639ee 100644 --- a/Software/PC_Application/Calibration/calibrationtracedialog.cpp +++ b/Software/PC_Application/Calibration/calibrationtracedialog.cpp @@ -21,9 +21,10 @@ CalibrationTraceDialog::CalibrationTraceDialog(Calibration *cal, double f_min, d model = new MeasurementModel(cal, measurements); ui->tableView->setModel(model); ui->tableView->setColumnWidth(0, 100); - ui->tableView->setColumnWidth(1, 350); - ui->tableView->setColumnWidth(2, 320); - ui->tableView->setColumnWidth(3, 160); + ui->tableView->setColumnWidth(1, 80); + ui->tableView->setColumnWidth(2, 350); + ui->tableView->setColumnWidth(3, 320); + ui->tableView->setColumnWidth(4, 160); UpdateCalibrationStatus(); auto updateThroughStandardUI = [=](){ @@ -37,6 +38,7 @@ CalibrationTraceDialog::CalibrationTraceDialog(Calibration *cal, double f_min, d ui->throughZero->setEnabled(true); ui->throughCalkit->setEnabled(true); } + model->genderUpdated(); }; connect(ui->port1Group, qOverload(&QButtonGroup::buttonClicked), [=](){ @@ -73,6 +75,7 @@ CalibrationTraceDialog::CalibrationTraceDialog(Calibration *cal, double f_min, d ui->port1Standards->hide(); ui->port2Standards->hide(); ui->throughStandard->hide(); + ui->tableView->hideColumn((int) MeasurementModel::ColIndex::Gender); // default selection is male ui->port1Male->click(); ui->port2Male->click(); diff --git a/Software/PC_Application/Calibration/measurementmodel.cpp b/Software/PC_Application/Calibration/measurementmodel.cpp index 4b17b4c..0f382b2 100644 --- a/Software/PC_Application/Calibration/measurementmodel.cpp +++ b/Software/PC_Application/Calibration/measurementmodel.cpp @@ -19,21 +19,46 @@ int MeasurementModel::rowCount(const QModelIndex &) const int MeasurementModel::columnCount(const QModelIndex &) const { - return ColIndexLast; + return (int) ColIndex::Last; } QVariant MeasurementModel::data(const QModelIndex &index, int role) const { auto info = cal->getMeasurementInfo(measurements[index.row()]); if(role == Qt::DisplayRole) { - switch(index.column()) { - case ColIndexName: + switch((ColIndex) index.column()) { + case ColIndex::Name: return info.name; break; - case ColIndexDescription: + case ColIndex::Gender: + switch(measurements[index.row()]) { + case Calibration::Measurement::Port1Load: + case Calibration::Measurement::Port1Open: + case Calibration::Measurement::Port1Short: + if(cal->getPortStandard(1) == Calibration::PortStandard::Male) { + return "Male"; + } else { + return "Female"; + } + break; + case Calibration::Measurement::Port2Load: + case Calibration::Measurement::Port2Open: + case Calibration::Measurement::Port2Short: + if(cal->getPortStandard(2) == Calibration::PortStandard::Male) { + return "Male"; + } else { + return "Female"; + } + break; + default: + return ""; + } + + break; + case ColIndex::Description: return info.prerequisites; break; - case ColIndexData: + case ColIndex::Data: if(info.points > 0) { QString data = QString::number(info.points); data.append(" points from "); @@ -45,16 +70,17 @@ QVariant MeasurementModel::data(const QModelIndex &index, int role) const return "Not available"; } break; - case ColIndexDate: + case ColIndex::Date: return info.timestamp.toString("dd.MM.yyyy hh:mm:ss"); break; } } else if(role == Qt::SizeHintRole) { - switch(index.column()) { - case ColIndexName: return 200; break; - case ColIndexDescription: return 500; break; - case ColIndexData: return 300; break; - case ColIndexDate: return 300; break; + switch((ColIndex) index.column()) { + case ColIndex::Name: return 200; break; + case ColIndex::Gender: return 150; break; + case ColIndex::Description: return 500; break; + case ColIndex::Data: return 300; break; + case ColIndex::Date: return 300; break; default: return QVariant(); break; } } @@ -65,11 +91,12 @@ QVariant MeasurementModel::data(const QModelIndex &index, int role) const QVariant MeasurementModel::headerData(int section, Qt::Orientation orientation, int role) const { if(orientation == Qt::Horizontal && role == Qt::DisplayRole) { - switch(section) { - case ColIndexName: return "Type"; break; - case ColIndexDescription: return "Prerequisites"; break; - case ColIndexData: return "Statistics"; break; - case ColIndexDate: return "Timestamp"; break; + switch((ColIndex) section) { + case ColIndex::Name: return "Type"; break; + case ColIndex::Gender: return "Gender"; break; + case ColIndex::Description: return "Prerequisites"; break; + case ColIndex::Data: return "Statistics"; break; + case ColIndex::Date: return "Timestamp"; break; default: return QVariant(); break; } } else { @@ -83,6 +110,11 @@ void MeasurementModel::measurementUpdated(Calibration::Measurement m) auto it = std::find(measurements.begin(), measurements.end(), m); if(it != measurements.end()) { int row = it - measurements.begin(); - emit dataChanged(index(row, 0), index(row, ColIndexLast - 1)); + emit dataChanged(index(row, 0), index(row, (int) ColIndex::Last - 1)); } } + +void MeasurementModel::genderUpdated() +{ + emit dataChanged(index(0, (int) ColIndex::Gender), index(rowCount() - 1, (int) ColIndex::Gender)); +} diff --git a/Software/PC_Application/Calibration/measurementmodel.h b/Software/PC_Application/Calibration/measurementmodel.h index 6674c27..edbba05 100644 --- a/Software/PC_Application/Calibration/measurementmodel.h +++ b/Software/PC_Application/Calibration/measurementmodel.h @@ -11,6 +11,15 @@ class MeasurementModel : public QAbstractTableModel { Q_OBJECT public: + enum class ColIndex { + Name, + Gender, + Description, + Data, + Date, + Last + }; + MeasurementModel(Calibration *cal, std::vector measurements); int rowCount(const QModelIndex &parent = QModelIndex()) const override; @@ -20,15 +29,9 @@ public: public slots: void measurementUpdated(Calibration::Measurement m); + void genderUpdated(); private: - enum { - ColIndexName, - ColIndexDescription, - ColIndexData, - ColIndexDate, - ColIndexLast - }; Calibration *cal; std::vector measurements; };