#!D:/IDE/anaconda3/envs/Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName：PauseScanningBusiness.py
@Description：
@Author：XSH
@Time：2025/12/2 17:47
@Department：研发部
@Copyright：©2025 乐辰生物
"""
from PyQt5 import Qt
from abc import abstractmethod, abstractclassmethod, abstractstaticmethod
from AppInterfaces.utils                    import *
from AppSettings.utils                      import *
from AppCore.Requests                       import *
from AppInterfaces.Interfaces               import *
from AppCore.Levels                         import *
from AppUtils.utils                         import *
from AppBackEnd.WebBusinessInterface import WebBusinessInterface


class PauseScanningBusiness(Qt.QObject, WebBusinessInterface):
    def __init__(self, manager: WebReaderInterface = None, parent: Qt.QObject = None):
        super(PauseScanningBusiness, self).__init__(parent=parent)
        self.Manager = manager
        self.Initialization("PauseScanningBusiness", self, parent)

    def initWEBAPILevel(self):
        self.Level = WebAPILevel.pauseScan



    def Done(self, handler: WebClientInterface, **kwargs):
        isWrong: int = RECODE_FAILURE
        from AppSettings.AppStatusSetting import AppStatusSetting, AppStatus
        try:
            self.Handler = handler
            isPause: bool = AppStatus.isPause
            AppStatus.setPause(not isPause)
            request = Request.APIInstance(self.level)
            request.data = AppStatus.scanningstatus()
            isWrong = self.WebSendFrame(request.toJson())
        except Exception as e:

            AppUtils.print_Exception(e)
        return
    def WaitDone(self, handler: WebClientInterface, **kwargs) -> int:
        isWrong: int = RECODE_FAILURE
        from AppSettings.AppStatusSetting import AppStatusSetting, AppStatus
        try:
            self.Handler    = handler
            isPause: bool   = AppStatus.isPause
            AppStatus.setPause(not isPause)
            request         = Request.APIInstance(self.level)
            request.data    = AppStatus.scanningstatus          ()
            isWrong         = self.WebSendFrame(request.toJson())
        except Exception as e:
            AppUtils.print_Exception(e)

        return isWrong







