"""Autogenerated module for the SweeperModule QCoDeS driver."""
import typing as t
from zhinst.toolkit.driver.modules.sweeper_module import (
    SweeperModule as TKSweeperModule,
)

from zhinst.qcodes.driver.modules.base_module import ZIBaseModule


if t.TYPE_CHECKING:
    from zhinst.qcodes.session import Session


class ZISweeperModule(ZIBaseModule):
    """Implements a base Sweeper Module for Lock-In instruments.

    The Sweeper Module allows for simple and efficient parameter sweeps while
    acquiring data streams from multiple different signal sources. The module
    supports well defined sweeps of various parameters as well as application
    specific measurement presets. For more information on how to use the Sweeper
    Module, have a look at the LabOne Programming Manual.

    For a complete documentation see the LabOne user manual
    https://docs.zhinst.com/labone_programming_manual/sweeper_module.html


    Args:
        tk_object: Underlying zhinst-toolkit object.
        session: Session to the Data Server.
        name: Name of the module in QCoDeS.
    """

    def __init__(
        self,
        tk_object: TKSweeperModule,
        session: "Session",
        name: str = "sweeper_module",
    ):
        super().__init__(tk_object, session, name)

        self._tk_object.root.update_nodes(
            {
                "/gridnode": {
                    "GetParser": lambda value: self._get_node(value),
                    "SetParser": lambda value: self._set_node(value),
                }
            },
            raise_for_invalid_node=False,
        )

    def finish(self) -> None:
        """Stop the module.

        .. versionadded:: 0.5.0
        """
        return self._tk_object.finish()
