mpylab.device.spectrumanalyzer_virtual module¶
Virtual spectrum analyzer driver for UI and API tests.
- class mpylab.device.spectrumanalyzer_virtual.SPECTRUMANALYZER(SearchPaths=None)
Bases:
SPECTRUMANALYZERDeterministic spectrum analyzer model with the standard driver API.
- Parameters:
SearchPaths (sequence of path-like, optional) – Directories searched for referenced configuration files.
- GetAtt()
Return the current input-attenuation setting.
- Returns:
Status code and attenuation setting.
- Return type:
tuple of (int, float or str)
- GetAttMode()
Return the current attenuation mode.
- Returns:
Status code and mode name.
- Return type:
tuple of (int, str)
- GetCenterFreq()
Return the current center frequency.
- Returns:
Status code and center frequency in Hz.
- Return type:
tuple of (int, float)
- GetDescription()
Return the configured instrument description string.
- Returns:
Status code and description string.
- Return type:
tuple of (int, str)
- GetDetector()
Return the current detector mode.
- Returns:
Status code and detector name.
- Return type:
tuple of (int, str)
- GetPreAmp()
Return the current preamplifier gain.
- Returns:
Status code and gain in dB.
- Return type:
tuple of (int, float)
- GetRBW()
Return the current resolution-bandwidth setting.
- Returns:
Status code and bandwidth in Hz or its textual mode.
- Return type:
tuple of (int, float or str)
- GetRefLevel()
Return the current display reference level.
- Returns:
Status code and reference level.
- Return type:
tuple of (int, float)
- GetSpan()
Return the current frequency span.
- Returns:
Status code and span in Hz.
- Return type:
tuple of (int, float)
- GetSpectrum()
Generate a deterministic synthetic spectrum trace.
- Returns:
Status code followed by frequency values in Hz and synthetic level values in the configured analyzer level unit.
- Return type:
tuple of (int, tuple of (list of float, list of float))
- GetSpectrumNB()
Return the same synthetic spectrum as the blocking API.
- Returns:
Status code followed by frequency and level values.
- Return type:
tuple of (int, tuple of (list of float, list of float))
- GetStartFreq()
Return the current start frequency.
- Returns:
Status code and start frequency in Hz.
- Return type:
tuple of (int, float)
- GetStopFreq()
Return the current stop frequency.
- Returns:
Status code and stop frequency in Hz.
- Return type:
tuple of (int, float)
- GetSweepCount()
Return the configured sweep count.
- Returns:
Status code and sweep count.
- Return type:
tuple of (int, int)
- GetSweepPoints()
Return the configured number of sweep points.
- Returns:
Status code and number of points.
- Return type:
tuple of (int, int)
- GetSweepTime()
Return the sweep time.
- Returns:
Status code and sweep time in seconds.
- Return type:
tuple of (int, float)
- GetTrace()
Return the active trace index.
- Returns:
Status code and trace index.
- Return type:
tuple of (int, int)
- GetTraceMode()
Return the current trace mode.
- Returns:
Status code and trace mode.
- Return type:
tuple of (int, str)
- GetTriggerDelay()
Return the trigger delay.
- Returns:
Status code and delay in seconds.
- Return type:
tuple of (int, float)
- GetTriggerMode()
Return the current trigger mode.
- Returns:
Status code and trigger mode.
- Return type:
tuple of (int, str)
- GetVBW()
Return the current video bandwidth.
- Returns:
Status code and bandwidth in Hz.
- Return type:
tuple of (int, float)
- GetVirtual()
Report that this driver instance is virtual.
- Returns:
Status code and
True.- Return type:
tuple of (int, bool)
- Init(ini=None, channel=None, ignore_bus=None)
Initialize the virtual analyzer from optional INI content.
- Parameters:
ini (path-like or file-like, optional) – INI configuration source.
channel (int, optional) – One-based configuration channel number. Defaults to channel 1.
ignore_bus (bool, optional) – Accepted for compatibility. The virtual driver never opens a bus.
- Returns:
Zero on success.
- Return type:
int
- Quit()
Close the virtual driver session.
- Returns:
Zero on success.
- Return type:
int
- SetAtt(value)
Set the input-attenuation setting.
- Parameters:
value (float or str) – Attenuation in dB or a textual setting.
- Returns:
Status code and applied attenuation setting.
- Return type:
tuple of (int, float or str)
- SetAttAuto()
Enable automatic attenuation mode.
- Returns:
Status code and
"auto".- Return type:
tuple of (int, str)
- SetAttMode(value)
Set the attenuation mode.
- Parameters:
value (str) – Attenuation mode name.
- Returns:
Status code and normalized mode name.
- Return type:
tuple of (int, str)
- SetCenterFreq(value)
Set center frequency and update start and stop frequencies.
- Parameters:
value (float) – Center frequency in Hz.
- Returns:
Status code and applied center frequency in Hz.
- Return type:
tuple of (int, float)
- SetDetector(value)
Set the detector mode.
- Parameters:
value (str) – Detector name.
- Returns:
Status code and normalized detector name.
- Return type:
tuple of (int, str)
- SetPreAmp(value)
Set the preamplifier gain.
- Parameters:
value (float) – Preamplifier gain in dB.
- Returns:
Status code and applied gain in dB.
- Return type:
tuple of (int, float)
- SetRBW(value)
Set the resolution-bandwidth setting.
- Parameters:
value (float or str) – Resolution bandwidth in Hz or a textual mode such as
"auto".- Returns:
Status code and applied setting.
- Return type:
tuple of (int, float or str)
- SetRefLevel(value)
Set the display reference level.
- Parameters:
value (float) – Reference level in the analyzer’s configured level unit.
- Returns:
Status code and applied reference level.
- Return type:
tuple of (int, float)
- SetSpan(value)
Set frequency span and update start and stop frequencies.
- Parameters:
value (float) – Frequency span in Hz.
- Returns:
Status code and applied span in Hz.
- Return type:
tuple of (int, float)
- SetStartFreq(value)
Set start frequency and update center and span values.
- Parameters:
value (float) – Start frequency in Hz.
- Returns:
Status code and applied start frequency in Hz.
- Return type:
tuple of (int, float)
- SetStopFreq(value)
Set stop frequency and update center and span values.
- Parameters:
value (float) – Stop frequency in Hz.
- Returns:
Status code and applied stop frequency in Hz.
- Return type:
tuple of (int, float)
- SetSweepCount(value)
Set the configured sweep count.
- Parameters:
value (int) – Number of sweeps.
- Returns:
Status code and applied sweep count.
- Return type:
tuple of (int, int)
- SetSweepPoints(value)
Set the number of sweep points.
- Parameters:
value (int) – Requested number of points. Values below two are raised to two.
- Returns:
Status code and applied number of points.
- Return type:
tuple of (int, int)
- SetSweepTime(value)
Set the sweep time.
- Parameters:
value (float) – Sweep time in seconds.
- Returns:
Status code and applied sweep time in seconds.
- Return type:
tuple of (int, float)
- SetTrace(value)
Set the active trace index.
- Parameters:
value (int) – Trace index.
- Returns:
Status code and applied trace index.
- Return type:
tuple of (int, int)
- SetTraceMode(value)
Set the trace mode.
- Parameters:
value (str) – Trace mode name.
- Returns:
Status code and normalized trace mode.
- Return type:
tuple of (int, str)
- SetTriggerDelay(value)
Set the trigger delay.
- Parameters:
value (float) – Trigger delay in seconds.
- Returns:
Status code and applied delay in seconds.
- Return type:
tuple of (int, float)
- SetTriggerMode(value)
Set the trigger mode.
- Parameters:
value (str) – Trigger mode name.
- Returns:
Status code and normalized trigger mode.
- Return type:
tuple of (int, str)
- SetVBW(value)
Set the video bandwidth.
- Parameters:
value (float) – Video bandwidth in Hz.
- Returns:
Status code and applied bandwidth in Hz.
- Return type:
tuple of (int, float)
- query(cmd, tmpl=None, send_opc=False)
Write a virtual SCPI query and return its response.
- Parameters:
cmd (str) – Command or query to process.
tmpl (str, optional) – Regular expression used to parse named response fields.
send_opc (bool, optional) – Simulate an operation-complete response after a non-query command.
- Returns:
Raw or parsed response.
- Return type:
str or dict
- Raises:
ValueError – If send_opc is requested for a command containing a query.
- read(tmpl=None)
Return or parse the last virtual SCPI response.
- Parameters:
tmpl (str, optional) – Regular expression used to parse named response fields.
- Returns:
Raw response without tmpl, otherwise the matched named fields.
- Return type:
str or dict
- write(cmd)
Handle a small SCPI-like command subset without a hardware bus.
- Parameters:
cmd (str) – Command to process.
- Returns:
Zero on success.
- Return type:
int