Source code for qblox_scheduler.backends.types.qblox.hardware

# SPDX-FileCopyrightText: Copyright 2020-2025, Quantify Consortium
# SPDX-FileCopyrightText: © 2025 Qblox <https://qblox.com>
# SPDX-License-Identifier: BSD-3-Clause

"""Python dataclasses for compilation to Qblox hardware."""

# ruff: noqa: TC001

from __future__ import annotations

from dataclasses import field as dataclasses_field
from typing import Annotated, Literal, Optional, Union

from pydantic import Field

from qblox_scheduler.backends.types.common import (
    HardwareDescription,
    IQMixerDescription,
    LocalOscillatorDescription,
    OpticalModulatorDescription,
)

from .modules import ClusterModuleDescription
from .settings import ExternalTriggerSyncSettings


class QbloxBaseDescription(HardwareDescription):
    """Base class for a Qblox hardware description."""

    ref: Literal["internal", "external"]
    """The reference source for the instrument."""
    sequence_to_file: bool = False
    """Write sequencer programs to files for (all modules in this) instrument."""


[docs] class ClusterDescription(QbloxBaseDescription): """Information needed to specify a Cluster in the :class:`~.CompilationConfig`.""" instrument_type: Literal["Cluster"] = "Cluster" # type: ignore # (valid override) """The instrument type, used to select this datastructure when parsing a :class:`~.CompilationConfig`.""" modules: dict[int, ClusterModuleDescription] = dataclasses_field(default_factory=dict) """Description of the modules of this Cluster, using slot index as key.""" ip: Optional[str] = None """Unique identifier (typically the ip address) used to connect to the cluster""" sync_on_external_trigger: Optional[ExternalTriggerSyncSettings] = None """Settings for synchronizing the cluster on an external trigger.""" port: Optional[int] = None """Optional port of the cluster.""" module_base_port: Optional[int] = None """ Optional module base port of the cluster. For example, if set to 1200, each cluster module will be associated with ports 1201, 1202, ..., 1220 (module_base_port + slot_index). """
QbloxHardwareDescription = Annotated[ Union[ ClusterDescription, LocalOscillatorDescription, IQMixerDescription, OpticalModulatorDescription, ], Field(discriminator="instrument_type"), ] """ Specifies a piece of Qblox hardware and its instrument-specific settings. """ __all__ = ["ClusterDescription", "QbloxBaseDescription", "QbloxHardwareDescription"]