Skip to content

Vocabulary

String-compatible enums for token-valued parameters (coupling, trigger mode/slope/source/coupling/type, bandwidth limit, tracking mode) -- enums in, strings out

Public, string-compatible vocabulary for token-valued instrument parameters.

Every enum subclasses (str, Enum) with name == value, so members compare and hash equal to the plain canonical strings the API has always spoken: Coupling.DC == "DC". Setters accept either form; getters keep returning plain strings (spec: "enums in, strings out").

This module is deliberately leaf-level: it imports nothing from the driver or command-table modules, so those can import it without cycles. Which tokens a CONNECTED dialect supports is the command layer's knowledge (scpi_commands.py token maps); the enums here are the union vocabulary.

Coupling

Bases: str, Enum

Channel coupling. Wire mapping is per-dialect (legacy speaks D1M/A1M).

TriggerType

Bases: str, Enum

Public trigger-type vocabulary (MAUI-descended naming: SLEW = slope trigger, GLIT = pulse/glitch trigger).

normalize_token

normalize_token(value: Union[str, Enum], *, parameter: str, valid: Iterable[str], aliases: Optional[Mapping[str, str]] = None, dialect: Optional[str] = None, model: Optional[str] = None) -> str

Uppercase, alias-fold, and validate a token; return the canonical string.

Raises InvalidParameterError (also a ValueError) carrying the parameter name, the offending value, and the valid options for THIS instrument.

Source code in scpi_control/vocabulary.py
def normalize_token(
    value: Union[str, Enum],
    *,
    parameter: str,
    valid: Iterable[str],
    aliases: Optional[Mapping[str, str]] = None,
    dialect: Optional[str] = None,
    model: Optional[str] = None,
) -> str:
    """Uppercase, alias-fold, and validate a token; return the canonical string.

    Raises InvalidParameterError (also a ValueError) carrying the parameter
    name, the offending value, and the valid options for THIS instrument.
    """
    # Unwrap enum members explicitly: on Python < 3.12, str() of a (str, Enum)
    # member is "Coupling.DC", not "DC" -- .value is the canonical string.
    if isinstance(value, Enum):
        value = value.value
    original = str(value)
    token = original.strip().upper()
    if aliases:
        token = aliases.get(token, token)
    valid_set = set(valid)
    if token not in valid_set:
        raise exceptions.InvalidParameterError(parameter=parameter, value=original, valid_options=valid_set, dialect=dialect, model=model)
    return token

See Also

  • Oscilloscope - Main oscilloscope control class for SCPI communication
  • Scope Capabilities - Derived, dialect-resolved capabilities of a connected oscilloscope (scope.capabilities)
  • Channel - Channel configuration and control
  • Trigger - Trigger configuration and modes