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


class CecFunctionalTestParam:
    """
    Class `CecFunctionalTestParam` describes requirement parameters for CEC tests:
    - Set and get `timeout`. Describes test timeout, in milliseconds.
    - Set and get `physical_address`. Describes Local CEC physical address.
    """
    def __init__(self, json_obj):
        self.__timeout = Param(json_obj["TSI_HDMI_RX_CEC_TIMEOUT"])
        self.__physical_address = Param(json_obj["TSI_HDMI_RX_CEC_LOCAL_PHY_ADDR"])

    @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 physical_address(self) -> int:
        """
        Set and get Local CEC physical address.

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

    @physical_address.setter
    def physical_address(self, physical_address: int):
        self.__physical_address.default_value = physical_address
