from .pdc_io import PDCPortIO


class BusElectricalStatus:

    """
    Class `BusElectricalStatus` contains information about current BUU Electrical status.
    - Get VBus voltage `vbus_voltage`, type `int`.
    - Get VBus current `vbus_current`, type `int`.
    - Get CC1 voltage `cc1_voltage`, type `int`.
    - Get CC2 voltage `cc2_voltage`, type `int`.
    - Get VCONN voltage `vconn_voltage`, type `int`.
    - Get VCONN current `vconn_current`, type `int`.
    - Get SBU-1 voltage `sbu_1_voltage`, type `int`.
    - Get SBU-2 voltage `sbu_2_voltage`, type `int`.
    """

    def __init__(self, pdc_io: PDCPortIO):
        self.__io = pdc_io

    @property
    def vbus_voltage(self) -> int:
        """
        Returns current VBus voltage.

        Returns:
            object of `int` type
        """
        return self.__io.read_adc_vbus_status()[0]

    @property
    def vbus_current(self) -> int:
        """
        Returns current VBus current.

        Returns:
            object of `int` type
        """
        return self.__io.read_adc_vbus_status()[1]

    @property
    def cc1_voltage(self) -> int:
        """
        Returns current CC1 voltage.

        Returns:
            object of `int` type
        """
        return self.__io.read_adc_vbus_status()[2]

    @property
    def cc2_voltage(self) -> int:
        """
        Returns current CC2 voltage.

        Returns:
            object of `int` type
        """
        return self.__io.read_adc_vbus_status()[3]

    @property
    def vconn_voltage(self) -> int:
        """
        Returns current VCONN voltage.

        Returns:
            object of `int` type
        """
        return self.__io.read_adc_vbus_status()[4]

    @property
    def vconn_current(self) -> int:
        """
        Returns current VCONN current.

        Returns:
            object of `int` type
        """
        return self.__io.read_adc_vbus_status()[5]

    @property
    def sbu_1_voltage(self) -> int:
        """
        Returns current SBU-1 voltage.

        Returns:
            object of `int` type
        """
        return self.__io.read_adc_vbus_status()[6]

    @property
    def sbu_2_voltage(self) -> int:
        """
        Returns current SBU-2 voltage.

        Returns:
            object of `int` type
        """
        return self.__io.read_adc_vbus_status()[7]

    def __str__(self) -> str:
        electrical_status = self.__io.read_adc_vbus_status()
        return f"Bus Electrical Status\n" \
               f"VBus current: {electrical_status[0]}\n" \
               f"VBus voltage: {electrical_status[1]}\n" \
               f"CC1 voltage: {electrical_status[2]}\n" \
               f"CC2 voltage: {electrical_status[3]}\n" \
               f"VCONN voltage: {electrical_status[4]}\n" \
               f"VCONN current: {electrical_status[5]}\n" \
               f"SBU-1 voltage: {electrical_status[6]}\n" \
               f"SBU-2 voltage: {electrical_status[7]}\n"
