Bugfixes TDR

This commit is contained in:
Jan Käberich 2020-12-05 13:33:42 +01:00
parent 8d382e8b9c
commit 5ddc3d6794
5 changed files with 68 additions and 6 deletions

View File

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

View File

@ -4,6 +4,7 @@
#include "ui_tdrdialog.h"
#include <QVBoxLayout>
#include <QLabel>
#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;
}

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TDRExplanationWidget</class>
<widget class="QWidget" name="TDRExplanationWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>364</width>
<height>412</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="widget">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;TDR (IDFT)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This operation performs an inverse DFT on the frequency data, resulting in time domain data.&lt;/p&gt;&lt;p&gt;Two modes are available:&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;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.&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;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.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -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<double>::quiet_NaN();
return numeric_limits<double>::max();
}
}
@ -501,7 +505,7 @@ double Trace::maxX()
if(lastMath->numSamples() > 0) {
return lastMath->rData().back().x;
} else {
return numeric_limits<double>::quiet_NaN();
return numeric_limits<double>::lowest();
}
}

View File

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