#!D:\IDE\Anaconda3\envs\Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
 @Author: Administrator
 @FileName: ModelInterface.py
 @DateTime: 2025/6/21 22:30
 @SoftWare: PyCharm
 @Author  ：xsh
"""
from PyQt5                          import Qt
from abc                            import abstractmethod
from AppInterfaces.AppInterface     import AppModelInterface, AppInterface
from AppInterfaces.AppDataInterface import AppDataInterface, AppConvert
from AppSettings.Settings           import RECODE_SUCCEED, RECODE_FAILURE, CODE_FAILURE, CODE_SUCCESS, CODE_WARNING
from AppUtils.utils                 import *

class ContextModelInterface(AppDataInterface):
    IsLoad: bool = False
    def reload(self) -> bool:
        self.IsLoad = self.load()
        if not self.IsLoad:
            self.IsLoad = self.save()
        return self.IsLoad

    def save_filename(self) -> str:
        return AppUtils.toSourceFile(f"Settings/{self.Name}.yaml")

    def copy(self):
        result = self.__class__.__new__(self.__class__)
        result.__init__()
        result.deserialize(self.serialize())
        return result


class RequestModelInterface(AppDataInterface):
    ResultNumber: int = RECODE_FAILURE

    def save_filename(self) -> str:
        return AppUtils.toSourceFile(f"/Requests/{self.Name}.yaml")



