#!D:/IDE/anaconda3/envs/Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName：main.py
@Description：
@Author：XSH
@Time：2025/12/6 13:17
@Department：研发部
@Copyright：©2025 乐辰生物
"""
import os
import threading
from PyQt5 import Qt
import sys
import asyncio
from qasync import QEventLoop, asyncSlot
import datetime
import time
from AppCore.Levels import *
from AppInterfaces.Interfaces import *

if __name__ == "__main__":
    app = Qt.QApplication(sys.argv)
    loop = QEventLoop(app)
    asyncio.set_event_loop(loop)
    from AppSettings.AppSetting import AppSetting, AppConfig
    AppConfig.reload()
    from AppCore.AppImpls.ZMicroscopeImpl import ZMicroscopeImpl
    impl: ZMicroscopeImpl = ZMicroscopeImpl.GetInstance()
    impl.ReOpen()
    if impl.IsOpen:
        print(impl.Manager.Accessibility)
        print(impl.Manager.AxisHandler.Accessibility)
        print(impl.GetMaxMoveSpeed())
        print(impl.GetMinMoveSpeed())
        print(impl.GetMaxPosition())
        print(impl.GetMinPosition())
        _, position = impl.GetPosition()
        print(position)
        position -= 3000000
        impl.SetPosition(position, MTBCmdSetModes.Default)
        impl.ObjectiveAbsSetPosition(ObjectiveLevel.Objective1, MTBCmdSetModes.Synchronous)
        print(impl.ObjectiveAbsPosition())
        _, position = impl.GetPosition()
        print(_, position)
        _, _position = impl.AlignPosition(0)
        print(_, _position)
        print(impl.SetMeasurementPosition(0))
        print(impl.Calibrate(MTBCalibrationModes.OnLowerLimit, MTBCmdSetModes.Default))
        impl.ObjectiveAbsSetPosition(ObjectiveLevel.Objective20, MTBCmdSetModes.Synchronous)
        print(impl.ObjectiveAbsPosition())
        _, position = impl.GetPosition()
        print(_, position)

    sys.exit(app.exec())
