Fix warning and valgrind issues
This commit is contained in:
parent
1a779531ea
commit
d08388f903
@ -790,7 +790,7 @@ bool Calibration::openFromFile(QString filename)
|
|||||||
qDebug() << "Associated calibration kit expected in" << calkit_file;
|
qDebug() << "Associated calibration kit expected in" << calkit_file;
|
||||||
try {
|
try {
|
||||||
kit = Calkit::fromFile(calkit_file);
|
kit = Calkit::fromFile(calkit_file);
|
||||||
} catch (runtime_error e) {
|
} catch (runtime_error &e) {
|
||||||
InformationBox::ShowError("Missing calibration kit", "The calibration kit file associated with the selected calibration could not be parsed. The calibration might not be accurate. (" + QString(e.what()) + ")");
|
InformationBox::ShowError("Missing calibration kit", "The calibration kit file associated with the selected calibration could not be parsed. The calibration might not be accurate. (" + QString(e.what()) + ")");
|
||||||
qWarning() << "Parsing of calibration kit failed while opening calibration file: " << e.what();
|
qWarning() << "Parsing of calibration kit failed while opening calibration file: " << e.what();
|
||||||
}
|
}
|
||||||
@ -809,7 +809,7 @@ bool Calibration::openFromFile(QString filename)
|
|||||||
nlohmann::json j;
|
nlohmann::json j;
|
||||||
file >> j;
|
file >> j;
|
||||||
fromJSON(j);
|
fromJSON(j);
|
||||||
} catch(exception e) {
|
} catch(exception &e) {
|
||||||
// json parsing failed, probably using a legacy file format
|
// json parsing failed, probably using a legacy file format
|
||||||
try {
|
try {
|
||||||
file.clear();
|
file.clear();
|
||||||
@ -818,7 +818,7 @@ bool Calibration::openFromFile(QString filename)
|
|||||||
InformationBox::ShowMessage("Loading calibration file", "The file \"" + filename + "\" is stored in a deprecated"
|
InformationBox::ShowMessage("Loading calibration file", "The file \"" + filename + "\" is stored in a deprecated"
|
||||||
" calibration format. Future versions of this application might not support"
|
" calibration format. Future versions of this application might not support"
|
||||||
" it anymore. Please save the calibration to update to the new format");
|
" it anymore. Please save the calibration to update to the new format");
|
||||||
} catch(exception e) {
|
} catch(exception &e) {
|
||||||
InformationBox::ShowError("File parsing error", e.what());
|
InformationBox::ShowError("File parsing error", e.what());
|
||||||
qWarning() << "Calibration file parsing failed: " << e.what();
|
qWarning() << "Calibration file parsing failed: " << e.what();
|
||||||
return false;
|
return false;
|
||||||
|
@ -13,6 +13,7 @@ class Calkit
|
|||||||
friend class CalkitDialog;
|
friend class CalkitDialog;
|
||||||
public:
|
public:
|
||||||
Calkit();
|
Calkit();
|
||||||
|
Calkit(const Calkit&) = default;
|
||||||
Calkit& operator=(const Calkit& other)
|
Calkit& operator=(const Calkit& other)
|
||||||
{
|
{
|
||||||
this->manufacturer = other.manufacturer;
|
this->manufacturer = other.manufacturer;
|
||||||
|
@ -195,7 +195,7 @@ CalkitDialog::CalkitDialog(Calkit &c, QWidget *parent) :
|
|||||||
if(filename.length() > 0) {
|
if(filename.length() > 0) {
|
||||||
try {
|
try {
|
||||||
ownKit = Calkit::fromFile(filename);
|
ownKit = Calkit::fromFile(filename);
|
||||||
} catch (runtime_error e) {
|
} catch (runtime_error &e) {
|
||||||
InformationBox::ShowError("Error", "The calibration kit file could not be parsed (" + QString(e.what()) + ")");
|
InformationBox::ShowError("Error", "The calibration kit file could not be parsed (" + QString(e.what()) + ")");
|
||||||
qWarning() << "Parsing of calibration kit failed while opening calibration file: " << e.what();
|
qWarning() << "Parsing of calibration kit failed while opening calibration file: " << e.what();
|
||||||
}
|
}
|
||||||
|
@ -113,12 +113,11 @@ QVariant JSONModel::data(const QModelIndex &index, int role) const
|
|||||||
case 0:
|
case 0:
|
||||||
return info.name;
|
return info.name;
|
||||||
case 1:
|
case 1:
|
||||||
if(item->is_object() || item->is_array()) {
|
if(!item->is_object() && !item->is_array()) {
|
||||||
return QVariant();
|
|
||||||
} else {
|
|
||||||
return info.data;
|
return info.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return QVariant();
|
||||||
case Qt::CheckStateRole: {
|
case Qt::CheckStateRole: {
|
||||||
if(index.column() == 0) {
|
if(index.column() == 0) {
|
||||||
return info.enabled ? Qt::Checked : Qt::Unchecked;
|
return info.enabled ? Qt::Checked : Qt::Unchecked;
|
||||||
|
@ -44,7 +44,7 @@ void TraceWidgetSA::importDialog()
|
|||||||
if(AppWindow::showGUI()) {
|
if(AppWindow::showGUI()) {
|
||||||
i->show();
|
i->show();
|
||||||
}
|
}
|
||||||
} catch(const std::exception e) {
|
} catch(const std::exception &e) {
|
||||||
InformationBox::ShowError("Failed to import file", QString("Attempt to import file ended with error: \"") + e.what()+"\"");
|
InformationBox::ShowError("Failed to import file", QString("Attempt to import file ended with error: \"") + e.what()+"\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ void ImpedanceMatchDialog::calculateMatch()
|
|||||||
ui->Image->setPixmap(QPixmap(":/icons/pCsC_small.png"));
|
ui->Image->setPixmap(QPixmap(":/icons/pCsC_small.png"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (exception e){
|
} catch (exception &e){
|
||||||
// something went wrong, probably caused by (intermediate) invalid input, such as f=0Hz
|
// something went wrong, probably caused by (intermediate) invalid input, such as f=0Hz
|
||||||
ui->lValue->setValue(nan(""));
|
ui->lValue->setValue(nan(""));
|
||||||
ui->cValue->setValue(nan(""));
|
ui->cValue->setValue(nan(""));
|
||||||
|
@ -81,6 +81,11 @@ static void createLogarithmicTicks(vector<double>& ticks, double start, double s
|
|||||||
} while(div <= stop);
|
} while(div <= stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
YAxis::YAxis()
|
||||||
|
{
|
||||||
|
type = Type::Magnitude;
|
||||||
|
}
|
||||||
|
|
||||||
double YAxis::sampleToCoordinate(Trace::Data data, Trace *t, unsigned int sample)
|
double YAxis::sampleToCoordinate(Trace::Data data, Trace *t, unsigned int sample)
|
||||||
{
|
{
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@ -246,7 +251,7 @@ QString YAxis::Unit(Type type, TraceModel::DataSource source)
|
|||||||
case Type::Reactance: return "Ω";
|
case Type::Reactance: return "Ω";
|
||||||
case Type::Capacitance: return "F";
|
case Type::Capacitance: return "F";
|
||||||
case Type::Inductance: return "H";
|
case Type::Inductance: return "H";
|
||||||
case Type::Last: return "";
|
default: return "";
|
||||||
}
|
}
|
||||||
} else if(source == TraceModel::DataSource::SA) {
|
} else if(source == TraceModel::DataSource::SA) {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@ -280,7 +285,7 @@ QString YAxis::Prefixes(Type type, TraceModel::DataSource source)
|
|||||||
case Type::Reactance: return "m kM";
|
case Type::Reactance: return "m kM";
|
||||||
case Type::Capacitance: return "pnum ";
|
case Type::Capacitance: return "pnum ";
|
||||||
case Type::Inductance: return "pnum ";
|
case Type::Inductance: return "pnum ";
|
||||||
case Type::Last: return " ";
|
default: return " ";
|
||||||
}
|
}
|
||||||
} else if(source == TraceModel::DataSource::SA) {
|
} else if(source == TraceModel::DataSource::SA) {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@ -358,8 +363,14 @@ bool Axis::getLog() const
|
|||||||
return log;
|
return log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XAxis::XAxis()
|
||||||
|
{
|
||||||
|
type = Type::Frequency;
|
||||||
|
}
|
||||||
|
|
||||||
double XAxis::sampleToCoordinate(Trace::Data data, Trace *t, unsigned int sample)
|
double XAxis::sampleToCoordinate(Trace::Data data, Trace *t, unsigned int sample)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(sample)
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case Type::Distance:
|
case Type::Distance:
|
||||||
if(!t) {
|
if(!t) {
|
||||||
@ -430,6 +441,16 @@ XAxis::Type XAxis::getType() const
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Axis::Axis()
|
||||||
|
{
|
||||||
|
log = false;
|
||||||
|
autorange = true;
|
||||||
|
rangeMin = -1.0;
|
||||||
|
rangeMax = 1.0;
|
||||||
|
rangeDiv = 1.0;
|
||||||
|
ticks.clear();
|
||||||
|
}
|
||||||
|
|
||||||
double Axis::transform(double value, double to_low, double to_high)
|
double Axis::transform(double value, double to_low, double to_high)
|
||||||
{
|
{
|
||||||
return Util::Scale(value, rangeMin, rangeMax, to_low, to_high, log);
|
return Util::Scale(value, rangeMin, rangeMax, to_low, to_high, log);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
class Axis {
|
class Axis {
|
||||||
public:
|
public:
|
||||||
|
Axis();
|
||||||
virtual double sampleToCoordinate(Trace::Data data, Trace *t = nullptr, unsigned int sample = 0) = 0;
|
virtual double sampleToCoordinate(Trace::Data data, Trace *t = nullptr, unsigned int sample = 0) = 0;
|
||||||
double transform(double value, double to_low, double to_high);
|
double transform(double value, double to_low, double to_high);
|
||||||
double inverseTransform(double value, double to_low, double to_high);
|
double inverseTransform(double value, double to_low, double to_high);
|
||||||
@ -55,6 +56,7 @@ public:
|
|||||||
Impedance,
|
Impedance,
|
||||||
Last,
|
Last,
|
||||||
};
|
};
|
||||||
|
YAxis();
|
||||||
double sampleToCoordinate(Trace::Data data, Trace *t = nullptr, unsigned int sample = 0) override;
|
double sampleToCoordinate(Trace::Data data, Trace *t = nullptr, unsigned int sample = 0) override;
|
||||||
void set(Type type, bool log, bool autorange, double min, double max, double div);
|
void set(Type type, bool log, bool autorange, double min, double max, double div);
|
||||||
static QString TypeToName(Type type);
|
static QString TypeToName(Type type);
|
||||||
@ -80,6 +82,7 @@ public:
|
|||||||
Power,
|
Power,
|
||||||
Last,
|
Last,
|
||||||
};
|
};
|
||||||
|
XAxis();
|
||||||
double sampleToCoordinate(Trace::Data data, Trace *t = nullptr, unsigned int sample = 0) override;
|
double sampleToCoordinate(Trace::Data data, Trace *t = nullptr, unsigned int sample = 0) override;
|
||||||
void set(Type type, bool log, bool autorange, double min, double max, double div);
|
void set(Type type, bool log, bool autorange, double min, double max, double div);
|
||||||
static QString TypeToName(Type type);
|
static QString TypeToName(Type type);
|
||||||
|
@ -20,6 +20,7 @@ TraceSmithChart::TraceSmithChart(TraceModel &model, QWidget *parent)
|
|||||||
: TracePlot(model, parent)
|
: TracePlot(model, parent)
|
||||||
{
|
{
|
||||||
limitToSpan = true;
|
limitToSpan = true;
|
||||||
|
limitToEdge = true;
|
||||||
edgeReflection = 1.0;
|
edgeReflection = 1.0;
|
||||||
initializeTraceInfo();
|
initializeTraceInfo();
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,11 @@ TraceWaterfall::TraceWaterfall(TraceModel &model, QWidget *parent)
|
|||||||
keepDataBeyondPlotSize(false),
|
keepDataBeyondPlotSize(false),
|
||||||
maxDataSweeps(500)
|
maxDataSweeps(500)
|
||||||
{
|
{
|
||||||
|
plotAreaTop = 0;
|
||||||
|
plotAreaLeft = 0;
|
||||||
|
plotAreaWidth = 0;
|
||||||
|
plotAreaBottom = 0;
|
||||||
|
|
||||||
xAxis.set(XAxis::Type::Frequency, false, true, 0, 6000000000, 500000000);
|
xAxis.set(XAxis::Type::Frequency, false, true, 0, 6000000000, 500000000);
|
||||||
yAxis.set(YAxis::Type::Magnitude, false, true, -1, 1, 1);
|
yAxis.set(YAxis::Type::Magnitude, false, true, -1, 1, 1);
|
||||||
initializeTraceInfo();
|
initializeTraceInfo();
|
||||||
@ -478,7 +483,7 @@ double TraceWaterfall::nearestTracePoint(Trace *t, QPoint pixel, double *distanc
|
|||||||
QString TraceWaterfall::mouseText(QPoint pos)
|
QString TraceWaterfall::mouseText(QPoint pos)
|
||||||
{
|
{
|
||||||
QString ret;
|
QString ret;
|
||||||
if(QRect(plotAreaLeft, 0, plotAreaWidth + 1, plotAreaBottom).contains(pos)) {
|
if(QRect(plotAreaLeft, plotAreaTop, plotAreaWidth + 1, plotAreaBottom).contains(pos)) {
|
||||||
double x = xAxis.inverseTransform(pos.x(), plotAreaLeft, plotAreaLeft + plotAreaWidth);
|
double x = xAxis.inverseTransform(pos.x(), plotAreaLeft, plotAreaLeft + plotAreaWidth);
|
||||||
int significantDigits = floor(log10(abs(xAxis.getRangeMax()))) - floor(log10((abs(xAxis.getRangeMax() - xAxis.getRangeMin())) / 1000.0)) + 1;
|
int significantDigits = floor(log10(abs(xAxis.getRangeMax()))) - floor(log10((abs(xAxis.getRangeMax() - xAxis.getRangeMin())) / 1000.0)) + 1;
|
||||||
ret += Unit::ToString(x, xAxis.Unit(), "fpnum kMG", significantDigits) + "\n";
|
ret += Unit::ToString(x, xAxis.Unit(), "fpnum kMG", significantDigits) + "\n";
|
||||||
|
@ -757,7 +757,7 @@ void VNA::fromJSON(nlohmann::json j)
|
|||||||
EnableDeembedding(false);
|
EnableDeembedding(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sweep configuration has to go last sog graphs can catch events from changed sweep
|
// sweep configuration has to go last so graphs can catch events from changed sweep
|
||||||
if(j.contains("sweep")) {
|
if(j.contains("sweep")) {
|
||||||
auto sweep = j["sweep"];
|
auto sweep = j["sweep"];
|
||||||
// restore sweep settings, keep current value as default in case of missing entry
|
// restore sweep settings, keep current value as default in case of missing entry
|
||||||
@ -882,7 +882,7 @@ void VNA::SettingsChanged(bool resetTraces, std::function<void (Device::Transmis
|
|||||||
}
|
}
|
||||||
changingSettings = true;
|
changingSettings = true;
|
||||||
// assemble VNA protocol settings
|
// assemble VNA protocol settings
|
||||||
Protocol::SweepSettings s;
|
Protocol::SweepSettings s = {};
|
||||||
s.suppressPeaks = Preferences::getInstance().Acquisition.suppressPeaks ? 1 : 0;
|
s.suppressPeaks = Preferences::getInstance().Acquisition.suppressPeaks ? 1 : 0;
|
||||||
if(Preferences::getInstance().Acquisition.alwaysExciteBothPorts) {
|
if(Preferences::getInstance().Acquisition.alwaysExciteBothPorts) {
|
||||||
s.excitePort1 = 1;
|
s.excitePort1 = 1;
|
||||||
@ -1102,7 +1102,7 @@ void VNA::SetPowerSweepFrequency(double freq)
|
|||||||
|
|
||||||
void VNA::SetPoints(unsigned int points)
|
void VNA::SetPoints(unsigned int points)
|
||||||
{
|
{
|
||||||
auto maxPoints = Preferences::getInstance().Acquisition.allowSegmentedSweep ? UINT16_MAX : Device::Info().limits_maxPoints;
|
unsigned int maxPoints = Preferences::getInstance().Acquisition.allowSegmentedSweep ? UINT16_MAX : Device::Info().limits_maxPoints;
|
||||||
if(points > maxPoints) {
|
if(points > maxPoints) {
|
||||||
points = maxPoints;
|
points = maxPoints;
|
||||||
} else if (points < 2) {
|
} else if (points < 2) {
|
||||||
@ -1176,7 +1176,7 @@ void VNA::ApplyCalibration(Calibration::Type type)
|
|||||||
} else {
|
} else {
|
||||||
DisableCalibration(true);
|
DisableCalibration(true);
|
||||||
}
|
}
|
||||||
} catch (runtime_error e) {
|
} catch (runtime_error &e) {
|
||||||
InformationBox::ShowError("Calibration failure", e.what());
|
InformationBox::ShowError("Calibration failure", e.what());
|
||||||
DisableCalibration(true);
|
DisableCalibration(true);
|
||||||
}
|
}
|
||||||
@ -1196,8 +1196,7 @@ void VNA::ApplyCalibration(Calibration::Type type)
|
|||||||
|
|
||||||
void VNA::StartCalibrationMeasurements(std::set<Calibration::Measurement> m)
|
void VNA::StartCalibrationMeasurements(std::set<Calibration::Measurement> m)
|
||||||
{
|
{
|
||||||
auto device = window->getDevice();
|
if(!window->getDevice()) {
|
||||||
if(!device) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Stop sweep
|
// Stop sweep
|
||||||
|
@ -42,6 +42,12 @@ public:
|
|||||||
|
|
||||||
class Settings {
|
class Settings {
|
||||||
public:
|
public:
|
||||||
|
Settings()
|
||||||
|
: sweepType(SweepType::Frequency)
|
||||||
|
, Freq({.start=1000000, .stop=6000000000, .excitation_power=-10, .logSweep=false})
|
||||||
|
, Power({.start=-40, .stop=-10, .frequency=1000000000})
|
||||||
|
, npoints(501), bandwidth(1000), excitingPort1(true), excitingPort2(true)
|
||||||
|
, segments(1), activeSegment(0){}
|
||||||
SweepType sweepType;
|
SweepType sweepType;
|
||||||
struct {
|
struct {
|
||||||
double start;
|
double start;
|
||||||
|
Loading…
Reference in New Issue
Block a user