#!D:/IDE/anaconda3/envs/Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName：ZMicroscopeInterface.py
@Description：
@Author：XSH
@Time：2025/11/11 12:55
@Department：研发部
@Copyright：©2025 乐辰生物
"""
import clr
from PyQt5                                                      import Qt
from abc                                                        import abstractmethod
from AppContexts.Contexts                                       import *
from AppCore.Levels                                             import *
from AppInterfaces.AppImplInterfaces.MicroscopeInterfaceBase    import MicroscopeInterfaceBase


class ZMicroscopeInterface(MicroscopeInterfaceBase):
    Parameter   : (ZeissContext, LeiCaContext)  # 显微镜参数类
    Manager     : 'IMicroscope'                 # 显微镜管理器
    Controller  : "IMicController"              # 显微镜控制器

    @property
    def parameter(self) -> ZeissContext:
        return self.Parameter if self.hasParameter else None

    def setParameter(self, value):
        self.Parameter = value if isinstance(value, ZeissContext) else None

    @property
    def manager(self):
        return self.Manager if self.hasManager else None

    @property
    def ID(self) -> str:
        return self.Parameter.MicroscopeID if self.hasParameter else None

    @property
    def microscope(self):
        try:
            return None if not self.hasManager else self.Manager.ZeissMicroscope
        except:
            return None

    @property
    def hasManager(self) -> bool:
        return hasattr(self, 'Manager') and self.Manager is not None

    @property
    def hasParameter(self) -> bool:
        return hasattr(self, 'Parameter') and isinstance(self.Parameter,  ZeissContext)

    @property
    def isSucceed(self) -> bool:
        return self.hasParameter and self.Parameter.isSucceed

