#!D:/IDE/anaconda3/envs/Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName：DropSlideTableTrayBusiness.py
@Description：
@Author：XSH
@Time：2025/12/3 13:12
@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 DropSlideTableTrayBusiness(Qt.QObject, WebBusinessInterface):
    def __init__(self, manager: WebReaderInterface = None, parent: Qt.QObject = None):
        super(DropSlideTableTrayBusiness, self).__init__(parent=parent)
        self.Manager = manager
        self.Initialization("DropSlideTableTrayBusiness", self, parent)

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



    def Done(self, handler: WebClientInterface, **args):
        """把载玻台托盘放入指定片仓"""
        isWrong: int = RECODE_FAILURE
        try:
            self.Handler = handler
            request: Request = Request(level=self.Level)
            request.initParameter(**args)
            if request.has_data:
                trayNum: int = request.get_data("trayNum", None)
                AppSlot.DropSlideTableTraySignal.emit(trayNum)
            isWrong = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return
    def WaitDone(self, handler: WebClientInterface, **args) -> int:
        """把载玻台托盘放入指定片仓"""
        isWrong: int = RECODE_FAILURE
        try:
            self.Handler = handler
            request: Request = Request(level=self.Level)
            request.deserialize(args)
            print(request.data)
            if request.has_data:
                trayNum: int = request.data.get("trayNum", None)
                AppSlot.DropSlideTableTraySignal.emit(trayNum)
            isWrong = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWrong

