mpylab.device.vlisn_virtual module¶
Virtual V-LISN driver for UI and workflow tests without hardware.
- class mpylab.device.vlisn_virtual.VLISN(SearchPaths=None)
Bases:
VLISNSynthetic V-LISN implementation using the public VLISN API.
- Parameters:
SearchPaths (sequence of path-like, optional) – Directories searched for referenced configuration and data files.
- GetChannels()
Return available correction data names.
- Returns:
Status code and channel names.
- Return type:
tuple of (int, tuple of str)
- GetData(what)
Return a correction value for the selected data channel.
- Parameters:
what (str) – Correction channel name.
- Returns:
Status code and correction quantity. An unknown channel returns
(-1, None).- Return type:
tuple of (int, scuq.quantities.Quantity or None)
- GetDescription()
Return the virtual device identification.
- Returns:
Status code and identification string.
- Return type:
tuple of (int, str)
- GetFilter()
Return the simulated filter state.
- Returns:
Status code and filter state.
- Return type:
tuple of (int, bool)
- GetFreq()
Return the active interpolation frequency.
- Returns:
Status code and frequency in Hz, or
Nonebefore initialization.- Return type:
tuple of (int, float or None)
- GetPath()
Return the selected LISN path.
- Returns:
Status code and selected path.
- Return type:
tuple of (int, str)
- GetVirtual()
Return whether this driver is virtual.
- Returns:
Status code and
True.- Return type:
tuple of (int, bool)
- Init(ini=None, channel=None, ignore_bus=None)
Initialize the virtual V-LISN without opening a bus.
- Parameters:
ini (path-like or file-like, optional) – INI configuration source.
channel (int, optional) – One-based configuration channel number.
ignore_bus (bool, optional) – Accepted for compatibility. The virtual driver always ignores the hardware bus.
- Returns:
Zero on success, otherwise the initialization error status.
- Return type:
int
- Quit()
Close the virtual V-LISN.
- Returns:
Zero on success.
- Return type:
int
- SetFilter(state)
Set and return the simulated filter state.
- Parameters:
state (bool or str) – Requested filter state. Common true-valued strings are accepted.
- Returns:
Status code and applied filter state.
- Return type:
tuple of (int, bool)
- SetFreq(freq)
Set the active interpolation frequency.
- Parameters:
freq (float) – Frequency in Hz.
- Returns:
Status code and applied frequency in Hz.
- Return type:
tuple of (int, float)
- SetPath(path)
Set and return the selected LISN path.
- Parameters:
path (str) – Path name, such as
"L","L1", or"N".- Returns:
Status code and selected path.
- Return type:
tuple of (int, str)
- Raises:
RuntimeError – If path is not supported.
- SetVirtual(virtual)
Set the virtual flag for API compatibility.
- Parameters:
virtual (bool) – Requested virtual state.
- Returns:
Zero on success.
- Return type:
int
- conftmpl = {'channel_%d': {'file': <function VLISN.<lambda>>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'filter': <function strbool>, 'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'nr_of_channels': <class 'int'>, 'path': <class 'str'>, 'unit': <class 'str'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}
- query(cmd, tmpl=None)
Write a virtual SCPI query and return its response.
- Parameters:
cmd (str) – Query command to process.
tmpl (str, optional) – Regular expression used to parse named response fields.
- Returns:
Raw or parsed response.
- Return type:
str or dict
- 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