#!D:/IDE/anaconda3/envs/Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName：ZMicroscopeImpl.py
@Description：
@Author：XSH
@Time：2025/11/12 14:45
@Department：研发部
@Copyright：©2025 乐辰生物
"""
import os
import sys
import gc
import clr
from pythonnet                                      import unload
from clr_loader.types                               import Assembly, ClrFunction    #
from PyQt5                                          import Qt
from AppInterfaces.ImplInterfaces                   import ZMicroscopeInterface
from AppContexts.Contexts                           import *
from AppInterfaces.utils                            import *
from AppUtils.utils                                 import *
from AppCore.Levels                                 import *
from AppSettings.Settings                           import *

MAX_LIMIT: float = 25000000.0
OBJECTIVE_OFFSET: float = 4000000.0

class ZMicroscopeImpl(Qt.QObject, ZMicroscopeInterface, SingletonInterface):
    Locker: Qt.QMutex = Qt.QMutex()

    @classmethod
    def GetInstance(cls, *args, **kwargs) -> 'ZMicroscopeImpl':
        return super(ZMicroscopeImpl, cls).GetInstance(*args, **kwargs)

    def __init__(self, parent: Qt.QObject = None):
        super(ZMicroscopeImpl, self).__init__(parent=parent)
        self.Initialization('ZMicroscopeImpl', self, parent)


    def initValue(self):
        super(ZMicroscopeImpl, self).initValue()




    def Open(self, timeOut: int = 1000, **args) -> int:
        if self.isAvailable:
            return RECODE_SUCCEED
        if not self.isSucceed:
            self.initManager(**args)
        if self.isSucceed:
            from AppUtils.HardWareUnit import HardWareUnit
            try:
                deviceCount = self.getDeviceCount()
                if deviceCount <= 0:

                    if self.Manager.IsValid:
                        self.Manager.Close()
                    MaxCount: int = 3
                    while MaxCount > 0:

                        if not self.Manager.IsLogin:
                            self.Manager.Login()
                        if not self.Manager.IsInit:
                            self.Manager.Init()
                        self.Manager.Open()
                        if self.Manager.IsInit:
                            deviceCount = self.getDeviceCount()
                            if deviceCount > 0:
                                break
                        self.Manager.Logout()
                        HardWareUnit.restart_windows_service(self.Parameter.MTB_SERVICES_NAME)
                        self.deleManager()
                        self.initManager()

            except Exception as e:
                AppUtils.print_Exception(e)
        return RECODE_SUCCEED if self.isAvailable else RECODE_FAILURE


    def getDeviceCount(self) -> int:
        count = 0
        if self.isAvailable:
            try:
                count = self.Manager.getDeviceCount()
            except Exception as e:
                AppUtils.print_Exception(e)

        return count


    def Close(self, timeOut: int = 1000, **args) -> int:
        """释放资源，断开连接"""
        if self.hasManager:
            try:
                self.Manager.Close()
                print("设备已断开连接")
            except:
                AppUtils.print_Exception(e)


    def initManager(self, **args):
        self.initContext()
        if self.isValid:
            if self.parameter.isSucceed:
                return
        self.Manager        = None
        self.Controller     = None
        self.parameter.IsSucceed = False
        gc.collect()

        filename: str = self.Parameter.absoluteFilePath
        info: Qt.QFileInfo = Qt.QFileInfo(filename)
        if info.exists() and Qt.QLibrary.isLibrary(info.absoluteFilePath()):
            try:
                clr.AddReference(info.absoluteFilePath())
                clr.AddReference('System')
                self.parameter.IsSucceed = True
                if info.absolutePath() not in sys.path:
                    sys.path.append(info.absolutePath())
                from ZeissMicroscopeAPI import  ZeissMicReader, MicManager, IMicroscope, IMicController
                self.Manager    = ZeissMicReader.GetInstance     ()
                self.Controller = MicManager    .GetInstance     ()
                self.Manager.MTBAxisUnit        = MTBAxisUnit                               #
                self.Manager.MTBUnit            = MTBUnit                                   #
                self.Manager.MTBSpeedUnit       = MTBSpeedUnit                              #
                self.Manager.MTBLightUnit       = MTBLightUnit                              #
                self.Parameter.MicroscopeID         = self.Manager.MicroscopeID             #
                self.Parameter.MicroscopeType       = self.Manager.MicroscopeType           #
                self.Parameter.MicroscopeVersion    = self.Manager.MicroscopeVersion        #
                self.Parameter.IsSucceed = self.hasManager
            except Exception as e:
                AppUtils.print_Exception(e)


    def deleManager(self):
        try:
            if self.hasManager:
                self.Manager.Close()
                self.Manager.deleManager()
        except Exception as e:
            AppUtils.print_Exception(e)
        self.Manager        = None
        self.Controller     = None
        self.Parameter      = None
        gc.collect()


    def initContext(self):
        if not self.hasParameter:
            from AppSettings.AppSetting import AppConfig
            self.Parameter = ZeissContext()
            try:
                self.Parameter.deserialize(AppConfig.ZeissMicroscope.serialize())
            except Exception as e:
                AppUtils.print_Exception(e)



    def initMicroscope(self):
        """初始化Z轴步骤"""
        # 1 移动Z轴到硬件限位下限位置
        # 2 设置下限位置为测量原点
        # 3 对Z轴进行下降校准
        # 4 对齐Z轴下限位置为0
        # 5 设置物镜为OjbectiveNone
        # 6 设置光源为OjbectiveNone
        zero_position: float = 0.0
        objective    : int = ObjectiveLevel.Objective1
        from AppCore.DBModels import ObjectiveModel
        self.stop_move()

        isWrong: int = self.init_z_speed(objective)
        if RECODE_SUCCEED != isWrong:
            return isWrong

        isWrong = self.init_z_range()
        if RECODE_SUCCEED != isWrong:
            return isWrong

        print(self.get_z_limit())
        """1 移动Z轴到硬件限位下限位置"""
        isWrong = self.waitmove_h_lower_limit()
        if RECODE_SUCCEED != isWrong:
            return isWrong
        isWrong = self.set_z_calibrate_low_limit()
        if RECODE_SUCCEED != isWrong:
            return isWrong

        isWrong, zero_position = self.set_z_measurement_origin(zero_position)
        if RECODE_SUCCEED != isWrong:
            return isWrong

        isWrong = self.set_z_calibrate_position()
        if RECODE_SUCCEED != isWrong:
            return isWrong
        isWrong, position = self.get_position()

        isWrong, position = self.set_z_measurement_position(position)
        if RECODE_SUCCEED != isWrong:
            return isWrong
        isWrong = self.set_objective(objective, is_lower_limit=False)
        if RECODE_SUCCEED != isWrong:
            return isWrong
        isWrong = self.changedLightIntensity(objective, isChanged=True)
        return isWrong





    def home(self) -> int:
        return self.initMicroscope()


    def waithome(self) -> int:
        return self.initMicroscope()


    def move(self, position: (int, float), mode: int = 0, **args) -> int:
        isWrong: int = RECODE_FAILURE
        result: bool = False
        if self.isAvailable and isinstance(position, (float, int)):
            from ZEISS import MTB
            StrID: str = MTBLevel.toStrID(MTBLevel.MTBFocus)
            changer = self.MTBFunctions.get(StrID, None)
            try:
                Object = MTB.Api.IMTBAxis(changer)
                current: float = Object.GetPosition(MTBAxisUnit)


                if isinstance(current, (int, float)) and float(round(current, 1)) == Float(round(position, 1)):
                    result = True

                else:
                    level: int = mode if isinstance(mode, int) and mode in MTBCmdSetModes.all() else MTBCmdSetModes.Default
                    for count in range(0, 3):
                        Object.SetPosition(float(position), MTBAxisUnit, MTBCmdSetModes.toObject(level))
                        if Object.IsBusy:
                            result = True
                            break

                isWrong = RECODE_SUCCEED if result else RECODE_FAILURE

            except Exception as e:
                AppUtils.print_Exception(e)

        return isWrong


    def stop_move(self) -> int:
        isWrong: int = self.Stop()
        return isWrong


    def rel_waitmove(self, value: (int, float), mode: int = 1, **args):
        isWrong: int
        Target : float
        isWrong, Target = self.GetPosition()
        if RECODE_SUCCEED != isWrong or not isinstance(Target, (int, float)) or not isinstance(value, (int, float)):
            return isWrong
        target: float = float(Target) + float(value)
        level: int = mode if isinstance(mode, int) and mode in MTBCmdSetModes.all() else MTBCmdSetModes.Synchronous
        isWrong = self.SetPosition(float(round(target, 2)), level)
        return isWrong

    def rel_move(self, value: (int, float), mode: int = 0, **args) -> int:
        isWrong: int
        Target: float
        isWrong, Target = self.GetPosition()
        if RECODE_SUCCEED != isWrong or not isinstance(Target, (int, float)) or not isinstance(value, (int, float)):
            return isWrong
        target: float = float(Target) + float(value)
        level: int = mode if isinstance(mode, int) and mode in MTBCmdSetModes.all() else MTBCmdSetModes.Default
        isWrong = self.SetPosition(float(round(target, 2)), level)
        return isWrong


    def waitmove(self, position: (int, float), mode: int = 1, **args) -> int:
        isWrong: int = RECODE_FAILURE
        self.Stop()
        if not isinstance(position, (int, float)) or not isinstance(mode, int):
            return isWrong

        try:
            Target  : float = round(position, 2)
            level   : int = MTBCmdSetModes.Synchronous
            isWrong = self.SetPosition(Target, level)
            if RECODE_SUCCEED == isWrong:
                isWrong = self.waitmove_complete(Target)
        except Exception as e:
            AppUtils.print_Exception(e)

        return isWrong

    def is_moving(self) -> int:
        isWrong: int = self.ZDriverIsBusy()
        return isWrong

    def waitmove_complete(self, target: (int, float), **args) -> int:
        isWrong         : int = RECODE_FAILURE
        isCheck         : bool = isinstance(target, (float, int))
        Target          : float = None if not isCheck else round(float( target), 2)
        maxwaittimes    : int = 360000      #
        position        : float             #
        Status          : int               #
        IsBusy          : int               #
        endtimes        : Qt.QDateTime = Qt.QDateTime.currentDateTime().addMSecs(maxwaittimes)
        while True:
            _, position = self.GetPosition()
            if _ == isWrong or Float(position) == Target:
                isWrong = RECODE_SUCCEED
                break
            IsBusy = self.ZDriverIsBusy()
            if not IsBusy:
                isWrong = RECODE_SUCCEED
                break
            Status = self.IsOnHWLimit()
            if Status == RECODE_SUCCEED or Status == RECODE_FAILURE:
                isWrong = RECODE_SUCCEED
                break
            Status = self.IsOnSWLimit()
            if Status == RECODE_SUCCEED or Status == RECODE_FAILURE:
                isWrong = RECODE_SUCCEED
                break
            if endtimes < Qt.QDateTime.currentDateTime():
                break
            AppTimeLoop.delay(2)
        return isWrong


    def waitmove_h_limit_complete(self, is_lower: bool = True, **args) -> int:
        isWrong         : int = RECODE_FAILURE
        maxwaittimes    : int = 360000      #
        position        : float             #
        Status          : int               #
        IsBusy          : int               #
        endtimes        : Qt.QDateTime = Qt.QDateTime.currentDateTime().addMSecs(maxwaittimes)
        while True:
            IsBusy = self.ZDriverIsBusy()
            if not IsBusy:
                break
            Status = self.IsOnHWLimit()
            if Status == RECODE_SUCCEED or Status == RECODE_WARNING:
                break
            Status = self.IsOnSWLimit()
            if Status == RECODE_SUCCEED or Status == RECODE_WARNING:
                break
            if endtimes < Qt.QDateTime.currentDateTime():
                break
            AppTimeLoop.delay(2)
        Status = self.IsOnHWLimit()
        if is_lower:
            isWrong = RECODE_SUCCEED if Status == RECODE_SUCCEED else RECODE_FAILURE
        else:
            isWrong = RECODE_SUCCEED if Status == RECODE_WARNING else RECODE_FAILURE
        return isWrong

    def waitmove_s_limit_complete(self, is_lower: bool = True, **args) -> int:
        isWrong         : int = RECODE_FAILURE
        maxwaittimes    : int = 360000      #
        position        : float             #
        Status          : int               #
        IsBusy          : int               #
        endtimes        : Qt.QDateTime = Qt.QDateTime.currentDateTime().addMSecs(maxwaittimes)
        while True:
            IsBusy = self.ZDriverIsBusy()
            if not IsBusy:
                break
            Status = self.IsOnHWLimit()
            if Status == RECODE_SUCCEED or Status == RECODE_WARNING:
                break
            Status = self.IsOnSWLimit()

            if Status == RECODE_SUCCEED or Status == RECODE_WARNING:
                break
            if endtimes < Qt.QDateTime.currentDateTime():
                break
            AppTimeLoop.delay(2)
        Status = self.IsOnSWLimit()
        if is_lower:
            isWrong = RECODE_SUCCEED if Status == RECODE_SUCCEED else RECODE_FAILURE
        else:
            isWrong = RECODE_SUCCEED if Status == RECODE_WARNING else RECODE_FAILURE
        return isWrong


    def waitmove_finish(self, target: (int, float), **args) -> int:
        isWrong         : int = RECODE_FAILURE
        isCheck         : bool = isinstance(target, (float, int))
        Target          : float = None if not isCheck else round(float( target), 2)
        maxwaittimes    : int = 360000      #
        position        : float             #
        Status          : int               #
        IsBusy          : int               #
        endtimes        : Qt.QDateTime = Qt.QDateTime.currentDateTime().addMSecs(maxwaittimes)
        while True:
            _, position = self.GetPosition()
            if _ == isWrong or Float(position) == Target:
                isWrong = RECODE_SUCCEED
                break
            IsBusy = self.ZDriverIsBusy()
            if not IsBusy:
                isWrong = RECODE_SUCCEED
                break
            Status = self.IsOnHWLimit()
            if Status == RECODE_SUCCEED or Status == RECODE_FAILURE:
                isWrong = RECODE_SUCCEED
                break
            Status = self.IsOnSWLimit()
            if Status == RECODE_SUCCEED or Status == RECODE_FAILURE:
                isWrong = RECODE_SUCCEED
                break
            if endtimes < Qt.QDateTime.currentDateTime():
                break
            AppTimeLoop.delay(2)
        return isWrong

    def waitmove_lower_limit(self, **args):
        return self.waitmove_h_lower_limit(**args)

    def waitmove_upper_limit(self, **args) -> int:
        return self.waitmove_h_upper_limit(**args)


    def waitmove_h_lower_limit(self, **args):
        isWrong: int = RECODE_FAILURE
        result: bool
        self.stop_move()
        _   , max_limit     = self.GetMaxPosition           ()
        __  , min_limit     = self.GetMinPosition           ()
        ___ , Measurement   = self.GetMeasurementPosition   ()
        if RECODE_SUCCEED != _ or RECODE_SUCCEED != __ or RECODE_SUCCEED != ___:
            return isWrong
        lower: float = -round(float(abs(max_limit) + abs(min_limit) + abs(Measurement)), 2)
        isWrong = self.EnableSWLimit(False, False)
        if RECODE_SUCCEED != isWrong:
            return isWrong
        isWrong = self.EnableSWLimit(True, False)
        if RECODE_SUCCEED != isWrong:
            return isWrong
        self.SetPosition(lower, MTBCmdSetModes.Synchronous)
        isWrong = self.waitingToStop()
        return isWrong


    def waitmove_h_upper_limit(self, **args) -> int:
        isWrong: int = RECODE_FAILURE
        result: bool
        self.stop_move()
        _   , max_limit     = self.GetMaxPosition           ()
        __  , min_limit     = self.GetMinPosition           ()
        ___ , Measurement   = self.GetMeasurementPosition   ()
        if RECODE_SUCCEED != _ or RECODE_SUCCEED != __ or RECODE_SUCCEED != ___:
            return isWrong
        lower: float = round(float(abs(max_limit) + abs(min_limit) + abs(Measurement)), 2)
        isWrong = self.EnableSWLimit(False, False)
        if RECODE_SUCCEED != isWrong:
            return isWrong
        isWrong = self.EnableSWLimit(True, False)
        if RECODE_SUCCEED != isWrong:
            return isWrong
        self.SetPosition(lower, MTBCmdSetModes.Synchronous)
        isWrong = self.waitingToStop()
        return isWrong

    def is_h_lower_limit(self) -> int:
        isWrong: int = RECODE_SUCCEED if self.IsOnHWLimit() == RECODE_SUCCEED else RECODE_FAILURE
        return isWrong



    def is_h_upper_limit(self) -> int:
        isWrong: int = RECODE_SUCCEED if self.IsOnHWLimit() == RECODE_WARNING else RECODE_FAILURE
        return isWrong

    def is_s_lower_limit(self) -> int:
        isWrong: int = RECODE_SUCCEED if self.IsOnSWLimit() == RECODE_SUCCEED else RECODE_FAILURE
        return isWrong


    def is_s_upper_limit(self) -> int:
        isWrong: int = RECODE_SUCCEED if self.IsOnSWLimit() == RECODE_WARNING else RECODE_FAILURE
        return isWrong

    def getPosition(self) -> int:
        """获取当前位置"""
        _, position = self.GetPosition()
        return  position

    def setFastSpeedMode(self):
        from AppCore.AppDBModels.DBModels import ObjectiveModel
        Objective: ObjectiveModel = ObjectiveModel.getConfig(ObjectiveLevel.Objective1)
        isWrong: int = self.set_z_speed(Objective.Scan_Speed)
        return isWrong


    def setNormalSpeedMode(self):
        from AppCore.AppDBModels.DBModels import ObjectiveModel
        Objective: ObjectiveModel = ObjectiveModel.getConfig(ObjectiveLevel.Objective1)
        isWrong: int = self.set_z_speed(Objective.Focus_Speed)
        return isWrong


    def set_objective(self, level: int, is_lower_limit: bool = False, **args) -> int:
        isWrong, target = self.ObjectiveAbsPosition()
        if RECODE_SUCCEED != isWrong:
            return isWrong
        if int(target) == int(level):
            return RECODE_SUCCEED

        if is_lower_limit:
            self.rel_waitmove(-OBJECTIVE_OFFSET)
        isWrong: int = self.ObjectiveAbsSetPosition(level, MTBCmdSetModes.Synchronous)
        if RECODE_SUCCEED != isWrong:
            isWrong = RECODE_SUCCEED if int(target) == int(level) else RECODE_FAILURE
            return isWrong
        self.waitForObjectiveComplete(level, target)
        return isWrong

    def changedObjective(self, level: int, is_lower_limit: bool = False, **args) -> int:
        if is_lower_limit:
            self.rel_waitmove(-OBJECTIVE_OFFSET)
        isWrong: int = self.ObjectiveAbsSetPosition(level, MTBCmdSetModes.Synchronous)
        if RECODE_SUCCEED != isWrong:
            isWrong, target = self.ObjectiveAbsPosition()
            if RECODE_SUCCEED != isWrong:
                return isWrong
            if int(target) == int(level):
                return RECODE_SUCCEED
            return RECODE_FAILURE
        self.waitForObjectiveComplete(level)
        return isWrong

    def waitForObjectiveComplete(self, level: int, target: (int, float), **args) -> int:
        isWrong: int = RECODE_FAILURE
        convert_waittimes   : int = 60000
        delay               : int = 200
        endtimes            : Qt.QDateTime = Qt.QDateTime.currentDateTime().addMSecs(convert_waittimes)
        objective           : int
        try:
            while True:
                IsBusy = self.ObjectiveIsBusy()
                if RECODE_SUCCEED != IsBusy:
                    _, objective = self.ObjectiveAbsPosition()
                    if RECODE_SUCCEED == _ and  objective == level:
                        isWrong = RECODE_SUCCEED
                        break
                if Qt.QDateTime.currentDateTime() > endtimes:
                    break
                AppTimeLoop.processGlobalEvents(delay)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWrong

    def changedLightIntensity(self, level: int, **args) -> int:
        from AppCore.AppDBModels.ConfigModels.ObjectiveModel import ObjectiveModel
        Objective: ObjectiveModel = ObjectiveModel.getConfig(level)
        isWrong: int = self.set_lamp_enable(True)
        if RECODE_SUCCEED != isWrong:
            return isWrong
        isWrong = self.set_lamp(Objective.LAMP, **args)
        if RECODE_SUCCEED != isWrong:
            return isWrong
        self.set_apbl(Objective.APBL, **args)
        return isWrong


    def set_z_upper_limit(self, limit=-1) -> int:
        isWrong: int
        Limit: float
        if not isinstance(limit, (int, float)) or int(limit) <= 0:
            Limit = float(MAX_LIMIT)
        else:
            Limit = float(limit)
        isWrong = self.SetSWLimit(True, Limit)

        return isWrong


    def set_z_lower_limit(self, limit=-1) -> int:
        isWrong: int
        Limit: float
        if not isinstance(limit, (int, float)) or int(limit) <= 0:
            Limit = 0
        else:
            Limit = float(limit)
        isWrong = self.SetSWLimit(False, Limit)

        return isWrong


    def set_z_upper_enable(self, enable: (int, bool), **args) -> int:
        isWrong: int = self.EnableSWLimit(True, True if isinstance(enable, (bool, int)) and enable else False)
        return isWrong


    def set_z_lower_enable(self, enable: (int, bool), **args) -> int:
        isWrong: int = self.EnableSWLimit(False, True if isinstance(enable, (bool, int)) and enable else False)
        return isWrong


    def init_objective_range(self, **args) -> int:
        min_result = self.EnableSWLimit(False   , False)
        max_result = self.EnableSWLimit(True    , False)
        self.SetSWLimit(False   , float(0           ))
        self.SetSWLimit(True    , float(MAX_LIMIT   ))
        isWrong: int = RECODE_SUCCEED if min_result ==  RECODE_SUCCEED and max_result ==  RECODE_SUCCEED else RECODE_FAILURE
        return isWrong

    def init_z_range(self) -> int:
        min_result = self.EnableSWLimit(False   , False)
        max_result = self.EnableSWLimit(True    , False)
        self.SetSWLimit(False   , float(0           ))
        self.SetSWLimit(True    , float(MAX_LIMIT   ))
        isWrong: int = RECODE_SUCCEED if min_result ==  RECODE_SUCCEED and max_result ==  RECODE_SUCCEED else RECODE_FAILURE
        return isWrong

    def init_z_speed(self, level: int) -> int:
        isWrong: int
        from AppCore.DBModels import ObjectiveModel
        Objective: ObjectiveModel = ObjectiveModel.getConfig(level)
        isWrong = self.set_z_speed(Objective.Default_Speed)
        return isWrong

    def set_z_range(self, min_limit: int = -1, max_limit: int = -1) -> int:
        if not isinstance(min_limit, (int, float)) or int(min_limit) <= 0:
            min_result = self.EnableSWLimit(False, False)
            self.SetSWLimit(False, float(0))
        else:
            min_result = self.EnableSWLimit(False, True)
            self.SetSWLimit(False, float(min_limit))
        if not isinstance(max_limit, (int, float)) or int(max_limit) <= 0:
            max_result = self.EnableSWLimit(True, False)
            self.SetSWLimit(True, float(MAX_LIMIT))
        else:
            max_result = self.EnableSWLimit(True, True)
            self.SetSWLimit(True, float(max_limit))
        isWrong: int = RECODE_SUCCEED if min_result == RECODE_SUCCEED and max_result == RECODE_SUCCEED else RECODE_FAILURE
        return isWrong


    def get_z_upper_limit(self) -> (int, float):
        isWrong     : int
        max_limit   : float
        isWrong, max_limit = self.GetSWLimit(True)
        return isWrong, max_limit


    def get_z_lower_limit(self) -> (int, float):
        isWrong: int
        min_limit: float
        isWrong, min_limit = self.GetSWLimit(False)
        return isWrong, min_limit


    def get_z_range(self) -> (int, float, float):
        isWrong: int
        max_limit: float
        _   , max_limit = self.GetSWLimit(True)
        __  , min_limit = self.GetSWLimit(False)
        isWrong: int = RECODE_SUCCEED if RECODE_SUCCEED == _ and RECODE_SUCCEED == __ else RECODE_FAILURE
        return isWrong, min_limit, max_limit

    def get_z_limit(self) -> (int, float, float):
        isWrong: int
        max_limit: float
        _, max_limit = self.GetSWLimit(True)
        __, min_limit = self.GetSWLimit(False)
        isWrong: int = RECODE_SUCCEED if RECODE_SUCCEED == _ and RECODE_SUCCEED == __ else RECODE_FAILURE
        return isWrong, min_limit, max_limit

    def set_z_acceleration(self, acceleration: (float, int)):
        isWrong: int = self.SetContinualAcceleration( acceleration)
        return isWrong


    def get_z_enabled(self) -> int:
        isWrong: int = self.GetOnOff()
        return isWrong


    def set_z_enabled(self, enable: (int, bool)) -> int:
        isWrong: int = self.SetOnOff(True if isinstance(enable, (bool, int)) and enable else False)
        return isWrong

    def setMeasurementOrigin(self, value: (int, float), **args) -> int:
        isWrong: int = RECODE_FAILURE
        if isinstance(value, (int, float)):
            isWrong = self.SetMeasurementOrigin(float(value))
        return isWrong

    def getMeasurementOrigin(self, **args) -> (int, float):
        isWrong: int
        position: float
        isWrong, position = self.GetMeasurementOrigin()
        return isWrong, position

    def setMeasurementPosition(self, value: (int, float), **args) -> int:
        isWrong: int = RECODE_FAILURE
        if isinstance(value, (int, float)):
            isWrong = self.SetMeasurementPosition(float(value))
        return isWrong

    def getMeasurementPosition(self, **args) -> (int, float):
        isWrong: int
        position: float
        isWrong, position = self.GetMeasurementPosition()
        return isWrong, position

    def set_z_speed(self, speed: (float, int)):
        isWrong: int = RECODE_FAILURE
        if isinstance(speed, (int, float)):
            isWrong = self.SetContinualSpeed(float(speed))
        return isWrong


    def set_z_move_mode(self, enable: (int, bool)):
        if isinstance(enable, (int, bool)) and enable:
            return self.setFastSpeedMode()
        else:
            return self.setNormalSpeedMode()


    def set_objective_upper_limit(self, level) -> int:
        from AppCore.AppDBModels.DBModels import ObjectiveModel
        Objective: ObjectiveModel = ObjectiveModel.getConfig(level)
        return self.set_z_upper_limit(Objective.Upper_Limit)


    def set_objective_limit(self, level) -> int:
        from AppCore.AppDBModels.DBModels import ObjectiveModel
        Objective: ObjectiveModel = ObjectiveModel.getConfig(level)
        isWrong = self.set_z_lower_limit(Objective.Lower_Limit)
        if RECODE_SUCCEED == isWrong:
            isWrong = self.set_z_upper_limit(Objective.Upper_Limit)
        return isWrong


    def set_objective_lower_limit(self, level) -> int:
        from AppCore.AppDBModels.DBModels import ObjectiveModel
        Objective: ObjectiveModel = ObjectiveModel.getConfig(level)
        return self.set_z_lower_limit(Objective.Lower_Limit)


    def set_objective_focus_speed(self, level) -> int:
        from AppCore.AppDBModels.DBModels import ObjectiveModel
        Objective: ObjectiveModel = ObjectiveModel.getConfig(level)
        return self.set_z_speed(Objective.Focus_Speed)


    def set_objective_default_speed(self, level) -> int:
        from AppCore.AppDBModels.DBModels import ObjectiveModel
        Objective: ObjectiveModel = ObjectiveModel.getConfig(level)
        return self.set_z_speed(Objective.Default_Speed)


    def set_objective_scan_speed(self, level) -> int:
        from AppCore.AppDBModels.DBModels import ObjectiveModel
        Objective: ObjectiveModel = ObjectiveModel.getConfig(level)
        return self.set_z_speed(Objective.Scan_Speed)


    def set_upper_limit(self, position: (int, float)) -> int:
        return self.set_z_upper_limit(position)


    def set_lower_limit(self, position: (int, float)) -> int:
        return self.set_z_lower_limit(position)


    def get_position(self) -> (int, int):
        """获取当前位置"""
        isWrong     : int
        position    : float
        isWrong, position = self.GetPosition()
        return isWrong, position


    def get_z_measurement_origin(self) -> (int, float):
        """获取测量原点位置"""
        isWrong     : int
        position    : float
        isWrong, position = self.GetMeasurementOrigin()
        return isWrong, position

    def get_z_measurement_position(self) -> (int, float):
        """获取当前测量位置"""
        isWrong     : int
        position    : float
        isWrong, position = self.GetMeasurementPosition()
        return isWrong, position

    def set_z_measurement_origin(self, position: (int, float), **args) -> (int, float):
        """设置当前测量原点"""
        isWrong: int = self.SetMeasurementOrigin(float(position))
        if RECODE_SUCCEED == isWrong:
            _, _position = self.GetMeasurementOrigin()
            return isWrong, _position
        return isWrong, position

    def set_z_measurement_position(self, position: (int, float), **args) -> (int, float):
        """设置当前测量位置"""
        isWrong: int = self.SetMeasurementPosition(float(position))
        if RECODE_SUCCEED == isWrong:
            _, _position = self.GetMeasurementPosition()
            return isWrong, _position
        return isWrong, position

    def set_z_align_position(self, position: (int, float), **args) -> int:
        isWrong, _position = self.AlignPosition(position)
        return isWrong, _position

    def get_objective(self) -> (int, int):
        isWrong, objective = self.ObjectiveAbsPosition()
        return isWrong, objective

    def getObjective(self) -> int:
        """获取当前物镜转换器的位置（物镜编号）"""
        isWrong, objective = self.ObjectiveAbsPosition()
        return objective


    def currentObjective(self) -> (int, int):
        isWrong, objective = self.ObjectiveAbsPosition()
        return isWrong, objective


    def changed_spot_light(self, enable: (bool, int)) -> int:
        return RECODE_FAILURE


    def get_spot_light(self) -> (int, int):
        return RECODE_FAILURE

    def POS_CONST_Z(self, SPEED: int, target: int = None, **args) -> int:
        isWrong: int = RECODE_FAILURE
        if isinstance(SPEED, (int, float)):
            isWrong = self.Move(SPEED)
        return isWrong





    def getHandwheelOnOff(self) -> int:
        """获取手轮控制状态"""
        isWrong: int = self.GetHandwheelOnOff()

        return isWrong


    def setHandwheelOnOff(self, enable: (bool, int)) -> int:
        """设置手轮控制状态"""
        isWrong: int = self.SetHandwheelOnOff(True if isinstance(enable, (bool, int)) and enable else False)
        return isWrong


    def set_z_calibrate(self, level: int = None) -> int:
        _level: int = level if isinstance(level, int) and level in MTBCalibrationModes.all() else MTBCalibrationModes.NotCalibrated
        isWrong: int = self.Calibrate(_level, MTBCmdSetModes.Synchronous)
        return isWrong


    def set_z_calibrate_low_limit(self) -> int:
        isWrong: int = self.Calibrate(MTBCalibrationModes.OnLowerLimit, MTBCmdSetModes.Synchronous)
        return isWrong


    def set_z_calibrate_position(self) -> int:
        isWrong: int = self.Calibrate(MTBCalibrationModes.OnCurrentPosition, MTBCmdSetModes.Synchronous)
        return isWrong

    def set_align_position(self, target: (int, float)) -> int:
        isWrong: int = self.AlignPosition(target)
        return isWrong



    def getLAMPOnOFF(self) -> (int, int):
        isWrong : int = self.LampGetOnOff()
        return RECODE_SUCCEED, isWrong


    def getAPBL(self) -> (int, float):
        isWrong : int
        APBL    : float
        isWrong, APBL = self.ApblGetPosition()
        return isWrong, APBL


    def getLFBL(self) -> (int, float):
        isWrong: int
        APBL: float
        isWrong, APBL = self.ApblGetPosition()
        return isWrong, APBL


    def changedLAMP(self, value: int, **args) -> int:
        self.set_lamp_enable(True)
        return self.set_lamp(value, **args)




    def changedLFBL(self, value: int, **args):
        return self.set_lfbl(value)



    def changedAPBL(self, value: int, **args) -> int:
        return self.set_apbl(value, **args)


    def set_apbl(self, value: (int, float), **args) -> int:
        isWrong: int = RECODE_FAILURE
        if isinstance(value, (float, int)):
            isWrong = self.ApblAbsSetPosition( float(value), MTBCmdSetModes.Synchronous)
        return isWrong


    def set_lfbl(self, value: (int, float), **args) -> int:
        isWrong: int = RECODE_FAILURE
        if isinstance(value, (float, int)):
            isWrong = self.ApblAbsSetPosition(float(value), MTBCmdSetModes.Synchronous)
        return isWrong


    def set_lamp(self, value: (int, float), **args) -> int:
        isWrong     : int = RECODE_FAILURE
        if isinstance(value, (int, float)):
            isWrong = self.LampAbsSetPosition(float(value), MTBCmdSetModes.Synchronous)

        return isWrong


    def set_lamp_enable(self, enable: (bool, int), **args) -> int:
        isWrong: int = self.LampSetOnOff(True if isinstance(enable, (bool, int)) and enable else False, MTBCmdSetModes.Synchronous)
        return isWrong

    def get_lamp_enable(self, **args) -> int:
        isWrong: int = self.LampGetOnOff()
        return isWrong

    def get_apbl(self, **args) -> (int, float):
        isWrong: int
        APBL: float
        isWrong, APBL = self.ApblGetPosition()
        return isWrong, APBL


    def get_lfbl(self, **args) -> (int, float):
        isWrong: int
        APBL: float
        isWrong, APBL = self.ApblGetPosition()
        return isWrong, APBL


    def get_lamp(self, **args) -> (int, int):
        isWrong : int
        ON      : int
        isWrong, ON = self.LampGetPosition()
        return isWrong, ON


    def set_tl_rl_switch(self, enable: (int, bool), **args):
        isWrong: int = RECODE_FAILURE
        ON          : int = 1 if isinstance(enable, (bool, int)) and enable else 2
        isWrong = self.SetLampILTLSwitch(ON)
        return isWrong


    def get_tl_rl_switch(self) -> (int, int):
        isWrong: int =self.GetLampILTLSwitch(ON)
        return RECODE_SUCCEED, isWrong
    

    
    def initMicroscopeObjective(self) -> int:
        return self.set_objective(ObjectiveLevel.Objective1)

    
    def set_max_lamp(self) -> int:
        isWrong, max_lamp = self.LampGetMaxPosition()
        if RECODE_SUCCEED == isWrong and isinstance(max_lamp, (int, float)):
            isWrong = self.LampAbsSetPosition(max_lamp, MTBCmdSetModes.Synchronous)
        return isWrong

    
    def set_min_lamp(self) -> int:
        isWrong, min_lamp = self.LampGetMinPosition()
        if RECODE_SUCCEED == isWrong and isinstance(min_lamp, (int, float)):
            isWrong = self.LampAbsSetPosition(min_lamp, MTBCmdSetModes.Synchronous)
        return isWrong
    
    def set_min_lfbl(self) -> int:
        isWrong, min_limit = self.ApblGetMinPosition()
        if RECODE_SUCCEED == isWrong and isinstance(min_lamp, (int, float)):
            isWrong = self.ApblAbsSetPosition(min_lamp, MTBCmdSetModes.Synchronous)
        return isWrong

    
    def set_max_lfbl(self):
        isWrong, max_limit = self.ApblGetMaxPosition()
        if RECODE_SUCCEED == isWrong and isinstance(max_limit, (int, float)):
            isWrong = self.ApblAbsSetPosition(max_limit, MTBCmdSetModes.Synchronous)
        return isWrong

    
    def set_min_apbl(self) -> int:
        isWrong, min_limit = self.ApblGetMinPosition()
        if RECODE_SUCCEED == isWrong and isinstance(min_lamp, (int, float)):
            isWrong = self.ApblAbsSetPosition(min_lamp, MTBCmdSetModes.Synchronous)
        return isWrong

    
    def set_max_apbl(self):
        isWrong, max_limit = self.ApblGetMaxPosition()
        if RECODE_SUCCEED == isWrong and isinstance(max_limit, (int, float)):
            isWrong = self.ApblAbsSetPosition(max_limit, MTBCmdSetModes.Synchronous)
        return isWrong

    
    def set_shutter_lamp(self, enable: (bool, int)) -> int:
        return RECODE_FAILURE

    
    def get_shutter_lamp(self) -> (int, int):
        return RECODE_FAILURE, RECODE_FAILURE

    
    def set_master_event(self):
        return RECODE_FAILURE

    
    def set_objective_event(self):
        return RECODE_FAILURE

    
    def set_z_event(self):
        return RECODE_FAILURE

    
    def set_tl_event(self):
        return RECODE_FAILURE

    
    def set_field_tl_event(self):
        return RECODE_FAILURE

    
    def set_led_event(self):
        return RECODE_FAILURE

    
    def set_config_mode(self, enable: (int, bool) = 0):
        """设置配置模式 0: 配置模式关闭 1：配置模式开启"""
        return RECODE_FAILURE

    
    def get_config_mode(self):
        """设置配置模式 0: 配置模式关闭 1：配置模式开启"""
        return RECODE_FAILURE



    def set_position(self, position: (int, float)) -> int:
        return self.SetPosition( position, MTBCmdSetModes.Synchronous)


    
    def waitForNotMoving(self):
        maxwaittimes    : int = 360000  #
        position        : float  #
        Status          : int  #
        IsBusy          : int  #
        endtimes        : Qt.QDateTime = Qt.QDateTime.currentDateTime().addMSecs(maxwaittimes)
        while True:
            IsBusy = self.ZDriverIsBusy()
            if not IsBusy:
                break
            Status = self.IsOnHWLimit()
            if Status == RECODE_SUCCEED or Status == RECODE_WARNING:
                break
            Status = self.IsOnSWLimit()
            if Status == RECODE_SUCCEED or Status == RECODE_WARNING:
                break
            if endtimes < Qt.QDateTime.currentDateTime():
                break
            AppTimeLoop.delay(2)
        self.Stop()
        return RECODE_SUCCEED

    
    def waitingToStop(self) -> int:
        maxwaittimes    : int = 360000  #
        position        : float  #
        Status          : int  #
        IsBusy          : int  #
        endtimes        : Qt.QDateTime = Qt.QDateTime.currentDateTime().addMSecs(maxwaittimes)
        while True:
            IsBusy = self.ZDriverIsBusy()
            if not IsBusy:
                break
            Status = self.IsOnHWLimit()
            if Status == RECODE_SUCCEED or Status == RECODE_WARNING:
                break
            Status = self.IsOnSWLimit()
            if Status == RECODE_SUCCEED or Status == RECODE_WARNING:
                break
            if endtimes < Qt.QDateTime.currentDateTime():
                break
            AppTimeLoop.delay(2)
        self.Stop()
        return RECODE_SUCCEED

    
    def isMoveRange(self) -> (int, int):
        Status = self.IsOnHWLimit()
        if Status == RECODE_SUCCEED or Status == RECODE_WARNING:
            return RECODE_SUCCEED, RECODE_SUCCEED
        Status = self.IsOnSWLimit()
        if Status == RECODE_SUCCEED or Status == RECODE_WARNING:
            return RECODE_SUCCEED, RECODE_SUCCEED
        return RECODE_SUCCEED, RECODE_FAILURE

    
    def isMoveLower(self) -> (int, int):
        Status = self.IsOnHWLimit()
        if Status == RECODE_SUCCEED:
            return RECODE_SUCCEED, RECODE_SUCCEED
        Status = self.IsOnSWLimit()
        if Status == RECODE_SUCCEED:
            return RECODE_SUCCEED, RECODE_SUCCEED
        return RECODE_SUCCEED, RECODE_FAILURE

    
    def isMoveUpper(self) -> (int, int):
        Status = self.IsOnHWLimit()
        if Status == RECODE_WARNING:
            return RECODE_SUCCEED, RECODE_SUCCEED
        Status = self.IsOnSWLimit()
        if Status == RECODE_WARNING:
            return RECODE_SUCCEED, RECODE_SUCCEED
        return RECODE_SUCCEED, RECODE_FAILURE

    
    def isMoveFocus(self) -> (int, int):
        Status = self.IsOnHWLimit()
        if Status == RECODE_SUCCEED or Status == RECODE_WARNING:
            return RECODE_SUCCEED, RECODE_SUCCEED
        Status = self.IsOnSWLimit()
        if Status == RECODE_SUCCEED or Status == RECODE_WARNING:
            return RECODE_SUCCEED, RECODE_SUCCEED
        return RECODE_SUCCEED, RECODE_FAILURE

    
    def isMoveMoving(self) -> (int, int):
        Status = self.IsOnHWLimit()
        if Status == RECODE_SUCCEED or Status == RECODE_WARNING:
            return RECODE_SUCCEED, RECODE_FAILURE
        Status = self.IsOnSWLimit()
        if Status == RECODE_SUCCEED or Status == RECODE_WARNING:
            return RECODE_SUCCEED, RECODE_FAILURE
        return RECODE_SUCCEED, self.ZDriverIsBusy()

    
    def check_z(self):
        return RECODE_FAILURE

    
    def reset_z(self) -> int:
        return RECODE_FAILURE


    def get_move_status(self) -> (int, int):
        isWarning: int  = RECODE_SUCCEED
        IsBusy          = self.ZDriverIsBusy()
        return isWarning, IsBusy


    
    def get_z_status(self) -> (int, int, int, int, int, int):
        isWarning: int = RECODE_SUCCEED
        Moving: int = self.ZDriverIsBusy()
        IsOnHWLimit = self.IsOnHWLimit()
        IsOnSWLimit = self.IsOnSWLimit()
        Lower = IsOnSWLimit == RECODE_SUCCEED
        Upper = IsOnSWLimit == RECODE_WARNING
        Limit = IsOnHWLimit == RECODE_SUCCEED
        Focus = IsOnSWLimit == RECODE_WARNING
        return isWarning, Moving, Lower, Upper, Limit, Focus

    
    def set_focus_position(self, position: (int, float)) -> int:
        if isinstance(position, (int, float)):
            return self.SetSWLimit(True, float(position))
        return RECODE_FAILURE

    
    def set_focus_limit_active(self, enable: (int, bool)) -> int:
        return self.EnableSWLimit(True, True if isinstance(enable, (bool, int)) and enable else False)

    
    def get_focus_limit_active(self) -> (int, int):
        return RECODE_SUCCEED, self.IsSWLimitEnabled(True)

    def set_objective_position(self, position: (int, float)) -> int:
        if isinstance(position, (int, float)):
            return self.ObjectiveAbsSetPosition(int(position), MTBCmdSetModes.Synchronous)
        return RECODE_FAILURE



    
    def wait_init_z_range(self) -> int:
        MaxCount: int = 3
        isWrong: int = RECODE_FAILURE
        for i in range(MaxCount):
            isWrong = self.SetSWLimit(False, float(0.0))
            if isWrong == RECODE_SUCCEED:
                break
            AppTimeLoop.processGlobalEvents(1000)
        if isWrong != RECODE_SUCCEED:
            return isWrong
        for i in range(MaxCount):
            isWrong = self.SetSWLimit(True, float(MAX_LIMIT))
            if isWrong == RECODE_SUCCEED:
                break
            AppTimeLoop.processGlobalEvents(1000)
        return isWrong
    

    def get_z_speed(self) -> (int, float):
        isWrong, speed = self.GetContinualSpeed()
        return isWrong, speed


    
    def get_z_acceleration(self) -> (int, float):
        isWrong, acceleration = self.GetContinualAcceleration()
        return isWrong, acceleration

    def get_objective_parameter(self, level: int) -> (int, int):
        return RECODE_FAILURE, RECODE_FAILURE

    
    def set_objective_parameter(self, level: int) -> (int, int):
        return RECODE_FAILURE, RECODE_FAILURE

    
    def get_objective_status(self) -> (int, int):
        return RECODE_SUCCEED, self.ObjectiveIsBusy()

    
    def set_objective_mode(self, mode: int) -> int:
        return RECODE_SUCCEED

    
    def get_objective_mode(self) -> (int, int):
        return RECODE_SUCCEED, None

    
    def set_objective_dry(self, dry: int) -> int:
        return RECODE_SUCCEED

    
    def get_objective_dry(self) -> (int, int):
        return RECODE_SUCCEED, None

    
    def set_objective_dip(self) -> int:
        return RECODE_SUCCEED

    
    def set_objective_patho_mode(self, mode: int = 0) -> int:
        return RECODE_SUCCEED, None

    
    def get_objective_patho_mode(self) -> (int, int):
        return RECODE_SUCCEED, None


    def get_objective_position(self) -> (int, int):
        return RECODE_SUCCEED, None


    def init_device_z(self):
        return RECODE_SUCCEED

    
    def init_apbl(self):
        return RECODE_SUCCEED

    
    def init_lfbl(self):
        return RECODE_SUCCEED

    
    def get_init_status(self) -> int:
        return RECODE_SUCCEED



    
    def set_current_position_low_limit(self) -> int:
        isWarning, position = self.GetPosition()
        if RECODE_SUCCEED == isWarning:
            return self.SetSWLimit(False, float(position))
        return RECODE_FAILURE

    
    def get_step_count(self) -> (int, float):
        return self.StepWidth()

    
    def get_min_acceleration(self) -> (int, float):
        return self.GetMinContinualAcceleration()

    
    def get_max_acceleration(self) -> (int, float):
        return self.GetMaxContinualAcceleration()





    def GetMaxMoveSpeed                     (self                                     ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result    = None
        try:
            if self.hasManager:
                result = self.Controller.GetMaxMoveSpeed(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetMinMoveSpeed                     (self                                     ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetMinMoveSpeed(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetSpeedUnit                        (self, index                  : int       ) -> (int, str     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetSpeedUnit(self.Manager, index)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetSpeedUnitCount                   (self                                     ) -> (int, int     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetSpeedUnitCount(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def Move                                (self, moveSpeed              : float     ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.Move(self.Manager, moveSpeed)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def Stop                                (self                                     ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.Stop(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def GetContinualAcceleration            (self                                     ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetContinualAcceleration(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetContinualAccelerationUnit        (self, index                  : int       ) -> (int, str     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetContinualAccelerationUnit(self.Manager, index)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetContinualAccelerationUnitCount   (self                                     ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.GetContinualAccelerationUnitCount(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def GetContinualSpeed                   (self                                     ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetContinualSpeed(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetContinualSpeedUnit               (self, index                  : int       ) -> (int, str     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetContinualSpeedUnit(self.Manager, index)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetContinualSpeedUnitCount          (self                                     ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.GetContinualSpeedUnitCount(self.Manager)

        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def GetContinualStartSpeed              (self                                     ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetContinualStartSpeed(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetContinualStartSpeedUnit          (self, index                  : int       ) -> (int, str     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetContinualStartSpeedUnit(self.Manager, index)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetContinualStartSpeedUnitCount     (self                                     ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.GetContinualStartSpeedUnitCount(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning
    def GetMaxContinualAcceleration         (self                                     ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetMaxContinualAcceleration(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result
    def GetMaxContinualSpeed                (self                                     ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetMaxContinualSpeed(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result
    def GetMaxContinualStartSpeed           (self                                     ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetMaxContinualStartSpeed(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result
    def GetMinContinualAcceleration         (self                                     ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetMinContinualAcceleration(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result
    def GetMinContinualSpeed                (self                                     ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetMinContinualSpeed(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result
    def GetMinContinualStartSpeed           (self                                     ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetMinContinualStartSpeed(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result
    def SetContinualAcceleration            (self, continualAcceleration  : float     ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.SetContinualAcceleration(self.Manager, continualAcceleration)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning


    def SetContinualSpeed                   (self, continualSpeed         : float     ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.SetContinualSpeed(self.Manager, continualSpeed)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning


    def SetContinualStartSpeed              (self, continualSpeed         : float     ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.SetContinualStartSpeed(self.Manager, continualSpeed)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def IsOnHWLimit                  (self,                                                                            ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.IsOnHWLimit(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def AlignPosition                (self, position  : float                                                          ) -> (int, float     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.AlignPosition(self.Manager, position)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetMaxPosition               (self,                                                                            ) -> (int, float     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetMaxPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetMinPosition               (self,                                                                            ) -> (int, float     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetMinPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetPosition                  (self,                                                                            ) -> (int, float     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetPositionUnit              (self, index     : int                                                            ) -> (int, str       ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetPositionUnit(self.Manager, index)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetPositionUnitCount         (self,                                                                            ) -> int:
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetPositionUnitCount(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetTargetPosition            (self,                                                                            ) -> (int, float     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetTargetPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def MaxDeviation                 (self,                                                                            ) -> (int, float     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.MaxDeviation(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def SetPosition                  (self, position  : float      , mode    : int                                     ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.SetPosition(self.Manager, position, mode)
                if RECODE_SUCCEED != isWarning:
                    result = self.Controller.GetPosition(self.Manager)
                    if isinstance(result, (float, int)) and Float(result) == float(position):
                        isWarning = RECODE_SUCCEED
                    else:
                        isWarning = self.Controller.ZDriverIsBusy(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def SetPositionTimeOut           (self, position  : float      , mode    : int         , timeout : int             ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.SetPosition(self.Manager, position, mode, timeout)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def StepWidth                    (self,                                                                            ) -> (int, float     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.StepWidth(self.Manager, position)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def TypicalDeviation             (self,                                                                            ) -> (int, float     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.TypicalDeviation(self.Manager, position)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def HasOnOff                     (self,                                                                            ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.HasOnOff(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def HasLoadWork                  (self,                                                                            ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.HasLoadWork(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def HasSWLimit                   (self,                                                                            ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.HasSWLimit(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def IsOnSWLimit                  (self,                                                                            ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.IsOnSWLimit(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def CoordinateDirection          (self,                                                                            ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.CoordinateDirection(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ClosedLoop                   (self,                                                                            ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ClosedLoop(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def HasHandwheelOnOff            (self,                                                                            ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.HasHandwheelOnOff(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def Calibrate                    (self, calMode   : int        , cmdMode : int                                     ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.Calibrate(self.Manager, calMode, cmdMode)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def CalibrateTimeOut             (self, calMode   : int        , cmdMode : int         , timeout : int             ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.Calibrate(self.Manager, calMode, cmdMode, timeout)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def EnableSWLimit                (self, upper     : bool       , enable  : bool                                    ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.EnableSWLimit(self.Manager, upper, enable)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def GetHandwheelOnOff            (self,                                                                            ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.GetHandwheelOnOff(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def GetMeasurementOrigin         (self,                                                                            ) -> (int, float     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetMeasurementOrigin(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetMeasurementPosition       (self,                                                                            ) -> (int, float     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetMeasurementPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def GetOnOff                     (self,                                                                            ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.GetOnOff(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def GetSWLimit                   (self, upper     : bool                                                           ) -> (int, float     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.GetSWLimit(self.Manager, upper)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def IsSWLimitEnabled             (self, upper     : bool                                                           ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.IsSWLimitEnabled(self.Manager, upper)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def SetHandwheelOnOff            (self, onOff     : bool                                                           ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.SetHandwheelOnOff(self.Manager, onOff)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def SetMeasurementOrigin         (self, origin    : float                                                          ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.SetMeasurementOrigin(self.Manager, origin)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def SetMeasurementPosition       (self, position  : float                                                          ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.SetMeasurementPosition(self.Manager, position)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def SetOnOff                     (self, onOff     : bool                                                           ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.SetOnOff(self.Manager, onOff)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def SetSWLimit                   (self, upper     : bool       , limit   : float                                   ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.SetSWLimit(self.Manager, upper, limit)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ObjectiveAbsPosition        (self                                                                                ) -> (int, int     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.ObjectiveAbsPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def ObjectiveMinPosition        (self                                                                                ) -> (int, int     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.ObjectiveMinPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def ObjectiveMaxPosition        (self                                                                                ) -> (int, int     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.ObjectiveMaxPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def ObjectiveWaitSetPosition    (self, position: int     , mode      : int       , timeout   : int                   ) -> (int, int     ):
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ObjectiveSetPosition(self.Manager, position, mode, timeout)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ObjectiveAbsSetPosition     (self, position: int     , mode      : int                                           ) -> (int, int     ):
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ObjectiveSetPosition(self.Manager, position, mode)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampType                    (self                                                                                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampType(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampIsActive                (self                                                                                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampIsActive(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampLightPathLocation       (self                                                                                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampLightPathLocation(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampHasRemote               (self                                                                                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampHasRemote(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampHasOnOff                (self                                                                                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampHasOnOff(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampHas3200K                (self                                                                                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampHas3200K(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampGet3200K                (self                                                                                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampGet3200K(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampGetOnOff                (self                                                                                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampGetOnOff(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampGetRemote               (self                                                                                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampGetRemote(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampSetRemote               (self, onOff   : bool                                                               ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampSetRemote(self.Manager, onOff)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampSet3200K                (self,onOff   : bool   , mode      : int                                           ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampSet3200K(self.Manager, onOff, mode)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning


    def LampSetOnOff                (self,onOff   : bool   , mode      : int                                           ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampSetOnOff(self.Manager, onOff, mode)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampWaitSet3200K            (self,onOff   : bool   , mode      : int       , timeout   : int                   ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampSet3200K(self.Manager, onOff, mode, timeout)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampWaitSetOnOff            (self,onOff   : bool   , mode      : int       , timeout   : int                   ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampSetOnOff(self.Manager, onOff, mode, timeout)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampIsOnHWLimit             (self                                                                               ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampIsOnHWLimit(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampGetMaxPosition          (self                                                                               ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.LampGetMaxPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def LampGetMinPosition          (self                                                                               ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.LampGetMinPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def LampGetPosition             (self                                                                               ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.LampGetPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def LampGetPositionUnitCount    (self                                                                               ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampGetPositionUnitCount(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampGetTargetPosition       (self                                                                               ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.LampGetTargetPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def LampMaxDeviation            (self                                                                               ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.LampMaxDeviation(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def LampStepWidth               (self                                                                               ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.LampStepWidth(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def LampTypicalDeviation        (self                                                                               ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.LampTypicalDeviation(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def LampGetPositionUnit         (self ,index   : int                                                                ) -> (int, str     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.LampGetPositionUnit(self.Manager, index)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def LampAbsSetPosition             (self ,position: float  , mode      : int                                           ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampSetPosition(self.Manager, position, mode)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampWaitSetPosition             (self ,position: float  , mode      : int       , timeout   : int                   ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampSetPosition(self.Manager, position, mode, timeout)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblGetMaxMoveSpeed         (self                                                                                ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.ApblGetMaxMoveSpeed(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def ApblGetMinMoveSpeed         (self                                                                                ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.ApblGetMinMoveSpeed(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def ApblGetSpeedUnitCount       (self                                                                                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblGetSpeedUnitCount(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblStop                    (self                                                                                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblStop(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblIsOnHWLimit             (self                                                                                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblIsOnHWLimit(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblGetMaxPosition          (self                                                                                ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.ApblGetMaxPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def ApblGetMinPosition          (self                                                                                ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.ApblGetMinPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def ApblGetPosition             (self                                                                                ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.ApblGetPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def ApblGetPositionUnitCount    (self                                                                                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblGetPositionUnitCount(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblGetTargetPosition       (self                                                                                ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.ApblGetTargetPosition(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def ApblMaxDeviation            (self                                                                                ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.ApblMaxDeviation(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def ApblStepWidth               (self                                                                                ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.ApblStepWidth(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def ApblTypicalDeviation        (self                                                            ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.ApblTypicalDeviation(self.Manager)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def ApblGetSpeedUnit            (self, index     : int                                           ) -> (int, str     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.ApblGetSpeedUnit(self.Manager, index)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def ApblGetPositionUnit         (self, index     : int                                           ) -> (int, str     ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.ApblGetPositionUnit(self.Manager, index)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def ApblMove                    (self, moveSpeed : float                                         ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblMove(self.Manager, moveSpeed)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblAlignPosition           (self, position  : float                                         ) -> (int, float   ):
        isWarning: int = RECODE_FAILURE
        result = None
        try:
            if self.hasManager:
                result = self.Controller.ApblAlignPosition(self.Manager, position)
                isWarning = RECODE_SUCCEED
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning, result

    def ApblWaitSetPosition             (self, position  : float     , mode      : int , timeout: int    ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblSetPosition(self.Manager, position, mode, timeout)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblAbsSetPosition             (self, position  : float     , mode      : int                   ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblSetPosition(self.Manager, position, mode)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning


    def ZDriverIsMonitoring            (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ZDriverIsMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ZDriverIsLocked                (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ZDriverIsLocked(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ZDriverIsBusy                  (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ZDriverIsBusy(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ZDriverHasMonitoring           (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ZDriverHasMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ZDriverIsLockedForClient       (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ZDriverIsLockedForClient(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ZDriverIsMonitoringForClient   (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ZDriverIsMonitoringForClient(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ZDriverLock                    (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ZDriverLock(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ZDriverStartMonitoring         (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ZDriverStartMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ZDriverStopMonitoring          (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ZDriverStopMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ZDriverUnlock                  (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ZDriverUnlock(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ObjectiveIsMonitoring          (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ObjectiveIsMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ObjectiveIsLocked              (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ObjectiveIsLocked(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ObjectiveIsBusy                (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ObjectiveIsBusy(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ObjectiveHasMonitoring         (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ObjectiveHasMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ObjectiveIsLockedForClient     (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ObjectiveIsLockedForClient(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ObjectiveIsMonitoringForClient (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ObjectiveIsMonitoringForClient(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ObjectiveLock                  (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ObjectiveLock(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ObjectiveStartMonitoring       (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ObjectiveStartMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ObjectiveStopMonitoring        (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ObjectiveStopMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ObjectiveUnlock                (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ObjectiveUnlock(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampIsMonitoring               (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampIsMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampIsLocked                   (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampIsLocked(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampIsBusy                     (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampIsBusy(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampHasMonitoring              (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampHasMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampIsLockedForClient          (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampIsLockedForClient(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampIsMonitoringForClient      (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampIsMonitoringForClient(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampLock                       (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampLock(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampStartMonitoring            (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampStartMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampStopMonitoring             (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampStopMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampUnlock                     (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampUnlock(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblIsMonitoring               (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblIsMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblIsLocked                   (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblIsLocked(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblIsBusy                     (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblIsBusy(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblHasMonitoring              (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblHasMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblIsLockedForClient          (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblIsLockedForClient(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblIsMonitoringForClient      (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblIsMonitoringForClient(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblLock                       (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblLock(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblStartMonitoring            (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblStartMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblStopMonitoring             (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblStopMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblUnlock                     (self                ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ZDriverIsMonitoring(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ZDriverWaitReady               (self, timeout: int  ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ZDriverWaitReady(self.Manager, timeout)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ObjectiveWaitReady             (self, timeout: int  ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ObjectiveWaitReady(self.Manager, timeout)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def LampWaitReady                  (self, timeout: int  ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.LampWaitReady(self.Manager, timeout)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def ApblWaitReady                  (self, timeout: int  ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.ApblWaitReady(self.Manager, timeout)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def SetLampILTLSwitch                  (self, enable: bool , mode: int                              ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.SetLampILTLSwitch(self.Manager, enable, int(mode))
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning

    def GetLampILTLSwitch                  (self                                                        ) -> int:
        isWarning: int = RECODE_FAILURE
        try:
            if self.hasManager:
                isWarning = self.Controller.GetLampILTLSwitch(self.Manager)
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWarning