#!D:/IDE/anaconda3/envs/Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName：HookContext.py
@Description：
@Author：XSH
@Time：2025/11/14 15:21
@Department：研发部
@Copyright：©2025 乐辰生物
"""
from PyQt5                              import Qt
from AppInterfaces.ModelInterface       import ContextModelInterface
from AppContexts.AxisRegisterContext    import AxisRegisterContext
from AppContexts.ModBusRegister         import ModBusRegister
from AppCore.Levels                     import *
from AppUtils.utils                     import *
from AppContexts.HookRegisterContext import HookRegisterContext
class HookContext(ContextModelInterface):
    Level                               : int                       #          '电机标志　　　　'
    HookClearZero                       : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=3    , Data = False        , Information='挂钩电机清零　　')#
    FrontLimit                          : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=14   , Data = False        , Information='挂钩前面限位　　')#
    BackLimit                           : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=15   , Data = False        , Information='挂钩后面限位　　')#
    PlaceRegister                       : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=16   , Data = False        , Information='托盘到位状态　　')#
    DetectorRegister                    : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=17   , Data = False        , Information='检测托盘状态　　')#
    LayerRegister                       : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=20   , Data = False        , Information='片仓一层状态　　')#
    PickTrayCompleteRegister            : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=44   , Data = False        , Information='取片完成状态　　')#
    DropTrayCompleteRegister            : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=45   , Data = False        , Information='放片完成状态　　')#
    DetectorTrayCompleteRegister        : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=46   , Data = False        , Information='检测托盘完成状态')#
    DetectorChamberCompleteRegister     : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=47   , Data = False        , Information='扫描片仓完成状态')#
    ScanCodePickTrayCompleteRegister    : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=48   , Data = False        , Information='扫码取片到位状态')#
    EmptyTrayReturnStatusRegister       : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=50   , Data = False        , Information='空挂退出完成状态')#
    ForceQuitRegister                   : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=59   , Data = False        , Information='设置强制退出功能')#
    PickTrayRegister                    : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=60   , Data = False        , Information='片仓取出托盘功能')#
    DropTrayRegister                    : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=61   , Data = False        , Information='托盘放回片仓功能')#
    DetectorTrayRegister                : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=62   , Data = False        , Information='检测指定托盘功能')#
    DetectorChamberRegister             : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=63   , Data = False        , Information='检测片仓托盘功能')#
    ScanCodePickRegister                : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=64   , Data = False        , Information='扫码托片功能　　')#
    EmptyTrayReturnRegister             : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=65   , Data = False        , Information='空挂返回功能　　')#
    ForwardRegister                     : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=72   , Data = False        , Information='挂钩电机前进功能')#
    BackwardRegister                    : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=73   , Data = False        , Information='挂钩电机后退功能')#
    ScanCodePlaceRegister               : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=80   , Data = False        , Information='到位扫码功能　　')#
    ScanCodeCompleteMoveRegister        : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=81   , Data = False        , Information='扫码完成前进功能')#
    HookResetRegister                   : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=423  , Data = False        , Information='挂钩电机复位功能')#
    AxisXMalfunction                    : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=401  , Data = False        , Information='当前Ｘ轴故障状态')#
    AxisYMalfunction                    : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=403  , Data = False        , Information='当前Ｙ轴故障状态')#
    AxisZMalfunction                    : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=405  , Data = False        , Information='当前Ｚ轴故障状态')#
    ForwardMalfunction                  : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=406  , Data = False        , Information='挂钩前进故障状态')#
    BackwardMalfunction                 : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=407  , Data = False        , Information='挂钩后退故障状态')#
    ChamberStatusRegister               : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=51   , Data = False        , Information='检测片仓返回状态')#
    CheckChamberRegister                : ModBusRegister            # Type=ModBusLevel.Bool   , Addr=67   , Data = False        , Information='检测片仓是否存在')#
    Position                            : ModBusRegister            # Type=ModBusLevel.Float  , Addr=100  , Data = float(  0.0) , Information='当前挂钩位置　　')#
    Velocity                            : ModBusRegister            # Type=ModBusLevel.Float  , Addr=102  , Data = float(  0.0) , Information='当前挂钩速度　　')#
    SetLayerHoverHeightRegister         : ModBusRegister            # Type=ModBusLevel.Float  , Addr=1200 , Data = float(  0.0) , Information='设置悬停高度功能')#
    SetLayerDragHoverHeightRegister     : ModBusRegister            # Type=ModBusLevel.Float  , Addr=1202 , Data = float(  0.0) , Information='设置拖拽高度功能')#
    SetLayerSpacingHeightRegister       : ModBusRegister            # Type=ModBusLevel.Float  , Addr=1204 , Data = float(  0.0) , Information='设置片仓间距功能')#
    SetAxisXPickPositionRegister        : ModBusRegister            # Type=ModBusLevel.Float  , Addr=1206 , Data = float(  0.0) , Information='设置Ｘ轴取片位置')#
    SetAxisYPickPositionRegister        : ModBusRegister            # Type=ModBusLevel.Float  , Addr=1208 , Data = float(  0.0) , Information='设置Ｙ轴取片位置')#
    SetScanCodePositionRegister         : ModBusRegister            # Type=ModBusLevel.Float  , Addr=1210 , Data = float(  0.0) , Information='设置扫码位置功能')#
    SetScanCodeSpacingRegister          : ModBusRegister            # Type=ModBusLevel.Float  , Addr=1212 , Data = float(  0.0) , Information='设置扫码间距功能')#
    SetAxisXDetectorPositionRegister    : ModBusRegister            # Type=ModBusLevel.Float  , Addr=1214 , Data = float(  0.0) , Information='设置Ｘ轴检测位置')#
    SetAxisYDetectorPositionRegister    : ModBusRegister            # Type=ModBusLevel.Float  , Addr=1216 , Data = float(  0.0) , Information='设置Ｙ轴检测位置')#
    SetLayerCountRegister               : ModBusRegister            # Type=ModBusLevel.UInt16 , Addr=1218 , Data = float(  0.0) , Information='设置片仓层数功能')#
    SetDetectorLayerPositionRegister    : ModBusRegister            # Type=ModBusLevel.Float  , Addr=1220 , Data = float(  0.0) , Information='检测片仓Ｚ轴位置')#
    SetAxisXCheckPositionRegister       : ModBusRegister            # Type=ModBusLevel.Float  , Addr=1222 , Data = float(  0.0) , Information='设置Ｘ轴取片位置')#
    SetAxisYCheckPositionRegister       : ModBusRegister            # Type=ModBusLevel.Float  , Addr=1224 , Data = float(  0.0) , Information='设置Ｙ轴取片位置')
    SetAxisZCheckHoverHeightRegister    : ModBusRegister            # Type=ModBusLevel.Float  , Addr=1226 , Data = float(  0.0) , Information='设置检测悬停高度')

    def __init__(self, **args):
        super(HookContext, self).__init__()
        self.initialization(self.__class__.__name__)
        self.initParameter(**args)

    def initValue(self):
        super(HookContext, self).initValue()
        self.initAxisH()

    def setLevel(self, level: int):
        from AppSettings.AppSetting import AppConfig, AppSetting
        self.Level = AxisLevel.AxisH
        self.asRegisterContext(AppConfig.Manipulator.AxisH.copy())

    def initParameter(self, **args):
        super(HookContext, self).initParameter(**args)
        for index, _property in enumerate(self.__slots__):
            dst_type = self.__types__[index]
            if dst_type == ModBusRegister:
                if isinstance(getattr(self, _property, None), ModBusRegister):
                    getattr(self, _property).deserialize(args.get(_property, {}))
            else:
                setattr(self, _property, AppConvert.ObjectConvert(args.get(_property, getattr(self, _property, None)), dst_type))

    def asRegisterContext(self, context: HookRegisterContext):
        if not isinstance(context, HookRegisterContext):
            return
        self.Level                                      = context.Level                                     #
        self.HookClearZero                        .Addr = context.HookClearZero                             #
        self.FrontLimit                           .Addr = context.FrontLimit                                #
        self.BackLimit                            .Addr = context.BackLimit                                 #
        self.PlaceRegister                        .Addr = context.PlaceRegister                             #
        self.DetectorRegister                     .Addr = context.DetectorRegister                          #
        self.LayerRegister                        .Addr = context.LayerRegister                             #
        self.PickTrayCompleteRegister             .Addr = context.PickTrayCompleteRegister                  #
        self.DropTrayCompleteRegister             .Addr = context.DropTrayCompleteRegister                  #
        self.DetectorTrayCompleteRegister         .Addr = context.DetectorTrayCompleteRegister              #
        self.DetectorChamberCompleteRegister      .Addr = context.DetectorChamberCompleteRegister           #
        self.ScanCodePickTrayCompleteRegister     .Addr = context.ScanCodePickTrayCompleteRegister          #
        self.EmptyTrayReturnStatusRegister        .Addr = context.EmptyTrayReturnStatusRegister             #
        self.ForceQuitRegister                    .Addr = context.ForceQuitRegister                         #
        self.PickTrayRegister                     .Addr = context.PickTrayRegister                          #
        self.DropTrayRegister                     .Addr = context.DropTrayRegister                          #
        self.DetectorTrayRegister                 .Addr = context.DetectorTrayRegister                      #
        self.DetectorChamberRegister              .Addr = context.DetectorChamberRegister                   #
        self.ScanCodePickRegister                 .Addr = context.ScanCodePickRegister                      #
        self.EmptyTrayReturnRegister              .Addr = context.EmptyTrayReturnRegister                   #
        self.ForwardRegister                      .Addr = context.ForwardRegister                           #
        self.BackwardRegister                     .Addr = context.BackwardRegister                          #
        self.ScanCodePlaceRegister                .Addr = context.ScanCodePlaceRegister                     #
        self.ScanCodeCompleteMoveRegister         .Addr = context.ScanCodeCompleteMoveRegister              #
        self.ForwardMalfunction                   .Addr = context.ForwardMalfunction                        #
        self.BackwardMalfunction                  .Addr = context.BackwardMalfunction                       #
        self.HookResetRegister                    .Addr = context.HookResetRegister                         #
        self.Position                             .Addr = context.Position                                  #
        self.Velocity                             .Addr = context.Velocity                                  #
        self.SetLayerHoverHeightRegister          .Addr = context.SetLayerHoverHeightRegister               #
        self.SetLayerDragHoverHeightRegister      .Addr = context.SetLayerDragHoverHeightRegister           #
        self.SetLayerSpacingHeightRegister        .Addr = context.SetLayerSpacingHeightRegister             #
        self.SetAxisXPickPositionRegister         .Addr = context.SetAxisXPickPositionRegister              #
        self.SetAxisYPickPositionRegister         .Addr = context.SetAxisYPickPositionRegister              #
        self.SetScanCodePositionRegister          .Addr = context.SetScanCodePositionRegister               #
        self.SetScanCodeSpacingRegister           .Addr = context.SetScanCodeSpacingRegister                #
        self.SetAxisXDetectorPositionRegister     .Addr = context.SetAxisXDetectorPositionRegister          #
        self.SetAxisYDetectorPositionRegister     .Addr = context.SetAxisYDetectorPositionRegister          #
        self.SetLayerCountRegister                .Addr = context.SetLayerCountRegister                     #
        self.SetDetectorLayerPositionRegister     .Addr = context.SetDetectorLayerPositionRegister          #
        self.ChamberStatusRegister                .Addr = context.ChamberStatusRegister                     #
        self.CheckChamberRegister                 .Addr = context.CheckChamberRegister                      #
        self.SetAxisXCheckPositionRegister        .Addr = context.SetAxisXCheckPositionRegister             #
        self.SetAxisYCheckPositionRegister        .Addr = context.SetAxisYCheckPositionRegister             #
        self.SetAxisZCheckHoverHeightRegister     .Addr = context.SetAxisZCheckHoverHeightRegister          #
        self.AxisXMalfunction                     .Addr = context.AxisXMalfunction                          #
        self.AxisYMalfunction                     .Addr = context.AxisYMalfunction                          #
        self.AxisZMalfunction                     .Addr = context.AxisZMalfunction                          #
        self.flushInfo()

    def toRegisterContext(self, context: HookRegisterContext):
        if not isinstance(context, HookRegisterContext):
            return
        self.flushInfo()
        context.Level                               = self.Level
        context.HookClearZero                       = self.HookClearZero                       .Addr
        context.FrontLimit                          = self.FrontLimit                          .Addr
        context.BackLimit                           = self.BackLimit                           .Addr
        context.PlaceRegister                       = self.PlaceRegister                       .Addr
        context.DetectorRegister                    = self.DetectorRegister                    .Addr
        context.LayerRegister                       = self.LayerRegister                       .Addr
        context.PickTrayCompleteRegister            = self.PickTrayCompleteRegister            .Addr
        context.DropTrayCompleteRegister            = self.DropTrayCompleteRegister            .Addr
        context.DetectorTrayCompleteRegister        = self.DetectorTrayCompleteRegister        .Addr
        context.DetectorChamberCompleteRegister     = self.DetectorChamberCompleteRegister     .Addr
        context.ScanCodePickTrayCompleteRegister    = self.ScanCodePickTrayCompleteRegister    .Addr
        context.EmptyTrayReturnStatusRegister       = self.EmptyTrayReturnStatusRegister                  .Addr
        context.ForceQuitRegister                   = self.ForceQuitRegister                   .Addr
        context.PickTrayRegister                    = self.PickTrayRegister                    .Addr
        context.DropTrayRegister                    = self.DropTrayRegister                    .Addr
        context.DetectorTrayRegister                = self.DetectorTrayRegister                .Addr
        context.DetectorChamberRegister             = self.DetectorChamberRegister             .Addr
        context.ScanCodePickRegister                = self.ScanCodePickRegister                .Addr
        context.EmptyTrayReturnRegister             = self.EmptyTrayReturnRegister             .Addr
        context.ForwardRegister                     = self.ForwardRegister                     .Addr
        context.BackwardRegister                    = self.BackwardRegister                    .Addr
        context.ScanCodePlaceRegister               = self.ScanCodePlaceRegister               .Addr
        context.ScanCodeCompleteMoveRegister        = self.ScanCodeCompleteMoveRegister        .Addr
        context.ForwardMalfunction                  = self.ForwardMalfunction                  .Addr
        context.BackwardMalfunction                 = self.BackwardMalfunction                 .Addr
        context.HookResetRegister                   = self.HookResetRegister                   .Addr
        context.Position                            = self.Position                            .Addr
        context.Velocity                            = self.Velocity                            .Addr
        context.SetLayerHoverHeightRegister         = self.SetLayerHoverHeightRegister         .Addr
        context.SetLayerDragHoverHeightRegister     = self.SetLayerDragHoverHeightRegister     .Addr
        context.SetLayerSpacingHeightRegister       = self.SetLayerSpacingHeightRegister       .Addr
        context.SetAxisXPickPositionRegister        = self.SetAxisXPickPositionRegister        .Addr
        context.SetAxisYPickPositionRegister        = self.SetAxisYPickPositionRegister        .Addr
        context.SetScanCodePositionRegister         = self.SetScanCodePositionRegister         .Addr
        context.SetScanCodeSpacingRegister          = self.SetScanCodeSpacingRegister          .Addr
        context.SetAxisXDetectorPositionRegister    = self.SetAxisXDetectorPositionRegister    .Addr
        context.SetAxisYDetectorPositionRegister    = self.SetAxisYDetectorPositionRegister    .Addr
        context.SetLayerCountRegister               = self.SetLayerCountRegister               .Addr
        context.SetDetectorLayerPositionRegister    = self.SetDetectorLayerPositionRegister    .Addr
        context.ChamberStatusRegister               = self.ChamberStatusRegister               .Addr
        context.CheckChamberRegister                = self.CheckChamberRegister                .Addr
        context.SetAxisXCheckPositionRegister       = self.SetAxisXCheckPositionRegister       .Addr
        context.SetAxisYCheckPositionRegister       = self.SetAxisYCheckPositionRegister       .Addr
        context.SetAxisZCheckHoverHeightRegister    = self.SetAxisZCheckHoverHeightRegister    .Addr
        context.AxisXMalfunction                    = self.AxisXMalfunction                      .Addr
        context.AxisYMalfunction                    = self.AxisYMalfunction                      .Addr
        context.AxisZMalfunction                    = self.AxisZMalfunction                      .Addr


    def initAxisH(self):
        self.Level                                      = AxisLevel.AxisH                                     #
        self.HookClearZero                         = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=3    , Data = False        , Information='挂钩电机清零　　')#
        self.FrontLimit                            = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=14   , Data = False        , Information='挂钩前面限位　　')#
        self.BackLimit                             = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=15   , Data = False        , Information='挂钩后面限位　　')#
        self.PlaceRegister                         = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=16   , Data = False        , Information='托盘到位状态　　')#
        self.DetectorRegister                      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=17   , Data = False        , Information='检测托盘状态　　')#
        self.LayerRegister                         = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=20   , Data = False        , Information='片仓一层状态　　')#
        self.PickTrayCompleteRegister              = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=44   , Data = False        , Information='取片完成状态　　')#
        self.DropTrayCompleteRegister              = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=45   , Data = False        , Information='放片完成状态　　')#
        self.DetectorTrayCompleteRegister          = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=46   , Data = False        , Information='检测托盘完成状态')#
        self.DetectorChamberCompleteRegister       = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=47   , Data = False        , Information='扫描片仓完成状态')#
        self.ScanCodePickTrayCompleteRegister      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=48   , Data = False        , Information='扫码取片到位状态')#
        self.EmptyTrayReturnStatusRegister         = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=50   , Data = False        , Information='空挂退出完成状态')#
        self.ForceQuitRegister                     = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=59   , Data = False        , Information='设置强制退出功能')#
        self.PickTrayRegister                      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=60   , Data = False        , Information='片仓取出托盘功能')#
        self.DropTrayRegister                      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=61   , Data = False        , Information='托盘放回片仓功能')#
        self.DetectorTrayRegister                  = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=62   , Data = False        , Information='检测指定托盘功能')#
        self.DetectorChamberRegister               = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=63   , Data = False        , Information='检测片仓托盘功能')#
        self.ScanCodePickRegister                  = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=64   , Data = False        , Information='扫码托片功能　　')#
        self.EmptyTrayReturnRegister               = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=65   , Data = False        , Information='空挂返回功能　　')#
        self.ForwardRegister                       = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=72   , Data = False        , Information='挂钩电机前进功能')#
        self.BackwardRegister                      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=73   , Data = False        , Information='挂钩电机后退功能')#
        self.ScanCodePlaceRegister                 = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=80   , Data = False        , Information='到位扫码功能　　')#
        self.ScanCodeCompleteMoveRegister          = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=81   , Data = False        , Information='扫码完成前进功能')#
        self.AxisXMalfunction                      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=401  , Data = False        , Information='当前Ｘ轴故障状态')#
        self.AxisYMalfunction                      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=403  , Data = False        , Information='当前Ｙ轴故障状态')#
        self.AxisZMalfunction                      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=405  , Data = False        , Information='当前Ｚ轴故障状态')#
        self.ForwardMalfunction                    = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=406  , Data = False        , Information='挂钩前进故障状态')#
        self.BackwardMalfunction                   = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=407  , Data = False        , Information='挂钩后退故障状态')#
        self.HookResetRegister                     = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=423  , Data = False        , Information='挂钩电机复位功能')#
        self.Position                              = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=100  , Data = float(  0.0) , Information='当前挂钩位置　　')#
        self.Velocity                              = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=102  , Data = float(  0.0) , Information='当前挂钩速度　　')#
        self.SetLayerHoverHeightRegister           = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1200 , Data = float(  0.0) , Information='设置悬停高度功能')#
        self.SetLayerDragHoverHeightRegister       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1202 , Data = float(  0.0) , Information='设置拖拽高度功能')#
        self.SetLayerSpacingHeightRegister         = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1204 , Data = float(  0.0) , Information='设置片仓间距功能')#
        self.SetAxisXPickPositionRegister          = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1206 , Data = float(  0.0) , Information='设置Ｘ轴取片位置')#
        self.SetAxisYPickPositionRegister          = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1208 , Data = float(  0.0) , Information='设置Ｙ轴取片位置')#
        self.SetScanCodePositionRegister           = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1210 , Data = float(  0.0) , Information='设置扫码位置功能')#
        self.SetScanCodeSpacingRegister            = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1212 , Data = float(  0.0) , Information='设置扫码间距功能')#
        self.SetAxisXDetectorPositionRegister      = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1214 , Data = float(  0.0) , Information='设置Ｘ轴检测位置')#
        self.SetAxisYDetectorPositionRegister      = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1216 , Data = float(  0.0) , Information='设置Ｙ轴检测位置')#
        self.SetLayerCountRegister                 = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=1218 , Data = float(  0.0) , Information='设置片仓层数功能')#
        self.SetDetectorLayerPositionRegister      = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1220 , Data = float(  0.0) , Information='检测片仓Ｚ轴位置')#
        self.ChamberStatusRegister                 = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=51   , Data = False        , Information='空挂返回功能　　')#
        self.CheckChamberRegister                  = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=67   , Data = False        , Information='空挂返回功能　　')#
        self.SetAxisXCheckPositionRegister         = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1222 , Data = float(  0.0) , Information='设置Ｘ轴取片位置')#
        self.SetAxisYCheckPositionRegister         = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1224 , Data = float(  0.0) , Information='设置Ｙ轴取片位置')#
        self.SetAxisZCheckHoverHeightRegister      = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1226 , Data = float(  0.0) , Information='设置检测悬停高度')#
        self.flushInfo()

    def flushInfo(self):
        if self.Level == AxisLevel.AxisX:
            self.Information = "Ｘ轴地址"
        elif self.Level == AxisLevel.AxisY:
            self.Information = "Ｙ轴地址"
        elif self.Level == AxisLevel.AxisH:
            self.Information = "快扫Ｈ轴地址"
        elif self.Level == AxisLevel.AxisZ:
            self.Information = "快扫Ｚ轴地址"
        elif self.Level == AxisLevel.ScanX:
            self.Information = "快扫Ｘ轴地址"
        elif self.Level == AxisLevel.ScanY:
            self.Information = "快扫Ｙ轴地址"
        elif self.Level == AxisLevel.SlowScanX:
            self.Information = "慢扫Ｘ轴地址"
        elif self.Level == AxisLevel.SlowScanY:
            self.Information = "慢扫Ｙ轴地址"
        elif self.Level == AxisLevel.DropOilX:
            self.Information = "滴油Ｘ轴地址"
        elif self.Level == AxisLevel.DropOilY:
            self.Information = "滴油Ｙ轴地址"
        elif self.Level == AxisLevel.AxisZ:
            self.Information = "片仓Ｚ轴地址"
        elif self.Level == AxisLevel.Detection:
            self.Information = "传感器地址"
        else:
            self.Information = "Ｘ轴地址"

    __slots__ = (
        'Level'                                  ,
        'HookClearZero'                          ,
        'FrontLimit'                             ,
        'BackLimit'                              ,
        'PlaceRegister'                          ,
        'DetectorRegister'                       ,
        'LayerRegister'                          ,
        'PickTrayCompleteRegister'               ,
        'DropTrayCompleteRegister'               ,
        'DetectorTrayCompleteRegister'           ,
        'DetectorChamberCompleteRegister'        ,
        'ScanCodePickTrayCompleteRegister'       ,
        'EmptyTrayReturnStatusRegister'                     ,
        'ForceQuitRegister'                      ,
        'PickTrayRegister'                       ,
        'DropTrayRegister'                       ,
        'DetectorTrayRegister'                   ,
        'DetectorChamberRegister'                ,
        'ScanCodePickRegister'                   ,
        'EmptyTrayReturnRegister'                ,
        'ForwardRegister'                        ,
        'BackwardRegister'                       ,
        'ScanCodePlaceRegister'                  ,
        'ScanCodeCompleteMoveRegister'           ,
        'AxisXMalfunction'                       ,
        'AxisYMalfunction'                       ,
        'AxisZMalfunction'                       ,
        'ForwardMalfunction'                     ,
        'BackwardMalfunction'                    ,
        'HookResetRegister'                      ,
        'Position'                               ,
        'Velocity'                               ,
        'SetLayerHoverHeightRegister'            ,
        'SetLayerDragHoverHeightRegister'        ,
        'SetLayerSpacingHeightRegister'          ,
        'SetAxisXPickPositionRegister'           ,
        'SetAxisYPickPositionRegister'           ,
        'SetScanCodePositionRegister'            ,
        'SetScanCodeSpacingRegister'             ,
        'SetAxisXDetectorPositionRegister'       ,
        'SetAxisYDetectorPositionRegister'       ,
        'SetLayerCountRegister'                  ,
        'SetDetectorLayerPositionRegister'       ,
        'ChamberStatusRegister'                  ,
        'CheckChamberRegister'                   ,
        'SetAxisXCheckPositionRegister'          ,
        'SetAxisYCheckPositionRegister'          ,
        'SetAxisZCheckHoverHeightRegister'       ,
    )
    __types__ = (
        int             ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
    )