SCPI API for setting/reading calkit meta data

This commit is contained in:
Jan Käberich 2025-12-02 11:05:51 +01:00
parent 9923038d6c
commit d0c8a1ae8e
4 changed files with 64 additions and 1 deletions

View file

@ -601,6 +601,9 @@ If no de-embedding is configured for the selected trace, enabling the de-embeddi
\hspace{1cm}LOAD\\ \hspace{1cm}LOAD\\
\hspace{1cm}THROUGH\\ \hspace{1cm}THROUGH\\
\hspace{1cm}ISOLATION\\ \hspace{1cm}ISOLATION\\
\hspace{1cm}SLIDINGLOAD\\
\hspace{1cm}REFLECT\\
\hspace{1cm}LINE\\
{[<standard>]}, calibration kit standard name, optional\\} {[<standard>]}, calibration kit standard name, optional\\}
\subsubsection{VNA:CALibration:TYPE} \subsubsection{VNA:CALibration:TYPE}
@ -609,7 +612,10 @@ If no de-embedding is configured for the selected trace, enabling the de-embeddi
\hspace{1cm}SHORT\\ \hspace{1cm}SHORT\\
\hspace{1cm}LOAD\\ \hspace{1cm}LOAD\\
\hspace{1cm}THROUGH\\ \hspace{1cm}THROUGH\\
\hspace{1cm}ISOLATION\\} \hspace{1cm}ISOLATION\\
\hspace{1cm}SLIDINGLOAD\\
\hspace{1cm}REFLECT\\
\hspace{1cm}LINE\\}
\subsubsection{VNA:CALibration:PORT} \subsubsection{VNA:CALibration:PORT}
\event{Sets the port for the specified measurement}{VNA:CALibration:PORT}{<measurement number> <port number>} \event{Sets the port for the specified measurement}{VNA:CALibration:PORT}{<measurement number> <port number>}
@ -637,6 +643,23 @@ Important points when saving/loading calibration files through SCPI commands:
\subsubsection{VNA:CALibration:LOAD} \subsubsection{VNA:CALibration:LOAD}
\query{Loads a calibration file}{VNA:CALibration:LOAD?}{<filename>}{TRUE or FALSE} \query{Loads a calibration file}{VNA:CALibration:LOAD?}{<filename>}{TRUE or FALSE}
\subsubsection{VNA:CALibration:KIT:MANufacturer}
\event{Sets the manufacturer name of the calibration kit}{VNA:CALibration:KIT:MANufacturer}{<manufacturer>}
\query{Returns the manufacturer name of the calibration kit}{VNA:CALibration:KIT:MANufacturer?}{None}{<manufacturer>}
\subsubsection{VNA:CALibration:KIT:SERial}
\event{Sets the serial number of the calibration kit}{VNA:CALibration:KIT:SERial}{<serial number>}
\query{Returns the serial number of the calibration kit}{VNA:CALibration:KIT:SERial?}{None}{<serial number>}
\subsubsection{VNA:CALibration:KIT:DESCription}
\event{Sets the description of the calibration kit}{VNA:CALibration:KIT:DESCription}{<description>}
\query{Returns the description of the calibration kit}{VNA:CALibration:KIT:DESCription?}{None}{<description>}
\subsubsection{VNA:CALibration:KIT:FILEname}
\query{Returns the filename of the calibration kit}{VNA:CALibration:KIT:FILEname?}{None}{<filename>}
The filename is only available if the calibration kit was loaded from a dedicated file. If it was loaded as part of a calibration file or has not been loaded since the GUI started, no filename will be returned.
\subsubsection{VNA:CALibration:KIT:SAVE} \subsubsection{VNA:CALibration:KIT:SAVE}
\event{Saves the active calibration kit to a file}{VNA:CALibration:KIT:SAVE}{<filename>} \event{Saves the active calibration kit to a file}{VNA:CALibration:KIT:SAVE}{<filename>}
Important points when saving/loading calibration kit files through SCPI commands: Important points when saving/loading calibration kit files through SCPI commands:

