plesty.pm100d.mock_traffic ========================== .. py:module:: plesty.pm100d.mock_traffic .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: plesty.pm100d.mock_traffic._POWER_BASELINE_W plesty.pm100d.mock_traffic._POWER_NOISE_REL plesty.pm100d.mock_traffic._STATIC_RESPONSES Classes ------- .. autoapisummary:: plesty.pm100d.mock_traffic.MockVisaTrafficManager Functions --------- .. autoapisummary:: plesty.pm100d.mock_traffic._load_param_schema Module Contents --------------- .. py:data:: _POWER_BASELINE_W :value: 1.5e-06 .. py:data:: _POWER_NOISE_REL :value: 0.02 .. py:data:: _STATIC_RESPONSES :type: dict[str, str] .. py:function:: _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. .. py:class:: MockVisaTrafficManager(address: str = 'mock', timeout: int = 5000, **kwargs: object) Bases: :py:obj:`plesty.lib.traffic.TrafficManager` Drop-in :class:`~plesty.lib.traffic.TrafficManager` PM100D simulator. Accept (and ignore) the VISA constructor surface. :param address: Resource name; kept for logging/registry purposes. :param timeout: Ignored; the mock answers instantly. :param \*\*kwargs: Ignored VISA options (terminations etc.). .. py:attribute:: _params :type: dict[str, str] .. py:method:: _open() -> None Mark the resource as open (sentinel instrument object). .. py:method:: _close() -> None Nothing to release. .. py:method:: _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. :param command: The SCPI command string. :param timeout: Ignored; the mock answers instantly. :param mode: SCPI direction, ``"write"`` or ``"query"`` (required). :returns: The simulated instrument response ('' for plain writes). :raises ValueError: If ``mode`` is not ``"write"`` or ``"query"``.