SCPI API for querying the sweep cursor

This commit is contained in:
Jan Käberich 2025-12-02 11:22:54 +01:00
parent d0c8a1ae8e
commit 65bc247a65
6 changed files with 62 additions and 0 deletions

View file

@ -462,6 +462,21 @@ If single sweep is enabled, the acquisition is stopped when the required number
\item Issue the command again (i.e. VNA:ACQ:SINGLE TRUE always triggers a new sweep) \item Issue the command again (i.e. VNA:ACQ:SINGLE TRUE always triggers a new sweep)
\end{itemize} \end{itemize}
\subsubsection{VNA:ACQuisition:FREQuency}
\query{Returns the current frequency of the sweep}{VNA:ACQuisition:FREQuency?}{None}{<Frequency in Hz>}
This command only returns valid data when a sweep is running and the the sweep is a frequency sweep.
\subsubsection{VNA:ACQuisition:POWer}
\query{Returns the current power of the sweep}{VNA:ACQuisition:POWer?}{None}{<Power in dBm>}
This command only returns valid data when a sweep is running and the the sweep is a power sweep.
\subsubsection{VNA:ACQuisition:TIME}
\query{Returns the current time of the sweep}{VNA:ACQuisition:TIME?}{None}{<Time in seconds>}
This command only returns valid data when a sweep is running and the the sweep is a zero-span sweep.
\subsubsection{VNA:STIMulus:LVL} \subsubsection{VNA:STIMulus:LVL}
\event{Sets the output power of the stimulus signal when sweep type is frequency}{VNA:STIMulus:LVL}{<power>, in dBm} \event{Sets the output power of the stimulus signal when sweep type is frequency}{VNA:STIMulus:LVL}{<power>, in dBm}
\query{Queries the currently selected output power}{VNA:STIMulus:LVL?}{None}{power in dBm} \query{Queries the currently selected output power}{VNA:STIMulus:LVL?}{None}{power in dBm}
@ -783,6 +798,16 @@ If single sweep is enabled, the acquisition is stopped when the required number
\event{Enables/disables signal identification}{SA:ACQuisition:SIGid}{<enabled>, option are TRUE, FALSE, 1 or 0} \event{Enables/disables signal identification}{SA:ACQuisition:SIGid}{<enabled>, option are TRUE, FALSE, 1 or 0}
\query{Queries whether signal identification is enabled}{SA:ACQuisition:SIGid?}{None}{TRUE or FALSE} \query{Queries whether signal identification is enabled}{SA:ACQuisition:SIGid?}{None}{TRUE or FALSE}
\subsubsection{SA:ACQuisition:FREQuency}
\query{Returns the current frequency of the sweep}{SA:ACQuisition:FREQuency?}{None}{<Frequency in Hz>}
This command only returns valid data when a sweep is running and the the sweep is a frequency sweep.
\subsubsection{SA:ACQuisition:TIME}
\query{Returns the current time of the sweep}{SA:ACQuisition:TIME?}{None}{<Time in seconds>}
This command only returns valid data when a sweep is running and the the sweep is a zero-span sweep.
\subsubsection{SA:TRACKing:ENable} \subsubsection{SA:TRACKing:ENable}
\event{Enables/disables the tracking generator}{SA:TRACKing:ENable}{<enabled>, option are TRUE, FALSE, 1 or 0} \event{Enables/disables the tracking generator}{SA:TRACKing:ENable}{<enabled>, option are TRUE, FALSE, 1 or 0}
\query{Queries whether tracking generator is enabled}{SA:TRACKing:ENable?}{None}{TRUE or FALSE} \query{Queries whether tracking generator is enabled}{SA:TRACKing:ENable?}{None}{TRUE or FALSE}

View file

