Source code for src.acquire

from collections import namedtuple
from typing import TYPE_CHECKING, Optional, Union

from rigol_ds1000z.src._scpi import Float, Int, String, read_fields, write_fields

if TYPE_CHECKING:
    from rigol_ds1000z.src.oscope import Rigol_DS1000Z

ACQUIRE = namedtuple("ACQUIRE", "type averages mdepth srate")

# ``type`` is declared first so it is written before ``averages`` (averages only
# takes effect while the type is AVERages). ``mdepth`` is an integer point count
# or the literal ``AUTO`` (an Int with ``AUTO`` as a pass-through keyword).
_SETTABLE = (
    String("type", ":ACQ:TYPE"),
    Int("averages", ":ACQ:AVER"),
    Int("mdepth", ":ACQ:MDEP", keywords=("AUTO",)),
)

# read-only fields (queried, never written)
_READONLY = (Float("srate", ":ACQ:SRAT"),)


[docs] def acquire( oscope: "Rigol_DS1000Z", averages: Optional[int] = None, mdepth: Union[int, str, None] = None, type: Optional[str] = None, ): """ Send commands to control an oscilloscope's acquisition behavior. All arguments are optional. ``averages`` only takes effect while the acquisition ``type`` is ``AVERages``; when both are specified the ``type`` command is issued first. Args: averages (int): ``:ACQuire:AVERages`` (a power of two, 2 to 1024). mdepth (int, str): ``:ACQuire:MDEPth`` (an integer point count or ``AUTO``). type (str): ``:ACQuire:TYPE`` (``NORM``, ``AVER``, ``PEAK``, or ``HRES``). Returns: A namedtuple with a field for each argument, queried back regardless of which were provided, plus the read-only ``srate`` (``:ACQuire:SRATe?``, the sample rate in samples per second). """ provided = dict(type=type, averages=averages, mdepth=mdepth) write_fields(oscope, _SETTABLE, provided) return ACQUIRE(**read_fields(oscope, _SETTABLE + _READONLY))