#!D:\IDE\Anaconda3\envs\Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
 @Author: Administrator
 @FileName: CameraContext.py
 @DateTime: 2025/4/8 20:30
 @SoftWare: PyCharm
 @Author  ：xsh
"""
from PyQt5                          import Qt
from AppUtils.utils                 import *
from AppInterfaces.ModelInterface   import ContextModelInterface

class CameraContext(ContextModelInterface):
    GrabFrameLength : int
    IsOpen          : bool
    IsGrabbing      : bool
    __slots__ = (
        'GrabFrameLength'  ,
        'IsOpen'           ,
        'IsGrabbing'       ,
    )
    __types__ = (
        int  ,
        bool ,
        bool ,
    )
    def __init__(self, **args):
        super(CameraContext, self).__init__()
        self.initialization("相机上下文")
        self.initParameter(**args)



    @classmethod
    def instance(cls, **args) -> 'CameraContext':
        result: CameraContext = cls.__new__(cls)
        result.__init__(**args)
        return result

    def initParameter(self, **args):
        super(CameraContext, self).initParameter(**args)
        if not isinstance(args, dict) or len(args) <= 0:
            return
        for index, _property in enumerate(self.__slots__):
            setattr(self, _property, AppConvert.ObjectConvert(args.get(_property, getattr(self, _property, None)), self.__types__[index]))

    def initValue(self):
        super(CameraContext, self).initValue()
        self.GrabFrameLength     = 1
        self.IsOpen              = False
        self.IsGrabbing          = False


