mpylab.device.receiver_virtual module

Virtual EMC receiver driver for UI and workflow tests without hardware.

class mpylab.device.receiver_virtual.RECEIVER(SearchPaths=None)

Bases: RECEIVER

Provide an in-memory EMC receiver without hardware access.

Parameters:

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

GetAttenuation()

Return simulated attenuation.

Returns:

(0, attenuation) in decibels.

Return type:

tuple

GetData()

Trigger and return one synthetic receiver reading.

Returns:

(0, level) with a scuq.Quantity.

Return type:

tuple

GetDataNB(retrigger=False)

Return the latest reading through the non-blocking interface.

Parameters:

retrigger (bool or str, optional) – Update the synthetic value after reading when true or equal to "on".

Returns:

(0, level) with a scuq.Quantity.

Return type:

tuple

GetDescription()

Return virtual device identification.

Returns:

(0, identification).

Return type:

tuple

GetDetector()

Return simulated detector mode.

Returns:

(0, detector).

Return type:

tuple

GetFreq()

Return simulated receiver frequency.

Returns:

(0, frequency) in hertz.

Return type:

tuple

GetMeasTime()

Return simulated measurement time.

Returns:

(0, measurement_time) in seconds.

Return type:

tuple

GetMinAttenuation()

Return simulated minimum attenuation.

Returns:

(0, minimum_attenuation) in decibels.

Return type:

tuple

GetPreamplifier()

Return simulated preamplifier state.

Returns:

(0, preamplifier).

Return type:

tuple

GetResolutionBandwidth()

Return simulated resolution bandwidth.

Returns:

(0, bandwidth) in hertz.

Return type:

tuple

GetVirtual()

Return the fixed virtual-mode flag.

Returns:

(0, True).

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 receiver 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

Quit()

Close the virtual receiver.

Returns:

Zero.

Return type:

int

SetAttenuation(attenuation)

Set fixed or automatic simulated attenuation.

Parameters:

attenuation (float or str) – Attenuation in decibels, or "auto" to use the minimum.

Returns:

(0, attenuation) in decibels.

Return type:

tuple

SetDetector(detector)

Set simulated detector mode.

Parameters:

detector ({"PEAK", "QPEAK", "AVERAGE"}) – Detector name, matched case-insensitively.

Returns:

(0, detector).

Return type:

tuple

SetFreq(freq)

Set simulated receiver frequency.

Parameters:

freq (float) – Frequency in hertz.

Returns:

(0, frequency).

Return type:

tuple

SetMeasTime(meas_time)

Set simulated measurement time.

Parameters:

meas_time (float) – Non-negative time in seconds.

Returns:

(0, measurement_time) in seconds.

Return type:

tuple

SetMinAttenuation(min_attenuation)

Set simulated minimum attenuation.

Parameters:

min_attenuation (float) – Non-negative minimum in decibels.

Returns:

(0, minimum_attenuation) in decibels.

Return type:

tuple

SetPreamplifier(preamplifier)

Set simulated preamplifier state.

Parameters:

preamplifier ({"ON", "OFF"}) – Requested state, matched case-insensitively.

Returns:

(0, preamplifier).

Return type:

tuple

SetResolutionBandwidth(rbw)

Set fixed or automatic resolution bandwidth.

Parameters:

rbw (float or str) – Bandwidth in hertz, or "auto" for 9 kHz.

Returns:

(0, bandwidth) in hertz.

Return type:

tuple

Trigger()

Update the synthetic measurement value.

Returns:

Zero.

Return type:

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