#!D:\IDE\Anaconda3\envs\Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
 @Author: Administrator
 @FileName: AxisContext.py
 @DateTime: 2025/4/8 20:27
 @SoftWare: PyCharm
 @Author  ：xsh
"""
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 AppCore.Requests                   import *

class AxisContext(ContextModelInterface):
    __slots__ = (
        'Level'                 ,
        'MovePosition'          ,
        'MoveVelocity'          ,
        'Acceleration'          ,
        'Deceleration'          ,
        'JOPVelocity'           ,
        'JOPAcceleration'       ,
        'JOPDeceleration'       ,
        'CurrentPosition'       ,
        'StatusRegister'        ,
        'ReadOnlyRegister'      ,
        'PowerRegister'         ,
        'MalfunctionRegister'   ,
    )
    __types__ = (
        int             ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
        ModBusRegister  ,
    )

    Level              : int
    MovePosition       : ModBusRegister
    MoveVelocity       : ModBusRegister
    Acceleration       : ModBusRegister
    Deceleration       : ModBusRegister
    JOPVelocity        : ModBusRegister
    JOPAcceleration    : ModBusRegister
    JOPDeceleration    : ModBusRegister
    CurrentPosition    : ModBusRegister
    StatusRegister     : ModBusRegister
    ReadOnlyRegister   : ModBusRegister
    PowerRegister      : ModBusRegister
    MalfunctionRegister: ModBusRegister
    def __init__(self, **args):
        super(AxisContext, self).__init__()
        self.initialization(self.__class__.__name__)
        self.initParameter(**args)


    @classmethod
    def instance(cls, level: int = 0) -> 'AxisContext':
        result: cls = cls.__new__(cls)
        result.__init__()
        result.setLevel(level)
        return result

    def setMoveProperty(self, position: float, velocity: float, acceleration: float, deceleration: float):
        self.MovePosition.Data       = position
        self.MoveVelocity.Data       = velocity
        self.Acceleration.Data       = acceleration
        self.Deceleration.Data       = deceleration

    def setPosition(self, position: float):
        self.MovePosition.Data = position

    def initValue(self):
        super(AxisContext, self).initValue()
        self.initAxisX()

    def setLevel(self, level: int):
        from AppSettings.AppSetting import AppConfig, AppSetting
        self.Level = level
        try:
            if self.Level == AxisLevel.AxisX:
                self.asRegisterContext(AppConfig.Manipulator.AxisX.copy())
            elif self.Level == AxisLevel.AxisY:
                self.asRegisterContext(AppConfig.Manipulator.AxisY.copy())
            elif self.Level == AxisLevel.ScanX:
                self.asRegisterContext(AppConfig.Manipulator.ScanX.copy())
            elif self.Level == AxisLevel.ScanY:
                self.asRegisterContext(AppConfig.Manipulator.ScanY.copy())
            elif self.Level == AxisLevel.SlowScanX:
                self.asRegisterContext(AppConfig.Manipulator.SlowX.copy())
            elif self.Level == AxisLevel.SlowScanY:
                self.asRegisterContext(AppConfig.Manipulator.SlowY.copy())
            elif self.Level == AxisLevel.DropOilX:
                self.asRegisterContext(AppConfig.Manipulator.DropX.copy())
            elif self.Level == AxisLevel.DropOilY:
                self.asRegisterContext(AppConfig.Manipulator.DropY.copy())
            elif self.Level == AxisLevel.AxisZ:
                self.asRegisterContext(AppConfig.Manipulator.AxisZ.copy())
            else:
                self.asRegisterContext(AppConfig.Manipulator.AxisX.copy())
        except Exception as e:
            pass

        self.Level = level
        self.flushInfo()

    def initParameter(self, **args):
        super(AxisContext, self).initParameter(**args)
        for index, _property in enumerate(self.__slots__):
            dst_type = self.__types__[index]
            if dst_type == 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: AxisRegisterContext):
        if not isinstance(context, AxisRegisterContext):
            return
        self.Level              = context.Level
        self.MovePosition       .Addr   = context.MovePosition            #
        self.MoveVelocity       .Addr   = context.MoveVelocity            #
        self.Acceleration       .Addr   = context.Acceleration            #
        self.Deceleration       .Addr   = context.Deceleration            #
        self.JOPVelocity        .Addr   = context.JOPVelocity             #
        self.JOPAcceleration    .Addr   = context.JOPAcceleration         #
        self.JOPDeceleration    .Addr   = context.JOPDeceleration         #
        self.CurrentPosition    .Addr   = context.CurrentPosition         #
        self.StatusRegister     .Addr   = context.StatusRegister          #
        self.ReadOnlyRegister   .Addr   = context.ReadOnlyRegister        #
        self.PowerRegister      .Addr   = context.PowerRegister           #
        self.MalfunctionRegister.Addr   = context.MalfunctionRegister     #

    def toRegisterContext(self, context: AxisRegisterContext):
        if not isinstance(context, AxisRegisterContext):
            return
        context.Level                   = self.Level                    #
        context.MovePosition            = self.MovePosition       .Addr #
        context.MoveVelocity            = self.MoveVelocity       .Addr #
        context.Acceleration            = self.Acceleration       .Addr #
        context.Deceleration            = self.Deceleration       .Addr #
        context.JOPVelocity             = self.JOPVelocity        .Addr #
        context.JOPAcceleration         = self.JOPAcceleration    .Addr #
        context.JOPDeceleration         = self.JOPDeceleration    .Addr #
        context.CurrentPosition         = self.CurrentPosition    .Addr #
        context.StatusRegister          = self.StatusRegister     .Addr #
        context.ReadOnlyRegister        = self.ReadOnlyRegister   .Addr #
        context.PowerRegister           = self.PowerRegister      .Addr #
        context.MalfunctionRegister     = self.MalfunctionRegister.Addr #

    def toRequest(self, request: ModBusRequest):
        if not isinstance(request, ModBusRequest):
            return
        request.Type    = self.MovePosition.Type
        request.Addr    = self.MovePosition.Addr
        request.Data    = self.MovePosition.Data
        request.Buffer  = [self.MovePosition.Data, self.MoveVelocity.Data,
                           self.Acceleration.Data, self.Deceleration.Data]

    def toJopRequest(self, request: ModBusRequest):
        if not isinstance(request, ModBusRequest):
            return

        request.Type    = self.JOPVelocity.Type
        request.Addr    = self.JOPVelocity.Addr
        request.Data    = self.JOPVelocity.Data
        request.Buffer  = [self.JOPVelocity.Data, self.JOPAcceleration.Data,
                           self.JOPDeceleration.Data]


    def asRequest(self, request: ModBusRequest):
        if not isinstance(request, ModBusRequest):
            return
        if request.Addr == self.MovePosition       .Addr:
            if not isinstance(request.Buffer, list):
                return
            if len(request.Buffer) >= 4:
                self.MovePosition.Data = request.Buffer[0]
                self.MoveVelocity.Data = request.Buffer[1]
                self.Acceleration.Data = request.Buffer[2]
                self.Deceleration.Data = request.Buffer[3]
        elif request.Addr == self.JOPVelocity        .Addr:
            if not isinstance(request.Buffer, list):
                return
            if len(request.Buffer) >= 3:
                self.JOPVelocity    .Data = request.Buffer[0]
                self.JOPAcceleration.Data = request.Buffer[1]
                self.JOPDeceleration.Data = request.Buffer[2]
            pass
        elif request.Addr == self.CurrentPosition    .Addr:
            self.CurrentPosition.Data = request.Data
            pass
        elif request.Addr == self.StatusRegister     .Addr:
            self.StatusRegister.Data = request.Data
        elif request.Addr == self.ReadOnlyRegister   .Addr:
            self.ReadOnlyRegister.Data = request.Data
        elif request.Addr == self.PowerRegister      .Addr:
            self.PowerRegister.Data = request.Data

    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 = "Ｘ轴地址"

    def initAxisX(self):
        self.Level              = AxisLevel.AxisX
        self.MovePosition       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1000, Data = float(  0.0) , Information="移动位置　　　")
        self.MoveVelocity       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1002, Data = float( 30.0) , Information="移动速度　　　")
        self.Acceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1004, Data = float(100.0) , Information="移动加速度　　")
        self.Deceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1006, Data = float(100.0) , Information="移动减速度　　")
        self.JOPVelocity        = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1008, Data = float( 10.0) , Information="点动速度　　　")
        self.JOPAcceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1010, Data = float(100.0) , Information="点动加速度　　")
        self.JOPDeceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1012, Data = float(100.0) , Information="点动减速度　　")
        self.CurrentPosition    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1014, Data = float(  0.0) , Information="当前位置　　　")
        self.StatusRegister     = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=0   , Data = 0            , Information="读写状态寄存器")
        self.ReadOnlyRegister   = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=20  , Data = 0            , Information="只读状态寄存器")
        self.PowerRegister      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=0   , Data = False        , Information="使能状态寄存器")
        self.MalfunctionRegister= ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=401 , Data = False        , Information="使能状态寄存器")

    def initAxisY(self):
        self.Level              = AxisLevel.AxisY
        self.MovePosition       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1020, Data = float(  0.0) , Information="移动位置　　　")
        self.MoveVelocity       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1022, Data = float(30.0 ) , Information="移动速度　　　")
        self.Acceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1024, Data = float(100.0) , Information="移动加速度　　")
        self.Deceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1026, Data = float(100.0) , Information="移动减速度　　")
        self.JOPVelocity        = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1028, Data = float( 10.0) , Information="点动速度　　　")
        self.JOPAcceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1030, Data = float(100.0) , Information="点动加速度　　")
        self.JOPDeceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1032, Data = float(100.0) , Information="点动减速度　　")
        self.CurrentPosition    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1034, Data = float(  0.0) , Information="当前位置　　　")
        self.StatusRegister     = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=1   , Data = 0            , Information="读写状态寄存器")
        self.ReadOnlyRegister   = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=21  , Data = 0            , Information="只读状态寄存器")
        self.PowerRegister      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=1   , Data = False        , Information="使能状态寄存器")
        self.MalfunctionRegister= ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=403 , Data = False        , Information="使能状态寄存器")



    def initScanAxisX(self):
        self.Level              = AxisLevel.ScanX
        self.MovePosition       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1000, Data = float(  0.0 ) , Information="移动位置　　　")
        self.MoveVelocity       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1002, Data = float(1000.0) , Information="移动速度　　　")
        self.Acceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1004, Data = float(2000.0) , Information="移动加速度　　")
        self.Deceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1006, Data = float(2000.0) , Information="移动减速度　　")
        self.JOPVelocity        = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1008, Data = float(1000.0) , Information="点动速度　　　")
        self.JOPAcceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1010, Data = float(2000.0) , Information="点动加速度　　")
        self.JOPDeceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1012, Data = float(2000.0) , Information="点动减速度　　")
        self.CurrentPosition    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1014, Data = float(  0.0  ), Information="当前位置　　　")
        self.StatusRegister     = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=0   , Data = 0             , Information="读写状态寄存器")
        self.ReadOnlyRegister   = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=20  , Data = 0             , Information="只读状态寄存器")
        self.PowerRegister      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=0   , Data = False         , Information="使能状态寄存器")
        self.MalfunctionRegister= ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=401 , Data = False        , Information="使能状态寄存器")

    def initScanAxisY(self):
        self.Level              = AxisLevel.ScanY
        self.MovePosition       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1020, Data = float(  0.0 ) , Information="移动位置　　　")
        self.MoveVelocity       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1022, Data = float(1000.0) , Information="移动速度　　　")
        self.Acceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1024, Data = float(2000.0) , Information="移动加速度　　")
        self.Deceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1026, Data = float(2000.0) , Information="移动减速度　　")
        self.JOPVelocity        = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1028, Data = float(1000.0) , Information="点动速度　　　")
        self.JOPAcceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1030, Data = float(2000.0) , Information="点动加速度　　")
        self.JOPDeceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1032, Data = float(2000.0) , Information="点动减速度　　")
        self.CurrentPosition    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1034, Data = float(  0.0  ), Information="当前位置　　　")
        self.StatusRegister     = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=1   , Data = 0             , Information="读写状态寄存器")
        self.ReadOnlyRegister   = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=21  , Data = 0             , Information="只读状态寄存器")
        self.PowerRegister      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=1   , Data = False         , Information="使能状态寄存器")
        self.MalfunctionRegister= ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=403 , Data = False        , Information="使能状态寄存器")

    def initSlowScanAxisX(self):
        self.Level              = AxisLevel.SlowScanX
        self.MovePosition       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1000, Data = float(  0.0 ) , Information="移动位置　　　")
        self.MoveVelocity       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1002, Data = float(100.0 ) , Information="移动速度　　　")
        self.Acceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1004, Data = float(2000.0) , Information="移动加速度　　")
        self.Deceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1006, Data = float(2000.0) , Information="移动减速度　　")
        self.JOPVelocity        = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1008, Data = float(1000.0) , Information="点动速度　　　")
        self.JOPAcceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1010, Data = float(2000.0) , Information="点动加速度　　")
        self.JOPDeceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1012, Data = float(2000.0) , Information="点动减速度　　")
        self.CurrentPosition    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1014, Data = float(  0.0  ), Information="当前位置　　　")
        self.StatusRegister     = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=0   , Data = 0             , Information="读写状态寄存器")
        self.ReadOnlyRegister   = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=20  , Data = 0             , Information="只读状态寄存器")
        self.PowerRegister      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=0   , Data = False         , Information="使能状态寄存器")
        self.MalfunctionRegister= ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=401 , Data = False        , Information="使能状态寄存器")

    def initSlowScanAxisY(self):
        self.Level              = AxisLevel.SlowScanY
        self.MovePosition       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1020, Data = float(  0.0 ) , Information="移动位置　　　")
        self.MoveVelocity       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1022, Data = float(100.0 ) , Information="移动速度　　　")
        self.Acceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1024, Data = float(2000.0) , Information="移动加速度　　")
        self.Deceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1026, Data = float(2000.0) , Information="移动减速度　　")
        self.JOPVelocity        = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1028, Data = float(1000.0) , Information="点动速度　　　")
        self.JOPAcceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1030, Data = float(2000.0) , Information="点动加速度　　")
        self.JOPDeceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1032, Data = float(2000.0) , Information="点动减速度　　")
        self.CurrentPosition    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1034, Data = float(  0.0  ), Information="当前位置　　　")
        self.StatusRegister     = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=1   , Data = 0             , Information="读写状态寄存器")
        self.ReadOnlyRegister   = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=21  , Data = 0             , Information="只读状态寄存器")
        self.PowerRegister      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=1   , Data = False         , Information="使能状态寄存器")
        self.MalfunctionRegister= ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=403 , Data = False        , Information="使能状态寄存器")

    def initDropOilAxisX(self):
        self.Level              = AxisLevel.DropOilX
        self.MovePosition       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1000, Data = float(  0.0 ) , Information="移动位置　　　")
        self.MoveVelocity       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1002, Data = float(100.0 ) , Information="移动速度　　　")
        self.Acceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1004, Data = float(2000.0) , Information="移动加速度　　")
        self.Deceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1006, Data = float(2000.0) , Information="移动减速度　　")
        self.JOPVelocity        = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1008, Data = float(1000.0) , Information="点动速度　　　")
        self.JOPAcceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1010, Data = float(2000.0) , Information="点动加速度　　")
        self.JOPDeceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1012, Data = float(2000.0) , Information="点动减速度　　")
        self.CurrentPosition    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1014, Data = float(  0.0  ), Information="当前位置　　　")
        self.StatusRegister     = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=0   , Data = 0             , Information="读写状态寄存器")
        self.ReadOnlyRegister   = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=20  , Data = 0             , Information="只读状态寄存器")
        self.PowerRegister      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=0   , Data = False         , Information="使能状态寄存器")
        self.MalfunctionRegister= ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=401 , Data = False        , Information="使能状态寄存器")
    def initDropOilAxisY(self):
        self.Level              = AxisLevel.DropOilY
        self.MovePosition       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1020, Data = float(  0.0 ) , Information="移动位置　　　")
        self.MoveVelocity       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1022, Data = float(100.0 ) , Information="移动速度　　　")
        self.Acceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1024, Data = float(2000.0) , Information="移动加速度　　")
        self.Deceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1026, Data = float(2000.0) , Information="移动减速度　　")
        self.JOPVelocity        = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1028, Data = float(1000.0) , Information="点动速度　　　")
        self.JOPAcceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1030, Data = float(2000.0) , Information="点动加速度　　")
        self.JOPDeceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1032, Data = float(2000.0) , Information="点动减速度　　")
        self.CurrentPosition    = ModBusRegister.instance(Type=ModBusLevel.Float  , Addr=1034, Data = float(  0.0  ), Information="当前位置　　　")
        self.StatusRegister     = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=1   , Data = 0             , Information="读写状态寄存器")
        self.ReadOnlyRegister   = ModBusRegister.instance(Type=ModBusLevel.UInt16 , Addr=21  , Data = 0             , Information="只读状态寄存器")
        self.PowerRegister      = ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=1   , Data = False         , Information="使能状态寄存器")
        self.MalfunctionRegister= ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=403 , Data = False        , Information="使能状态寄存器")


    def initAxisZ(self):
        self.Level              = AxisLevel.AxisZ
        self.MovePosition       = ModBusRegister.instance(Type=ModBusLevel.Float  , AAddr=1040, Data = float(  0.0) , Information="移动位置　　　")
        self.MoveVelocity       = ModBusRegister.instance(Type=ModBusLevel.Float  , AAddr=1042, Data = float( 20.0) , Information="移动速度　　　")
        self.Acceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , AAddr=1044, Data = float(500.0) , Information="移动加速度　　")
        self.Deceleration       = ModBusRegister.instance(Type=ModBusLevel.Float  , AAddr=1046, Data = float(500.0) , Information="移动减速度　　")
        self.JOPVelocity        = ModBusRegister.instance(Type=ModBusLevel.Float  , AAddr=1048, Data = float(500.0) , Information="点动速度　　　")
        self.JOPAcceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , AAddr=1050, Data = float(500.0) , Information="点动加速度　　")
        self.JOPDeceleration    = ModBusRegister.instance(Type=ModBusLevel.Float  , AAddr=1052, Data = float(500.0) , Information="点动减速度　　")
        self.CurrentPosition    = ModBusRegister.instance(Type=ModBusLevel.Float  , AAddr=1054, Data = float(0.0  ) , Information="当前位置　　　")
        self.StatusRegister     = ModBusRegister.instance(Type=ModBusLevel.UInt16 , AAddr=2   , Data = 0            , Information="读写状态寄存器")
        self.ReadOnlyRegister   = ModBusRegister.instance(Type=ModBusLevel.UInt16 , AAddr=22  , Data = 0            , Information="只读状态寄存器")
        self.PowerRegister      = ModBusRegister.instance(Type=ModBusLevel.Bool   , AAddr=2   , Data = False        , Information="使能状态寄存器")
        self.MalfunctionRegister= ModBusRegister.instance(Type=ModBusLevel.Bool   , Addr=405 , Data = False        , Information="使能状态寄存器")

















