# ruff: noqa: D402,PLR0913
# pyright: reportConstantRedefinition=none
"""The trigger commands module.

These commands are used in the following models: SMU2601B_Pulse

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

Please report an issue if one is found.
"""
from typing import Dict, Optional, TYPE_CHECKING

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

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


# pylint: disable=too-few-public-methods
class TriggerTimerItem(ValidatedDynamicNumberCmd, BaseTSPCmd):
    """The ``trigger.timer[N]`` command tree.

    Constants:
        - ``.EVENT_ID``: The trigger timer event number (1 to 8).
    """

    EVENT_ID = "trigger.timer[N].EVENT_ID"
    """str: The trigger timer event number (1 to 8)."""

    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]}]"
        )


# pylint: disable=too-few-public-methods
class TriggerGeneratorItem(ValidatedDynamicNumberCmd, BaseTSPCmd):
    """The ``trigger.generator[N]`` command tree.

    Constants:
        - ``.EVENT_ID``: The trigger event generated by  trigger event generator 1.
    """

    EVENT_ID = "trigger.generator[N].EVENT_ID"
    """str: The trigger event generated by  trigger event generator 1."""

    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]}]"
        )


# pylint: disable=too-few-public-methods
class TriggerBlenderItem(ValidatedDynamicNumberCmd, BaseTSPCmd):
    """The ``trigger.blender[N]`` command tree.

    Constants:
        - ``.EVENT_ID``: Selects the event that causes a trigger to be asserted on the digital
          output line after a collection of events is detected.
    """

    EVENT_ID = "trigger.blender[N].EVENT_ID"
    """str: Selects the event that causes a trigger to be asserted on the digital output line after a collection of events is detected."""  # noqa: E501

    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]}]"
        )


class Trigger(BaseTSPCmd):
    r"""The ``trigger`` command tree.

    Constants:
        - ``.EVENT_ID``: Selects the event that causes a trigger to be asserted on the digital
          output line as a \*TRG command received on the remote interface.

    Properties/methods:
        - ``.blender``: The ``trigger.blender[N]`` command tree.
        - ``.generator``: The ``trigger.generator[N]`` command tree.
        - ``.timer``: The ``trigger.timer[N]`` command tree.
    """

    EVENT_ID = "trigger.EVENT_ID"
    r"""str: Selects the event that causes a trigger to be asserted on the digital output line as a \*TRG command received on the remote interface."""  # noqa: E501

    def __init__(self, device: Optional["TSPDevice"] = None, cmd_syntax: str = "trigger") -> None:
        super().__init__(device, cmd_syntax)
        self._blender: Dict[int, TriggerBlenderItem] = DefaultDictPassKeyToFactory(
            lambda x: TriggerBlenderItem(device, f"{self._cmd_syntax}.blender[{x}]")
        )
        self._generator: Dict[int, TriggerGeneratorItem] = DefaultDictPassKeyToFactory(
            lambda x: TriggerGeneratorItem(device, f"{self._cmd_syntax}.generator[{x}]")
        )
        self._timer: Dict[int, TriggerTimerItem] = DefaultDictPassKeyToFactory(
            lambda x: TriggerTimerItem(device, f"{self._cmd_syntax}.timer[{x}]")
        )

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

        Constants:
            - ``.EVENT_ID``: Selects the event that causes a trigger to be asserted on the digital
              output line after a collection of events is detected.
        """
        return self._blender

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

        Constants:
            - ``.EVENT_ID``: The trigger event generated by  trigger event generator 1.
        """
        return self._generator

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

        Constants:
            - ``.EVENT_ID``: The trigger timer event number (1 to 8).
        """
        return self._timer
