mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-04 14:07:30 +00:00
Document and fix deembedding SCPI API
This commit is contained in:
parent
3aac724298
commit
da1228c9b1
7 changed files with 181 additions and 8 deletions
|
|
@ -127,6 +127,31 @@ Deembedding::Deembedding(TraceModel &tm)
|
|||
addOption(option);
|
||||
return SCPI::getResultName(SCPI::Result::Empty);
|
||||
}, nullptr));
|
||||
add(new SCPICommand("DELete", [=](QStringList params) -> QString {
|
||||
unsigned long long index;
|
||||
if(!SCPI::paramToULongLong(params, 0, index)) {
|
||||
return SCPI::getResultName(SCPI::Result::Error);
|
||||
}
|
||||
if(index < 1 || index > options.size()) {
|
||||
return SCPI::getResultName(SCPI::Result::Error);
|
||||
}
|
||||
removeOption(index-1);
|
||||
return SCPI::getResultName(SCPI::Result::Empty);
|
||||
}, nullptr));
|
||||
add(new SCPICommand("SWAP", [=](QStringList params) -> QString {
|
||||
unsigned long long index1, index2;
|
||||
if(!SCPI::paramToULongLong(params, 0, index1)) {
|
||||
return SCPI::getResultName(SCPI::Result::Error);
|
||||
}
|
||||
if(!SCPI::paramToULongLong(params, 1, index2)) {
|
||||
return SCPI::getResultName(SCPI::Result::Error);
|
||||
}
|
||||
if(index1 < 1 || index1 > options.size() || index2 < 1 || index2 > options.size()) {
|
||||
return SCPI::getResultName(SCPI::Result::Error);
|
||||
}
|
||||
swapOptions(index1-1, index2-1);
|
||||
return SCPI::getResultName(SCPI::Result::Empty);
|
||||
}, nullptr));
|
||||
add(new SCPICommand("CLEAR", [=](QStringList params) -> QString {
|
||||
Q_UNUSED(params);
|
||||
clear();
|
||||
|
|
@ -209,12 +234,12 @@ void Deembedding::addOption(DeembeddingOption *option)
|
|||
emit optionAdded();
|
||||
}
|
||||
|
||||
void Deembedding::swapOptions(unsigned int index)
|
||||
void Deembedding::swapOptions(unsigned int index1, unsigned int index2)
|
||||
{
|
||||
if(index + 1 >= options.size()) {
|
||||
if(index1 > options.size() || index2 > options.size() || index1 == index2) {
|
||||
return;
|
||||
}
|
||||
std::swap(options[index], options[index+1]);
|
||||
std::swap(options[index1], options[index2]);
|
||||
updateSCPINames();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public:
|
|||
|
||||
void removeOption(unsigned int index);
|
||||
void addOption(DeembeddingOption* option);
|
||||
void swapOptions(unsigned int index);
|
||||
void swapOptions(unsigned int index1, unsigned int index2);
|
||||
void clear();
|
||||
|
||||
bool isMeasuring();
|
||||
|
|
|
|||
|
|
@ -44,12 +44,12 @@ DeembeddingDialog::DeembeddingDialog(Deembedding *d, QWidget *parent) :
|
|||
});
|
||||
connect(ui->bMoveUp, &QPushButton::clicked, [=](){
|
||||
auto index = ui->view->currentIndex();
|
||||
d->swapOptions(index.row() - 1);
|
||||
d->swapOptions(index.row() - 1, index.row());
|
||||
ui->view->setCurrentIndex(index.sibling(index.row() - 1, 0));
|
||||
});
|
||||
connect(ui->bMoveDown, &QPushButton::clicked, [=](){
|
||||
auto index = ui->view->currentIndex();
|
||||
d->swapOptions(index.row());
|
||||
d->swapOptions(index.row(), index.row() + 1);
|
||||
ui->view->setCurrentIndex(index.sibling(index.row() + 1, 0));
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,17 @@ MatchingNetwork::MatchingNetwork()
|
|||
addComponent(index, c);
|
||||
return SCPI::getResultName(SCPI::Result::Empty);
|
||||
}, nullptr));
|
||||
add(new SCPICommand("DELete", [=](QStringList params) -> QString {
|
||||
unsigned long long index;
|
||||
if(!SCPI::paramToULongLong(params, 0, index)) {
|
||||
return SCPI::getResultName(SCPI::Result::Error);
|
||||
}
|
||||
if(index < 1 || index > network.size()) {
|
||||
return SCPI::getResultName(SCPI::Result::Error);
|
||||
}
|
||||
removeComponent(index-1);
|
||||
return SCPI::getResultName(SCPI::Result::Empty);
|
||||
}, nullptr));
|
||||
add(new SCPICommand("TYPE", nullptr, [=](QStringList params) -> QString {
|
||||
unsigned long long index = 0;
|
||||
if(!SCPI::paramToULongLong(params, 0, index)) {
|
||||
|
|
@ -267,6 +278,7 @@ void MatchingNetwork::fromJSON(nlohmann::json j)
|
|||
}
|
||||
addNetwork = j.value("addNetwork", true);
|
||||
matching.clear();
|
||||
updateSCPINames();
|
||||
}
|
||||
|
||||
void MatchingNetwork::clearNetwork()
|
||||
|
|
@ -643,7 +655,7 @@ MatchingComponent::MatchingComponent(Type type)
|
|||
// failed to load file
|
||||
return SCPI::getResultName(SCPI::Result::Error);
|
||||
}
|
||||
}, nullptr));
|
||||
}, nullptr, false));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -787,6 +799,7 @@ void MatchingComponent::updateTouchstoneLabel()
|
|||
return;
|
||||
}
|
||||
QFont font = touchstoneLabel->font();
|
||||
touchstoneLabel->setStyleSheet("color: black");
|
||||
font.setPointSize(10);
|
||||
touchstoneLabel->setFont(font);
|
||||
if(touchstone->points() == 0) {
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ bool SCPINode::addDoubleParameter(QString name, double ¶m, bool gettable, bo
|
|||
return SCPI::getResultName(SCPI::Result::Error);
|
||||
}
|
||||
} : (std::function<QString(QStringList)>) nullptr;
|
||||
auto query = gettable ? [=](QStringList params) -> QString {
|
||||
auto query = gettable ? [¶m](QStringList params) -> QString {
|
||||
Q_UNUSED(params)
|
||||
return QString::number(param);
|
||||
} : (std::function<QString(QStringList)>) nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue