"""Autogenerated module for the PIDAdvisorModule QCoDeS driver."""
import typing as t
from zhinst.toolkit.driver.modules.pid_advisor_module import (
    PIDAdvisorModule as TKPIDAdvisorModule,
)

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


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


class ZIPIDAdvisorModule(ZIBaseModule):
    """PID Advisor Module.

    The PID Advisor Module provides the functionality available in the Advisor,
    Tuner and Display sub-tabs of the LabOne User Interface’s PID / PLL tab.
    The PID Advisor is a mathematical model of the instrument’s PID and can be
    used to calculate PID controller parameters for optimal feedback loop
    performance. The controller gains calculated by the module can be easily
    transferred to the device via the API and the results of the Advisor’s
    modeling are available as Bode and step response plot data.

    For a complete documentation see the LabOne user manual
    https://docs.zhinst.com/labone_programming_manual/pid_advisor_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: TKPIDAdvisorModule,
        session: "Session",
        name: str = "pid_advisor_module",
    ):
        super().__init__(tk_object, session, name)

    def wait_done(self, *, timeout: float = 20.0, sleep_time: float = 2) -> None:
        """Waits until the pid advisor is finished.

        Args:
            timeout (float): The maximum waiting time in seconds for the
                measurement (default: 20).
            sleep_time (int): Time in seconds to wait between
                requesting sweeper state. (default: 0.5)

        Raises:
            TimeoutError: The measurement is not completed before
                timeout.
        """
        return self._tk_object.wait_done(timeout=timeout, sleep_time=sleep_time)