View file

@ -19,10 +19,44 @@ Calkit::Calkit()
: SCPINode("KIT") : SCPINode("KIT")
{ {
// set default values // set default values
filename = "";
for(auto e : descr) { for(auto e : descr) {
e.var.setValue(e.def); e.var.setValue(e.def);
} }
add(new SCPICommand("MANufacturer", [=](QStringList params) -> QString {
if(params.size() != 1 ) {
// no new value given
return SCPI::getResultName(SCPI::Result::Error);
}
manufacturer = params[0];
return SCPI::getResultName(SCPI::Result::Empty);
}, [=](QStringList) -> QString {
return manufacturer;
}, false));
add(new SCPICommand("SERial", [=](QStringList params) -> QString {
if(params.size() != 1 ) {
// no new value given
return SCPI::getResultName(SCPI::Result::Error);
}
serialnumber = params[0];
return SCPI::getResultName(SCPI::Result::Empty);
}, [=](QStringList) -> QString {
return serialnumber;
}, false));
add(new SCPICommand("DESCription", [=](QStringList params) -> QString {
if(params.size() != 1 ) {
// no new value given
return SCPI::getResultName(SCPI::Result::Error);
}
description = params[0];
return SCPI::getResultName(SCPI::Result::Empty);
}, [=](QStringList) -> QString {
return description;
}, false));
add(new SCPICommand("FILEname", nullptr, [=](QStringList) -> QString {
return filename;
}));
add(new SCPICommand("SAVE", [=](QStringList params) -> QString { add(new SCPICommand("SAVE", [=](QStringList params) -> QString {
if(params.size() != 1 ) { if(params.size() != 1 ) {
// no filename given or no calibration active // no filename given or no calibration active
@ -57,6 +91,7 @@ void Calkit::toFile(QString filename)
file.open(filename.toStdString()); file.open(filename.toStdString());
file << setw(4) << toJSON() << endl; file << setw(4) << toJSON() << endl;
file.close(); file.close();
this->filename = filename;
} }
static QString readLine(ifstream &file) { static QString readLine(ifstream &file) {
@ -83,6 +118,7 @@ Calkit Calkit::fromFile(QString filename)
throw runtime_error("JSON parsing error: " + string(e.what())); throw runtime_error("JSON parsing error: " + string(e.what()));
} }
c.clearStandards(); c.clearStandards();
c.filename = "";
if(j.contains("standards")) { if(j.contains("standards")) {
qDebug() << "new JSON format detected"; qDebug() << "new JSON format detected";
c.fromJSON(j); c.fromJSON(j);
@ -345,6 +381,7 @@ Calkit Calkit::fromFile(QString filename)
} }
file.close(); file.close();
c.filename = filename;
return c; return c;
} }
@ -411,6 +448,7 @@ nlohmann::json Calkit::toJSON()
void Calkit::fromJSON(nlohmann::json j) void Calkit::fromJSON(nlohmann::json j)
{ {
clearStandards(); clearStandards();
filename = "";
Savable::parseJSON(j, descr); Savable::parseJSON(j, descr);
for(auto js : j["standards"]) { for(auto js : j["standards"]) {
if(!js.contains("type") || !js.contains("params")) { if(!js.contains("type") || !js.contains("params")) {

View file

@ -26,6 +26,7 @@ public:
this->serialnumber = other.serialnumber; this->serialnumber = other.serialnumber;
this->description = other.description; this->description = other.description;
this->standards = other.standards; this->standards = other.standards;
this->filename = other.filename;
return *this; return *this;
} }
@ -58,6 +59,7 @@ public:
private: private:
void clearStandards(); void clearStandards();
QString manufacturer, serialnumber, description; QString manufacturer, serialnumber, description;
QString filename;
std::vector<CalStandard::Virtual*> standards; std::vector<CalStandard::Virtual*> standards;
const std::vector<Savable::SettingDescription> descr = {{ const std::vector<Savable::SettingDescription> descr = {{