mpylab.device.sg_virtual module

Virtual signal generator driver for UI and workflow tests.

class mpylab.device.sg_virtual.SIGNALGENERATOR(SearchPaths=None)

Bases: SIGNALGENERATOR

Provide an in-memory signal generator without hardware access.

Parameters:

SearchPaths (sequence of path-like, optional) – Directories searched for the virtual device configuration.

AMOff()

Disable simulated AM.

Returns:

(0, 0).

Return type:

tuple of int

AMOn()

Enable simulated AM.

Returns:

(0, 0).

Return type:

tuple of int

ConfAM(source, freq, depth, waveform, LFOut)

Configure simulated amplitude modulation.

Parameters:
  • source (str) – Modulation source from the public signal-generator vocabulary.

  • freq (float) – Modulation frequency in hertz.

  • depth (float) – Linear modulation depth.

  • waveform (str) – Modulation waveform.

  • LFOut (str) – Low-frequency output state.

Returns:

Zero.

Return type:

int

ConfPM(source, freq, pol, width, delay)

Configure simulated pulse modulation.

Parameters:
  • source (str) – Modulation source from the public signal-generator vocabulary.

  • freq (float) – Pulse repetition frequency in hertz.

  • pol (str) – Pulse polarity.

  • width (float) – Pulse width.

  • delay (float) – Pulse delay.

Returns:

Zero.

Return type:

int

GetAMState()

Return simulated AM state.

Returns:

(0, state) with lowercase "on" or "off".

Return type:

tuple

GetDescription()

Return virtual device identification.

Returns:

(0, identification).

Return type:

tuple

GetFreq()

Return simulated RF frequency.

Returns:

(0, frequency) in hertz.

Return type:

tuple

GetLevel()

Return simulated RF level.

Returns:

(0, level) with a scuq.Quantity.

Return type:

tuple

GetPMState()

Return simulated pulse-modulation state.

Returns:

(0, state) with lowercase "on" or "off".

Return type:

tuple

GetRFState()

Return simulated RF output state.

Returns:

(0, state) with lowercase "on" or "off".

Return type:

tuple

Init(ini=None, channel=None, ignore_bus=None)

Initialize state from configuration without opening a bus.

Parameters:
  • ini (path-like or file-like, optional) – Virtual signal-generator configuration source.

  • channel (int or str, optional) – Logical channel; channel one is used by default.

  • ignore_bus (bool, optional) – Accepted for compatibility; the hardware bus is always ignored.

Returns:

Device status; zero indicates success.

Return type:

int

PMOff()

Disable simulated pulse modulation.

Returns:

(0, 0).

Return type:

tuple of int

PMOn()

Enable simulated pulse modulation.

Returns:

(0, 0).

Return type:

tuple of int

Quit()

Stop all simulated outputs.

Returns:

Zero.

Return type:

int

RFOff()

Disable simulated RF output.

Returns:

(0, 0).

Return type:

tuple of int

RFOn()

Enable simulated RF output.

Returns:

(0, 0).

Return type:

tuple of int

SetAM(state)

Set simulated AM state.

Parameters:

state (str or bool-like) – "on" enables AM; every other value disables it.

Returns:

(0, 0).

Return type:

tuple of int

SetFreq(freq)

Set simulated RF frequency.

Parameters:

freq (float) – Frequency in hertz.

Returns:

(0, frequency).

Return type:

tuple

Raises:

ValueError – If freq is not finite and positive.

SetLevel(lv)

Set simulated RF level.

Parameters:

lv (scuq.Quantity) – Requested output power or voltage. Complex scalar values are represented by their magnitude.

Returns:

(0, level) with a scuq.Quantity.

Return type:

tuple

Raises:
  • TypeError – If lv is not a scuq.Quantity.

  • ValueError – If lv is non-scalar or non-finite.

SetPM(state)

Set simulated pulse-modulation state.

Parameters:

state (str or bool-like) – "on" enables pulse modulation; every other value disables it.

Returns:

(0, 0).

Return type:

tuple of int

SetState(state)

Set simulated RF output state.

Parameters:

state (str or bool-like) – "on" enables RF; every other value disables it.

Returns:

(0, 0).

Return type:

tuple of int

query(cmd, tmpl=None, send_opc=False)

Write a command and return its virtual response.

Parameters:
  • cmd (str) – SCPI-like command.

  • tmpl (str, optional) – Regular expression used to parse the response.

  • send_opc (bool, optional) – Return operation-complete after a non-query command.

Returns:

Raw or parsed response.

Return type:

str or dict

read(tmpl=None)

Read the last virtual SCPI response.

Parameters:

tmpl (str, optional) – Regular expression with named groups used to parse the response.

Returns:

Raw response, matching named groups, or an empty dictionary.

Return type:

str or dict

write(cmd)

Handle one command through the virtual SCPI facade.

Parameters:

cmd (str) – Supported SCPI-like command.

Returns:

Zero after processing the command.

Return type:

int

mpylab.device.sg_virtual.main()

main function.