From 5ddc3d67948eaad82cd3e3773ca82392544f8013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Sat, 5 Dec 2020 13:33:42 +0100 Subject: [PATCH] Bugfixes TDR --- Software/PC_Application/Application.pro | 1 + Software/PC_Application/Traces/Math/tdr.cpp | 15 +++++-- .../Traces/Math/tdrexplanationwidget.ui | 44 +++++++++++++++++++ Software/PC_Application/Traces/trace.cpp | 8 +++- .../PC_Application/Traces/tracemarker.cpp | 6 +++ 5 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 Software/PC_Application/Traces/Math/tdrexplanationwidget.ui diff --git a/Software/PC_Application/Application.pro b/Software/PC_Application/Application.pro index 60a7d7c..d7e10f6 100644 --- a/Software/PC_Application/Application.pro +++ b/Software/PC_Application/Application.pro @@ -136,6 +136,7 @@ FORMS += \ Traces/Math/medianfilterdialog.ui \ Traces/Math/newtracemathdialog.ui \ Traces/Math/tdrdialog.ui \ + Traces/Math/tdrexplanationwidget.ui \ Traces/Math/tracematheditdialog.ui \ Traces/markerwidget.ui \ Traces/smithchartdialog.ui \ diff --git a/Software/PC_Application/Traces/Math/tdr.cpp b/Software/PC_Application/Traces/Math/tdr.cpp index 3fadf63..d0dae10 100644 --- a/Software/PC_Application/Traces/Math/tdr.cpp +++ b/Software/PC_Application/Traces/Math/tdr.cpp @@ -4,6 +4,7 @@ #include "ui_tdrdialog.h" #include #include +#include "ui_tdrexplanationwidget.h" using namespace Math; using namespace std; @@ -85,6 +86,9 @@ void TDR::edit() ui->DCmanual->setChecked(true); } ui->computeStepResponse->setChecked(stepResponse); + if(mode == Mode::Bandpass) { + ui->mode->setCurrentIndex(1); + } ui->manualMag->setUnit("dBm"); ui->manualMag->setPrecision(3); @@ -108,7 +112,10 @@ void TDR::edit() QWidget *TDR::createExplanationWidget() { - return new QLabel("Test"); + auto w = new QWidget(); + auto ui = new Ui::TDRExplanationWidget; + ui->setupUi(w); + return w; } nlohmann::json TDR::toJSON() @@ -151,10 +158,10 @@ void TDR::fromJSON(nlohmann::json j) void TDR::inputSamplesChanged(unsigned int begin, unsigned int end) { - Q_UNUSED(begin); + Q_UNUSED(end); if(input->rData().size() >= 2) { - // TDR is computationally expensive, only update at the end of sweep - if(end != input->rData().size()) { + // TDR is computationally expensive, only update at the end of sweep -> check if this is the first changed data in the next sweep + if(begin != 0) { // not the end, do nothing return; } diff --git a/Software/PC_Application/Traces/Math/tdrexplanationwidget.ui b/Software/PC_Application/Traces/Math/tdrexplanationwidget.ui new file mode 100644 index 0000000..a4ab4d6 --- /dev/null +++ b/Software/PC_Application/Traces/Math/tdrexplanationwidget.ui @@ -0,0 +1,44 @@ + + + TDRExplanationWidget + + + + 0 + 0 + 364 + 412 + + + + Form + + + + + + <html><head/><body><p><span style=" font-weight:600;">TDR (IDFT)</span></p><p>This operation performs an inverse DFT on the frequency data, resulting in time domain data.</p><p>Two modes are available:</p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Bandpass: The center frequency is used as the DC bin for the IDFT. In this mode, any span can be used as the input, but in the time domain no step response is available.</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Lowpass: The start frequency is used as the DC bin. If a step response should also be calculated, the start frequency should be as low as possible.</li></ul><p><br/></p><p><br/></p></body></html> + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/Software/PC_Application/Traces/trace.cpp b/Software/PC_Application/Traces/trace.cpp index 8e1c9a2..3478eb8 100644 --- a/Software/PC_Application/Traces/trace.cpp +++ b/Software/PC_Application/Traces/trace.cpp @@ -130,6 +130,7 @@ void Trace::fillFromTouchstone(Touchstone &t, unsigned int parameter, QString fi } touchstone = true; emit typeChanged(this); + emit outputSamplesChanged(0, data.size()); } void Trace::fromLivedata(Trace::LivedataType type, LiveParameter param) @@ -283,6 +284,9 @@ void Trace::fromJSON(nlohmann::json j) } qDebug() << "Creating math operation of type:" << operation; auto op = TraceMath::createMath(type); + if(jm.contains("settings")) { + op->fromJSON(jm["settings"]); + } MathInfo info; info.enabled = jm.value("enabled", true); info.math = op; @@ -492,7 +496,7 @@ double Trace::minX() if(lastMath->numSamples() > 0) { return lastMath->rData().front().x; } else { - return numeric_limits::quiet_NaN(); + return numeric_limits::max(); } } @@ -501,7 +505,7 @@ double Trace::maxX() if(lastMath->numSamples() > 0) { return lastMath->rData().back().x; } else { - return numeric_limits::quiet_NaN(); + return numeric_limits::lowest(); } } diff --git a/Software/PC_Application/Traces/tracemarker.cpp b/Software/PC_Application/Traces/tracemarker.cpp index dc2eed6..20307bb 100644 --- a/Software/PC_Application/Traces/tracemarker.cpp +++ b/Software/PC_Application/Traces/tracemarker.cpp @@ -74,6 +74,12 @@ Trace *TraceMarker::trace() QString TraceMarker::readableData() { + if(!parentTrace) { + return ""; + } + if(position < parentTrace->minX() || position > parentTrace->maxX()) { + return ""; + } if(isTimeDomain()) { switch(type) { case Type::Manual: {