from .dptx import *
from .modules.fec import FecTx, FECCounters, FECErrorType8b10b
from .modules.vtg.pg import DpMstPatternGenerator
from .modules.edid.edid import DisplayIdSource


class DPTX4xx(DPTX):

    """

    Main class of `DPTX4xx` object.
    Inherited from class `DPTX`.
    Class describes capabilities of 400th (4XX) series of DP and USB-C devices in Source (TX - transmitter) role.

    Attributes:
        __fec (FecTx): object of `FecTx`.
        __pg (DpMstPatternGenerator): object of `DpMstPatternGenerator`

    """

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

        hw_caps = port_io.get(TSI_DPTX_HW_CAPS_R, DPTXHWCaps)[1]
        self.__fec = FecTx(port_io, self.dpcd)
        self.__pg = DpMstPatternGenerator(port_io, memory_manager, hw_caps.mst_stream_count)
        self.__display_id = DisplayIdSource(port_io, hw_caps.mst_stream_count)

    @property
    def fec(self) -> FecTx:
        """

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

        Returns:
            object of `FecTx` type.
        """
        return self.__fec

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

        Should be used to control Pattern generator functionality on Source (TX - transmitter) side.
        `DpMstPatternGenerator` contain list of `DpPatternGenerator` objects. For access to element in list,
        use expression `pg.[index]`.

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

    @property
    def display_id(self) -> DisplayIdSource:
        """

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

        Returns:
            object of `DisplayIdSource` type.
        """
        return self.__display_id