from .tx import *
from .modules.edid.edid import EdidSource
from .modules.link.hdmi.link import HdmiLinkTx
from .modules.vtg.pg import HdmiPatternGenerator
from .modules.hdcp import HdcpSource
from .modules.capturer.event.event_capturer import EventCapturer, EventFilterHdTx
from .modules.cec.cec_tx import CecTx
from UniTAP.libs.lib_tsi.tsi_types import TSI_HDTX_HDCP_CAPS_R, TSI_HDTX_HDCP_STATUS_R
from UniTAP.libs.lib_tsi.tsi_types import TSI_HDTX_LOG_CONTROL


class HDTX(TX):

    """

    Main class of `HDTX` object.
    Inherited from class `TX`.
    Class describes capabilities of 300th (3XX) series of HDMI devices in Source (TX - transmitter) role.

    Attributes:
        __link (HdmiLinkTx): object of `HdmiLinkTx`.
        __edid (EdidSource): object of `EdidSource`.
        __hdcp (HdcpSource): object of `HdcpSource`.
        __pg (HdmiPatternGenerator): object of `HdmiPatternGenerator`.
        __event_capturer (EventCapturer): object of `EventCapturer`.
        __cec (CecTx): object of `CecTx`.
    """

    def __init__(self, port_io: PortIO, memory_manager: MemoryManager, capturer: Capturer):
        super().__init__(port_io, memory_manager, capturer)

        self.__link = HdmiLinkTx(port_io)
        self.__edid = EdidSource(port_io, 1)
        self.__pg = HdmiPatternGenerator(port_io, memory_manager)
        self.__hdcp = HdcpSource(port_io, TSI_HDTX_HDCP_CAPS_R, TSI_HDTX_HDCP_STATUS_R)
        self.__event_capturer = EventCapturer(capturer, port_io.index(), [EventFilterHdTx(0)])
        self.__cec = CecTx(port_io)

    @property
    def link(self) -> HdmiLinkTx:
        """

        Should be used to control link settings on Source (TX - transmitter) side.

        Returns:
            object of `HdmiLinkTx` type.
        """
        return self.__link

    @property
    def pg(self) -> HdmiPatternGenerator:
        """

        Should be used to control Pattern generator functionality on Source (TX - transmitter) side.

        Returns:
            object of `HdmiPatternGenerator` type.
        """
        return self.__pg

    @property
    def edid(self):
        """

        Should be used to work with EDID on Source (TX - transmitter) side.

        Returns:
            object of `EdidSource` type.
        """
        return self.__edid

    @property
    def hdcp(self) -> HdcpSource:
        """

        Should be used to work with HDCP on Source (TX - transmitter) side.

        Returns:
            object of `HdcpSource`.
        """
        return self.__hdcp

    @property
    def event_capturer(self) -> EventCapturer:
        """

        Should be used to control `EventCapturer` on Source (TX - transmitter) role.

        Returns:
            object of `EventCapturer` type.
        """
        return self.__event_capturer

    @property
    def cec(self) -> CecTx:
        """

        Should be used to control `CecTx` on Source (TX - transmitter) role.

        Returns:
            object of `CecTx` type.
        """
        return self.__cec