@ -64,6 +64,9 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window, QString name)
normalize.measure = nullptr; normalize.measure = nullptr;
normalize.enable = nullptr; normalize.enable = nullptr;
lastFreq = 0.0;
lastTime = 0.0;
configurationTimer.setSingleShot(true); configurationTimer.setSingleShot(true);
connect(&configurationTimer, &QTimer::timeout, this, [=](){ connect(&configurationTimer, &QTimer::timeout, this, [=](){
ConfigureDevice(); ConfigureDevice();
@ -584,6 +587,9 @@ void SpectrumAnalyzer::NewDatapoint(DeviceDriver::SAMeasurement m)
qWarning() << "Got point" << m_avg.pointNum << "but last received point was" << lastPoint << "("<<(m_avg.pointNum-lastPoint-1)<<"missed points)"; qWarning() << "Got point" << m_avg.pointNum << "but last received point was" << lastPoint << "("<<(m_avg.pointNum-lastPoint-1)<<"missed points)";
} }
lastPoint = m_avg.pointNum; lastPoint = m_avg.pointNum;
lastFreq = m_avg.frequency;
lastTime = (double) m_avg.us / 1000000;
} }
void SpectrumAnalyzer::SettingsChanged() void SpectrumAnalyzer::SettingsChanged()
@ -1102,6 +1108,12 @@ void SpectrumAnalyzer::SetupSCPI()
}, [=](QStringList) -> QString { }, [=](QStringList) -> QString {
return singleSweep ? SCPI::getResultName(SCPI::Result::True): SCPI::getResultName(SCPI::Result::False); return singleSweep ? SCPI::getResultName(SCPI::Result::True): SCPI::getResultName(SCPI::Result::False);
})); }));
scpi_acq->add(new SCPICommand("FREQuency", nullptr, [=](QStringList) -> QString {
return QString::number(lastFreq);
}));
scpi_acq->add(new SCPICommand("TIME", nullptr, [=](QStringList) -> QString {
return QString::number(lastTime);
}));
auto scpi_tg = new SCPINode("TRACKing"); auto scpi_tg = new SCPINode("TRACKing");
SCPINode::add(scpi_tg); SCPINode::add(scpi_tg);
scpi_tg->add(new SCPICommand("ENable", [=](QStringList params) -> QString { scpi_tg->add(new SCPICommand("ENable", [=](QStringList params) -> QString {

View file

@ -132,6 +132,10 @@ private:
QList<QAction*> importActions; QList<QAction*> importActions;
QList<QAction*> exportActions; QList<QAction*> exportActions;
// meta data from the last received datapoint
double lastFreq;
double lastTime;
signals: signals:
void dataChanged(); void dataChanged();
void startFreqChanged(double freq); void startFreqChanged(double freq);

View file

@ -69,6 +69,10 @@ VNA::VNA(AppWindow *window, QString name)
calWaitFirst = false; calWaitFirst = false;
calDialog = nullptr; calDialog = nullptr;
lastFreq = 0.0;
lastPower = 0.0;
lastTime = 0.0;
changingSettings = false; changingSettings = false;
settings.sweepType = SweepType::Frequency; settings.sweepType = SweepType::Frequency;
settings.zerospan = false; settings.zerospan = false;
@ -1015,6 +1019,10 @@ void VNA::NewDatapoint(DeviceDriver::VNAMeasurement m)
} }
} }
lastFreq = m_avg.frequency;
lastPower = m_avg.dBm;
lastTime = (double) m_avg.us / 1000000;
window->addStreamingData(m_avg, AppWindow::VNADataType::Raw, settings.zerospan); window->addStreamingData(m_avg, AppWindow::VNADataType::Raw, settings.zerospan);
if(average.settled()) { if(average.settled()) {
@ -1592,6 +1600,15 @@ void VNA::SetupSCPI()
}, [=](QStringList) -> QString { }, [=](QStringList) -> QString {
return singleSweep ? SCPI::getResultName(SCPI::Result::True) : SCPI::getResultName(SCPI::Result::False); return singleSweep ? SCPI::getResultName(SCPI::Result::True) : SCPI::getResultName(SCPI::Result::False);
})); }));
scpi_acq->add(new SCPICommand("FREQuency", nullptr, [=](QStringList) -> QString {
return QString::number(lastFreq);
}));
scpi_acq->add(new SCPICommand("POWer", nullptr, [=](QStringList) -> QString {
return QString::number(lastPower);
}));
scpi_acq->add(new SCPICommand("TIME", nullptr, [=](QStringList) -> QString {
return QString::number(lastTime);
}));
auto scpi_stim = new SCPINode("STIMulus"); auto scpi_stim = new SCPINode("STIMulus");
SCPINode::add(scpi_stim); SCPINode::add(scpi_stim);
scpi_stim->add(new SCPICommand("LVL", [=](QStringList params) -> QString { scpi_stim->add(new SCPICommand("LVL", [=](QStringList params) -> QString {

View file

@ -201,6 +201,10 @@ private:
// Statistics for detecting missing points and sweep time // Statistics for detecting missing points and sweep time
QDateTime lastStart; QDateTime lastStart;
int lastPoint; int lastPoint;
// meta data from the last received datapoint
double lastFreq;
double lastPower;
double lastTime;
signals: signals:
void deviceInitialized(); void deviceInitialized();