from UniTAP.libs.lib_tsi import PortIO
from .private_link_rx_types import CableAttributesStruct, PortCableAttributesStruct
from .link_rx_types import CableCapabilitiesEnum


class DpCableInfo:

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

    def __read_cable_attributes(self) -> CableAttributesStruct:
        return self.__io.get(self.__ci, CableAttributesStruct)[1]

    def get_current_port_cable_type(self) -> CableCapabilitiesEnum:
        return PortCableAttributesStruct(self.__read_cable_attributes().currentPort).get_cable_caps()

    def get_another_port_cable_type(self) -> CableCapabilitiesEnum:
        return PortCableAttributesStruct(self.__read_cable_attributes().anotherPort).get_cable_caps()
