from UniTAP.libs.lib_tsi.tsi_io import PortIO
from .pr_private_types import *
from UniTAP.libs.lib_tsi.tsi import *
from .pr_types import *


class PanelReplayStatus:
    """
    Class `PanelReplayStatus` contains information about Panel Replay Status.
    - Get PR command `command`.
    - Get current state (enabled/disabled) `status`.
    - Get PR Error `error`.
    """

    def __init__(self, port_io: PortIO):
        self.__io = port_io

    def command(self) -> PRCommand:
        """
        Returns current command of PR.

        Returns:
            object of `PRCommand` type
        """
        return PRCommand(self.__read().command_status)

    def status(self) -> PRStatus:
        """
        Returns current status of PR (enabled/disabled).

        Returns:
            object of `PRStatus` type
        """
        return PRStatus(self.__read().status)

    def error(self) -> PRError:
        """
        Returns current error of PR.

        Returns:
            object of `PRError` type
        """
        return PRError(self.__read().error)

    def __read(self) -> PrStatus:
        self.__io.set(TSI_PG_STREAM_SELECT, 0)
        return self.__io.get(TSI_PG_PR_STATUS_R, PrStatus)[1]

