mirror of
https://github.com/jankae/LibreVNA.git
synced 2025-12-06 07:12:10 +01:00
bugfixes from LibreCAL repo
This commit is contained in:
parent
6d6ffc60ea
commit
fc717a8f88
|
|
@ -177,7 +177,7 @@ void CalDevice::loadCoefficientSets(QStringList names, QList<int> ports, bool fa
|
||||||
coeffSets.clear();
|
coeffSets.clear();
|
||||||
|
|
||||||
if(ports.isEmpty()) {
|
if(ports.isEmpty()) {
|
||||||
for(int i=1;i<=ports.size();i++) {
|
for(unsigned int i=1;i<=getNumPorts();i++) {
|
||||||
ports.append(i);
|
ports.append(i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -331,7 +331,7 @@ void CalDevice::loadCoefficientSetsThreadFast(QStringList names, QList<int> port
|
||||||
coeffList = names;
|
coeffList = names;
|
||||||
}
|
}
|
||||||
|
|
||||||
int total_coeffs = (ports.size() * 3 + ports.size() * (ports.size() - 1) / 2) * names.size();
|
int total_coeffs = (ports.size() * 3 + ports.size() * (ports.size() - 1) / 2) * coeffList.size();
|
||||||
int read_coeffs = 0;
|
int read_coeffs = 0;
|
||||||
|
|
||||||
for(auto name : coeffList) {
|
for(auto name : coeffList) {
|
||||||
|
|
@ -538,6 +538,15 @@ void CalDevice::saveCoefficientSetsThread()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// prune empty coefficient sets
|
||||||
|
auto i = coeffSets.begin();
|
||||||
|
while(i != coeffSets.end()) {
|
||||||
|
if(i->isEmpty()) {
|
||||||
|
i = coeffSets.erase(i);
|
||||||
|
} else {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
emit updateCoefficientsDone(success);
|
emit updateCoefficientsDone(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -551,10 +560,7 @@ void CalDevice::addCoefficientSet(QString name)
|
||||||
CoefficientSet set;
|
CoefficientSet set;
|
||||||
set.name = name;
|
set.name = name;
|
||||||
set.ports = numPorts;
|
set.ports = numPorts;
|
||||||
set.loads.clear();
|
set.createEmptyCoefficients();
|
||||||
set.shorts.clear();
|
|
||||||
set.opens.clear();
|
|
||||||
set.throughs.clear();
|
|
||||||
coeffSets.push_back(set);
|
coeffSets.push_back(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -650,3 +656,45 @@ void CalDevice::CoefficientSet::portsFromThroughIndex(int &port1, int &port2, in
|
||||||
port2 = -1;
|
port2 = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CalDevice::CoefficientSet::createEmptyCoefficients()
|
||||||
|
{
|
||||||
|
loads.clear();
|
||||||
|
shorts.clear();
|
||||||
|
opens.clear();
|
||||||
|
throughs.clear();
|
||||||
|
for(int i=1;i<=ports;i++) {
|
||||||
|
opens[i] = new Coefficient();
|
||||||
|
shorts[i] = new Coefficient();
|
||||||
|
loads[i] = new Coefficient();
|
||||||
|
for(int j=i+1;j<=ports;j++) {
|
||||||
|
throughs[portsToThroughIndex(i,j)] = new Coefficient();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CalDevice::CoefficientSet::isEmpty()
|
||||||
|
{
|
||||||
|
for(auto o : opens) {
|
||||||
|
if(o.second->t.points() > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(auto s : shorts) {
|
||||||
|
if(s.second->t.points() > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(auto l : loads) {
|
||||||
|
if(l.second->t.points() > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(auto t : throughs) {
|
||||||
|
if(t.second->t.points() > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// no coefficients or all coefficients empty
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,9 @@ public:
|
||||||
|
|
||||||
int portsToThroughIndex(int port1, int port2);
|
int portsToThroughIndex(int port1, int port2);
|
||||||
void portsFromThroughIndex(int &port1, int &port2, int index);
|
void portsFromThroughIndex(int &port1, int &port2, int index);
|
||||||
|
|
||||||
|
void createEmptyCoefficients();
|
||||||
|
bool isEmpty();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extracts the coefficients from the device. This is done with a dedicated thread.
|
// Extracts the coefficients from the device. This is done with a dedicated thread.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue