#!D:/IDE/anaconda3/envs/Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName：ButtonOperation.py
@Description：
@Author：XSH
@Time：2025/12/18 15:03
@Department：研发部
@Copyright：©2025 乐辰生物
"""
from abc                        import abstractmethod                     #
from PyQt5                      import Qt                                 #
from AppInterfaces.UiInterface  import UiInterface                        #
from AppInterfaces.globalSlot   import globalSlot, AppSlot                #
from AppCore.Contexts           import *                                  #
from AppCore.DBModels           import *                                  #
from AppCore.Levels             import *                                  #
from AppUtils.utils             import *                                  #

class ButtonOperation(Qt.QWidget, UiInterface):
    StatusTimer             : Qt.QTimer                 #
    ButtonGroup             : Qt.QGroupBox              #
    CameraOnButton          : Qt.QPushButton            #
    CameraLineButton        : Qt.QPushButton            #
    CameraOffButton         : Qt.QPushButton            #
    InitXButton             : Qt.QPushButton            #
    InitYButton             : Qt.QPushButton            #
    InitMicroscopeButton    : Qt.QPushButton            #
    InitButton              : Qt.QPushButton            #
    ExitPlcButton           : Qt.QPushButton            #
    EmptyReturnButton       : Qt.QPushButton            #
    EditPickButton          : Qt.QPushButton            #
    EditDropButton          : Qt.QPushButton            #
    TrayNumberButton        : Qt.QPushButton            #
    EditTrayNumber          : Qt.QSpinBox               #
    SlideNumberButton       : Qt.QPushButton            #
    EditSlideNumber         : Qt.QSpinBox               #
    OilSwitchButton         : Qt.QPushButton            #
    ClearWarningButton      : Qt.QPushButton            #
    LowScanButton           : Qt.QPushButton            #
    OilScanButton           : Qt.QPushButton            #
    HigScanButton           : Qt.QPushButton            #
    AllScanButton           : Qt.QPushButton            #
    PauseButton             : Qt.QPushButton            #
    StopButton              : Qt.QPushButton            #
    StartButton             : Qt.QPushButton            #
    CalibrateButton         : Qt.QPushButton            #
    BeginSlideButton        : Qt.QPushButton            #
    EndSlideButton          : Qt.QPushButton            #
    CheckChamberButton      : Qt.QPushButton            #
    PickSlideButton         : Qt.QPushButton            #
    SafeButton              : Qt.QPushButton            #
    InitStatusButton        : Qt.QPushButton            #
    CameraButton            : Qt.QPushButton            #
    ObjectiveButton         : Qt.QPushButton            #
    FocusingButton          : Qt.QPushButton            #
    AnointingButton         : Qt.QPushButton            #
    ObjectiveOffsetButton   : Qt.QPushButton            #
    AxisButton              : Qt.QPushButton            #
    ChamberButton           : Qt.QPushButton            #
    IntegrationButton       : Qt.QPushButton            #
    AnalysisButton          : Qt.QPushButton            #
    TrayConfigButton        : Qt.QPushButton            #
    CellButton              : Qt.QPushButton            #
    TrayButton              : Qt.QPushButton            #

    def __init__(self, parent: Qt.QWidget = None):
        super(ButtonOperation, self).__init__(parent)
        self.Initialization("ButtonOperation", self, parent)
        self.start()

    def initValue(self):
        super(ButtonOperation, self).initValue()
        self.initButtonGroup             ()
        self.initCameraOnButton          ()
        self.initCameraLineButton        ()
        self.initCameraOffButton         ()
        self.initInitXButton             ()
        self.initInitYButton             ()
        self.initInitMicroscopeButton    ()
        self.initInitButton              ()
        self.initExitPlcButton           ()
        self.initEmptyReturnButton       ()
        self.initEditPickButton          ()
        self.initEditDropButton          ()
        self.initTrayNumberButton        ()
        self.initEditTrayNumber          ()
        self.initSlideNumberButton       ()
        self.initEditSlideNumber         ()
        self.initOilSwitchButton         ()
        self.initClearWarningButton      ()
        self.initLowScanButton           ()
        self.initOilScanButton           ()
        self.initHigScanButton           ()
        self.initAllScanButton           ()
        self.initPauseButton             ()
        self.initStopButton              ()
        self.initStartButton             ()
        self.initStatusTimer             ()
        self.initCalibrateButton         ()
        self.initBeginSlideButton        ()
        self.initEndSlideButton          ()
        self.initCheckChamberButton      ()
        self.initPickSlideButton         ()
        self.initSafeButton              ()
        self.initCameraButton            ()
        self.initObjectiveButton         ()
        self.initFocusingButton          ()
        self.initAnointingButton         ()
        self.initObjectiveOffsetButton   ()
        self.initAxisButton              ()
        self.initChamberButton           ()
        self.initIntegrationButton       ()
        self.initAnalysisButton          ()
        self.initTrayConfigButton        ()
        self.initCellButton              ()
        self.initTrayButton              ()
        self.initInitStatusButton        ()

    def initProperty(self):
        super(ButtonOperation, self).initProperty()
        self.CameraOnButton             .setText('　相机打开　')
        self.CameraLineButton           .setText('　画面十字　')
        self.CameraOffButton            .setText('　相机关闭　')
        self.InitXButton                .setText('　初始Ｘ轴　')
        self.InitYButton                .setText('　初始Ｙ轴　')
        self.InitMicroscopeButton       .setText('　初始Ｚ轴　')
        self.InitButton                 .setText('　初始仪器　')
        self.ExitPlcButton              .setText('　退出循环　')
        self.EmptyReturnButton          .setText('　空挂返回　')
        self.EditPickButton             .setText('　片仓取片　')
        self.EditDropButton             .setText('　片仓放片　')
        self.TrayNumberButton           .setText('　托盘编号　')
        self.SlideNumberButton          .setText('　玻片编号　')
        self.OilSwitchButton            .setText('　油泵开关　')
        self.ClearWarningButton         .setText('　清除告警　')
        self.StartButton                .setText('　开始扫描　')
        self.CheckChamberButton         .setText('　检测片仓　')
        self.LowScanButton              .setText('低倍物镜扫描')
        self.OilScanButton              .setText('测试玻片滴油')
        self.HigScanButton              .setText('高倍物镜扫描')
        self.AllScanButton              .setText('测试扫描片仓')
        self.PauseButton                .setText('　暂停扫描　')
        self.StopButton                 .setText('　停止扫描　')
        self.CalibrateButton            .setText('　物镜校准　')
        self.PickSlideButton            .setText('　扫码取片　')
        self.SafeButton                 .setText('　安全位置　')
        self.CameraButton               .setText('　相机参数　')
        self.ObjectiveButton            .setText('　物镜参数　')
        self.FocusingButton             .setText('　定焦参数　')
        self.AnointingButton            .setText('　加油参数　')
        self.ObjectiveOffsetButton      .setText('　物镜偏移量')
        self.AxisButton                 .setText('　速度参数　')
        self.ChamberButton              .setText('　片仓参数　')
        self.IntegrationButton          .setText('　图像参数　')
        self.AnalysisButton             .setText('　预处理参数')
        self.TrayConfigButton           .setText('　托盘参数　')
        self.CellButton                 .setText('　核型小图　')
        self.TrayButton                 .setText('托盘玻片参数')
        self.InitStatusButton           .setText('仪器已经初始')
        self.EditTrayNumber             .setRange(1, 24)
        self.EditTrayNumber             .setSingleStep(1)
        self.EditSlideNumber            .setRange(1, 5)
        self.EditSlideNumber            .setSingleStep(1)
        self.BeginSlideButton           .setText('设置玻片起始位置')
        self.EndSlideButton             .setText('设置玻片结束位置')

        self.TrayNumberButton           .setFlat(True)
        self.SlideNumberButton          .setFlat(True)

        self.CameraOnButton             .setFixedHeight(35)
        self.CameraLineButton           .setFixedHeight(35)
        self.CameraOffButton            .setFixedHeight(35)
        self.InitXButton                .setFixedHeight(35)
        self.InitYButton                .setFixedHeight(35)
        self.InitMicroscopeButton       .setFixedHeight(35)
        self.InitButton                 .setFixedHeight(35)
        self.TrayNumberButton           .setFixedHeight(35)
        self.EditTrayNumber             .setFixedHeight(35)
        self.EditPickButton             .setFixedHeight(35)
        self.EditDropButton             .setFixedHeight(35)
        self.ExitPlcButton              .setFixedHeight(35)
        self.EmptyReturnButton          .setFixedHeight(35)
        self.OilSwitchButton            .setFixedHeight(35)
        self.ClearWarningButton         .setFixedHeight(35)
        self.LowScanButton              .setFixedHeight(35)
        self.OilScanButton              .setFixedHeight(35)
        self.HigScanButton              .setFixedHeight(35)
        self.AllScanButton              .setFixedHeight(35)
        self.SlideNumberButton          .setFixedHeight(35)
        self.EditSlideNumber            .setFixedHeight(35)
        self.PauseButton                .setFixedHeight(35)
        self.StopButton                 .setFixedHeight(35)
        self.StartButton                .setFixedHeight(35)
        self.BeginSlideButton           .setFixedHeight(35)
        self.EndSlideButton             .setFixedHeight(35)
        self.CalibrateButton            .setFixedHeight(35)
        self.CheckChamberButton         .setFixedHeight(35)
        self.PickSlideButton            .setFixedHeight(35)
        self.SafeButton                 .setFixedHeight(35)
        self.CameraButton               .setFixedHeight(35)
        self.ObjectiveButton            .setFixedHeight(35)
        self.FocusingButton             .setFixedHeight(35)
        self.AnointingButton            .setFixedHeight(35)
        self.ObjectiveOffsetButton      .setFixedHeight(35)
        self.AxisButton                 .setFixedHeight(35)
        self.ChamberButton              .setFixedHeight(35)
        self.IntegrationButton          .setFixedHeight(35)
        self.AnalysisButton             .setFixedHeight(35)
        self.TrayConfigButton           .setFixedHeight(35)
        self.CellButton                 .setFixedHeight(35)
        self.TrayButton                 .setFixedHeight(35)
        self.InitStatusButton           .setFixedHeight(35)
        self.ButtonGroup.setTitle('操作按钮')
        self.setMinimumWidth(640)

    def initLayouts(self):
        if self.hasWindowLayouts:
            return
        main_layout: Qt.QGridLayout = Qt.QGridLayout()
        main_layout.setSpacing(1)
        main_layout.setContentsMargins(5, 5, 5, 5)

        group_layout: Qt.QGridLayout = Qt.QGridLayout()
        group_layout.setSpacing(1)
        group_layout.setContentsMargins(10, 10, 10, 10)
        group_layout.setAlignment(Qt.Qt.AlignTop)

        group1: Qt.QGroupBox = Qt.QGroupBox()
        group1_layout: Qt.QGridLayout = Qt.QGridLayout()
        group1_layout.setSpacing(1)
        group1_layout.setContentsMargins(10, 10, 10, 10)

        group1_layout.addWidget(self.TrayNumberButton         , 0, 0)
        group1_layout.addWidget(self.EditTrayNumber           , 0, 1)
        group1_layout.addWidget(self.SlideNumberButton        , 0, 2)
        group1_layout.addWidget(self.EditSlideNumber          , 0, 3)


        group1_layout.addWidget(self.InitButton               , 1, 0, 1, -1)
        group1_layout.addWidget(self.StartButton              , 2, 0, 1, -1)
        group1_layout.addWidget(self.PauseButton              , 3, 0, 1, -1)
        group1_layout.addWidget(self.StopButton               , 4, 0, 1, -1)
        group1_layout.addWidget(self.InitXButton              , 5, 0)
        group1_layout.addWidget(self.InitYButton              , 5, 1)
        group1_layout.addWidget(self.InitMicroscopeButton     , 5, 2)
        group1_layout.addWidget(self.CameraLineButton         , 5, 3)

        group1_layout.addWidget(self.OilSwitchButton          , 6, 0)
        group1_layout.addWidget(self.ClearWarningButton       , 6, 1)
        group1_layout.addWidget(self.CameraOnButton           , 6, 2)
        group1_layout.addWidget(self.CameraOffButton          , 6, 3)

        group1.setLayout(group1_layout)


        group2: Qt.QGroupBox = Qt.QGroupBox()
        group2_layout: Qt.QGridLayout = Qt.QGridLayout()
        group2_layout.setSpacing(1)
        group2_layout.setContentsMargins(10, 1, 10, 1)

        group2_layout.addWidget(self.LowScanButton            , 0, 0)
        group2_layout.addWidget(self.HigScanButton            , 0, 1)
        group2_layout.addWidget(self.OilScanButton            , 0, 2)
        group2_layout.addWidget(self.AllScanButton            , 0, 3)

        group2_layout.addWidget(self.CheckChamberButton       , 1, 0)
        group2_layout.addWidget(self.EditPickButton           , 1, 1)
        group2_layout.addWidget(self.EditDropButton           , 1, 2)
        group2_layout.addWidget(self.PickSlideButton          , 1, 3)

        group2_layout.addWidget(self.EmptyReturnButton        , 2, 0)
        group2_layout.addWidget(self.ExitPlcButton            , 2, 1)
        group2_layout.addWidget(self.SafeButton               , 2, 2)
        group2_layout.addWidget(self.InitStatusButton         , 2, 3)
        group2.setLayout(group2_layout)

        group3: Qt.QGroupBox = Qt.QGroupBox()
        group3_layout: Qt.QGridLayout = Qt.QGridLayout()
        group3_layout.setSpacing(1)
        group3_layout.setContentsMargins(10, 1, 10, 1)

        group3_layout.addWidget(self.CameraButton             , 0, 0)
        group3_layout.addWidget(self.ObjectiveButton          , 0, 1)
        group3_layout.addWidget(self.FocusingButton           , 0, 2)

        group3_layout.addWidget(self.AnointingButton          , 1, 0)
        group3_layout.addWidget(self.ObjectiveOffsetButton    , 1, 1)
        group3_layout.addWidget(self.AxisButton               , 1, 2)

        group3_layout.addWidget(self.ChamberButton            , 2, 0)
        group3_layout.addWidget(self.IntegrationButton        , 2, 1)
        group3_layout.addWidget(self.AnalysisButton           , 2, 2)

        group3_layout.addWidget(self.TrayConfigButton         , 3, 0)
        group3_layout.addWidget(self.CellButton               , 3, 1)
        group3_layout.addWidget(self.TrayButton               , 3, 2)
        group3.setLayout(group3_layout)

        group4: Qt.QGroupBox = Qt.QGroupBox()
        group4_layout: Qt.QGridLayout = Qt.QGridLayout()
        group4_layout.setSpacing(1)
        group4_layout.setContentsMargins(10, 1, 10, 1)

        group4_layout.addWidget(self.CalibrateButton          , 0, 1)
        group4_layout.addWidget(self.BeginSlideButton         , 0, 2)
        group4_layout.addWidget(self.EndSlideButton           , 0, 3)

        group4.setLayout(group4_layout)

        group_layout.addWidget(group1, 0, 0, 1, -1)
        group_layout.addWidget(group2, 1, 0, 1, -1)
        group_layout.addWidget(group3, 2, 0, 1, -1)
        group_layout.addWidget(group4, 3, 0, 1, -1)

        self.ButtonGroup.setLayout(group_layout)

        main_layout.addWidget(self.ButtonGroup               , 0, 0, -1, -1)
        self.setLayout(main_layout)

    def initSafeButton(self):
        if not self.hasSafeButton:
            self.SafeButton = Qt.QPushButton()
    def initButtonGroup             (self):
        if not self.hasButtonGroup             :
            self.ButtonGroup              = Qt.QGroupBox   ()

    def initCameraOnButton          (self):
        if not self.hasCameraOnButton          :
            self.CameraOnButton           = Qt.QPushButton ()

    def initCameraLineButton        (self):
        if not self.hasCameraLineButton        :
            self.CameraLineButton         = Qt.QPushButton ()

    def initCameraOffButton         (self):
        if not self.hasCameraOffButton         :
            self.CameraOffButton          = Qt.QPushButton ()

    def initInitXButton             (self):
        if not self.hasInitXButton             :
            self.InitXButton              = Qt.QPushButton ()

    def initInitYButton             (self):
        if not self.hasInitYButton             :
            self.InitYButton              = Qt.QPushButton ()

    def initInitMicroscopeButton    (self):
        if not self.hasInitMicroscopeButton    :
            self.InitMicroscopeButton     = Qt.QPushButton ()

    def initInitButton(self):
        if not self.hasInitButton:
            self.InitButton = Qt.QPushButton()

    def initEditPickButton   (self):
        if not self.hasEditPickButton   :
            self.EditPickButton    = Qt.QPushButton  ()

    def initEditDropButton   (self):
        if not self.hasEditDropButton   :
            self.EditDropButton    = Qt.QPushButton  ()

    def initTrayNumberButton (self):
        if not self.hasTrayNumberButton :
            self.TrayNumberButton  = Qt.QPushButton  ()

    def initEditTrayNumber   (self):
        if not self.hasEditTrayNumber   :
            self.EditTrayNumber    = Qt.QSpinBox     ()

    def initExitPlcButton     (self):
        if not self.hasExitPlcButton     :
            self.ExitPlcButton      = Qt.QPushButton()

    def initEmptyReturnButton (self):
        if not self.hasEmptyReturnButton :
            self.EmptyReturnButton  = Qt.QPushButton()

    def initSlideNumberButton       (self):
        if not self.hasSlideNumberButton       :
            self.SlideNumberButton        = Qt.QPushButton()

    def initEditSlideNumber         (self):
        if not self.hasEditSlideNumber         :
            self.EditSlideNumber          = Qt.QSpinBox()

    def initOilSwitchButton         (self):
        if not self.hasOilSwitchButton         :
            self.OilSwitchButton          = Qt.QPushButton()

    def initClearWarningButton      (self):
        if not self.hasClearWarningButton      :
            self.ClearWarningButton       = Qt.QPushButton()

    def initLowScanButton           (self):
        if not self.hasLowScanButton           :
            self.LowScanButton            = Qt.QPushButton()

    def initOilScanButton           (self):
        if not self.hasOilScanButton           :
            self.OilScanButton            = Qt.QPushButton()

    def initHigScanButton           (self):
        if not self.hasHigScanButton           :
            self.HigScanButton            = Qt.QPushButton()

    def initAllScanButton           (self):
        if not self.hasAllScanButton           :
            self.AllScanButton            = Qt.QPushButton()

    def initPauseButton       (self):
        if not self.hasPauseButton       :
            self.PauseButton        = Qt.QPushButton()

    def initStopButton        (self):
        if not self.hasStopButton        :
            self.StopButton         = Qt.QPushButton()


    def initStartButton(self):
        if not self.hasStartButton:
            self.StartButton = Qt.QPushButton()

    def initCalibrateButton(self):
        if not self.hasCalibrateButton:
            self.CalibrateButton = Qt.QPushButton()

    def initBeginSlideButton (self):
        if not self.hasBeginSlideButton:
            self.BeginSlideButton = Qt.QPushButton()

    def initEndSlideButton   (self):
        if not self.hasEndSlideButton  :
            self.EndSlideButton   = Qt.QPushButton()

    def initCheckChamberButton(self):
        if not self.hasCheckChamberButton:
            self.CheckChamberButton = Qt.QPushButton()
    def initPickSlideButton(self):
        if not self.hasPickSlideButton:
            self.PickSlideButton = Qt.QPushButton()

    def initCameraButton               (self) :
        if not self.hasCameraButton               :
            self.CameraButton                = Qt.QPushButton()

    def initObjectiveButton            (self) :
        if not self.hasObjectiveButton            :
            self.ObjectiveButton             = Qt.QPushButton()

    def initFocusingButton             (self) :
        if not self.hasFocusingButton             :
            self.FocusingButton              = Qt.QPushButton()

    def initAnointingButton            (self) :
        if not self.hasAnointingButton            :
            self.AnointingButton             = Qt.QPushButton()

    def initObjectiveOffsetButton      (self) :
        if not self.hasObjectiveOffsetButton      :
            self.ObjectiveOffsetButton       = Qt.QPushButton()

    def initAxisButton                 (self) :
        if not self.hasAxisButton                 :
            self.AxisButton                  = Qt.QPushButton()

    def initChamberButton              (self) :
        if not self.hasChamberButton              :
            self.ChamberButton               = Qt.QPushButton()

    def initIntegrationButton          (self) :
        if not self.hasIntegrationButton          :
            self.IntegrationButton           = Qt.QPushButton()

    def initAnalysisButton             (self) :
        if not self.hasAnalysisButton             :
            self.AnalysisButton              = Qt.QPushButton()

    def initTrayConfigButton           (self) :
        if not self.hasTrayConfigButton           :
            self.TrayConfigButton            = Qt.QPushButton()

    def initCellButton                 (self) :
        if not self.hasCellButton                 :
            self.CellButton                  = Qt.QPushButton()

    def initTrayButton                 (self) :
        if not self.hasTrayButton                 :
            self.TrayButton                  = Qt.QPushButton()

    def initInitStatusButton(self):
        if not self.hasInitStatusButton:
            self.InitStatusButton = Qt.QPushButton()

    @property
    def chamber_number(self) -> int:
        return self.EditTrayNumber.value()

    @property
    def slide_number(self) -> int:
        return self.EditSlideNumber.value()

    def start(self):
        self.initStatusTimer()
        self.statustimer.start()

    def stop(self):
        if self.hasStatusTimer:
            self.statustimer.stop()



















    @property
    def hasInitStatusButton          (self) -> bool:
        return self.has_field('InitStatusButton'      , Qt.QPushButton            )

    @property
    def hasButtonGroup             (self) -> bool:
        return self.has_field('ButtonGroup'           , Qt.QGroupBox              )

    @property
    def hasCameraOnButton          (self) -> bool:
        return self.has_field('CameraOnButton'        , Qt.QPushButton            )

    @property
    def hasCameraLineButton        (self) -> bool:
        return self.has_field('CameraLineButton'      , Qt.QPushButton            )

    @property
    def hasCameraOffButton         (self) -> bool:
        return self.has_field('CameraOffButton'       , Qt.QPushButton            )

    @property
    def hasInitXButton             (self) -> bool:
        return self.has_field('InitXButton'           , Qt.QPushButton            )

    @property
    def hasInitYButton             (self) -> bool:
        return self.has_field('InitYButton'           , Qt.QPushButton            )

    @property
    def hasInitMicroscopeButton    (self) -> bool:
        return self.has_field('InitMicroscopeButton'  , Qt.QPushButton            )

    @property
    def hasInitButton              (self) -> bool:
        return self.has_field('InitButton'            , Qt.QPushButton            )

    @property
    def hasExitPlcButton           (self) -> bool:
        return self.has_field('ExitPlcButton'         , Qt.QPushButton            )

    @property
    def hasEmptyReturnButton       (self) -> bool:
        return self.has_field('EmptyReturnButton'     , Qt.QPushButton            )

    @property
    def hasEditPickButton          (self) -> bool:
        return self.has_field('EditPickButton'        , Qt.QPushButton            )

    @property
    def hasEditDropButton          (self) -> bool:
        return self.has_field('EditDropButton'        , Qt.QPushButton            )

    @property
    def hasTrayNumberButton        (self) -> bool:
        return self.has_field('TrayNumberButton'      , Qt.QPushButton            )

    @property
    def hasEditTrayNumber          (self) -> bool:
        return self.has_field('EditTrayNumber'        , Qt.QSpinBox               )

    @property
    def hasSlideNumberButton       (self) -> bool:
        return self.has_field('SlideNumberButton'     , Qt.QPushButton            )

    @property
    def hasEditSlideNumber         (self) -> bool:
        return self.has_field('EditSlideNumber'       , Qt.QSpinBox               )

    @property
    def hasOilSwitchButton         (self) -> bool:
        return self.has_field('OilSwitchButton'       , Qt.QPushButton            )

    @property
    def hasClearWarningButton      (self) -> bool:
        return self.has_field('ClearWarningButton'    , Qt.QPushButton            )

    @property
    def hasLowScanButton           (self) -> bool:
        return self.has_field('LowScanButton'         , Qt.QPushButton            )

    @property
    def hasOilScanButton           (self) -> bool:
        return self.has_field('OilScanButton'         , Qt.QPushButton            )

    @property
    def hasHigScanButton           (self) -> bool:
        return self.has_field('HigScanButton'         , Qt.QPushButton            )

    @property
    def hasAllScanButton           (self) -> bool:
        return self.has_field('AllScanButton'         , Qt.QPushButton            )



    @property
    def hasPauseButton             (self) -> bool:
        return self.has_field('PauseButton'   , Qt.QPushButton)

    @property
    def hasStopButton              (self) -> bool:
        return self.has_field('StopButton'    , Qt.QPushButton)

    @property
    def hasStartButton             (self) -> bool:
        return self.has_field('StartButton'   , Qt.QPushButton)

    @property
    def hasStatusTimer(self) -> bool:
        return self.has_field('StatusTimer'   , Qt.QTimer)

    @property
    def hasCalibrateButton(self) -> bool:
        return self.has_field('CalibrateButton' , Qt.QPushButton)



    @property
    def hasBeginSlideButton        (self) -> bool:
        return self.has_field('BeginSlideButton', Qt.QPushButton)

    @property
    def hasEndSlideButton          (self) -> bool:
        return self.has_field('EndSlideButton', Qt.QPushButton)

    @property
    def hasCheckChamberButton(self) -> bool:
        return self.has_field('CheckChamberButton', Qt.QPushButton)

    @ property
    def hasPickSlideButton(self) -> bool:
        return self.has_field('PickSlideButton', Qt.QPushButton)

    @property
    def hasSafeButton(self):
        return self.has_field('SafeButton', Qt.QPushButton)














    @property
    def hasCameraButton            (self) -> bool:
        return self.has_field('CameraButton'         , Qt.QPushButton)

    @property
    def hasObjectiveButton         (self) -> bool:
        return self.has_field('ObjectiveButton'      , Qt.QPushButton)

    @property
    def hasFocusingButton          (self) -> bool:
        return self.has_field('FocusingButton'       , Qt.QPushButton)

    @property
    def hasAnointingButton         (self) -> bool:
        return self.has_field('AnointingButton'      , Qt.QPushButton)

    @property
    def hasObjectiveOffsetButton   (self) -> bool:
        return self.has_field('ObjectiveOffsetButton', Qt.QPushButton)

    @property
    def hasAxisButton              (self) -> bool:
        return self.has_field('AxisButton'           , Qt.QPushButton)

    @property
    def hasChamberButton           (self) -> bool:
        return self.has_field('ChamberButton'        , Qt.QPushButton)

    @property
    def hasIntegrationButton       (self) -> bool:
        return self.has_field('IntegrationButton'    , Qt.QPushButton)

    @property
    def hasAnalysisButton          (self) -> bool:
        return self.has_field('AnalysisButton'       , Qt.QPushButton)

    @property
    def hasTrayConfigButton        (self) -> bool:
        return self.has_field('TrayConfigButton'     , Qt.QPushButton)

    @property
    def hasCellButton              (self) -> bool:
        return self.has_field('CellButton'           , Qt.QPushButton)

    @property
    def hasTrayButton              (self) -> bool:
        return self.has_field('TrayButton'           , Qt.QPushButton)

    @property
    def statustimer(self) -> Qt.QTimer:
        self.initStatusTimer()
        return self.StatusTimer

    def initStatusTimer(self):
        if not self.hasStatusTimer:
            TYPE: Qt.Qt.ConnectionType = Qt.Qt.ConnectionType(Qt.Qt.AutoConnection | Qt.Qt.UniqueConnection)
            self.StatusTimer = Qt.QTimer()
            self.StatusTimer.setInterval(500)
            self.StatusTimer.timeout.connect(self.SlotFlushScanningStatus, TYPE)


    def SlotFlushScanningStatus(self):
        from AppSettings.AppStatusSetting import AppStatusSetting, AppStatus
        isPause: bool = AppStatus.isPause
        if isPause:
            self.PauseButton.setText('继续扫描')
        else:
            self.PauseButton.setText('暂停扫描')
        isExit: bool = AppStatus.isExit
        self.StopButton.setEnabled(not isExit)
        self.StartButton.setEnabled(isExit)
        self.PauseButton.setEnabled(not isExit)