from UniTAP.dev.modules.dut_tests.test_group_params_types import Param


class HdmiElectricalTestParam:
    """
    Class `DpElectricalTestParam` describes parameters for DP electrical tests.
    - Test timeout, in milliseconds `timeout`.
    - HDMI power line voltage low limit, in millivolts `power_low_limit`.
    - HDMI power line voltage high limit, in millivolts `power_high_limit`.
    - HDMI link line voltage low limit, in millivolts `link_low_limit`.
    - HDMI link line voltage high limit, in millivolts `link_high_limit`.
    - HDMI HPD logical zero voltage level, lower limit, in millivolts `hpd_zero_low_limit`.
    - HDMI HPD logical zero voltage level, higher limit, in millivolts `hpd_zero_high_limit`.
    - HDMI HPD logical one voltage level, lower limit, in millivolts `hpd_one_low_limit`.
    - HDMI HPD logical one voltage level, higher limit, in millivolts `hpd_one_high_limit`.
    - DDC Line voltage low limit, in millivolts `ddc_low_limit`.
    - DDC Line voltage high limit, in millivolts `_ddc_high_limit`.
    - CCE Line logical zero voltage level, lower limit, in millivolts `cec_zero_low_limit`.
    - CCE Line logical zero voltage level, higher limit, in millivolts `cec_zero_high_limit`.
    - CCE Line logical one voltage level, lower limit, in millivolts `cec_one_low_limit`.
    - CCE Line logical one voltage level, higher limit, in millivolts `cec_one_high_limit`.
    """
    def __init__(self, json_obj):
        self.__timeout = Param(json_obj["TSI_HDMI_RX_TIMEOUT"])
        self.__power_low_limit = Param(json_obj["TSI_HDMI_RX_POWER_LOW_LIMIT"])
        self.__power_high_limit = Param(json_obj["TSI_HDMI_RX_POWER_HIGH_LIMIT"])
        self.__link_low_limit = Param(json_obj["TSI_HDMI_RX_LINK_LOW_LIMIT"])
        self.__link_high_limit = Param(json_obj["TSI_HDMI_RX_LINK_HIGH_LIMIT"])
        self.__hpd_zero_low_limit = Param(json_obj["TSI_HDMI_RX_HPD_ZERO_LOW_LIMIT"])
        self.__hpd_zero_high_limit = Param(json_obj["TSI_HDMI_RX_HPD_ZERO_HIGH_LIMIT"])
        self.__hpd_one_low_limit = Param(json_obj["TSI_HDMI_RX_HPD_ONE_LOW_LIMIT"])
        self.__hpd_one_high_limit = Param(json_obj["TSI_HDMI_RX_HPD_ONE_HIGHT_LIMIT"])
        self.__ddc_low_limit = Param(json_obj["TSI_HDMI_RX_DDC_LOW_LIMIT"])
        self.__ddc_high_limit = Param(json_obj["TSI_HDMI_RX_DDC_HIGH_LIMIT"])
        self.__cec_zero_low_limit = Param(json_obj["TSI_HDMI_RX_CEC_ZERO_LOW_LIMIT"])
        self.__cec_zero_high_limit = Param(json_obj["TSI_HDMI_RX_CEC_ZERO_HIGH_LIMIT"])
        self.__cec_one_low_limit = Param(json_obj["TSI_HDMI_RX_CEC_ONE_LOW_LIMIT"])
        self.__cec_one_high_limit = Param(json_obj["TSI_HDMI_RX_CEC_ONE_HIGH_LIMIT"])

    @property
    def timeout(self) -> int:
        """
        Set and get test timeout, in milliseconds.

        Returns:
            object of int type
        """
        return self.__timeout.default_value

    @timeout.setter
    def timeout(self, timeout: int):
        if not(self.__timeout.min_value < timeout < self.__timeout.max_value):
            raise ValueError(f"Timeout cannot be less than {self.__timeout.min_value} and more than "
                             f"{self.__timeout.max_value}.")
        self.__timeout.default_value = timeout

    @property
    def power_low_limit(self) -> int:
        """
        Set and get HDMI power line voltage low limit.

        Returns:
            object of int type
        """
        return self.__power_low_limit.default_value

    @power_low_limit.setter
    def power_low_limit(self, power_low_limit: int):
        if not(self.__power_low_limit.min_value < power_low_limit < self.__power_low_limit.max_value):
            raise ValueError(f"Power low limit cannot be less than {self.__power_low_limit.min_value} and more than "
                             f"{self.__power_low_limit.max_value}.")
        self.__power_low_limit.default_value = power_low_limit

    @property
    def power_high_limit(self) -> int:
        """
        Set and get HDMI power line voltage high limit.

        Returns:
            object of int type
        """
        return self.__power_high_limit.default_value

    @power_high_limit.setter
    def power_high_limit(self, power_high_limit: int):
        if not(self.__power_high_limit.min_value < power_high_limit < self.__power_high_limit.max_value):
            raise ValueError(f"Power high limit cannot be less than {self.__power_high_limit.min_value} and more than "
                             f"{self.__power_high_limit.max_value}.")
        self.__power_high_limit.default_value = power_high_limit

    @property
    def link_low_limit(self) -> int:
        """
        Set and get HDMI link line voltage low limit.

        Returns:
            object of int type
        """
        return self.__link_low_limit.default_value

    @link_low_limit.setter
    def link_low_limit(self, link_low_limit: int):
        if not(self.__link_low_limit.min_value < link_low_limit < self.__link_low_limit.max_value):
            raise ValueError(f"Link low limit cannot be less than {self.__link_low_limit.min_value} and more than "
                             f"{self.__link_low_limit.max_value}.")
        self.__link_low_limit.default_value = link_low_limit

    @property
    def link_high_limit(self) -> int:
        """
        Set and get HDMI link line voltage high limit.

        Returns:
            object of int type
        """
        return self.__link_high_limit.default_value

    @link_high_limit.setter
    def link_high_limit(self, link_high_limit: int):
        if not(self.__link_high_limit.min_value < link_high_limit < self.__link_high_limit.max_value):
            raise ValueError(f"Link high limit cannot be less than {self.__link_high_limit.min_value} and more than "
                             f"{self.__link_high_limit.max_value}.")
        self.__link_high_limit.default_value = link_high_limit

    @property
    def hpd_zero_low_limit(self) -> int:
        """
        Set and get HDMI HPD logical zero voltage level, lower limit.

        Returns:
            object of int type
        """
        return self.__hpd_zero_low_limit.default_value

    @hpd_zero_low_limit.setter
    def hpd_zero_low_limit(self, hpd_zero_low_limit: int):
        if not(self.__hpd_zero_low_limit.min_value < hpd_zero_low_limit < self.__hpd_zero_low_limit.max_value):
            raise ValueError(f"HPD zero low limit cannot be less than {self.__hpd_zero_low_limit.min_value} "
                             f"and more than {self.__hpd_zero_low_limit.max_value}.")
        self.__hpd_zero_low_limit.default_value = hpd_zero_low_limit

    @property
    def hpd_zero_high_limit(self) -> int:
        """
        Set and get HDMI HPD logical zero voltage level, higher limit.

        Returns:
            object of int type
        """
        return self.__hpd_zero_high_limit.default_value

    @hpd_zero_high_limit.setter
    def hpd_zero_high_limit(self, hpd_zero_high_limit: int):
        if not(self.__hpd_zero_high_limit.min_value < hpd_zero_high_limit < self.__hpd_zero_high_limit.max_value):
            raise ValueError(f"HPD zero high limit cannot be less than {self.__hpd_zero_high_limit.min_value} "
                             f"and more than {self.__hpd_zero_high_limit.max_value}.")
        self.__hpd_zero_high_limit.default_value = hpd_zero_high_limit

    @property
    def hpd_one_low_limit(self) -> int:
        """
        Set and get HDMI HPD logical one voltage level, lower limit.

        Returns:
            object of int type
        """
        return self.__hpd_one_low_limit.default_value

    @hpd_one_low_limit.setter
    def hpd_one_low_limit(self, hpd_one_low_limit: int):
        if not(self.__hpd_one_low_limit.min_value < hpd_one_low_limit < self.__hpd_one_low_limit.max_value):
            raise ValueError(f"HPD one low limit cannot be less than {self.__hpd_one_low_limit.min_value} "
                             f"and more than {self.__hpd_one_low_limit.max_value}.")
        self.__hpd_one_low_limit.default_value = hpd_one_low_limit

    @property
    def hpd_one_high_limit(self) -> int:
        """
        Set and get HDMI HPD logical one voltage level, higher limit.

        Returns:
            object of int type
        """
        return self.__hpd_one_high_limit.default_value

    @hpd_one_high_limit.setter
    def hpd_one_high_limit(self, hpd_one_high_limit: int):
        if not(self.__hpd_one_high_limit.min_value < hpd_one_high_limit < self.__hpd_one_high_limit.max_value):
            raise ValueError(f"HPD one high limit cannot be less than {self.__hpd_one_high_limit.min_value} "
                             f"and more than {self.__hpd_one_high_limit.max_value}.")
        self.__hpd_one_high_limit.default_value = hpd_one_high_limit

    @property
    def ddc_low_limit(self) -> int:
        """
        Set and get DDC Line voltage low limit.

        Returns:
            object of int type
        """
        return self.__ddc_low_limit.default_value

    @ddc_low_limit.setter
    def ddc_low_limit(self, ddc_low_limit: int):
        if not(self.__ddc_low_limit.min_value < ddc_low_limit < self.__ddc_low_limit.max_value):
            raise ValueError(f"DDC low limit cannot be less than {self.__ddc_low_limit.min_value} and more than "
                             f"{self.__ddc_low_limit.max_value}.")
        self.__ddc_low_limit.default_value = ddc_low_limit

    @property
    def ddc_high_limit(self) -> int:
        """
        Set and get DDC Line voltage high limit.

        Returns:
            object of int type
        """
        return self.__ddc_high_limit.default_value

    @ddc_high_limit.setter
    def ddc_high_limit(self, ddc_high_limit: int):
        if not(self.__ddc_high_limit.min_value < ddc_high_limit < self.__ddc_high_limit.max_value):
            raise ValueError(f"DDC high limit cannot be less than {self.__ddc_high_limit.min_value} and more than "
                             f"{self.__ddc_high_limit.max_value}.")
        self.__ddc_high_limit.default_value = ddc_high_limit

    @property
    def cec_zero_low_limit(self) -> int:
        """
        Set and get CCE Line logical zero voltage level, lower limit.

        Returns:
            object of int type
        """
        return self.__cec_zero_low_limit.default_value

    @cec_zero_low_limit.setter
    def cec_zero_low_limit(self, cec_zero_low_limit: int):
        if not(self.__cec_zero_low_limit.min_value < cec_zero_low_limit < self.__cec_zero_low_limit.max_value):
            raise ValueError(f"CEC zero low limit cannot be less than {self.__cec_zero_low_limit.min_value} "
                             f"and more than {self.__cec_zero_low_limit.max_value}.")
        self.__cec_zero_low_limit.default_value = cec_zero_low_limit

    @property
    def cec_zero_high_limit(self) -> int:
        """
        Set and get CCE Line logical zero voltage level, higher limit.

        Returns:
            object of int type
        """
        return self.__cec_zero_high_limit.default_value

    @cec_zero_high_limit.setter
    def cec_zero_high_limit(self, cec_zero_high_limit: int):
        if not(self.__cec_zero_high_limit.min_value < cec_zero_high_limit < self.__cec_zero_high_limit.max_value):
            raise ValueError(f"CEC zero high limit cannot be less than {self.__cec_zero_high_limit.min_value} "
                             f"and more than {self.__cec_zero_high_limit.max_value}.")
        self.__cec_zero_high_limit.default_value = cec_zero_high_limit

    @property
    def cec_one_low_limit(self) -> int:
        """
        Set and get CCE Line logical one voltage level, lower limit.

        Returns:
            object of int type
        """
        return self.__cec_one_low_limit.default_value

    @cec_one_low_limit.setter
    def cec_one_low_limit(self, cec_one_low_limit: int):
        if not(self.__cec_one_low_limit.min_value < cec_one_low_limit < self.__cec_one_low_limit.max_value):
            raise ValueError(f"CEC one low limit cannot be less than {self.__cec_one_low_limit.min_value} "
                             f"and more than {self.__cec_one_low_limit.max_value}.")
        self.__cec_one_low_limit.default_value = cec_one_low_limit

    @property
    def cec_one_high_limit(self) -> int:
        """
        Set and get CCE Line logical one voltage level, higher limit.

        Returns:
            object of int type
        """
        return self.__cec_one_high_limit.default_value

    @cec_one_high_limit.setter
    def cec_one_high_limit(self, cec_one_high_limit: int):
        if not(self.__cec_one_high_limit.min_value < cec_one_high_limit < self.__cec_one_high_limit.max_value):
            raise ValueError(f"CEC one high limit cannot be less than {self.__cec_one_high_limit.min_value} "
                             f"and more than {self.__cec_one_high_limit.max_value}.")
        self.__cec_one_high_limit.default_value = cec_one_high_limit
