from UniTAP.dev.modules.dut_tests.dut_default_params.dp_2_1_common_video_modes import VideoModeInfo


class Dp21AvailableDscVideoModes:
    """
    Class `Dp21AvailableDscVideoModes` allows working with video modes.
    - Set and get...
    """
    def __init__(self, json_obj):
        self.__is_config_changed = False

        self.__1920x1080_30hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_1920_1080_30"])
        self.__1920x1080_60hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_1920_1080_60"])
        self.__1920x1080_120hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_1920_1080_120"])
        self.__1920x1080_144hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_1920_1080_144"])
        self.__1920x1080_240hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_1920_1080_240"])
        self.__3840x2160_30hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_3840_2160_30"])
        self.__3840x2160_60hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_3840_2160_60"])
        self.__3840x2160_120hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_3840_2160_120"])
        self.__3840x2160_144hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_3840_2160_144"])
        self.__3840x2160_240hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_3840_2160_240"])
        self.__5120x2160_30hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_5120_2160_30"])
        self.__5120x2160_60hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_5120_2160_60"])
        self.__5120x2160_120hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_5120_2160_120"])
        self.__5120x2160_144hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_5120_2160_144"])
        self.__5120x2160_240hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_5120_2160_240"])
        self.__7680x4320_30hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_7680_4320_30"])
        self.__7680x4320_60hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_7680_4320_60"])
        self.__7680x4320_120hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_7680_4320_120"])
        self.__10240x4320_30hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_10240_4320_30"])
        self.__10240x4320_60hz = VideoModeInfo(json_obj["TSI_DP20_SRCCTS_DSC_VMT_10240_4320_60"])

    def __getattribute__(self, name):
        attr = super().__getattribute__(name)
        if "vm_" in name or "_all" in name:
            self.__is_config_changed = True
        return attr

    @property
    def vm_1920x1080_30hz(self) -> VideoModeInfo:
        return self.__1920x1080_30hz

    @property
    def vm_1920x1080_60hz(self) -> VideoModeInfo:
        return self.__1920x1080_60hz

    @property
    def vm_1920x1080_120hz(self) -> VideoModeInfo:
        return self.__1920x1080_120hz

    @property
    def vm_1920x1080_144hz(self) -> VideoModeInfo:
        return self.__1920x1080_144hz

    @property
    def vm_1920x1080_240hz(self) -> VideoModeInfo:
        return self.__1920x1080_240hz

    @property
    def vm_3840x2160_30hz(self) -> VideoModeInfo:
        return self.__3840x2160_30hz

    @property
    def vm_3840x2160_60hz(self) -> VideoModeInfo:
        return self.__3840x2160_60hz

    @property
    def vm_3840x2160_120hz(self) -> VideoModeInfo:
        return self.__3840x2160_120hz

    @property
    def vm_3840x2160_144hz(self) -> VideoModeInfo:
        return self.__3840x2160_144hz

    @property
    def vm_3840x2160_240hz(self) -> VideoModeInfo:
        return self.__3840x2160_240hz

    @property
    def vm_5120x2160_30hz(self) -> VideoModeInfo:
        return self.__5120x2160_30hz

    @property
    def vm_5120x2160_60hz(self) -> VideoModeInfo:
        return self.__5120x2160_60hz

    @property
    def vm_5120x2160_120hz(self) -> VideoModeInfo:
        return self.__5120x2160_120hz

    @property
    def vm_5120x2160_144hz(self) -> VideoModeInfo:
        return self.__5120x2160_144hz

    @property
    def vm_5120x2160_240hz(self) -> VideoModeInfo:
        return self.__5120x2160_240hz

    @property
    def vm_7680x4320_30hz(self) -> VideoModeInfo:
        return self.__7680x4320_30hz

    @property
    def vm_7680x4320_60hz(self) -> VideoModeInfo:
        return self.__7680x4320_60hz

    @property
    def vm_7680x4320_120hz(self) -> VideoModeInfo:
        return self.__7680x4320_120hz

    @property
    def vm_10240x4320_30hz(self) -> VideoModeInfo:
        return self.__10240x4320_30hz

    @property
    def vm_10240x4320_60hz(self) -> VideoModeInfo:
        return self.__10240x4320_60hz

    def select_all_standards(self):
        var_list = self.__dict__
        for item in var_list:
            if isinstance(self.__getattribute__(item), VideoModeInfo):
                self.__getattribute__(item).standard.set_all()

    def select_all_cta_standard(self):
        var_list = self.__dict__
        for item in var_list:
            if isinstance(self.__getattribute__(item), VideoModeInfo):
                self.__getattribute__(item).standard.cta = True

    def select_all_dmt_standard(self):
        var_list = self.__dict__
        for item in var_list:
            if isinstance(self.__getattribute__(item), VideoModeInfo):
                self.__getattribute__(item).standard.dmt = True

    def select_all_cvt_standard(self):
        var_list = self.__dict__
        for item in var_list:
            if isinstance(self.__getattribute__(item), VideoModeInfo):
                self.__getattribute__(item).standard.cvt = True

    def select_all_cvt_rb1_standard(self):
        var_list = self.__dict__
        for item in var_list:
            if isinstance(self.__getattribute__(item), VideoModeInfo):
                self.__getattribute__(item).standard.cvt_rb1 = True

    def select_all_cvt_rb2_standard(self):
        var_list = self.__dict__
        for item in var_list:
            if isinstance(self.__getattribute__(item), VideoModeInfo):
                self.__getattribute__(item).standard.cvt_rb2 = True

    def select_all_ovt_standard(self):
        var_list = self.__dict__
        for item in var_list:
            if isinstance(self.__getattribute__(item), VideoModeInfo):
                self.__getattribute__(item).standard.ovt = True

    def select_all_colorimetries(self, bpc: int = 8):
        var_list = self.__dict__
        for item in var_list:
            if isinstance(self.__getattribute__(item), VideoModeInfo):
                self.__getattribute__(item).colorimetry.set_all(bpc)

    def select_all_rgb_colorimetry(self, bpc: int = 8):
        var_list = self.__dict__
        for item in var_list:
            if isinstance(self.__getattribute__(item), VideoModeInfo):
                self.__getattribute__(item).colorimetry.rgb = bpc

    def select_all_ycbcr444_colorimetry(self, bpc: int = 8):
        var_list = self.__dict__
        for item in var_list:
            if isinstance(self.__getattribute__(item), VideoModeInfo):
                self.__getattribute__(item).colorimetry.ycbcr444 = bpc

    def select_all_ycbcr422_colorimetry(self, bpc: int = 8):
        var_list = self.__dict__
        for item in var_list:
            if isinstance(self.__getattribute__(item), VideoModeInfo):
                self.__getattribute__(item).colorimetry.ycbcr422 = bpc

    def select_all_ycbcr_simple422_colorimetry(self, bpc: int = 8):
        var_list = self.__dict__
        for item in var_list:
            if isinstance(self.__getattribute__(item), VideoModeInfo):
                self.__getattribute__(item).colorimetry.ycbcr_simple422 = bpc

    def select_all_ycbcr420_colorimetry(self, bpc: int = 8):
        var_list = self.__dict__
        for item in var_list:
            if isinstance(self.__getattribute__(item), VideoModeInfo):
                self.__getattribute__(item).colorimetry.ycbcr420 = bpc

    def clear_all(self):
        var_list = self.__dict__
        for item in var_list:
            if isinstance(self.__getattribute__(item), VideoModeInfo):
                self.__getattribute__(item).colorimetry.clear_all()
                self.__getattribute__(item).standard.clear_all()
