# pylint: disable=too-many-lines
# ruff: noqa: D402,PLR0913
# pyright: reportConstantRedefinition=none
"""The channel commands module.

These commands are used in the following models:
SS3706A

THIS FILE IS AUTO-GENERATED, IT SHOULD NOT BE MANUALLY MODIFIED.

Please report an issue if one is found.

Attributes and Functions:

::

    - channel.calibration.adjustcount()
    - channel.calibration.adjustdate()
    - channel.calibration.lock()
    - channel.calibration.password()
    - channel.calibration.save()
    - channel.calibration.step()
    - channel.calibration.unlock()
    - channel.calibration.verifydate()
    - channel.clearforbidden()
    - channel.close()
    - channel.connectrule
    - channel.connectsequential
    - channel.exclusiveclose()
    - channel.exclusiveslotclose()
    - channel.getbackplane()
    - channel.getclose()
    - channel.getcount()
    - channel.getdelay()
    - channel.getforbidden()
    - channel.getimage()
    - channel.getlabel()
    - channel.getmatch()
    - channel.getmatchtype()
    - channel.getmode()
    - channel.getoutputenable()
    - channel.getpole()
    - channel.getpowerstate()
    - channel.getstate()
    - channel.getstatelatch()
    - channel.gettype()
    - channel.open()
    - channel.pattern.delete()
    - channel.pattern.getimage()
    - channel.pattern.setimage()
    - channel.pattern.snapshot()
    - channel.read()
    - channel.reset()
    - channel.resetstatelatch()
    - channel.setbackplane()
    - channel.setdelay()
    - channel.setforbidden()
    - channel.setlabel()
    - channel.setmatch()
    - channel.setmatchtype()
    - channel.setmode()
    - channel.setoutputenable()
    - channel.setpole()
    - channel.setstatelatch()
    - channel.trigger[N].clear()
    - channel.trigger[N].get()
    - channel.trigger[N].set()
    - channel.trigger[N].wait()
    - channel.write()
"""
from typing import Dict, Optional, TYPE_CHECKING, Union

from .._helpers import (
    BaseTSPCmd,
    DefaultDictPassKeyToFactory,
    NoDeviceProvidedError,
    ValidatedDynamicNumberCmd,
)

if TYPE_CHECKING:
    from tm_devices.drivers.pi.tsp_device import TSPDevice


class ChannelTriggerItem(ValidatedDynamicNumberCmd, BaseTSPCmd):
    """The ``channel.trigger[N]`` command tree.

    **Info:**
        - ``N``, the number indicating the channel trigger event ID (1 to 8).

    Constants:
        - ``.EVENT_ID``: This constant indicates the trigger event generated by the channel trigger
          N.

    Properties/methods:
        - ``.clear()``: The ``channel.trigger[N].clear()`` function.
        - ``.get()``: The ``channel.trigger[N].get()`` function.
        - ``.set()``: The ``channel.trigger[N].set()`` function.
        - ``.wait()``: The ``channel.trigger[N].wait()`` function.
    """

    EVENT_ID = "channel.trigger[N].EVENT_ID"
    """str: This constant indicates the trigger event generated by the channel trigger N."""

    def __init__(self, device: Optional["TSPDevice"], cmd_syntax: str) -> None:
        super().__init__(device, cmd_syntax)
        # pylint: disable=invalid-name
        self.EVENT_ID = self.EVENT_ID.replace(
            "[N]", f"[{self._cmd_syntax.rsplit('[', maxsplit=1)[-1].split(']', maxsplit=1)[0]}]"
        )

    def clear(self) -> None:
        """Run the ``channel.trigger[N].clear()`` function.

        **Description:**
            - This function clears any pending events.

        **TSP Syntax:**

        ::

            - channel.trigger[N].clear()

        **Info:**
            - ``N``, the number indicating the trigger line to clear (1 to 8).

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(f"{self._cmd_syntax}.clear()")  # type: ignore[union-attr]
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.clear()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def get(self) -> str:
        """Run the ``channel.trigger[N].get()`` function.

        **Description:**
            - This function gets the channel status trigger information that is used to watch the
              state of a specific channel.

        **TSP Syntax:**

        ::

            - channel.trigger[N].get()

        **Info:**
            - ``N``, the number indicating the channel trigger to get (1 to 8).

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f"print({self._cmd_syntax}.get())"
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.get()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def set_(self, channel_list: str, state_match: str) -> None:
        """Run the ``channel.trigger[N].set()`` function.

        **Description:**
            - This function sets the channel status trigger model to watch the state of a specific
              channel.

        **TSP Syntax:**

        ::

            - channel.trigger[N].set()

        Args:
            channel_list: The channels to set, using standard channel naming.
            state_match: Value specifying the status to match when triggering an event.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.set("{channel_list}", {state_match})'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.set()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def wait(self, timeout: float) -> str:
        """Run the ``channel.trigger[N].wait()`` function.

        **Description:**
            - This function waits for the specified trigger or timeout period, whichever comes
              first.

        **TSP Syntax:**

        ::

            - channel.trigger[N].wait()

        Args:
            timeout: The number of seconds to wait.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f"print({self._cmd_syntax}.wait({timeout}))"
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.wait()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error


