#!D:\IDE\Anaconda3\envs\Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
 @Author: Administrator
 @FileName: EventInterface.py
 @DateTime: 2025/4/8 0:29
 @SoftWare: PyCharm
 @Author  ：xsh
"""
from PyQt5 import Qt
from abc import abstractmethod
from AppSettings.Settings import RECODE_SUCCEED, RECODE_FAILURE
from AppInterfaces.GlobalInterface import GlobalInterface
from AppInterfaces.ReaderInterface import ReaderInterface
from AppCore.AppLevelModels.EventLevel import EventLevel

class EventInterface(GlobalInterface):
    Mode: int

    @property
    def hasMode(self) -> bool:
        return hasattr(self, 'Mode') and isinstance(self.Mode, int)

    @property
    def mode(self) -> int:
        return EventLevel.OnlyDrawMode if not self.hasMode else self.Mode

    @property
    def isWebSocketMode   (self) -> bool:
        return False if not self.hasEVLevel else EventLevel.isWebSocketMode  (self.Mode)

    @property
    def isQualityMode     (self) -> bool:
        return False if not self.hasMode else EventLevel.isQualityMode    (self.Mode)

    @property
    def isPersistenceMode (self) -> bool:
        return False if not self.hasMode else EventLevel.isPersistenceMode(self.Mode)

    @property
    def isOnlyDrawMode    (self) -> bool:
        return False if not self.hasMode else EventLevel.isOnlyDrawMode   (self.Mode)

    @property
    def isOtherMode(self) -> bool:
        return True if not self.hasMode else EventLevel.isOtherMode(self.Mode)

    def setWebSocketMode   (self):
        self.Mode = EventLevel.setWebSocketMode   (0 if not self.hasMode else self.Mode)

    def setQualityMode     (self):
        self.Mode = EventLevel.setQualityMode     (0 if not self.hasMode else self.Mode)

    def setPersistenceMode (self):
        self.Mode = EventLevel.setPersistenceMode (0 if not self.hasMode else self.Mode)

    def setOnlyDrawMode    (self):
        self.Mode = EventLevel.setOnlyDrawMode    (0 if not self.hasMode else self.Mode)


    def cancelWebSocketMode   (self):
        self.Mode = EventLevel.cancelWebSocketMode   (0 if not self.hasMode else self.Mode)

    def cancelQualityMode     (self):
        self.Mode = EventLevel.cancelQualityMode     (0 if not self.hasMode else self.Mode)

    def cancelPersistenceMode (self):
        self.Mode = EventLevel.cancelPersistenceMode (0 if not self.hasMode else self.Mode)

    def cancelOnlyDrawMode    (self):
        self.Mode = EventLevel.cancelOnlyDrawMode    (0 if not self.hasMode else self.Mode)

    @abstractmethod
    def initEvent(self, src = None, **args):
        pass

    @abstractmethod
    def copyEvent(self):
        pass

    @abstractmethod
    def isValid(self) -> bool:
        return False

    @abstractmethod
    def WaitDone(self, *args, **kwargs):
        return RECODE_FAILURE
