mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-05 06:25:16 +00:00
Documentation of SCPI commands
This commit is contained in:
parent
438b62e06e
commit
aebe92111b
10 changed files with 687 additions and 18 deletions
|
|
@ -91,7 +91,7 @@ bool Calibration::constructErrorTerms(Calibration::Type type)
|
|||
case Type::FullSOLT: construct12TermPoints(); break;
|
||||
case Type::TransmissionNormalization: constructTransmissionNormalization(); break;
|
||||
case Type::TRL: constructTRL(); break;
|
||||
case Type::None: break;
|
||||
default: break;
|
||||
}
|
||||
this->type = type;
|
||||
return true;
|
||||
|
|
@ -430,6 +430,17 @@ Calibration::InterpolationType Calibration::getInterpolation(Protocol::SweepSett
|
|||
}
|
||||
}
|
||||
|
||||
Calibration::Measurement Calibration::MeasurementFromString(QString s)
|
||||
{
|
||||
for(unsigned int i=0;i<(int)Measurement::Last;i++) {
|
||||
auto m = (Measurement) i;
|
||||
if(s.compare(MeasurementToString(m), Qt::CaseInsensitive)==0) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return Measurement::Last;
|
||||
}
|
||||
|
||||
QString Calibration::MeasurementToString(Calibration::Measurement m)
|
||||
{
|
||||
switch(m) {
|
||||
|
|
@ -456,6 +467,17 @@ QString Calibration::MeasurementToString(Calibration::Measurement m)
|
|||
}
|
||||
}
|
||||
|
||||
Calibration::Type Calibration::TypeFromString(QString s)
|
||||
{
|
||||
for(unsigned int i=0;i<(int)Type::Last;i++) {
|
||||
auto t = (Type) i;
|
||||
if(s.compare(TypeToString(t), Qt::CaseInsensitive)==0) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return Type::Last;
|
||||
}
|
||||
|
||||
QString Calibration::TypeToString(Calibration::Type t)
|
||||
{
|
||||
switch(t) {
|
||||
|
|
@ -551,6 +573,10 @@ Calibration::MeasurementInfo Calibration::getMeasurementInfo(Calibration::Measur
|
|||
info.name = "Line";
|
||||
info.prerequisites = "Port 1 connected to port 2 via line standard";
|
||||
break;
|
||||
default:
|
||||
info.name = "Invalid";
|
||||
info.prerequisites = "Invalid";
|
||||
break;
|
||||
}
|
||||
info.points = measurements[m].datapoints.size();
|
||||
if(info.points > 0) {
|
||||
|
|
@ -620,6 +646,8 @@ std::vector<Trace *> Calibration::getMeasurementTraces()
|
|||
case Measurement::Isolation:
|
||||
usedPrefixes = {"S11", "S12", "S21", "S22"};
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
for(auto prefix : usedPrefixes) {
|
||||
auto t = new Trace(prefix + " " + info.name);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public:
|
|||
Isolation,
|
||||
Through,
|
||||
Line,
|
||||
Last,
|
||||
};
|
||||
void clearMeasurements();
|
||||
void clearMeasurement(Measurement type);
|
||||
|
|
@ -39,6 +40,7 @@ public:
|
|||
TransmissionNormalization,
|
||||
TRL,
|
||||
None,
|
||||
Last,
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -59,7 +61,9 @@ public:
|
|||
|
||||
InterpolationType getInterpolation(Protocol::SweepSettings settings);
|
||||
|
||||
static Measurement MeasurementFromString(QString s);
|
||||
static QString MeasurementToString(Measurement m);
|
||||
static Type TypeFromString(QString s);
|
||||
static QString TypeToString(Type t);
|
||||
|
||||
class MeasurementInfo {
|
||||
|
|
|
|||
|
|
@ -745,7 +745,7 @@ void SpectrumAnalyzer::SetupSCPI()
|
|||
default: return "ERROR";
|
||||
}
|
||||
}));
|
||||
scpi_acq->add(new SCPICommand("WINDow", [=](QStringList params) -> QString {
|
||||
scpi_acq->add(new SCPICommand("DETector", [=](QStringList params) -> QString {
|
||||
if (params.size() != 1) {
|
||||
return "ERROR";
|
||||
}
|
||||
|
|
@ -788,16 +788,16 @@ void SpectrumAnalyzer::SetupSCPI()
|
|||
if (params.size() != 1) {
|
||||
return "ERROR";
|
||||
}
|
||||
if(params[0] == "1" || params[0] == "ON") {
|
||||
if(params[0] == "1" || params[0] == "TRUE") {
|
||||
SetSignalID(true);
|
||||
} else if(params[0] == "0" || params[0] == "OFF") {
|
||||
} else if(params[0] == "0" || params[0] == "FALSE") {
|
||||
SetSignalID(false);
|
||||
} else {
|
||||
return "ERROR";
|
||||
}
|
||||
return "";
|
||||
}, [=](QStringList) -> QString {
|
||||
return settings.SignalID ? "1" : "0";
|
||||
return settings.SignalID ? "TRUE" : "FALSE";
|
||||
}));
|
||||
auto scpi_tg = new SCPINode("TRACKing");
|
||||
SCPINode::add(scpi_tg);
|
||||
|
|
@ -805,16 +805,16 @@ void SpectrumAnalyzer::SetupSCPI()
|
|||
if (params.size() != 1) {
|
||||
return "ERROR";
|
||||
}
|
||||
if(params[0] == "1" || params[0] == "ON") {
|
||||
if(params[0] == "1" || params[0] == "TRUE") {
|
||||
SetTGEnabled(true);
|
||||
} else if(params[0] == "0" || params[0] == "OFF") {
|
||||
} else if(params[0] == "0" || params[0] == "FALSE") {
|
||||
SetTGEnabled(false);
|
||||
} else {
|
||||
return "ERROR";
|
||||
}
|
||||
return "";
|
||||
}, [=](QStringList) -> QString {
|
||||
return settings.trackingGenerator ? "1" : "0";
|
||||
return settings.trackingGenerator ? "TRUE" : "FALSE";
|
||||
}));
|
||||
scpi_tg->add(new SCPICommand("Port", [=](QStringList params) -> QString {
|
||||
if (params.size() != 1) {
|
||||
|
|
@ -860,16 +860,16 @@ void SpectrumAnalyzer::SetupSCPI()
|
|||
if (params.size() != 1) {
|
||||
return "ERROR";
|
||||
}
|
||||
if(params[0] == "1" || params[0] == "ON") {
|
||||
if(params[0] == "1" || params[0] == "TRUE") {
|
||||
EnableNormalization(true);
|
||||
} else if(params[0] == "0" || params[0] == "OFF") {
|
||||
} else if(params[0] == "0" || params[0] == "FALSE") {
|
||||
EnableNormalization(false);
|
||||
} else {
|
||||
return "ERROR";
|
||||
}
|
||||
return "";
|
||||
}, [=](QStringList) -> QString {
|
||||
return normalize.active ? "1" : "0";
|
||||
return normalize.active ? "TRUE" : "FALSE";
|
||||
}));
|
||||
scpi_norm->add(new SCPICommand("MEASure", [=](QStringList params) -> QString {
|
||||
Q_UNUSED(params)
|
||||
|
|
|
|||
|
|
@ -981,6 +981,51 @@ void VNA::SetupSCPI()
|
|||
return QString::number(settings.cdbm_excitation / 100.0);
|
||||
}));
|
||||
SCPINode::add(traceWidget);
|
||||
auto scpi_cal = new SCPINode("CALibration");
|
||||
SCPINode::add(scpi_cal);
|
||||
scpi_cal->add(new SCPICommand("TYPE", [=](QStringList params) -> QString {
|
||||
if(params.size() != 1) {
|
||||
return "ERROR";
|
||||
} else {
|
||||
auto type = Calibration::TypeFromString(params[0].replace('_', ' '));
|
||||
if(type == Calibration::Type::Last) {
|
||||
// failed to parse string
|
||||
return "ERROR";
|
||||
} else if(type == Calibration::Type::None) {
|
||||
DisableCalibration();
|
||||
} else {
|
||||
// check if calibration can be activated
|
||||
if(cal.calculationPossible(type)) {
|
||||
ApplyCalibration(type);
|
||||
} else {
|
||||
return "ERROR";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}, [=](QStringList) -> QString {
|
||||
auto ret = Calibration::TypeToString(cal.getType());
|
||||
ret.replace(' ', '_');
|
||||
return ret;
|
||||
}));
|
||||
scpi_cal->add(new SCPICommand("MEASure", [=](QStringList params) -> QString {
|
||||
if(params.size() != 1 || CalibrationMeasurementActive() || !window->getDevice() || Mode::getActiveMode() != this) {
|
||||
// no measurement specified, still busy or invalid mode
|
||||
return "ERROR";
|
||||
} else {
|
||||
auto meas = Calibration::MeasurementFromString(params[0].replace('_', ' '));
|
||||
if(meas == Calibration::Measurement::Last) {
|
||||
// failed to parse string
|
||||
return "ERROR";
|
||||
} else {
|
||||
StartCalibrationMeasurement(meas);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}, nullptr));
|
||||
scpi_cal->add(new SCPICommand("BUSy", nullptr, [=](QStringList) -> QString {
|
||||
return CalibrationMeasurementActive() ? "TRUE" : "FALSE";
|
||||
}));
|
||||
}
|
||||
|
||||
void VNA::ConstrainAndUpdateFrequencies()
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ signals:
|
|||
void CalibrationMeasurementComplete(Calibration::Measurement m);
|
||||
|
||||
private:
|
||||
bool CalibrationMeasurementActive() { return calWaitFirst || calMeasuring; }
|
||||
void SetupSCPI();
|
||||
void UpdateAverageCount();
|
||||
void SettingsChanged(std::function<void (Device::TransmissionResult)> cb = nullptr);
|
||||
|
|
|
|||
|
|
@ -444,7 +444,7 @@ void AppWindow::SetupSCPI()
|
|||
default: return "ERROR";
|
||||
}
|
||||
}));
|
||||
scpi.add(new SCPICommand("MODE", [=](QStringList params) -> QString {
|
||||
scpi_dev->add(new SCPICommand("MODE", [=](QStringList params) -> QString {
|
||||
if (params.size() != 1) {
|
||||
return "ERROR";
|
||||
}
|
||||
|
|
@ -474,13 +474,13 @@ void AppWindow::SetupSCPI()
|
|||
scpi_dev->add(scpi_status);
|
||||
scpi_status->add(new SCPICommand("UNLOcked", nullptr, [=](QStringList){
|
||||
bool locked = Device::Info().source_locked && Device::Info().LO1_locked;
|
||||
return locked ? "0" : "1";
|
||||
return locked ? "FALSE" : "TRUE";
|
||||
}));
|
||||
scpi_status->add(new SCPICommand("ADCOVERload", nullptr, [=](QStringList){
|
||||
return Device::Info().ADC_overload ? "1" : "0";
|
||||
return Device::Info().ADC_overload ? "TRUE" : "FALSE";
|
||||
}));
|
||||
scpi_status->add(new SCPICommand("UNLEVel", nullptr, [=](QStringList){
|
||||
return Device::Info().unlevel ? "1" : "0";
|
||||
return Device::Info().unlevel ? "TRUE" : "FALSE";
|
||||
}));
|
||||
auto scpi_info = new SCPINode("INFo");
|
||||
scpi_dev->add(scpi_info);
|
||||
|
|
|
|||
|
|
@ -75,9 +75,7 @@ void SCPI::input(QString line)
|
|||
}
|
||||
cmd = cmd.toUpper();
|
||||
auto response = lastNode->parse(cmd, lastNode);
|
||||
if(!response.isEmpty()) {
|
||||
emit output(response);
|
||||
}
|
||||
emit output(response);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,6 +131,9 @@ void SCPINode::createCommandList(QString prefix, QString &list)
|
|||
|
||||
QString SCPINode::parse(QString cmd, SCPINode* &lastNode)
|
||||
{
|
||||
if(cmd.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
auto splitPos = cmd.indexOf(':');
|
||||
if(splitPos > 0) {
|
||||
// have not reached a leaf, find next subnode
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue