#!D:\IDE\Anaconda3\envs\Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
 @Author: Administrator
 @FileName: AppSetting.py
 @DateTime: 2025/4/8 15:17
 @SoftWare: PyCharm
 @Author  ：xsh
"""
from PyQt5 import Qt
from AppInterfaces.SingletonInterface               import SingletonInterface
from AppContexts.Contexts import *
from AppInterfaces.AppConfigInterfaces.ContextConfigureInterface import ContextConfigureInterface, ManipulatorConfigureInterface
class AppSetting(ContextConfigureInterface, SingletonInterface):
    Locker: Qt.QMutex = Qt.QMutex()
    @classmethod
    def GetInstance(cls, *args, **kwargs) -> 'AppSetting':
        return super(AppSetting, cls).GetInstance(*args, **kwargs)

    def __init__(self):
        super(AppSetting, self).__init__()
        self.initialization("AppSetting")


    def initValue(self):
        super(AppSetting, self).initValue()
        self.initManipulatorConfig   ()
        self.initCameraConfig        ()
        self.initMicroscopeConfig    ()
        self.initZeissMicroscope     ()
        self.initCodeScanningConfig  ()
        self.initLeiCaMicroscope     ()
        self.initSocketConfig        ()
        self.initWebConfig           ()
        self.initDBConfig            ()
        self.initPathConfig          ()
        self.initClassifierConfig    ()




    def initManipulatorConfig   (self):
        if not self.hasManipulatorConfig   :
            from AppSettings.ManipulatorSetting import ManipulatorSetting
            self.ManipulatorConfig    = ManipulatorSetting            ()

    def initCameraConfig        (self):
        if not self.hasCameraConfig        :
            self.CameraConfig         = CameraContext                 ()

    def initMicroscopeConfig    (self):
        if not self.hasMicroscopeConfig    :
            self.MicroscopeConfig     = MicroscopeContext             ()

    def initCodeScanningConfig  (self):
        if not self.hasCodeScanningConfig  :
            self.CodeScanningConfig   = SerialContext                 ()
            self.CodeScanningConfig.initScanning()

    def initSocketConfig        (self):
        if not self.hasSocketConfig        :
            self.SocketConfig         = SocketContext                 ()

    def initWebConfig           (self):
        if not self.hasWebConfig           :
            self.WebConfig            = WebSocketContext              ()

    def initDBConfig            (self):
        if not self.hasDBConfig            :
            self.DBConfig             = DBContext                     ()

    def initPathConfig          (self):
        if not self.hasPathConfig          :
            self.PathConfig           = PathContext                   ()

    def initClassifierConfig    (self):
        if not self.hasClassifierConfig    :
            self.ClassifierConfig     = ClassifierContext             ()

    def initLeiCaMicroscope(self):
        if not self.hasLMicroscopeConfig:
            self.LMicroscopeConfig = LeiCaContext()
            self.LMicroscopeConfig.initMicroscope()

    def initZeissMicroscope(self):
        if not self.hasZMicroscopeConfig:
            self.ZMicroscopeConfig = ZeissContext()

AppConfig: AppSetting = AppSetting.GetInstance()