class ChannelPattern(BaseTSPCmd):
    """The ``channel.pattern`` command tree.

    Properties/methods:
        - ``.delete()``: The ``channel.pattern.delete()`` function.
        - ``.getimage()``: The ``channel.pattern.getimage()`` function.
        - ``.setimage()``: The ``channel.pattern.setimage()`` function.
        - ``.snapshot()``: The ``channel.pattern.snapshot()`` function.
    """

    def delete(self, name: str) -> None:
        """Run the ``channel.pattern.delete()`` function.

        **Description:**
            - This function deletes a channel pattern.

        **TSP Syntax:**

        ::

            - channel.pattern.delete()

        Args:
            name: A string representing the name of the channel pattern to delete.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(f'{self._cmd_syntax}.delete("{name}")')  # type: ignore[union-attr]
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.delete()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getimage(self, name: str) -> str:
        """Run the ``channel.pattern.getimage()`` function.

        **Description:**
            - This function queries a channel pattern for associated channels and analog backplane
              relays.

        **TSP Syntax:**

        ::

            - channel.pattern.getimage()

        Args:
            name: A string representing the name of the channel pattern to query.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.getimage("{name}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getimage()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def setimage(self, channel_list: str, name: str) -> None:
        """Run the ``channel.pattern.setimage()`` function.

        **Description:**
            - This function creates a channel pattern and associates it with the specified name.

        **TSP Syntax:**

        ::

            - channel.pattern.setimage()

        Args:
            channel_list: A string listing the channels, channel patterns, or analog backplane
                relays to use when creating the new channel pattern.
            name: A string representing the name to associate with the new channel pattern.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.setimage("{channel_list}", "{name}")'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.setimage()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def snapshot(self, name: str) -> None:
        """Run the ``channel.pattern.snapshot()`` function.

        **Description:**
            - This function creates a channel pattern.

        **TSP Syntax:**

        ::

            - channel.pattern.snapshot()

        Args:
            name: A string representing the name to associate with the present state of channels and
                analog backplane relays.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(f'{self._cmd_syntax}.snapshot("{name}")')  # type: ignore[union-attr]
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.snapshot()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error


class ChannelCalibration(BaseTSPCmd):
    """The ``channel.calibration`` command tree.

    Properties/methods:
        - ``.adjustcount()``: The ``channel.calibration.adjustcount()`` function.
        - ``.adjustdate()``: The ``channel.calibration.adjustdate()`` function.
        - ``.lock()``: The ``channel.calibration.lock()`` function.
        - ``.password()``: The ``channel.calibration.password()`` function.
        - ``.save()``: The ``channel.calibration.save()`` function.
        - ``.step()``: The ``channel.calibration.step()`` function.
        - ``.unlock()``: The ``channel.calibration.unlock()`` function.
        - ``.verifydate()``: The ``channel.calibration.verifydate()`` function.
    """

    def adjustcount(self, x: str) -> str:
        """Run the ``channel.calibration.adjustcount()`` function.

        **Description:**
            - This function gets the number of times that a card has been adjusted.

        **TSP Syntax:**

        ::

            - channel.calibration.adjustcount()

        Args:
            x: The slot number ( 1 to 6).

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f"print({self._cmd_syntax}.adjustcount({x}))"
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.adjustcount()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def adjustdate(self, x: str, date: Optional[str] = None) -> str:
        """Run the ``channel.calibration.adjustdate()`` function.

        **Description:**
            - This function sets or gets the adjustment date in UTC format (number of seconds since
              January 1, 1970) on the unlocked channel.

        **TSP Syntax:**

        ::

            - channel.calibration.adjustdate()

        Args:
            x: The slot number ( 1 to 6).
            date (optional): The date of the adjustment (UTC formatted).

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            function_args = ", ".join(
                str(x)
                for x in (
                    x,
                    date,
                )
                if x is not None
            )
            return self._device.query(  # type: ignore[union-attr]
                f"print({self._cmd_syntax}.adjustdate({function_args}))"
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.adjustdate()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def lock(self) -> None:
        """Run the ``channel.calibration.lock()`` function.

        **Description:**
            - This function prevents further calibration on the currently unlocked card.

        **TSP Syntax:**

        ::

            - channel.calibration.lock()

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(f"{self._cmd_syntax}.lock()")  # type: ignore[union-attr]
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.lock()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def password(self, password: str) -> None:
        """Run the ``channel.calibration.password()`` function.

        **Description:**
            - This function sets the password needed to unlock the calibration functionality of a
              card.

        **TSP Syntax:**

        ::

            - channel.calibration.password()

        Args:
            password: A string of characters that contain the password.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.password("{password}")'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.password()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def save(self) -> None:
        """Run the ``channel.calibration.save()`` function.

        **Description:**
            - This function saves the calibration data to the card.

        **TSP Syntax:**

        ::

            - channel.calibration.save()

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(f"{self._cmd_syntax}.save()")  # type: ignore[union-attr]
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.save()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def step(self, channel: str, step: str, value: Optional[str] = None) -> None:
        """Run the ``channel.calibration.step()`` function.

        **Description:**
            - This function sends a calibration command.

        **TSP Syntax:**

        ::

            - channel.calibration.step()

        Args:
            channel: The channel to be calibrated.
            step: The number corresponding to the specified step.
            value (optional): The measured value for the specified step when the step value is even.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            function_args = ", ".join(
                str(x)
                for x in (
                    channel,
                    step,
                    value,
                )
                if x is not None
            )
            self._device.write(  # type: ignore[union-attr]
                f"{self._cmd_syntax}.step({function_args})"
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.step()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def unlock(self, x: str, password: str) -> None:
        """Run the ``channel.calibration.unlock()`` function.

        **Description:**
            - This function unlocks calibration functionality for a card so that calibration
              operations can be performed.

        **TSP Syntax:**

        ::

            - channel.calibration.unlock()

        Args:
            x: The slot number ( 1 to 6).
            password: The password that unlocks calibration.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f"{self._cmd_syntax}.unlock({x}, {password})"
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.unlock()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def verifydate(self, x: str, date: Optional[str] = None) -> str:
        """Run the ``channel.calibration.verifydate()`` function.

        **Description:**
            - This function gets or sets the date the calibration was verified in UTC format (number
              of seconds since January 1, 1970).

        **TSP Syntax:**

        ::

            - channel.calibration.verifydate()

        Args:
            x: The slot number ( 1 to 6).
            date (optional): UTC formatted date to which to set the calibration verification date.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            function_args = ", ".join(
                str(x)
                for x in (
                    x,
                    date,
                )
                if x is not None
            )
            return self._device.query(  # type: ignore[union-attr]
                f"print({self._cmd_syntax}.verifydate({function_args}))"
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.verifydate()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error


#  pylint: disable=too-many-public-methods
class Channel(BaseTSPCmd):
    """The ``channel`` command tree.

    Properties/methods:
        - ``.calibration``: The ``channel.calibration`` command tree.
        - ``.clearforbidden()``: The ``channel.clearforbidden()`` function.
        - ``.close()``: The ``channel.close()`` function.
        - ``.connectrule``: The ``channel.connectrule`` attribute.
        - ``.connectsequential``: The ``channel.connectsequential`` attribute.
        - ``.exclusiveclose()``: The ``channel.exclusiveclose()`` function.
        - ``.exclusiveslotclose()``: The ``channel.exclusiveslotclose()`` function.
        - ``.getbackplane()``: The ``channel.getbackplane()`` function.
        - ``.getclose()``: The ``channel.getclose()`` function.
        - ``.getcount()``: The ``channel.getcount()`` function.
        - ``.getdelay()``: The ``channel.getdelay()`` function.
        - ``.getforbidden()``: The ``channel.getforbidden()`` function.
        - ``.getimage()``: The ``channel.getimage()`` function.
        - ``.getlabel()``: The ``channel.getlabel()`` function.
        - ``.getmatch()``: The ``channel.getmatch()`` function.
        - ``.getmatchtype()``: The ``channel.getmatchtype()`` function.
        - ``.getmode()``: The ``channel.getmode()`` function.
        - ``.getoutputenable()``: The ``channel.getoutputenable()`` function.
        - ``.getpole()``: The ``channel.getpole()`` function.
        - ``.getpowerstate()``: The ``channel.getpowerstate()`` function.
        - ``.getstate()``: The ``channel.getstate()`` function.
        - ``.getstatelatch()``: The ``channel.getstatelatch()`` function.
        - ``.gettype()``: The ``channel.gettype()`` function.
        - ``.open()``: The ``channel.open()`` function.
        - ``.pattern``: The ``channel.pattern`` command tree.
        - ``.read()``: The ``channel.read()`` function.
        - ``.reset()``: The ``channel.reset()`` function.
        - ``.resetstatelatch()``: The ``channel.resetstatelatch()`` function.
        - ``.setbackplane()``: The ``channel.setbackplane()`` function.
        - ``.setdelay()``: The ``channel.setdelay()`` function.
        - ``.setforbidden()``: The ``channel.setforbidden()`` function.
        - ``.setlabel()``: The ``channel.setlabel()`` function.
        - ``.setmatch()``: The ``channel.setmatch()`` function.
        - ``.setmatchtype()``: The ``channel.setmatchtype()`` function.
        - ``.setmode()``: The ``channel.setmode()`` function.
        - ``.setoutputenable()``: The ``channel.setoutputenable()`` function.
        - ``.setpole()``: The ``channel.setpole()`` function.
        - ``.setstatelatch()``: The ``channel.setstatelatch()`` function.
        - ``.trigger``: The ``channel.trigger[N]`` command tree.
        - ``.write()``: The ``channel.write()`` function.
    """

    def __init__(self, device: Optional["TSPDevice"] = None, cmd_syntax: str = "channel") -> None:
        super().__init__(device, cmd_syntax)
        self._calibration = ChannelCalibration(device, f"{self._cmd_syntax}.calibration")
        self._pattern = ChannelPattern(device, f"{self._cmd_syntax}.pattern")
        self._trigger: Dict[int, ChannelTriggerItem] = DefaultDictPassKeyToFactory(
            lambda x: ChannelTriggerItem(device, f"{self._cmd_syntax}.trigger[{x}]")
        )

    @property
    def calibration(self) -> ChannelCalibration:
        """Return the ``channel.calibration`` command tree.

        Sub-properties/methods:
            - ``.adjustcount()``: The ``channel.calibration.adjustcount()`` function.
            - ``.adjustdate()``: The ``channel.calibration.adjustdate()`` function.
            - ``.lock()``: The ``channel.calibration.lock()`` function.
            - ``.password()``: The ``channel.calibration.password()`` function.
            - ``.save()``: The ``channel.calibration.save()`` function.
            - ``.step()``: The ``channel.calibration.step()`` function.
            - ``.unlock()``: The ``channel.calibration.unlock()`` function.
            - ``.verifydate()``: The ``channel.calibration.verifydate()`` function.
        """
        return self._calibration

    @property
    def connectrule(self) -> str:
        """Access the ``channel.connectrule`` attribute.

        **Description:**
            - This attribute controls the connection rule for closing and opening channels in the
              instrument.

        **Usage:**
            - Accessing this property will send the ``print(channel.connectrule)`` query.
            - Setting this property to a value will send the ``channel.connectrule = value``
              command.

        **TSP Syntax:**

        ::

            - channel.connectrule = value
            - print(channel.connectrule)

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            if self._device.command_syntax_enabled:  # type: ignore[union-attr]
                return self._cmd_syntax + ".connectrule"
            return self._device.query(  # type: ignore[union-attr]
                f"print({self._cmd_syntax}.connectrule)"
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.connectrule`` attribute."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    @connectrule.setter
    def connectrule(self, value: Union[str, float]) -> None:
        """Access the ``channel.connectrule`` attribute.

        **Description:**
            - This attribute controls the connection rule for closing and opening channels in the
              instrument.

        **Usage:**
            - Accessing this property will send the ``print(channel.connectrule)`` query.
            - Setting this property to a value will send the ``channel.connectrule = value``
              command.

        **TSP Syntax:**

        ::

            - channel.connectrule = value
            - print(channel.connectrule)

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            if self._device.command_verification_enabled:  # type: ignore[union-attr]
                self._device.set_and_check(  # type: ignore[union-attr]
                    self._cmd_syntax + ".connectrule", value
                )
            else:
                self._device.write(  # type: ignore[union-attr]
                    f"{self._cmd_syntax}.connectrule = {value}"
                )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.connectrule`` attribute."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    @property
    def connectsequential(self) -> str:
        """Access the ``channel.connectsequential`` attribute.

        **Description:**
            - This attribute controls whether or not channels are closed sequentially.

        **Usage:**
            - Accessing this property will send the ``print(channel.connectsequential)`` query.
            - Setting this property to a value will send the ``channel.connectsequential = value``
              command.

        **TSP Syntax:**

        ::

            - channel.connectsequential = value
            - print(channel.connectsequential)

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            if self._device.command_syntax_enabled:  # type: ignore[union-attr]
                return self._cmd_syntax + ".connectsequential"
            return self._device.query(  # type: ignore[union-attr]
                f"print({self._cmd_syntax}.connectsequential)"
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.connectsequential`` attribute."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    @connectsequential.setter
    def connectsequential(self, value: Union[str, float]) -> None:
        """Access the ``channel.connectsequential`` attribute.

        **Description:**
            - This attribute controls whether or not channels are closed sequentially.

        **Usage:**
            - Accessing this property will send the ``print(channel.connectsequential)`` query.
            - Setting this property to a value will send the ``channel.connectsequential = value``
              command.

        **TSP Syntax:**

        ::

            - channel.connectsequential = value
            - print(channel.connectsequential)

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            if self._device.command_verification_enabled:  # type: ignore[union-attr]
                self._device.set_and_check(  # type: ignore[union-attr]
                    self._cmd_syntax + ".connectsequential", value
                )
            else:
                self._device.write(  # type: ignore[union-attr]
                    f"{self._cmd_syntax}.connectsequential = {value}"
                )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to access the ``{self._cmd_syntax}.connectsequential`` attribute."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    @property
    def pattern(self) -> ChannelPattern:
        """Return the ``channel.pattern`` command tree.

        Sub-properties/methods:
            - ``.delete()``: The ``channel.pattern.delete()`` function.
            - ``.getimage()``: The ``channel.pattern.getimage()`` function.
            - ``.setimage()``: The ``channel.pattern.setimage()`` function.
            - ``.snapshot()``: The ``channel.pattern.snapshot()`` function.
        """
        return self._pattern

    @property
    def trigger(self) -> Dict[int, ChannelTriggerItem]:
        """Return the ``channel.trigger[N]`` command tree.

        **Info:**
            - ``N``, the number indicating the channel trigger event ID (1 to 8).

        Constants:
            - ``.EVENT_ID``: This constant indicates the trigger event generated by the channel
              trigger N.

        Sub-properties/methods:
            - ``.clear()``: The ``channel.trigger[N].clear()`` function.
            - ``.get()``: The ``channel.trigger[N].get()`` function.
            - ``.set()``: The ``channel.trigger[N].set()`` function.
            - ``.wait()``: The ``channel.trigger[N].wait()`` function.
        """
        return self._trigger

    def clearforbidden(self, channel_list: str) -> None:
        """Run the ``channel.clearforbidden()`` function.

        **Description:**
            - This function clears the list of channels specified from being forbidden to close.

        **TSP Syntax:**

        ::

            - channel.clearforbidden()

        Args:
            channel_list: The channels to set, using standard channel naming.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.clearforbidden("{channel_list}")'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.clearforbidden()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def close(self, channel_list: str) -> None:
        """Run the ``channel.close()`` function.

        **Description:**
            - This function closes the channels, analog backplane relays, and channel patterns that
              are specified by the channel list parameter.

        **TSP Syntax:**

        ::

            - channel.close()

        Args:
            channel_list: The channels, analog backplane relays, and channel patterns to close,
                using standard channel naming.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.close("{channel_list}")'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.close()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def exclusiveclose(self, channel_list: str) -> None:
        """Run the ``channel.exclusiveclose()`` function.

        **Description:**
            - This function closes the specified channels so that they are the only channels that
              are closed on the instrument.

        **TSP Syntax:**

        ::

            - channel.exclusiveclose()

        Args:
            channel_list: A string listing the channels (including analog backplane relays) and
                channel patterns to exclusively close.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.exclusiveclose("{channel_list}")'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.exclusiveclose()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def exclusiveslotclose(self, channel_list: str) -> None:
        """Run the ``channel.exclusiveslotclose()`` function.

        **Description:**
            - This function closes the specified channels and channel patterns on the associated
              slots and opens any channels that are not specified.

        **TSP Syntax:**

        ::

            - channel.exclusiveslotclose()

        Args:
            channel_list: A string that lists the channels and channel patterns to exclusively close
                on the cards in associated slots (you can specify analog backplane relays).

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.exclusiveslotclose("{channel_list}")'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.exclusiveslotclose()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getbackplane(self, channel_list: str) -> str:
        """Run the ``channel.getbackplane()`` function.

        **Description:**
            - This function returns a string that lists the analog backplane relays that are
              controlled when the specified channels are used with switching operations.

        **TSP Syntax:**

        ::

            - channel.getbackplane()

        Args:
            channel_list: A string listing the channels being queried.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.getbackplane("{channel_list}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getbackplane()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getclose(self, channel_list: str) -> str:
        """Run the ``channel.getclose()`` function.

        **Description:**
            - This function queries for the closed channels indicated by the channel list parameter.

        **TSP Syntax:**

        ::

            - channel.getclose()

        Args:
            channel_list: A string representing the channels, channel patterns, and backplane relays
                that will be queried.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.getclose("{channel_list}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getclose()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getcount(self, channel_list: str) -> str:
        """Run the ``channel.getcount()`` function.

        **Description:**
            - This function returns the number of times the relays have been closed for the
              specified channels.

        **TSP Syntax:**

        ::

            - channel.getcount()

        Args:
            channel_list: A string listing the items to query, which can include.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.getcount("{channel_list}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getcount()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getdelay(self, channel_list: str) -> str:
        """Run the ``channel.getdelay()`` function.

        **Description:**
            - This function queries for the additional delay time for the specified channels.

        **TSP Syntax:**

        ::

            - channel.getdelay()

        Args:
            channel_list: A string listing the channels to query for their delay times.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.getdelay("{channel_list}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getdelay()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getforbidden(self, channel_list: str) -> str:
        """Run the ``channel.getforbidden()`` function.

        **Description:**
            - This function returns a string listing the channels and analog backplane relays in the
              channel list that are forbidden to close.

        **TSP Syntax:**

        ::

            - channel.getforbidden()

        Args:
            channel_list: A string listing the channels, backplane relays, and channel patterns that
                are to be checked to see if they are forbidden to close.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.getforbidden("{channel_list}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getforbidden()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getimage(self, channel_list: str) -> str:
        """Run the ``channel.getimage()`` function.

        **Description:**
            - This function queries a channel for items associated with that channel when used in a
              switching operation.

        **TSP Syntax:**

        ::

            - channel.getimage()

        Args:
            channel_list: A string representing the channels and analog backplane relays to query.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.getimage("{channel_list}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getimage()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getlabel(self, channel_list: str) -> str:
        """Run the ``channel.getlabel()`` function.

        **Description:**
            - This function retrieves the label associated with one or more channels.

        **TSP Syntax:**

        ::

            - channel.getlabel()

        Args:
            channel_list: A string listing the channels to query for the label associated with them.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.getlabel("{channel_list}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getlabel()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getmatch(self, channel_list: str) -> str:
        """Run the ``channel.getmatch()`` function.

        **Description:**
            - This function gets the match value on a channel.

        **TSP Syntax:**

        ::

            - channel.getmatch()

        Args:
            channel_list: String specifying digital I/O or totalizer channels to query, using normal
                channel list syntax.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.getmatch("{channel_list}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getmatch()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getmatchtype(self, channel_list: str) -> str:
        """Run the ``channel.getmatchtype()`` function.

        **Description:**
            - This function returns the match type for digital I/O and totalizer channels.

        **TSP Syntax:**

        ::

            - channel.getmatchtype()

        Args:
            channel_list: String specifying the digital I/O or totalizer channels to query, using
                normal channel list syntax.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.getmatchtype("{channel_list}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getmatchtype()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getmode(self, channel_list: str) -> str:
        """Run the ``channel.getmode()`` function.

        **Description:**
            - This function returns the present mode of digital and totalizer channels.

        **TSP Syntax:**

        ::

            - channel.getmode()

        Args:
            channel_list: String that specifies the channels to query, using normal channel list
                syntax.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.getmode("{channel_list}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getmode()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getoutputenable(self, channel_list: str) -> str:
        """Run the ``channel.getoutputenable()`` function.

        **Description:**
            - This function gets the present output enable attribute for a channel.

        **TSP Syntax:**

        ::

            - channel.getoutputenable()

        Args:
            channel_list: String specifying the DAC channels to query, using normal channel list
                syntax.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.getoutputenable("{channel_list}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getoutputenable()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getpole(self, channel_list: str) -> str:
        """Run the ``channel.getpole()`` function.

        **Description:**
            - This function queries the pole settings for the specified channels.

        **TSP Syntax:**

        ::

            - channel.getpole()

        Args:
            channel_list: A string listing the channels to query for their pole settings.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.getpole("{channel_list}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getpole()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getpowerstate(self, channel_list: str) -> str:
        """Run the ``channel.getpowerstate()`` function.

        **Description:**
            - This function gets the current power state attribute for a totalizer or DAC channel.

        **TSP Syntax:**

        ::

            - channel.getpowerstate()

        Args:
            channel_list: String specifying the channels to query, using normal channel list syntax.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.getpowerstate("{channel_list}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getpowerstate()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getstate(self, channel_list: str, indicator_mask: Optional[str] = None) -> str:
        """Run the ``channel.getstate()`` function.

        **Description:**
            - This function returns the state indicators of the channels in the instrument.

        **TSP Syntax:**

        ::

            - channel.getstate()

        Args:
            channel_list: String specifying the channels to query, using normal channel list syntax.
            indicator_mask (optional): Value to specify only certain indicators; if omitted, all
                indicators are returned.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            function_args = ", ".join(
                str(x)
                for x in (
                    f'"{channel_list}"',
                    indicator_mask,
                )
                if x is not None
            )
            return self._device.query(  # type: ignore[union-attr]
                f"print({self._cmd_syntax}.getstate({function_args}))"
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getstate()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def getstatelatch(self, channel_list: str) -> str:
        """Run the ``channel.getstatelatch()`` function.

        **Description:**
            - This function gets the mask representing the states that would be latched if they
              occurred.

        **TSP Syntax:**

        ::

            - channel.getstatelatch()

        Args:
            channel_list: String specifying the channels to query, using normal channel list syntax.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.getstatelatch("{channel_list}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.getstatelatch()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def gettype(self, channel_list: str) -> str:
        """Run the ``channel.gettype()`` function.

        **Description:**
            - This function returns the type associated with a channel.

        **TSP Syntax:**

        ::

            - channel.gettype()

        Args:
            channel_list: String specifying the channels to query, using normal channelList syntax.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            return self._device.query(  # type: ignore[union-attr]
                f'print({self._cmd_syntax}.gettype("{channel_list}"))'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.gettype()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def open(self, channel_list: str) -> None:
        """Run the ``channel.open()`` function.

        **Description:**
            - This function opens the specified channels, analog backplane relays, and channel
              patterns.

        **TSP Syntax:**

        ::

            - channel.open()

        Args:
            channel_list: String listing the channels, analog backplane relays, and channel patterns
                to open.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.open("{channel_list}")'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.open()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def read(
        self, channel_list: str, width: Optional[str] = None, reading_buffer: Optional[str] = None
    ) -> str:
        """Run the ``channel.read()`` function.

        **Description:**
            - This function reads a value from a totalizer, DAC, or digital I/O channel.

        **TSP Syntax:**

        ::

            - channel.read()

        Args:
            channel_list: The channels to set, using standard channel naming.
            width (optional): Specifies reading over multiple consecutive channels (default 1).
            reading_buffer (optional): Reading buffer to store read values.

        Returns:
            The result of the function call.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            function_args = ", ".join(
                str(x)
                for x in (
                    f'"{channel_list}"',
                    width,
                    reading_buffer,
                )
                if x is not None
            )
            return self._device.query(  # type: ignore[union-attr]
                f"print({self._cmd_syntax}.read({function_args}))"
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.read()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def reset(self, channel_list: str) -> None:
        """Run the ``channel.reset()`` function.

        **Description:**
            - This function resets the specified channel list items to factory default settings.

        **TSP Syntax:**

        ::

            - channel.reset()

        Args:
            channel_list: A string that lists the items to reset; the string can include.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.reset("{channel_list}")'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.reset()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def resetstatelatch(self, channel_list: str, state: str) -> None:
        """Run the ``channel.resetstatelatch()`` function.

        **Description:**
            - This function resets the channel state.

        **TSP Syntax:**

        ::

            - channel.resetstatelatch()

        Args:
            channel_list: String that specifies the channels that need to have their states reset,
                using normal channel list syntax.
            state: The comma-delimited states for channels in channelList that are to have their
                states reset.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.resetstatelatch("{channel_list}", {state})'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.resetstatelatch()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def setbackplane(self, channel_list: str, abuslist: str) -> None:
        """Run the ``channel.setbackplane()`` function.

        **Description:**
            - This function specifies the list of analog backplane relays to use with the specified
              channels when they are used in switching applications.

        **TSP Syntax:**

        ::

            - channel.setbackplane()

        Args:
            channel_list: A string that lists the channels to change.
            abuslist: A string that lists the analog backplane relays to set for the channels
                specified in channelList.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.setbackplane("{channel_list}", "{abuslist}")'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.setbackplane()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def setdelay(self, channel_list: str, delay: float) -> None:
        """Run the ``channel.setdelay()`` function.

        **Description:**
            - This function sets additional delay time for specified channels.

        **TSP Syntax:**

        ::

            - channel.setdelay()

        Args:
            channel_list: A string listing the channels for which to add delay time.
            delay: Delay time for the selected channels; minimum is 0 seconds.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.setdelay("{channel_list}", {delay})'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.setdelay()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def setforbidden(self, channel_list: str) -> None:
        """Run the ``channel.setforbidden()`` function.

        **Description:**
            - This function prevents the closing of specified channels and analog backplane relays.

        **TSP Syntax:**

        ::

            - channel.setforbidden()

        Args:
            channel_list: A string that lists the channels and analog backplane relays to make
                forbidden to close.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.setforbidden("{channel_list}")'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.setforbidden()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def setlabel(self, channel_list: str, labelname: str) -> None:
        """Run the ``channel.setlabel()`` function.

        **Description:**
            - This function sets the label associated with a channel.

        **TSP Syntax:**

        ::

            - channel.setlabel()

        Args:
            channel_list: A string that lists the channel to which to set the label; the string
                cannot contain spaces.
            labelname: A string that contains the label for the channel in channelList, up to 19
                characters.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.setlabel("{channel_list}", "{labelname}")'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.setlabel()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def setmatch(
        self,
        channel_list: str,
        match_value: str,
        mask: Optional[str] = None,
        width: Optional[str] = None,
    ) -> None:
        """Run the ``channel.setmatch()`` function.

        **Description:**
            - This function sets the match value on a digital input or totalizer channel.

        **TSP Syntax:**

        ::

            - channel.setmatch()

        Args:
            channel_list: String that specifies the channels to query, using normal channel list
                syntax.
            match_value: Channel value to compare on the specified channel.
            mask (optional): Value to specify the bits used to mask matchValue.
            width (optional): Value that specifies matches over multiple consecutive channels
                (default 1).

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            function_args = ", ".join(
                str(x)
                for x in (
                    f'"{channel_list}"',
                    match_value,
                    mask,
                    width,
                )
                if x is not None
            )
            self._device.write(  # type: ignore[union-attr]
                f"{self._cmd_syntax}.setmatch({function_args})"
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.setmatch()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def setmatchtype(self, channel_list: str, type_: str) -> None:
        """Run the ``channel.setmatchtype()`` function.

        **Description:**
            - This function sets the match type on a channel.

        **TSP Syntax:**

        ::

            - channel.setmatchtype()

        Args:
            channel_list: String specifying the channels to set, using normal channel list syntax.
            type_: A value for setting the match operation used on this specific channel.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.setmatchtype("{channel_list}", {type_})'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.setmatchtype()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def setmode(self, channel_list: str, mode: str) -> None:
        """Run the ``channel.setmode()`` function.

        **Description:**
            - This function sets the mode of operation of a channel.

        **TSP Syntax:**

        ::

            - channel.setmode()

        Args:
            channel_list: String specifying the channels to set, using normal channel list syntax.
            mode: The value that sets the mode of operation for a channel; see Details.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.setmode("{channel_list}", {mode})'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.setmode()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def setoutputenable(self, channel_list: str, state: str) -> None:
        """Run the ``channel.setoutputenable()`` function.

        **Description:**
            - This function sets the output enable attribute on a channel.

        **TSP Syntax:**

        ::

            - channel.setoutputenable()

        Args:
            channel_list: String specifying the channels to set, using normal channel list syntax.
            state: A value representing the state of the output of the channel.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.setoutputenable("{channel_list}", {state})'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.setoutputenable()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def setpole(self, channel_list: str, value: str) -> None:
        """Run the ``channel.setpole()`` function.

        **Description:**
            - This function specifies the pole setting for a list of channels.

        **TSP Syntax:**

        ::

            - channel.setpole()

        Args:
            channel_list: String specifying the channels to set, using normal channel list syntax.
            value: Pole setting for the channels in channelList. Use the following.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.setpole("{channel_list}", {value})'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.setpole()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def setstatelatch(self, channel_list: str, state_latch_mask: str) -> None:
        """Run the ``channel.setstatelatch()`` function.

        **Description:**
            - This function sets the state indicators to either latching or nonlatching.

        **TSP Syntax:**

        ::

            - channel.setstatelatch()

        Args:
            channel_list: The channels to set, using standard channel naming.
            state_latch_mask: A value specifying the indicators to latch.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            self._device.write(  # type: ignore[union-attr]
                f'{self._cmd_syntax}.setstatelatch("{channel_list}", {state_latch_mask})'
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.setstatelatch()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error

    def write(self, channel_list: str, value: str, width: Optional[str] = None) -> None:
        """Run the ``channel.write()`` function.

        **Description:**
            - This function writes a value to a channel.

        **TSP Syntax:**

        ::

            - channel.write()

        Args:
            channel_list: The channels to set, using standard channel naming.
            value: The value to be written to the channel (must be decimal value).
            width (optional): Value that specifies the channel width of the write.

        Raises:
            tm_devices.commands.NoDeviceProvidedError: Indicates that no device connection exists.
        """
        try:
            function_args = ", ".join(
                str(x)
                for x in (
                    f'"{channel_list}"',
                    value,
                    width,
                )
                if x is not None
            )
            self._device.write(  # type: ignore[union-attr]
                f"{self._cmd_syntax}.write({function_args})"
            )
        except AttributeError as error:
            msg = f"No TSPDevice object was provided, unable to run the ``{self._cmd_syntax}.write()`` function."  # noqa: E501
            raise NoDeviceProvidedError(msg) from error
