#!D:/IDE/anaconda3/envs/Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName：MicScanSystemLeiCa.py
@Description：
@Author：XSH
@Time：2025/12/24 15:03
@Department：研发部
@Copyright：©2025 乐辰生物
"""
import os
import threading
from PyQt5 import Qt
import sys
import asyncio
from qasync import QEventLoop, asyncSlot
from AppInterfaces.AppTimeLoop import AppTimeLoop
from AppSettings.Settings import *
from AppCore.Levels import *
from AppInterfaces.AppDaemonController import AppDaemonController, DaemonController

if __name__ == "__main__":
    app = Qt.QApplication(sys.argv)
    loop = QEventLoop(app)
    asyncio.set_event_loop(loop)
    DaemonController.Manager = loop
    from AppUtils.DataBaseDeploy import DataBaseDeploy, ChamberStatusModel, TrayModel


    DataBaseDeploy.init()
    from AppSettings.SystemSetting import SystemConfig

    SystemConfig.UpdateMaxLocation()
    TrayModel.UpdateMaxLocation()
    from AppSettings.AppSetting import AppConfig
    SystemConfig.setAsyncioLoop(loop)
    AppConfig.reload()
    from AppCore.AppManagers.HardWareManager import HardWareManager
    from AppHeadEnd.ControlWindows.MainController import MainController
    from AppBackEnd.AppScanningFlow import AppScanningFlow, AppBusinessInterface
    from AppCore.DBModels import *
    from AppHeadEnd.DBModelViews.DBModelView import DBModelView
    from AppBackEnd.AppBackEndBusiness import *
    AppEventBusPool.GetInstance()

    business: AppBusinessInterface =  AppScanningFlow.GetInstance()
    business.initModules()
    frame: MainController = MainController.GetInstance(business=business)

    frame.show()

    DaemonController.Start(loop)
    sys.exit(app.exec())
