Skip to content

Connection¤

Connection ¤

Connection(
    address: str,
    *,
    backend: (
        Literal["MSL", "PyVISA", "NIDAQ"] | Backend
    ) = MSL,
    eid: str = "",
    manufacturer: str = "",
    model: str = "",
    serial: str = "",
    **properties: Any
)

Information about how to interface with equipment.

Parameters:

Name Type Description Default
address str

The VISA-style address of the connection (see here for examples).

required
backend Literal['MSL', 'PyVISA', 'NIDAQ'] | Backend

The backend to use to communicate with the equipment.

MSL
eid str

The equipment id to associate with the Connection instance.

''
manufacturer str

The name of the manufacturer of the equipment.

''
model str

The model number of the equipment.

''
serial str

The serial number (or unique identifier) of the equipment.

''
properties Any

Additional key-value pairs to use when communicating with the equipment. For example, the baud_rate and parity values for an RS-232 connection.

{}
Source code in src/msl/equipment/schema.py
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
def __init__(  # noqa: PLR0913
    self,
    address: str,
    *,
    backend: Literal["MSL", "PyVISA", "NIDAQ"] | Backend = Backend.MSL,
    eid: str = "",
    manufacturer: str = "",
    model: str = "",
    serial: str = "",
    **properties: _Any,  # noqa: ANN401
) -> None:
    """Information about how to interface with equipment.

    Args:
        address: The VISA-style address of the connection (see [here][address-syntax] for examples).
        backend: The [backend][msl.equipment.enumerations.Backend] to use to communicate with the equipment.
        eid: The [equipment id][msl.equipment.schema.Equipment.id] to associate with the [Connection][] instance.
        manufacturer: The name of the manufacturer of the equipment.
        model: The model number of the equipment.
        serial: The serial number (or unique identifier) of the equipment.
        properties: Additional key-value pairs to use when communicating with the equipment.
            For example, the _baud_rate_ and _parity_ values for an _RS-232_ connection.
    """
    self.address: str = address
    """The VISA-style address of the connection (see [here][address-syntax] for examples)."""

    self.backend: Backend = Backend(backend)
    """The [backend][msl.equipment.enumerations.Backend] that is used to communicate with the equipment."""

    self.eid: str = eid
    """The [equipment id][msl.equipment.schema.Equipment.id] associated with the [Connection][] instance."""

    self.manufacturer: str = manufacturer
    """The name of the manufacturer of the equipment."""

    self.model: str = model
    """The model number of the equipment."""

    # check for a properties key being explicitly defined and the value is a dict
    properties = (  # pyright: ignore[reportUnknownVariableType]
        properties["properties"]
        if ("properties" in properties and isinstance(properties["properties"], dict))
        else properties
    )

    self.properties: dict[str, _Any] = properties
    """Additional key-value pairs to use when communicating with the equipment.

    For example, the _baud_rate_ and _parity_ values for an _RS-232_ connection.
    """

    self.serial: str = serial
    """The serial number (or unique identifier) of the equipment."""

address instance-attribute ¤

address: str = address

The VISA-style address of the connection (see here for examples).

backend instance-attribute ¤

backend: Backend = Backend(backend)

The backend that is used to communicate with the equipment.

eid instance-attribute ¤

eid: str = eid

The equipment id associated with the Connection instance.

manufacturer instance-attribute ¤

manufacturer: str = manufacturer

The name of the manufacturer of the equipment.

model instance-attribute ¤

model: str = model

The model number of the equipment.

properties instance-attribute ¤

properties: dict[str, Any] = properties

Additional key-value pairs to use when communicating with the equipment.

For example, the baud_rate and parity values for an RS-232 connection.

serial instance-attribute ¤

serial: str = serial

The serial number (or unique identifier) of the equipment.

connect ¤

connect() -> Any

Connect to the equipment.

Source code in src/msl/equipment/schema.py
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
def connect(self) -> _Any:  # noqa: ANN401
    """Connect to the equipment."""
    equipment = Equipment(
        id=self.eid,
        manufacturer=self.manufacturer,
        model=self.model,
        serial=self.serial,
        connection=self,
    )
    return equipment.connect()