plesty.pm100d.mock_traffic

In-memory SCPI simulator of the PM100D for hardware-free operation.

Answers the same SCPI vocabulary the real console speaks (measurement queries, parameter writes/queries, zero adjustment), so the full device → server → client stack can be exercised without an instrument: run the server with --mock or construct the device with address="mock".

Attributes

_POWER_BASELINE_W

_POWER_NOISE_REL

_STATIC_RESPONSES

Classes

MockVisaTrafficManager

Drop-in TrafficManager PM100D simulator.

Functions

_load_param_schema(→ tuple[dict[str, str], dict[str, ...)

Read defaults and MIN/MAX limits from the parameter schema.

Module Contents

plesty.pm100d.mock_traffic._POWER_BASELINE_W = 1.5e-06
plesty.pm100d.mock_traffic._POWER_NOISE_REL = 0.02
plesty.pm100d.mock_traffic._STATIC_RESPONSES: dict[str, str]
plesty.pm100d.mock_traffic._load_param_schema() tuple[dict[str, str], dict[str, tuple[str, str]]]

Read defaults and MIN/MAX limits from the parameter schema.

Both are derived from schema_param.json rather than restated here: a hand-maintained copy drifts, and a simulator answering a value the schema forbids sends every caller chasing a bug that does not exist on hardware.

Returns:

Defaults and (min, max) limits, both keyed by SCPI command stem.

Return type:

tuple[dict[str, str], dict[str, tuple[str, str]]]

class plesty.pm100d.mock_traffic.MockVisaTrafficManager(address: str = 'mock', timeout: int = 5000, **kwargs: object)

Bases: plesty.lib.traffic.TrafficManager

Drop-in TrafficManager PM100D simulator.

Accept (and ignore) the VISA constructor surface.

Parameters:
  • address (str) – Resource name; kept for logging/registry purposes.

  • timeout (int) – Ignored; the mock answers instantly.

  • **kwargs (object) – Ignored VISA options (terminations etc.).

_params: dict[str, str]
_open() None

Mark the resource as open (sentinel instrument object).

Return type:

None

_close() None

Nothing to release.

Return type:

None

_send_command(command: str, timeout: object = None, mode: str | None = None) str

Answer one SCPI command from the in-memory instrument state.

Mirrors the real VisaTrafficManager contract: mode must be "write" or "query" — a missing mode fails here exactly like it does on hardware, so tests cannot mask that bug.

Parameters:
  • command (str) – The SCPI command string.

  • timeout (object) – Ignored; the mock answers instantly.

  • mode (str | None) – SCPI direction, "write" or "query" (required).

Returns:

The simulated instrument response (’’ for plain writes).

Raises:

ValueError – If mode is not "write" or "query".

Return type:

str