mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-21 06:13:41 +00:00
Updated graphs to use new math system
This commit is contained in:
parent
a7ff3d60fb
commit
49f9b5442d
16 changed files with 263 additions and 518 deletions
|
|
@ -23,7 +23,7 @@ TraceMath::DataType TDRLowpass::outputType(TraceMath::DataType inputType)
|
|||
|
||||
QString TDRLowpass::description()
|
||||
{
|
||||
return "TDR (bandpass mode)";
|
||||
return "TDR (lowpass mode)";
|
||||
}
|
||||
|
||||
void TDRLowpass::edit()
|
||||
|
|
@ -85,11 +85,13 @@ void TDRLowpass::inputSamplesChanged(unsigned int begin, unsigned int end)
|
|||
data[i].x = fs * i;
|
||||
data[i].y = frequencyDomain[i] / (double) fft_bins;
|
||||
}
|
||||
updateStepResponse(true);
|
||||
emit outputSamplesChanged(0, data.size());
|
||||
success();
|
||||
} else {
|
||||
// not enough input data
|
||||
data.clear();
|
||||
updateStepResponse(false);
|
||||
emit outputSamplesChanged(0, 0);
|
||||
warning("Not enough input samples");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,15 @@ TraceMath::Data TraceMath::getSample(unsigned int index)
|
|||
return data.at(index);
|
||||
}
|
||||
|
||||
double TraceMath::getStepResponse(unsigned int index)
|
||||
{
|
||||
if(stepResponse.size() > index) {
|
||||
return stepResponse[index];
|
||||
} else {
|
||||
return std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
}
|
||||
|
||||
TraceMath::Data TraceMath::getInterpolatedSample(double x)
|
||||
{
|
||||
Data ret;
|
||||
|
|
@ -120,6 +129,7 @@ void TraceMath::inputTypeChanged(TraceMath::DataType type)
|
|||
emit outputTypeChanged(dataType);
|
||||
if(dataType == DataType::Invalid) {
|
||||
error("Invalid input data");
|
||||
updateStepResponse(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -146,6 +156,20 @@ void TraceMath::success()
|
|||
}
|
||||
}
|
||||
|
||||
void TraceMath::updateStepResponse(bool valid)
|
||||
{
|
||||
if(valid) {
|
||||
stepResponse.resize(data.size());
|
||||
double accumulate = 0.0;
|
||||
for(unsigned int i=0;i<data.size();i++) {
|
||||
accumulate += data[i].y.real();
|
||||
stepResponse[i] = accumulate;
|
||||
}
|
||||
} else {
|
||||
stepResponse.clear();
|
||||
}
|
||||
}
|
||||
|
||||
QString TraceMath::getStatusDescription() const
|
||||
{
|
||||
return statusString;
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ public:
|
|||
static TypeInfo getInfo(Type type);
|
||||
|
||||
Data getSample(unsigned int index);
|
||||
double getStepResponse(unsigned int index);
|
||||
Data getInterpolatedSample(double x);
|
||||
unsigned int numSamples();
|
||||
|
||||
|
|
@ -115,6 +116,11 @@ protected:
|
|||
void error(QString err);
|
||||
void success();
|
||||
std::vector<Data> data;
|
||||
// buffer for time domain step response data. This makes it possible to access an arbitrary sample of the step response without having to
|
||||
// integrate the impulse response every time. Call updateStepResponse in your derived class, if step response data is valid after updating
|
||||
// data.
|
||||
std::vector<double> stepResponse;
|
||||
void updateStepResponse(bool valid);
|
||||
TraceMath *input;
|
||||
DataType dataType;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue