#!D:/IDE/anaconda3/envs/Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName：MicroscopeReaderInterface.py
@Description：
@Author：XSH
@Time：2025/11/11 15:04
@Department：研发部
@Copyright：©2025 乐辰生物
"""
from PyQt5 import Qt
from abc import abstractmethod
from AppContexts.Contexts import SerialContext, MicroscopeContext
from AppInterfaces.AppImplInterfaces.MicroscopeInterface import MicroscopeInterface, MicroscopeInterfaceBase
from AppInterfaces.ReaderInterface import ReaderInterface
from AppSettings.Settings import *
from AppCore.Levels import *
class MicroscopeReaderInterface(ReaderInterface):
    Manager     : MicroscopeInterface   #
    Parameter   : MicroscopeContext     #

    @property
    def parameter(self) -> MicroscopeContext:
        return self.Parameter if self.hasParameter else None

    def setParameter(self, value):
        self.Parameter = value if isinstance(value, MicroscopeContext) else None

    @property
    def hasParameter(self) -> bool:
        return hasattr(self, 'Parameter') and self.Parameter is not None and isinstance(self.Parameter, MicroscopeContext)

    @property
    def hasManager(self) -> bool:
        return hasattr(self, 'Manager') and self.Manager is not None and isinstance(self.Manager, MicroscopeInterface)

    @property
    def manager(self) -> MicroscopeInterface:
        return None if not self.hasManager else self.Manager


    @property
    def isAvailable(self) -> bool:
        return self.hasManager and self.Manager.isAvailable
    
    @property
    def isValid(self) -> bool:
        return self.hasManager and self.manager.isValid
    
    @property
    def isSucceed(self) -> bool:
        return self.hasManager and self.manager.isSucceed

    @property
    def IsOpen(self) -> bool:
        return self.hasManager and self.manager.IsOpen

    @property
    def isEnabled(self) -> bool:
        return self.hasManager and self.manager.isEnabled

    @property
    def isDisable(self) -> bool:
        return self.hasManager and self.manager.isDisable


    @abstractmethod
    def Open(self, timeOut: int = 1000, **args) -> int:
        raise Exception('Interface Instance error')

    @abstractmethod
    def Close(self, timeOut: int = 1000, **args) -> int:
        raise Exception('Interface Instance error')

    @abstractmethod
    def initManager(self, **args):
        raise Exception('Interface Instance error')

    @abstractmethod
    def deleManager(self):
        raise Exception('Interface Instance error')

    @abstractmethod
    def initContext(self):
        raise Exception('Interface Instance error')


    def Transmit(self, **args) -> int:
        return RECODE_FAILURE


    def Received(self, **args) -> int:
        return RECODE_FAILURE


    def Send(self, **args) -> int:
        return RECODE_FAILURE


    def Read(self, **args) -> int:
        return RECODE_FAILURE


    def WaitDone(self, **args) -> int:
        return RECODE_FAILURE
    
    



    def initMicroscope(self):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.initMicroscope()
        return isWrong
            
    def initMicroscopeObjective(self):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.initMicroscopeObjective()
        return isWrong
    
    def home(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.home()
        return isWrong

    
    def waithome(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.waithome()
        return isWrong

    
    def move(self, value: (int, float), mode: int = 0, **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.move(value, mode, **args)
        return isWrong


    def stop_z(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.stop_move()
        return isWrong


    def stop_move(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.stop_move()
        return isWrong


    def rel_waitmove(self, value: (int, float), mode: int = 1, **args):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.rel_waitmove(value, mode, **args)
        return isWrong


    def rel_move(self, value: (int, float), mode: int = 0, **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.rel_move(value, mode, **args)
        return isWrong

    
    def waitmove(self, position: (int, float), mode: int = 1, **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.waitmove(position, mode, **args)
        return isWrong

    def waitmove_z(self, position: (int, float), mode: int = 1, **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.waitmove(position, mode, **args)
        return isWrong

    def is_moving(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.is_moving()
        return isWrong

    def get_z_status(self) -> (int, int, int, int, int, int):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_z_status()
        return isWrong, None, None, None, None, None

    def waitmove_complete(self, position: (int, float), **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.waitmove_complete(position, **args)
        return isWrong

    
    def waitmove_finish(self, position: (int, float), **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.waitmove_finish(position, **args)
        return isWrong

    
    def waitmove_lower_limit(self, **args):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.waitmove_lower_limit(**args)
        return isWrong

    
    def waitmove_upper_limit(self, **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.waitmove_upper_limit(**args)
        return isWrong

    
    def waitmove_h_lower_limit(self, **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.waitmove_h_lower_limit(**args)
        return isWrong

    
    def waitmove_h_upper_limit(self, **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.waitmove_h_upper_limit(**args)
        return isWrong

    
    def is_h_lower_limit(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.is_h_lower_limit()
        return isWrong

    
    def is_h_upper_limit(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.is_h_upper_limit()
        return isWrong

    
    def is_s_lower_limit(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.is_s_lower_limit()
        return isWrong

    
    def is_s_upper_limit(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.is_s_upper_limit()
        return isWrong

    
    def getPosition(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.getPosition()
        return isWrong

    def get_position_z(self) -> (int, float):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_position()
        return isWrong, 0.0
    
    def setFastSpeedMode(self):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.setFastSpeedMode()
        return isWrong

    
    def setNormalSpeedMode(self):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.setNormalSpeedMode()
        return isWrong

    
    def changedObjective(self, level: int, is_lower_limit: bool = False, **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.changedObjective(level, is_lower_limit, **args)
        return isWrong

    
    def set_objective(self, level: int, is_lower_limit: bool = False, **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_objective(level, is_lower_limit, **args)
        return isWrong

    def set_objective_dip(self):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_objective_dip()
        return isWrong

    def changedLightIntensity(self, level: int, **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.changedLightIntensity(level, **args)
        return isWrong

    
    def set_z_upper_limit(self, limit=-1) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_z_upper_limit(limit)
        return isWrong

    
    def set_z_lower_limit(self, limit=-1) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_z_lower_limit(limit)
        return isWrong

    
    def set_z_upper_enable(self, enable: (int, bool), **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_z_upper_enable(enable, **args)
        return isWrong

    
    def set_z_lower_enable(self, enable: (int, bool), **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_z_lower_enable(enable, **args)
        return isWrong


    def init_objective_range(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.init_objective_range()
        return isWrong

    def init_z_range(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.init_z_range()
        return isWrong

    def wait_init_z_range(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.wait_init_z_range()
        return isWrong

    def init_z_speed(self, level: int) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.init_z_speed(level)
        return isWrong

    def set_z_range(self, min_limit: int = -1, max_limit: int = -1) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_z_range(min_limit, max_limit)
        return isWrong

    
    def get_z_upper_limit(self) -> (int, float):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_z_upper_limit()
        return isWrong, None

    
    def get_z_lower_limit(self) -> (int, float):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_z_lower_limit()
        return isWrong, None

    
    def get_z_range(self) -> (int, float, float):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_z_range()
        return isWrong, None, None

    
    def get_z_limit(self) -> (int, float, float):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_z_limit()
        return isWrong, None, None

    
    def set_z_speed(self, speed: (float, int)):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_z_speed(speed)
        return isWrong

    
    def set_z_acceleration(self, acceleration: (float, int)):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_z_acceleration(acceleration)
        return isWrong

    
    def get_z_enabled(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_z_enabled()
        return isWrong

    
    def set_z_enabled(self, enable: (int, bool)) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_z_enabled(enable)
        return isWrong

    
    def setMeasurementOrigin(self, value: (int, float), **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.setMeasurementOrigin(value, **args)
        return isWrong

    
    def getMeasurementOrigin(self, **args) -> (int, float):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.getMeasurementOrigin(**args)
        return isWrong, None

    
    def setMeasurementPosition(self, value: (int, float), **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.setMeasurementPosition(value, **args)
        return isWrong

    
    def getMeasurementPosition(self, **args) -> (int, float):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.getMeasurementPosition(**args)
        return isWrong

    
    def set_z_move_mode(self, enable: (int, bool)):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_z_move_mode(enable)
        return isWrong

    
    def set_objective_upper_limit(self, level) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_objective_upper_limit(level)
        return isWrong

    
    def set_objective_limit(self, level) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_objective_limit(level)
        return isWrong

    
    def set_objective_lower_limit(self, level) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_objective_lower_limit(level)
        return isWrong

    
    def set_objective_focus_speed(self, level) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_objective_focus_speed(level)
        return isWrong

    
    def set_objective_default_speed(self, level) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_objective_default_speed(level)
        return isWrong

    
    def set_objective_scan_speed(self, level) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_objective_scan_speed(level)
        return isWrong

    
    def set_upper_limit(self, position: (int, float)) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_upper_limit(position)
        return isWrong

    
    def set_lower_limit(self, position: (int, float)) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_lower_limit(position)
        return isWrong

    
    def get_position(self) -> (int, int):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_position()
        return isWrong, None

    def get_objective(self) -> (int, int):
        isWrong: int = RECODE_FAILURE
        objective: int = 1
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            isWrong, objective =  self.manager.get_objective()
        return isWrong, objective
    
    def get_z_measurement_origin(self) -> (int, float):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_z_measurement_origin()
        return isWrong, None

    
    def get_z_measurement_position(self) -> (int, float):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_z_measurement_position()
        return isWrong, None

    
    def set_z_measurement_origin(self, position: (int, float), **args) -> (int, float):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_z_measurement_origin(position, **args)
        return isWrong, None

    
    def set_z_measurement_position(self, position: (int, float), **args) -> (int, float):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_z_measurement_position(position, **args)
        return isWrong, None

    
    def set_z_align_position(self, position: (int, float), **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_z_align_position(position, **args)
        return isWrong

    
    def getObjective(self) -> int:
        objective: int = ObjectiveLevel.Objective1
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            objective = self.manager.getObjective()
        return objective

    
    def currentObjective(self) -> (int, int):
        isWrong: int = RECODE_FAILURE
        objective: int = ObjectiveLevel.Objective1
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            isWrong, objective = self.manager.currentObjective()
        return isWrong, objective

    
    def changed_spot_light(self, enable: (bool, int)) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.changed_spot_light(enable)
        return isWrong

    
    def get_spot_light(self) -> (int, int):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_spot_light()
        return isWrong, None

    
    def POS_CONST_Z(self, SPEED: int, target: int = None, **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.POS_CONST_Z(SPEED, target, **args)
        return isWrong

    
    def getHandwheelOnOff(self) -> int:
        """获取手轮控制状态"""
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.getHandwheelOnOff()
        return isWrong

    
    def setHandwheelOnOff(self, enable: (bool, int)) -> int:
        """设置手轮控制状态"""
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.setHandwheelOnOff(enable)
        return isWrong

    
    def set_z_calibrate(self, level: int = None) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_z_calibrate(level)
        return isWrong

    
    def set_z_calibrate_low_limit(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_z_calibrate_low_limit()
        return isWrong

    
    def set_z_calibrate_position(self) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_z_calibrate_position()
        return isWrong

    
    def set_align_position(self, target: (int, float)) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_align_position(target)
        return isWrong

    
    def getLAMPOnOFF(self) -> (int, int):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.getLAMPOnOFF()
        return isWrong, None

    
    def getAPBL(self) -> (int, float):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.getAPBL()
        return isWrong, None

    
    def getLFBL(self) -> (int, float):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.getLFBL()
        return isWrong, None

    
    def changedLAMP(self, value: int, **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.changedLAMP(value, **args)
        return isWrong

    
    def changedLFBL(self, value: int, **args):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.changedLFBL(value, **args)
        return isWrong

    
    def changedAPBL(self, value: int, **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.changedAPBL(value, **args)
        return isWrong

    
    def set_apbl(self, value: (int, float), **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_apbl(value, **args)
        return isWrong

    
    def set_lfbl(self, value: (int, float), **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_lfbl(value, **args)
        return isWrong

    
    def set_lamp(self, value: (int, float), **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_lamp(value, **args)
        return isWrong

    
    def set_lamp_enable(self, enable: (bool, int), **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_lamp_enable(enable, **args)
        return isWrong

    
    def get_lamp_enable(self, **args) -> int:
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_lamp_enable(**args)
        return isWrong

    
    def get_apbl(self, **args) -> (int, int):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_apbl(**args)
        return isWrong, None

    
    def get_lfbl(self, **args) -> (int, int):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_lfbl(**args)
        return isWrong, None

    
    def get_lamp(self, **args) -> (int, int):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_lamp(**args)
        return isWrong, None

    
    def set_tl_rl_switch(self, enable: (int, bool), **args):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.set_tl_rl_switch(enable, **args)
        return isWrong

    
    def get_tl_rl_switch(self) -> (int, int):
        isWrong: int = RECODE_FAILURE
        if not self.isAvailable:
            self.manager.ReOpen()
        if self.isAvailable:
            return self.manager.get_tl_rl_switch()
        return isWrong, None
