diff --git a/Documentation/UserManual/ProgrammingGuide.pdf b/Documentation/UserManual/ProgrammingGuide.pdf index 9d2243e..9ed0646 100644 Binary files a/Documentation/UserManual/ProgrammingGuide.pdf and b/Documentation/UserManual/ProgrammingGuide.pdf differ diff --git a/Documentation/UserManual/ProgrammingGuide.tex b/Documentation/UserManual/ProgrammingGuide.tex index a1dafed..ecc0fcf 100644 --- a/Documentation/UserManual/ProgrammingGuide.tex +++ b/Documentation/UserManual/ProgrammingGuide.tex @@ -1135,13 +1135,27 @@ There are a total of 5 streaming servers available. They can all be enabled and \vspace{0.5cm} -All servers output a newline-terminated line of json formatted data for each measurement point in the sweep: +All servers output a newline-terminated line of json formatted data for each measurement point in the sweep. The format of the output data changes depending on the configured sweep type. +\begin{itemize} +\item VNA frequency or power sweeps: \begin{example} {"Z0":50.0,"dBm":-20.0,"frequency":42993000.0,"measurements":{"S11_imag":-0.061379313997181856,"S11_real":0.023033630841401063,"S12_imag":0.3205479840477101,"S12_real":-0.5742283570681822,"S21_imag":-0.3746074656570865,"S21_real":0.6126114195570408,"S22_imag":0.06312766256272641,"S22_real":-0.018668561526968372},"pointNum":7} \end{example} +\item VNA zero span sweeps: +\begin{example} +{"Z0":50.0,"measurements":{"S11_imag":0.0697879786634009,"S11_real":0.11959939538177566,"S12_imag":-0.2820494760489866,"S12_real":0.4134518710922877,"S21_imag":0.11201366122663228,"S21_real":-0.4258244924547545,"S22_imag":-0.004193267854043776,"S22_real":0.028964823536021114},"pointNum":7,"time":2.438674} +\end{example} +\item Spectrum analyzer non zero span sweeps: \begin{example} {"frequency":2182396.0,"measurements":{"PORT1":7.343487141042715e-06,"PORT2":6.78117066854611e-06},"pointNum":445} \end{example} +\item Spectrum analyzer zero span sweeps: +\begin{example} +{"measurements":{"PORT1":2.595309979369631e-06,"PORT2":1.4385256008608849e-06},"pointNum":7,"time":0.344095} +\end{example} +\end{itemize} + +For zero span sweeps, the time in seconds since the beginning of the sweep is given instead of a frequency of power level. The time is always relative to point 0 of the current sweep and point 0 will have a time of 0. \end{document} diff --git a/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp b/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp index 7bbbd5d..6f28d66 100644 --- a/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp +++ b/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp @@ -538,7 +538,7 @@ void SpectrumAnalyzer::NewDatapoint(DeviceDriver::SAMeasurement m) } } - window->addStreamingData(m_avg, AppWindow::SADataType::Raw); + window->addStreamingData(m_avg, AppWindow::SADataType::Raw, settings.freqStart == settings.freqStop); if(normalize.measuring) { if(average.currentSweep() == averages) { @@ -569,7 +569,7 @@ void SpectrumAnalyzer::NewDatapoint(DeviceDriver::SAMeasurement m) m.second /= normalize.portCorrection[m.first][m_avg.pointNum]; m.second *= corr; } - window->addStreamingData(m_avg, AppWindow::SADataType::Normalized); + window->addStreamingData(m_avg, AppWindow::SADataType::Normalized, settings.freqStart == settings.freqStop); } diff --git a/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp b/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp index fa25d6c..1ed594e 100644 --- a/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp +++ b/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp @@ -981,7 +981,30 @@ void VNA::NewDatapoint(DeviceDriver::VNAMeasurement m) m_avg = average.process(m_avg); - window->addStreamingData(m_avg, AppWindow::VNADataType::Raw); + TraceMath::DataType type = TraceMath::DataType::Frequency; + if(settings.zerospan) { + type = TraceMath::DataType::TimeZeroSpan; + + // keep track of first point time + if(m_avg.pointNum == 0) { + settings.firstPointTime = m_avg.us; + m_avg.us = 0; + } else { + m_avg.us -= settings.firstPointTime; + } + } else { + switch(settings.sweepType) { + case SweepType::Last: + case SweepType::Frequency: + type = TraceMath::DataType::Frequency; + break; + case SweepType::Power: + type = TraceMath::DataType::Power; + break; + } + } + + window->addStreamingData(m_avg, AppWindow::VNADataType::Raw, settings.zerospan); if(average.settled()) { setOperationPending(false); @@ -1006,36 +1029,13 @@ void VNA::NewDatapoint(DeviceDriver::VNAMeasurement m) cal.correctMeasurement(m_avg); if(cal.getCaltype().type != Calibration::Type::None) { - window->addStreamingData(m_avg, AppWindow::VNADataType::Calibrated); - } - - TraceMath::DataType type = TraceMath::DataType::Frequency; - if(settings.zerospan) { - type = TraceMath::DataType::TimeZeroSpan; - - // keep track of first point time - if(m_avg.pointNum == 0) { - settings.firstPointTime = m_avg.us; - m_avg.us = 0; - } else { - m_avg.us -= settings.firstPointTime; - } - } else { - switch(settings.sweepType) { - case SweepType::Last: - case SweepType::Frequency: - type = TraceMath::DataType::Frequency; - break; - case SweepType::Power: - type = TraceMath::DataType::Power; - break; - } + window->addStreamingData(m_avg, AppWindow::VNADataType::Calibrated, settings.zerospan); } traceModel.addVNAData(m_avg, type, false); if(deembedding_active) { deembedding.Deembed(m_avg); - window->addStreamingData(m_avg, AppWindow::VNADataType::Deembedded); + window->addStreamingData(m_avg, AppWindow::VNADataType::Deembedded, settings.zerospan); traceModel.addVNAData(m_avg, type, true); } diff --git a/Software/PC_Application/LibreVNA-GUI/appwindow.cpp b/Software/PC_Application/LibreVNA-GUI/appwindow.cpp index efb8bae..1e4399d 100644 --- a/Software/PC_Application/LibreVNA-GUI/appwindow.cpp +++ b/Software/PC_Application/LibreVNA-GUI/appwindow.cpp @@ -866,7 +866,7 @@ SCPI* AppWindow::getSCPI() return &scpi; } -void AppWindow::addStreamingData(const DeviceDriver::VNAMeasurement &m, VNADataType type) +void AppWindow::addStreamingData(const DeviceDriver::VNAMeasurement &m, VNADataType type, bool is_zerospan) { StreamingServer *server = nullptr; switch(type) { @@ -876,11 +876,11 @@ void AppWindow::addStreamingData(const DeviceDriver::VNAMeasurement &m, VNADataT } if(server) { - server->addData(m); + server->addData(m, is_zerospan); } } -void AppWindow::addStreamingData(const DeviceDriver::SAMeasurement &m, SADataType type) +void AppWindow::addStreamingData(const DeviceDriver::SAMeasurement &m, SADataType type, bool is_zerospan) { StreamingServer *server = nullptr; switch(type) { @@ -889,7 +889,7 @@ void AppWindow::addStreamingData(const DeviceDriver::SAMeasurement &m, SADataTyp } if(server) { - server->addData(m); + server->addData(m, is_zerospan); } } diff --git a/Software/PC_Application/LibreVNA-GUI/appwindow.h b/Software/PC_Application/LibreVNA-GUI/appwindow.h index 71e5a18..4a0469b 100644 --- a/Software/PC_Application/LibreVNA-GUI/appwindow.h +++ b/Software/PC_Application/LibreVNA-GUI/appwindow.h @@ -59,14 +59,14 @@ public: Deembedded = 2, }; - void addStreamingData(const DeviceDriver::VNAMeasurement &m, VNADataType type); + void addStreamingData(const DeviceDriver::VNAMeasurement &m, VNADataType type, bool is_zerospan); enum class SADataType { Raw = 0, Normalized = 1, }; - void addStreamingData(const DeviceDriver::SAMeasurement &m, SADataType type); + void addStreamingData(const DeviceDriver::SAMeasurement &m, SADataType type, bool is_zerospan); public slots: void setModeStatus(QString msg); diff --git a/Software/PC_Application/LibreVNA-GUI/streamingserver.cpp b/Software/PC_Application/LibreVNA-GUI/streamingserver.cpp index 1e29caf..72c3ce6 100644 --- a/Software/PC_Application/LibreVNA-GUI/streamingserver.cpp +++ b/Software/PC_Application/LibreVNA-GUI/streamingserver.cpp @@ -20,12 +20,16 @@ StreamingServer::StreamingServer(int port) }); } -void StreamingServer::addData(const DeviceDriver::VNAMeasurement &m) +void StreamingServer::addData(const DeviceDriver::VNAMeasurement &m, bool is_zerospan) { nlohmann::json j; j["pointNum"] = m.pointNum; - j["frequency"] = m.frequency; - j["dBm"] = m.dBm; + if(is_zerospan) { + j["time"] = m.us * 0.000001; + } else { + j["frequency"] = m.frequency; + j["dBm"] = m.dBm; + } j["Z0"] = m.Z0; nlohmann::json jp; for(auto const &p : m.measurements) { @@ -41,11 +45,15 @@ void StreamingServer::addData(const DeviceDriver::VNAMeasurement &m) } } -void StreamingServer::addData(const DeviceDriver::SAMeasurement &m) +void StreamingServer::addData(const DeviceDriver::SAMeasurement &m, bool is_zerospan) { nlohmann::json j; j["pointNum"] = m.pointNum; - j["frequency"] = m.frequency; + if(is_zerospan) { + j["time"] = m.us * 0.000001; + } else { + j["frequency"] = m.frequency; + } nlohmann::json jp; for(auto const &p : m.measurements) { jp[p.first.toStdString()] = p.second; diff --git a/Software/PC_Application/LibreVNA-GUI/streamingserver.h b/Software/PC_Application/LibreVNA-GUI/streamingserver.h index 7bcfcc3..a0596f4 100644 --- a/Software/PC_Application/LibreVNA-GUI/streamingserver.h +++ b/Software/PC_Application/LibreVNA-GUI/streamingserver.h @@ -13,8 +13,8 @@ class StreamingServer : public QObject public: StreamingServer(int port); - void addData(const DeviceDriver::VNAMeasurement &m); - void addData(const DeviceDriver::SAMeasurement &m); + void addData(const DeviceDriver::VNAMeasurement &m, bool is_zerospan); + void addData(const DeviceDriver::SAMeasurement &m, bool is_zerospan); int getPort() {return port;}