#!D:\IDE\Anaconda3\envs\Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName   : SystemConfigModel.py
@Account    : Administrator
@Time       : 2025/8/14 10:23
@Author     : xsh
@Description:
"""
from PyQt5 import Qt
from datetime import datetime, date
import copy
from AppCore.AppDBModels.CoreModel import (CoreModel, DBManager, dbController)
from sqlalchemy.orm import declarative_base, mapper, sessionmaker, Session
from sqlalchemy.orm import (declarative_base, Mapped, mapped_column, relationship, mapper, sessionmaker)
from sqlalchemy import Table, Engine, create_engine, Column, ForeignKey, and_, or_, insert, delete, update, select, func, ColumnElement,distinct
from sqlalchemy.types import (Text, VARCHAR, REAL, Float, Integer, String, SmallInteger, DateTime, Date, ARRAY,Boolean, JSON, LargeBinary)
from sqlalchemy.orm.decl_api import DeclarativeBase, MetaData
from AppUtils.utils import *
from AppCore.Levels import *
from AppCore.Requests import SerialRequest
from AppCore.AppDBModels.CameraModels.CameraInterface import CameraInterface
class SystemConfigModel(CoreModel):
    __tablename__ = 't_SystemConfigModel'
    ID                                  : Mapped[int    ] = mapped_column(primary_key=True                              , nullable=False, doc='系统数据序号　', comment='系统数据序号　')
    ReceivedTails                       : Mapped[bytes  ] = mapped_column(LargeBinary, default=b"\r\n"                  , nullable=True , doc='扫码结束标志　', comment='扫码结束标志　')
    ReceivedWaits                       : Mapped[int    ] = mapped_column(default=500                                   , nullable=True , doc='接收扫码时长　', comment='接收扫码时长　')
    MaxWaitTimes                        : Mapped[int    ] = mapped_column(default=1000                                  , nullable=True , doc='扫码等待时长　', comment='扫码等待时长　')
    MinChamberNumber                    : Mapped[int    ] = mapped_column(default=1                                     , nullable=True , doc='片仓最小组数　', comment='片仓最小组数　')
    MaxChamberNumber                    : Mapped[int    ] = mapped_column(default=24                                    , nullable=True , doc='片仓最大组数　', comment='片仓最大组数　')
    MinRowNumber                        : Mapped[int    ] = mapped_column(default=1                                     , nullable=True , doc='片仓最小行数　', comment='片仓最小行数　')
    MaxRowNumber                        : Mapped[int    ] = mapped_column(default=5                                     , nullable=True , doc='片仓最大行数　', comment='片仓最大行数　')
    MinTrayRowNumber                    : Mapped[int    ] = mapped_column(default=1                                     , nullable=True , doc='载玻台最小行数', comment='载玻台最小行数')
    MinTrayColNumber                    : Mapped[int    ] = mapped_column(default=1                                     , nullable=True , doc='载玻台最小列数', comment='载玻台最小列数')
    MaxTrayRowNumber                    : Mapped[int    ] = mapped_column(default=25                                    , nullable=True , doc='载玻台最大行数', comment='载玻台最大行数')
    MaxTrayColNumber                    : Mapped[int    ] = mapped_column(default=40                                    , nullable=True , doc='载玻台最大列数', comment='载玻台最大列数')
    MaxTrayRowNumber20X                 : Mapped[int    ] = mapped_column(default=25                                    , nullable=True , doc='载玻台最大行数', comment='载玻台最大行数')
    MaxTrayColNumber20X                 : Mapped[int    ] = mapped_column(default=40                                    , nullable=True , doc='载玻台最大列数', comment='载玻台最大列数')
    MODBUS_POOL_LENGTH                  : Mapped[int    ] = mapped_column(default=20                                    , nullable=True , doc='连接池连接数量', comment='连接池连接数量')
    DebugMode                           : Mapped[int    ] = mapped_column(default=1                                     , nullable=True , doc='仪器调试模式　', comment='仪器调试模式　')
    BuzzerMode                          : Mapped[int    ] = mapped_column(default=1                                     , nullable=True , doc='蜂鸣器模式　　', comment='蜂鸣器模式　　')
    IsLeiCa                             : Mapped[int    ] = mapped_column(default=1                                     , nullable=True , doc='莱卡蔡司显微镜', comment='莱卡蔡司显微镜')
    EnglishMode                         : Mapped[int    ] = mapped_column(default=0                                     , nullable=True , doc='英文模式　　　', comment='英文模式　　　')
    WarningSpaceTimes                   : Mapped[int    ] = mapped_column(default=60000                                 , nullable=True , doc='告警间隔时长　', comment='告警间隔时长　')
    CameraName                          : Mapped[str    ] = mapped_column(Text, default='acA2040-90um, acA4112-20uc'    , nullable=True , doc='相机名称　　　', comment='相机名称　　　')
    def __init__(self, **args):
        super(SystemConfigModel, self).__init__()
        self.initialize()
        self.initParameter(**args)

    def initValue(self):
        super(SystemConfigModel, self).initValue()
        self.ID                                  = 1                            #
        self.ReceivedTails                       = b"\r\n"                      #
        self.ReceivedWaits                       = 500                          #
        self.MaxWaitTimes                        = 1000                         #
        self.MinChamberNumber                    = 1                            #
        self.MaxChamberNumber                    = 24                           #
        self.MinRowNumber                        = 1                            #
        self.MaxRowNumber                        = 5                            #
        self.MinTrayRowNumber                    = 1                            #
        self.MinTrayColNumber                    = 1                            #
        self.MaxTrayRowNumber                    = 25                           #
        self.MaxTrayColNumber                    = 40                           #
        self.MaxTrayRowNumber20X                 = 25                           #
        self.MaxTrayColNumber20X                 = 40                           #
        self.MODBUS_POOL_LENGTH                  = 20                           #
        self.DebugMode                           = 1                            #
        self.BuzzerMode                          = 1                            #
        self.EnglishMode                         = 0                            #
        self.WarningSpaceTimes                   = 60000                        #
        self.CameraName                          = 'acA2040-90um, acA4112-20uc' #
        self.IsLeiCa                             = 1





















    __field__ = (
        'ID'                     ,
        'ReceivedTails'          ,
        'ReceivedWaits'          ,
        'MaxWaitTimes'           ,
        'MinChamberNumber'       ,
        'MaxChamberNumber'       ,
        'MinRowNumber'           ,
        'MaxRowNumber'           ,
        'MinTrayRowNumber'       ,
        'MinTrayColNumber'       ,
        'MaxTrayRowNumber'       ,
        'MaxTrayColNumber'       ,
        'MaxTrayRowNumber20X'    ,
        'MaxTrayColNumber20X'    ,
        'MODBUS_POOL_LENGTH'     ,
        'DebugMode'              ,
        'BuzzerMode'             ,
        'EnglishMode'            ,
        'IsLeiCa'                ,
        'WarningSpaceTimes'      ,
        'CameraName'             ,
    )

    __types__ = (
        int    ,
        bytes  ,
        int    ,
        int    ,
        int    ,
        int    ,
        int    ,
        int    ,
        int    ,
        int    ,
        int    ,
        int    ,
        int    ,
        int    ,
        int    ,
        int    ,
        int    ,
        int    ,
        int    ,
        int    ,
        str    ,
    )

    @classmethod
    def UpdateMaxLocation(cls):
        from AppCore.AppDBModels.TrayModels.TrayModel import TrayModel
        from AppSettings.Settings import MAX_SLIDE_WIDTH, MAX_SLIDE_HEIGHT
        tray: TrayModel = TrayModel.getTrayConfig(TrayLevel.TraySlide1)
        MinRowNumber        : int = 1
        MinColNumber        : int = 1
        MaxRowNumber        : int = int(round(MAX_SLIDE_HEIGHT / tray.Step_X, 0))
        MaxColNumber        : int = int(round(MAX_SLIDE_WIDTH / tray.Step_Y, 0))
        MaxTrayRowNumber20X : int = int(round(MAX_SLIDE_HEIGHT / tray.Step_X_20X, 0))
        MaxTrayColNumber20X : int = int(round(MAX_SLIDE_WIDTH / tray.Step_Y_20X, 0))
        cls.model_update({cls.MaxTrayRowNumber: MaxRowNumber            ,
                          cls.MaxTrayColNumber: MaxColNumber            ,
                          cls.MinTrayRowNumber: MinRowNumber            ,
                          cls.MinTrayColNumber: MinColNumber            ,
                          cls.MaxTrayRowNumber20X: MaxTrayRowNumber20X  ,
                          cls.MaxTrayColNumber20X: MaxTrayColNumber20X  }, cls.ID == 1)

        TrayModel.model_update(
            {
                TrayModel.MinRowNumber          : MinRowNumber          ,
                TrayModel.MinColNumber          : MinColNumber          ,
                TrayModel.MaxRowNumber          : MaxRowNumber          ,
                TrayModel.MaxColNumber          : MaxColNumber          ,
                TrayModel.MaxRowNumber20X       : MaxTrayRowNumber20X   ,
                TrayModel.MaxColNumber20X       : MaxTrayColNumber20X   ,
            },
            TrayModel.Level == ModuleLevel.ModuleTraySlide1,
        )
        TrayModel.model_update(
            {
                TrayModel.MinRowNumber          : MinRowNumber          ,
                TrayModel.MinColNumber          : MinColNumber          ,
                TrayModel.MaxRowNumber          : MaxRowNumber          ,
                TrayModel.MaxColNumber          : MaxColNumber          ,
                TrayModel.MaxRowNumber20X       : MaxTrayRowNumber20X   ,
                TrayModel.MaxColNumber20X       : MaxTrayColNumber20X   ,
            },
            TrayModel.Level == ModuleLevel.ModuleTraySlide2,
        )


    @classmethod
    def initModels(cls):
        return [cls.instance(ID                                  = 1                            ,ReceivedTails                       = b"\r\n"                      ,ReceivedWaits                       = 500                          ,MaxWaitTimes                        = 1000                         ,MinChamberNumber                    = 1                            ,MaxChamberNumber                    = 24                           ,MinRowNumber                        = 1                            ,MaxRowNumber                        = 5                            ,MinTrayRowNumber                    = 1                            ,MinTrayColNumber                    = 1                            ,MaxTrayRowNumber                    = 25                           ,MaxTrayColNumber                    = 40                           ,MaxTrayRowNumber20X                 = 25                           ,MaxTrayColNumber20X                 = 40                           ,MODBUS_POOL_LENGTH                  = 20                           ,DebugMode                           = 1                            ,BuzzerMode                          = 1                            ,IsLeiCa = 1, EnglishMode                         = 0                            ,WarningSpaceTimes                   = 60000                        ,CameraName                          = 'acA2040-90um, acA4112-20uc' )]


    @classmethod
    def Request(cls) -> (SerialRequest, int):
        request: SerialRequest = SerialRequest()
        request.initValue()
        item: cls = cls.GetMaxPrimaryItem()
        MaxWaitTimes: int = 1000
        if item is not None:
            request.ReceivedWaits = AppConvert.ObjectConvert(item.ReceivedWaits, int  )
            request.ReceivedTails = AppConvert.ObjectConvert(item.ReceivedTails, bytes)
            MaxWaitTimes = AppConvert.ObjectConvert(item.MaxWaitTimes, int  )
        return request, MaxWaitTimes

    @classmethod
    def ScanCodeRequest(cls) -> (SerialRequest, int):
        request: SerialRequest = SerialRequest()
        request.initValue()
        item: cls = cls.getMaxPrimaryItem()
        MaxWaitTimes: int = 1000
        if item is not None:
            request.ReceivedWaits = AppConvert.ObjectConvert(item.ReceivedWaits, int)
            request.ReceivedTails = AppConvert.ObjectConvert(item.ReceivedTails, bytes)
            MaxWaitTimes = AppConvert.ObjectConvert(item.MaxWaitTimes, int)
        return request, MaxWaitTimes

    @classmethod
    def isDebugMode          (cls) -> int:
        item: cls = cls.first()
        return item.GetDebugMode

    @classmethod
    def isBuzzerMode         (cls) -> int:
        item: cls = cls.first()
        return item.GetBuzzerMode

    @classmethod
    def isEnglishMode        (cls) -> int:
        item: cls = cls.first()
        return item.GetEnglishMode

    @classmethod
    def getReceivedTails                       (cls) -> bytes  :
        item: cls = cls.first()
        return item.GetReceivedTails           #

    @classmethod
    def getReceivedWaits                       (cls) -> int    :
        item: cls = cls.first()
        return item.GetReceivedWaits           #

    @classmethod
    def getMaxWaitTimes                        (cls) -> int    :
        item: cls = cls.first()
        return item.GetMaxWaitTimes            #

    @classmethod
    def getMinChamberNumber                    (cls) -> int    :
        item: cls = cls.first()
        return item.GetMinChamberNumber        #

    @classmethod
    def getMaxChamberNumber                    (cls) -> int    :
        item: cls = cls.first()
        return item.GetMaxChamberNumber        #

    @classmethod
    def getMinRowNumber                        (cls) -> int    :
        item: cls = cls.first()
        return item.GetMinRowNumber            #

    @classmethod
    def getMaxRowNumber                        (cls) -> int    :
        item: cls = cls.first()
        return item.GetMaxRowNumber            #

    @classmethod
    def getMinTrayRowNumber                    (cls) -> int    :
        item: cls = cls.first()
        return item.GetMinTrayRowNumber        #

    @classmethod
    def getMinTrayColNumber                    (cls) -> int    :
        item: cls = cls.first()
        return item.GetMinTrayColNumber        #

    @classmethod
    def getMaxTrayRowNumber                    (cls) -> int    :
        item: cls = cls.first()
        return item.GetMaxTrayRowNumber        #

    @classmethod
    def getMaxTrayColNumber                    (cls) -> int    :
        item: cls = cls.first()
        return item.GetMaxTrayColNumber        #

    @classmethod
    def getMaxTrayRowNumber20X                 (cls) -> int    :
        item: cls = cls.first()
        return item.GetMaxTrayRowNumber20X     #

    @classmethod
    def getMaxTrayColNumber20X                 (cls) -> int    :
        item: cls = cls.first()
        return item.GetMaxTrayColNumber20X     #

    @classmethod
    def getMODBUS_POOL_LENGTH                  (cls) -> int    :
        item: cls = cls.first()
        return item.GetMODBUS_POOL_LENGTH      #

    @classmethod
    def getDebugMode                           (cls) -> int    :
        item: cls = cls.first()
        return item.GetDebugMode               #

    @classmethod
    def getBuzzerMode                          (cls) -> int    :
        item: cls = cls.first()
        return item.GetBuzzerMode              #

    @classmethod
    def getEnglishMode                         (cls) -> int    :
        item: cls = cls.first()
        return item.GetEnglishMode             #

    @classmethod
    def getWarningSpaceTimes                   (cls) -> int    :
        item: cls = cls.first()
        return item.GetWarningSpaceTimes       #

    @classmethod
    def getCameraName(cls) -> str:
        item: cls = cls.first()
        return item.GetCameraName

    @classmethod
    def setReceivedTails        (cls, value):
        if isinstance(value, (bytes, bytearray, Qt.QByteArray)   ):
            cls.changed({cls.ReceivedTails       : value})

    @classmethod
    def setReceivedWaits        (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.ReceivedWaits       : value})

    @classmethod
    def setMaxWaitTimes         (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.MaxWaitTimes        : value})

    @classmethod
    def setMinChamberNumber     (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.MinChamberNumber    : value})

    @classmethod
    def setMaxChamberNumber     (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.MaxChamberNumber    : value})

    @classmethod
    def setMinRowNumber         (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.MinRowNumber        : value})

    @classmethod
    def setMaxRowNumber         (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.MaxRowNumber        : value})

    @classmethod
    def setMinTrayRowNumber     (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.MinTrayRowNumber    : value})

    @classmethod
    def setMinTrayColNumber     (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.MinTrayColNumber    : value})

    @classmethod
    def setMaxTrayRowNumber     (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.MaxTrayRowNumber    : value})

    @classmethod
    def setMaxTrayColNumber     (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.MaxTrayColNumber    : value})

    @classmethod
    def setMaxTrayRowNumber20X  (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.MaxTrayRowNumber20X : value})

    @classmethod
    def setMaxTrayColNumber20X  (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.MaxTrayColNumber20X : value})

    @classmethod
    def setMODBUS_POOL_LENGTH   (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.MODBUS_POOL_LENGTH  : value})

    @classmethod
    def setDebugMode            (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.DebugMode           : value})

    @classmethod
    def setBuzzerMode           (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.BuzzerMode          : value})

    @classmethod
    def setEnglishMode          (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.EnglishMode         : value})

    @classmethod
    def setWarningSpaceTimes    (cls, value):
        if isinstance(value, int                                 ):
            cls.changed({cls.WarningSpaceTimes   : value})

    @classmethod
    def setCameraName(cls, value):
        if isinstance(value, str):
            cls.changed({cls.CameraName: value})

    @classmethod
    def setLeiCaMicroscope(cls, enable: (bool, int)):
        cls.changed({cls.LeiCa: 1 if isinstance(enable, (bool, int)) and enable else 0})

    @classmethod
    def isLeiCaMicroscope(cls) -> bool:
        item: cls = cls.first()
        if isinstance(item, cls) and item.hasIsLeiCa:
            return item.IsLeiCa
        return True

    @property
    def GetID                                  (self) -> int    :
        return None if not self.hasID                                   else self.ID                      #

    @property
    def GetReceivedTails                       (self) -> bytes  :
        return None if not self.hasReceivedTails                        else self.ReceivedTails           #

    @property
    def GetReceivedWaits                       (self) -> int    :
        return None if not self.hasReceivedWaits                        else self.ReceivedWaits           #

    @property
    def GetMaxWaitTimes                        (self) -> int    :
        return None if not self.hasMaxWaitTimes                         else self.MaxWaitTimes            #

    @property
    def GetMinChamberNumber                    (self) -> int    :
        return None if not self.hasMinChamberNumber                     else self.MinChamberNumber        #

    @property
    def GetMaxChamberNumber                    (self) -> int    :
        return None if not self.hasMaxChamberNumber                     else self.MaxChamberNumber        #

    @property
    def GetMinRowNumber                        (self) -> int    :
        return None if not self.hasMinRowNumber                         else self.MinRowNumber            #

    @property
    def GetMaxRowNumber                        (self) -> int    :
        return None if not self.hasMaxRowNumber                         else self.MaxRowNumber            #

    @property
    def GetMinTrayRowNumber                    (self) -> int    :
        return None if not self.hasMinTrayRowNumber                     else self.MinTrayRowNumber        #

    @property
    def GetMinTrayColNumber                    (self) -> int    :
        return None if not self.hasMinTrayColNumber                     else self.MinTrayColNumber        #

    @property
    def GetMaxTrayRowNumber                    (self) -> int    :
        return None if not self.hasMaxTrayRowNumber                     else self.MaxTrayRowNumber        #

    @property
    def GetMaxTrayColNumber                    (self) -> int    :
        return None if not self.hasMaxTrayColNumber                     else self.MaxTrayColNumber        #

    @property
    def GetMaxTrayRowNumber20X                 (self) -> int    :
        return None if not self.hasMaxTrayRowNumber20X                  else self.MaxTrayRowNumber20X     #

    @property
    def GetMaxTrayColNumber20X                 (self) -> int    :
        return None if not self.hasMaxTrayColNumber20X                  else self.MaxTrayColNumber20X     #

    @property
    def GetMODBUS_POOL_LENGTH                  (self) -> int    :
        return None if not self.hasMODBUS_POOL_LENGTH                   else self.MODBUS_POOL_LENGTH      #

    @property
    def GetDebugMode                           (self) -> int    :
        return None if not self.hasDebugMode                            else self.DebugMode               #

    @property
    def GetBuzzerMode                          (self) -> int    :
        return None if not self.hasBuzzerMode                           else self.BuzzerMode              #

    @property
    def GetEnglishMode                         (self) -> int    :
        return None if not self.hasEnglishMode                          else self.EnglishMode             #

    @property
    def GetWarningSpaceTimes                   (self) -> int    :
        return None if not self.hasWarningSpaceTimes                    else self.WarningSpaceTimes       #

    @property
    def GetCameraName(self) -> str:
        return None if not self.hasCameraName else self.CameraName


    def SetID                                  (self, value):
        if isinstance(value, int    ):
            self.ID                                  = value

    def SetReceivedTails                       (self, value):
        if isinstance(value, bytes  ):
            self.ReceivedTails                       = value

    def SetReceivedWaits                       (self, value):
        if isinstance(value, int    ):
            self.ReceivedWaits                       = value

    def SetMaxWaitTimes                        (self, value):
        if isinstance(value, int    ):
            self.MaxWaitTimes                        = value

    def SetMinChamberNumber                    (self, value):
        if isinstance(value, int    ):
            self.MinChamberNumber                    = value

    def SetMaxChamberNumber                    (self, value):
        if isinstance(value, int    ):
            self.MaxChamberNumber                    = value

    def SetMinRowNumber                        (self, value):
        if isinstance(value, int    ):
            self.MinRowNumber                        = value

    def SetMaxRowNumber                        (self, value):
        if isinstance(value, int    ):
            self.MaxRowNumber                        = value

    def SetMinTrayRowNumber                    (self, value):
        if isinstance(value, int    ):
            self.MinTrayRowNumber                    = value

    def SetMinTrayColNumber                    (self, value):
        if isinstance(value, int    ):
            self.MinTrayColNumber                    = value

    def SetMaxTrayRowNumber                    (self, value):
        if isinstance(value, int    ):
            self.MaxTrayRowNumber                    = value

    def SetMaxTrayColNumber                    (self, value):
        if isinstance(value, int    ):
            self.MaxTrayColNumber                    = value

    def SetMaxTrayRowNumber20X                 (self, value):
        if isinstance(value, int    ):
            self.MaxTrayRowNumber20X                 = value

    def SetMaxTrayColNumber20X                 (self, value):
        if isinstance(value, int    ):
            self.MaxTrayColNumber20X                 = value

    def SetMODBUS_POOL_LENGTH                  (self, value):
        if isinstance(value, int    ):
            self.MODBUS_POOL_LENGTH                  = value

    def SetDebugMode                           (self, value):
        if isinstance(value, int    ):
            self.DebugMode                           = value

    def SetBuzzerMode                          (self, value):
        if isinstance(value, int    ):
            self.BuzzerMode                          = value

    def SetEnglishMode                         (self, value):
        if isinstance(value, int    ):
            self.EnglishMode                         = value

    def SetWarningSpaceTimes                   (self, value):
        if isinstance(value, int    ):
            self.WarningSpaceTimes                   = value

    def SetCameraName(self, value):
        if isinstance(value, str):
            self.CameraName = value



    @property
    def hasID                                  (self) -> bool:
        return hasattr(self, 'ID'                     ) and isinstance(self.ID                                  , int    )

    @property
    def hasReceivedTails                       (self) -> bool:
        return hasattr(self, 'ReceivedTails'          ) and isinstance(self.ReceivedTails                       , (bytes, bytearray, Qt.QByteArray)  )

    @property
    def hasReceivedWaits                       (self) -> bool:
        return hasattr(self, 'ReceivedWaits'          ) and isinstance(self.ReceivedWaits                       , int    )

    @property
    def hasMaxWaitTimes                        (self) -> bool:
        return hasattr(self, 'MaxWaitTimes'           ) and isinstance(self.MaxWaitTimes                        , int    )

    @property
    def hasMinChamberNumber                    (self) -> bool:
        return hasattr(self, 'MinChamberNumber'       ) and isinstance(self.MinChamberNumber                    , int    )

    @property
    def hasMaxChamberNumber                    (self) -> bool:
        return hasattr(self, 'MaxChamberNumber'       ) and isinstance(self.MaxChamberNumber                    , int    )

    @property
    def hasMinRowNumber                        (self) -> bool:
        return hasattr(self, 'MinRowNumber'           ) and isinstance(self.MinRowNumber                        , int    )

    @property
    def hasMaxRowNumber                        (self) -> bool:
        return hasattr(self, 'MaxRowNumber'           ) and isinstance(self.MaxRowNumber                        , int    )

    @property
    def hasMinTrayRowNumber                    (self) -> bool:
        return hasattr(self, 'MinTrayRowNumber'       ) and isinstance(self.MinTrayRowNumber                    , int    )

    @property
    def hasMinTrayColNumber                    (self) -> bool:
        return hasattr(self, 'MinTrayColNumber'       ) and isinstance(self.MinTrayColNumber                    , int    )

    @property
    def hasMaxTrayRowNumber                    (self) -> bool:
        return hasattr(self, 'MaxTrayRowNumber'       ) and isinstance(self.MaxTrayRowNumber                    , int    )

    @property
    def hasMaxTrayColNumber                    (self) -> bool:
        return hasattr(self, 'MaxTrayColNumber'       ) and isinstance(self.MaxTrayColNumber                    , int    )

    @property
    def hasMaxTrayRowNumber20X                 (self) -> bool:
        return hasattr(self, 'MaxTrayRowNumber20X'    ) and isinstance(self.MaxTrayRowNumber20X                 , int    )

    @property
    def hasMaxTrayColNumber20X                 (self) -> bool:
        return hasattr(self, 'MaxTrayColNumber20X'    ) and isinstance(self.MaxTrayColNumber20X                 , int    )

    @property
    def hasMODBUS_POOL_LENGTH                  (self) -> bool:
        return hasattr(self, 'MODBUS_POOL_LENGTH'     ) and isinstance(self.MODBUS_POOL_LENGTH                  , int    )

    @property
    def hasDebugMode                           (self) -> bool:
        return hasattr(self, 'DebugMode'              ) and isinstance(self.DebugMode                           , int    )

    @property
    def hasBuzzerMode                          (self) -> bool:
        return hasattr(self, 'BuzzerMode'             ) and isinstance(self.BuzzerMode                          , int    )

    @property
    def hasEnglishMode                         (self) -> bool:
        return hasattr(self, 'EnglishMode'            ) and isinstance(self.EnglishMode                         , int    )

    @property
    def hasWarningSpaceTimes                   (self) -> bool:
        return hasattr(self, 'WarningSpaceTimes'      ) and isinstance(self.WarningSpaceTimes                   , int    )


    @property
    def hasCameraName(self) -> bool:
        return hasattr(self, 'CameraName') and isinstance(self.CameraName, str)

    @property
    def hasIsLeiCa(self) -> bool:
        return self.hasAttribute('IsLeiCa', (int, bool))
