#!D:\IDE\Anaconda3\envs\Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
 @Author: Administrator
 @FileName: WebAPILevel.py
 @DateTime: 2025/4/8 13:51
 @SoftWare: PyCharm
 @Author  ：xsh
"""
class WebAPILevel(int):
    NoneWebAPI                  = -1
    exitScanning                = 0         # 'exitScanning'                // 退出扫描
    jumpScanning                = 1         # 'jumpScanning'                // 跳过扫描
    stopScan                    = 2         # 'stopScan'                    // 停止扫描
    startScan                   = 3         # 'startScan'                   // 开始扫描
    pauseScan                   = 4         # 'pauseScan'                   // 暂停扫描
    getSlideAreaImage           = 5         # 'getSlideAreaImage'           // 获取玻片区域图片
    getPreviewImage             = 6         # 'getPreviewImage'             // 获取预览图片
    getVideoStream              = 7         # 'getVideoStream'              // 获取视频流
    getImageList                = 8         # 'getImageList'                // 获取图片列表
    getScanningData             = 9         # 'getScanningData'             // 获取扫描数据
    scanComplete                = 10        # 'scanComplete'                // 扫描完成
    getConnectionStatus         = 11        # 'getConnectionStatus'         // 获取连接状态
    getScanningStatus           = 12        # 'getScanningStatus'           // 获取连接状态
    getTempLate                 = 13        # 'getTempLate'                 // 获取扫描模板
    selectTemplateList          = 14        # 'selectTemplateList'          // 增扫描模板
    selectClassifier            = 15        # 'selectClassifier'            // 模型类型
    deleteTemplate              = 16        # 'deleteTemplate'              // 删扫描模板
    updateTempLate              = 17        # 'updateTempLate'              // 改扫描模板
    saveTemplate                = 18        # 'saveTemplate'                // 查扫描模板
    pushTemplate                = 19        # 'pushTemplate'                // 推扫描模板
    focusingPosition            = 20        # 'focusingPosition'            // 定焦位置信息
    getChamberStatus            = 21        # 'chamberStatus'               // 片仓状态
    getClassifiers              = 22        # ‘getClassifiers'              // 获取分类模型
    clearPreview                = 23        # ‘clearPreview'                // 清除预览图像
    pushWarning                 = 24        # 'pushWarning'                 // 推送报警
    clearWarning                = 25        # 'clearWarning'                // 清空报警
    setCustomData               = 26        # 'setCustomData'               // 设置自定义模板
    getCustomData               = 27        # 'getCustomData'               // 获取自定义模板
    pushMessage                 = 28        # 'pushMessage'                 // 推送弹窗
    changedLanguage             = 29        # 'changedLanguage'             // 修改语言
    pushSlideTableTrayWarning   = 30        # 'pushSlideTableTrayWarning'   // 载玻台有托盘告警
    dropSlideTableTray          = 31        # ‘dropSlideTableTray'          // 移出载玻台托盘
    @staticmethod
    def exists(value: int) -> bool:
        try:
            return WebAPILevel.toList().index(value) >= 0
        except Exception as e:
            return False

    @classmethod
    def all(cls) -> list[int]:
        return [
            cls.exitScanning                ,
            cls.jumpScanning                ,
            cls.stopScan                    ,
            cls.startScan                   ,
            cls.pauseScan                   ,
            cls.getSlideAreaImage           ,
            cls.getPreviewImage             ,
            cls.getVideoStream              ,
            cls.getImageList                ,
            cls.getScanningData             ,
            cls.scanComplete                ,
            cls.getConnectionStatus         ,
            cls.getScanningStatus           ,
            cls.getTempLate                 ,
            cls.selectTemplateList          ,
            cls.selectClassifier            ,
            cls.deleteTemplate              ,
            cls.updateTempLate              ,
            cls.saveTemplate                ,
            cls.pushTemplate                ,
            cls.focusingPosition            ,
            cls.getChamberStatus            ,
            cls.getClassifiers              ,
            cls.clearPreview                ,
            cls.pushWarning                 ,
            cls.clearWarning                ,
            cls.setCustomData               ,
            cls.getCustomData               ,
            cls.pushMessage                 ,
            cls.changedLanguage             ,
            cls.pushSlideTableTrayWarning   ,
            cls.dropSlideTableTray          ,
        ]
    @staticmethod
    def isExists(value: str) -> bool:
        keys = WebAPILevel.toItem().keys()
        try:
            return keys.index(value) >= 0
        except Exception:
            return False
    @staticmethod
    def toValue(value: str) -> int:
        return WebAPILevel.toItem().get(value, WebAPILevel.NoneWebAPI)

    @staticmethod
    def toString(value: int) -> str:
        try:
            key = list(WebAPILevel.toItem().keys())[list(WebAPILevel.toItem().values()).index(value)]
            return key
        except Exception as e:
            return ""

    @classmethod
    def toList(cls) -> list[int]:
        return [
            cls.exitScanning                ,
            cls.jumpScanning                ,
            cls.stopScan                    ,
            cls.startScan                   ,
            cls.pauseScan                   ,
            cls.getSlideAreaImage           ,
            cls.getPreviewImage             ,
            cls.getVideoStream              ,
            cls.getImageList                ,
            cls.getScanningData             ,
            cls.scanComplete                ,
            cls.getConnectionStatus         ,
            cls.getScanningStatus           ,
            cls.getTempLate                 ,
            cls.selectTemplateList          ,
            cls.selectClassifier            ,
            cls.deleteTemplate              ,
            cls.updateTempLate              ,
            cls.saveTemplate                ,
            cls.pushTemplate                ,
            cls.focusingPosition            ,
            cls.getChamberStatus            ,
            cls.getClassifiers              ,
            cls.clearPreview                ,
            cls.pushWarning                 ,
            cls.clearWarning                ,
            cls.setCustomData               ,
            cls.getCustomData               ,
            cls.pushMessage                 ,
            cls.changedLanguage             ,
            cls.pushSlideTableTrayWarning   ,
            cls.dropSlideTableTray          ,
        ]



    @classmethod
    def toItem(cls) -> dict[str, object]:
        return {
            'exitScanning'              : cls.exitScanning              ,
            'jumpScanning'              : cls.jumpScanning              ,
            'stopScan'                  : cls.stopScan                  ,
            'startScan'                 : cls.startScan                 ,
            'pauseScan'                 : cls.pauseScan                 ,
            'getSlideAreaImage'         : cls.getSlideAreaImage         ,
            'getPreviewImage'           : cls.getPreviewImage           ,
            'getVideoStream'            : cls.getVideoStream            ,
            'getImageList'              : cls.getImageList              ,
            'getScanningData'           : cls.getScanningData           ,
            'scanComplete'              : cls.scanComplete              ,
            'getConnectionStatus'       : cls.getConnectionStatus       ,
            'getScanningStatus'         : cls.getScanningStatus         ,
            'getTempLate'               : cls.getTempLate               ,
            'selectTemplateList'        : cls.selectTemplateList        ,
            'selectClassifier'          : cls.selectClassifier          ,
            'deleteTemplate'            : cls.deleteTemplate            ,
            'updateTempLate'            : cls.updateTempLate            ,
            'saveTemplate'              : cls.saveTemplate              ,
            'pushTemplate'              : cls.pushTemplate              ,
            'focusingPosition'          : cls.focusingPosition          ,
            'getChamberStatus'          : cls.getChamberStatus          ,
            'getClassifiers'            : cls.getClassifiers            ,
            'clearPreview'              : cls.clearPreview              ,
            'pushWarning'               : cls.pushWarning               ,
            'clearWarning'              : cls.clearWarning              ,
            'setCustomData'             : cls.setCustomData             ,
            'getCustomData'             : cls.getCustomData             ,
            'pushMessage'               : cls.pushMessage               ,
            'changedLanguage'           : cls.changedLanguage           ,
            'pushSlideTableTrayWarning' : cls.pushSlideTableTrayWarning ,
            'dropSlideTableTray'        : cls.dropSlideTableTray        ,
        }
