#!D:\IDE\Anaconda3\envs\Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName   : CameraModel.py
@Account    : Administrator
@Time       : 2025/8/28 15:39
@Author     : xsh
@Description: 
"""
from PyQt5 import Qt
from sqlalchemy.orm import (Mapped, mapped_column)
from sqlalchemy.types import (Text, Boolean)
from AppCore.AppDBModels.CameraModels.CameraInterface import CameraInterface
from AppCore.Levels import *
class CameraModel(CameraInterface):
    __tablename__ = 't_CameraModel'
    Information                         : Mapped[str   ] = mapped_column(Text      , default=''                , nullable=True , doc='说明信息　　', comment='说明信息　　')
    Level                               : Mapped[int   ] = mapped_column(primary_key=True                      , nullable=False, doc='物镜类型　　', comment='物镜类型　　')
    ExposureMode                        : Mapped[int   ] = mapped_column(            default= 1                , nullable=True , doc='曝光模式　　', comment='曝光模式　　')
    TriggerMode                         : Mapped[int   ] = mapped_column(            default= 0                , nullable=True , doc='触发模式　　', comment='触发模式　　')
    ShutterMode                         : Mapped[int   ] = mapped_column(            default= 2                , nullable=True , doc='快门模式　　', comment='快门模式　　')
    ExposureAuto                        : Mapped[int   ] = mapped_column(            default= 0                , nullable=True , doc='自动曝光　　', comment='自动曝光　　')
    GainAuto                            : Mapped[int   ] = mapped_column(            default= 0                , nullable=True , doc='自动增益　　', comment='自动增益　　')
    Width                               : Mapped[int   ] = mapped_column(            default= 2040             , nullable=True , doc='图像宽度　　', comment='图像宽度　　')
    Height                              : Mapped[int   ] = mapped_column(            default= 2040             , nullable=True , doc='图像高度　　', comment='图像高度　　')
    BalanceWhiteAuto                    : Mapped[int   ] = mapped_column(            default= 2                , nullable=True , doc='自动白平恒　', comment='自动白平恒　')
    ImageCount                          : Mapped[int   ] = mapped_column(            default= 1                , nullable=True , doc='图像采集数量', comment='图像采集数量')
    ExposureTime                        : Mapped[float ] = mapped_column(            default= 60.0             , nullable=True , doc='曝光时间　　', comment='曝光时间　　')
    Gain                                : Mapped[float ] = mapped_column(            default= 0.0              , nullable=True , doc='增益数值　　', comment='增益数值　　')
    Gamma                               : Mapped[float ] = mapped_column(            default= 1.0              , nullable=True , doc='伽马数值　　', comment='伽马数值　　')
    BlackLevel                          : Mapped[float ] = mapped_column(            default= 0.0              , nullable=True , doc='图像亮度　　', comment='图像亮度　　')
    Axis_Offset_X                       : Mapped[float ] = mapped_column(            default= 0.0              , nullable=True , doc='位置偏移量　', comment='位置偏移量　')
    Axis_Offset_Y                       : Mapped[float ] = mapped_column(            default= 0.0              , nullable=True , doc='位置偏移量　', comment='位置偏移量　')
    Image_Offset_W                      : Mapped[float ] = mapped_column(            default= 1.0              , nullable=True , doc='像素偏移量　', comment='像素偏移量　')
    Image_Offset_H                      : Mapped[float ] = mapped_column(            default= 1.0              , nullable=True , doc='像素偏移量　', comment='像素偏移量　')
    PixelFormat                         : Mapped[str   ] = mapped_column(Text      , default='Mono8'           , nullable=True , doc='图像格式　　', comment='图像格式　　')
    LightSourcePreset                   : Mapped[str   ] = mapped_column(Text      , default='Off'             , nullable=True , doc='光源预设　　', comment='光源预设　　')
    VendorName                          : Mapped[str   ] = mapped_column(Text      , default='Basler'          , nullable=True , doc='相机厂家名称', comment='相机厂家名称')
    ModelName                           : Mapped[str   ] = mapped_column(Text      , default='acA2040-90um'    , nullable=True , doc='相机型号名称', comment='相机型号名称')
    CenterX                             : Mapped[float ] = mapped_column(Boolean   , default=True              , nullable=True , doc='水平居中　　', comment='水平居中　　')
    CenterY                             : Mapped[float ] = mapped_column(Boolean   , default=True              , nullable=True , doc='垂直居中　　', comment='垂直居中　　')
    ReverseX                            : Mapped[float ] = mapped_column(Boolean   , default=False             , nullable=True , doc='水平镜像　　', comment='水平镜像　　')
    ReverseY                            : Mapped[float ] = mapped_column(Boolean   , default=False             , nullable=True , doc='垂直镜像　　', comment='垂直镜像　　')
    AberrationExposureTime              : Mapped[float ] = mapped_column(            default= 60.0             , nullable=True , doc='畸变曝光时间', comment='畸变曝光时间')
    MicronucleusExposureTime            : Mapped[float ] = mapped_column(            default= 60.0             , nullable=True , doc='微核曝光时间', comment='微核曝光时间')
    KaryotypingExposureTime             : Mapped[float ] = mapped_column(            default= 60.0             , nullable=True , doc='核型曝光时间', comment='核型曝光时间')
    def __init__(self, **args):
        super(CameraModel, self).__init__()
        self.initialize()
        self.initParameter(**args)

    def initDefaultModel(self):
        self.Information                            = '未知物镜相机参数　　'
        self.Level                                  = ObjectiveLevel.ObjectiveNone #
        self.ExposureMode                           = 1                            #
        self.TriggerMode                            = 0                            #
        self.ShutterMode                            = 2                            #
        self.ExposureAuto                           = 0                            #
        self.GainAuto                               = 0                            #
        self.Width                                  = 2048                         #
        self.Height                                 = 2048                         #
        self.BalanceWhiteAuto                       =  0                           #
        self.ImageCount                             =  1                           #
        self.ExposureTime                           =  200.0                       #
        self.ColorTransformationSelector            =  0                           #
        self.Gain                                   = 0.0                          #
        self.Gamma                                  = 1.0                          #
        self.BlackLevel                             = 0.0                          #
        self.Axis_Offset_X                          = 0.0                          #
        self.Axis_Offset_Y                          = 0.0                          #
        self.Image_Offset_W                         = 1.0                          #
        self.Image_Offset_H                         = 1.0                          #
        self.PixelFormat                            = 'Mono8'                      #
        self.LightSourcePreset                      = 'Off'                        #
        self.VendorName                             = 'Basler'                     #
        self.ModelName                              = 'acA2040-90um'               #
        self.CenterX                                = True                         #
        self.CenterY                                = True                         #
        self.ReverseX                               = False                        #
        self.ReverseY                               = False                        #
        self.AberrationExposureTime                 = 60.0
        self.MicronucleusExposureTime               = 60.0
        self.KaryotypingExposureTime                = 60.0


    @classmethod
    def initModels(cls) -> list:
        """托盘XY轴和相机XY的并系为  托盘X -> 相机Y 托盘Y -> 相机X"""
        items: list[cls] = [
            cls.instance(Information      = '１　　倍物镜相机参数'    ,  Level            = ObjectiveLevel.Objective1    ,ExposureMode                           = 1             ,TriggerMode                            = 0             ,ShutterMode                            = 2             ,ExposureAuto                           = 0             ,GainAuto                               = 0             ,Width                                  = 2048          ,Height                                 = 2048          ,BalanceWhiteAuto                       =  0            ,ImageCount                             =  1            ,ExposureTime                           =  200.0        ,AberrationExposureTime     = 65.0 , MicronucleusExposureTime   = 65.0 , KaryotypingExposureTime    = 65.0 ,ColorTransformationSelector            =  0            ,Gain                                   = 0.0           ,Gamma                                  = 1.0           ,BlackLevel                             = 0.0           ,Axis_Offset_X                          = 0.0           ,Axis_Offset_Y                          = 0.0           ,Image_Offset_W                         = 1.0           ,Image_Offset_H                         = 1.0           ,PixelFormat                            = 'Mono8'       ,LightSourcePreset                      = 'Off'              ,VendorName                             = 'Basler'      ,ModelName                              = 'acA2040-90um' ,CenterX                                = True          ,CenterY                                = True          ,ReverseX                               = False         ,ReverseY                               = False         ),
            cls.instance(Information      = '１０　倍物镜相机参数'    ,  Level            = ObjectiveLevel.Objective10   ,ExposureMode                           = 1             ,TriggerMode                            = 0             ,ShutterMode                            = 2             ,ExposureAuto                           = 0             ,GainAuto                               = 0             ,Width                                  = 2048          ,Height                                 = 2048          ,BalanceWhiteAuto                       =  0            ,ImageCount                             =  1            ,ExposureTime                           =  200.0        ,AberrationExposureTime     = 65.0 , MicronucleusExposureTime   = 65.0 , KaryotypingExposureTime    = 65.0 ,ColorTransformationSelector            =  0            ,Gain                                   = 0.0           ,Gamma                                  = 1.0           ,BlackLevel                             = 0.0           ,Axis_Offset_X                          = 0.0           ,Axis_Offset_Y                          = 0.0           ,Image_Offset_W                         = 1.0           ,Image_Offset_H                         = 1.0           ,PixelFormat                            = 'Mono8'       ,LightSourcePreset                      = 'Off'              ,VendorName                             = 'Basler'      ,ModelName                              = 'acA2040-90um' ,CenterX                                = True          ,CenterY                                = True          ,ReverseX                               = False         ,ReverseY                               = False         ),
            cls.instance(Information      = '２０　倍物镜相机参数'    ,  Level            = ObjectiveLevel.Objective20   ,ExposureMode                           = 1             ,TriggerMode                            = 0             ,ShutterMode                            = 2             ,ExposureAuto                           = 0             ,GainAuto                               = 0             ,Width                                  = 2048          ,Height                                 = 2048          ,BalanceWhiteAuto                       =  0            ,ImageCount                             =  1            ,ExposureTime                           =  200.0        ,AberrationExposureTime     = 65.0 , MicronucleusExposureTime   = 65.0 , KaryotypingExposureTime    = 65.0 ,ColorTransformationSelector            =  0            ,Gain                                   = 0.0           ,Gamma                                  = 1.0           ,BlackLevel                             = 0.0           ,Axis_Offset_X                          = 0.0           ,Axis_Offset_Y                          = 0.0           ,Image_Offset_W                         = 1.0           ,Image_Offset_H                         = 1.0           ,PixelFormat                            = 'BayerRG8'    ,LightSourcePreset                      = 'Daylight6500K'    ,VendorName                             = 'Basler'      ,ModelName                              = 'acA4112-20uc' ,CenterX                                = True          ,CenterY                                = True          ,ReverseX                               = False         ,ReverseY                               = False         ),
            cls.instance(Information      = '４０　倍物镜相机参数'    ,  Level            = ObjectiveLevel.Objective40   ,ExposureMode                           = 1             ,TriggerMode                            = 0             ,ShutterMode                            = 2             ,ExposureAuto                           = 0             ,GainAuto                               = 0             ,Width                                  = 2048          ,Height                                 = 2048          ,BalanceWhiteAuto                       =  0            ,ImageCount                             =  1            ,ExposureTime                           =  200.0        ,AberrationExposureTime     = 65.0 , MicronucleusExposureTime   = 65.0 , KaryotypingExposureTime    = 65.0 ,ColorTransformationSelector            =  0            ,Gain                                   = 0.0           ,Gamma                                  = 1.0           ,BlackLevel                             = 0.0           ,Axis_Offset_X                          = 0.0           ,Axis_Offset_Y                          = 0.0           ,Image_Offset_W                         = 1.0           ,Image_Offset_H                         = 1.0           ,PixelFormat                            = 'BayerRG8'    ,LightSourcePreset                      = 'Daylight6500K'    ,VendorName                             = 'Basler'      ,ModelName                              = 'acA4112-20uc' ,CenterX                                = True          ,CenterY                                = True          ,ReverseX                               = False         ,ReverseY                               = False         ),
            cls.instance(Information      = '６３　倍物镜相机参数'    ,  Level            = ObjectiveLevel.Objective63   ,ExposureMode                           = 1             ,TriggerMode                            = 0             ,ShutterMode                            = 2             ,ExposureAuto                           = 0             ,GainAuto                               = 0             ,Width                                  = 2048          ,Height                                 = 2048          ,BalanceWhiteAuto                       =  0            ,ImageCount                             =  1            ,ExposureTime                           =  200.0        ,AberrationExposureTime     = 65.0 , MicronucleusExposureTime   = 65.0 , KaryotypingExposureTime    = 65.0 ,ColorTransformationSelector            =  0            ,Gain                                   = 0.0           ,Gamma                                  = 1.0           ,BlackLevel                             = 0.0           ,Axis_Offset_X                          = 0.0           ,Axis_Offset_Y                          = 0.0           ,Image_Offset_W                         = 1.0           ,Image_Offset_H                         = 1.0           ,PixelFormat                            = 'Mono8'       ,LightSourcePreset                      = 'Off'              ,VendorName                             = 'Basler'      ,ModelName                              = 'acA2040-90um' ,CenterX                                = True          ,CenterY                                = True          ,ReverseX                               = False         ,ReverseY                               = False         ),
            cls.instance(Information      = '１００倍物镜相机参数'    ,  Level            = ObjectiveLevel.Objective100  ,ExposureMode                           = 1             ,TriggerMode                            = 0             ,ShutterMode                            = 2             ,ExposureAuto                           = 0             ,GainAuto                               = 0             ,Width                                  = 2048          ,Height                                 = 2048          ,BalanceWhiteAuto                       =  0            ,ImageCount                             =  1            ,ExposureTime                           =  200.0        ,AberrationExposureTime     = 65.0 , MicronucleusExposureTime   = 65.0 , KaryotypingExposureTime    = 65.0 ,ColorTransformationSelector            =  0            ,Gain                                   = 0.0           ,Gamma                                  = 1.0           ,BlackLevel                             = 0.0           ,Axis_Offset_X                          = 0.0           ,Axis_Offset_Y                          = 0.0           ,Image_Offset_W                         = 1.0           ,Image_Offset_H                         = 1.0           ,PixelFormat                            = 'Mono8'       ,LightSourcePreset                      = 'Off'              ,VendorName                             = 'Basler'      ,ModelName                              = 'acA2040-90um' ,CenterX                                = True          ,CenterY                                = True          ,ReverseX                               = False         ,ReverseY                               = False         ),
            cls.instance(Information      = '未知物镜相机参数　　'    ,  Level            = ObjectiveLevel.ObjectiveNone ,ExposureMode                           = 1             ,TriggerMode                            = 0             ,ShutterMode                            = 2             ,ExposureAuto                           = 0             ,GainAuto                               = 0             ,Width                                  = 2048          ,Height                                 = 2048          ,BalanceWhiteAuto                       =  0            ,ImageCount                             =  1            ,ExposureTime                           =  200.0        ,AberrationExposureTime     = 65.0 , MicronucleusExposureTime   = 65.0 , KaryotypingExposureTime    = 65.0 ,ColorTransformationSelector            =  0            ,Gain                                   = 0.0           ,Gamma                                  = 1.0           ,BlackLevel                             = 0.0           ,Axis_Offset_X                          = 0.0           ,Axis_Offset_Y                          = 0.0           ,Image_Offset_W                         = 1.0           ,Image_Offset_H                         = 1.0           ,PixelFormat                            = 'Mono8'       ,LightSourcePreset                      = 'Off'              ,VendorName                             = 'Basler'      ,ModelName                              = 'acA2040-90um' ,CenterX                                = True          ,CenterY                                = True          ,ReverseX                               = False         ,ReverseY                               = False         ),
        ]
        return items






































































