Bladeren bron

OptionAction类。

scbc.sat2 5 jaren geleden
bovenliggende
commit
dd3ad4417d

+ 354 - 0
ssat_sdk/MenuTree3/OptionAction.py

@@ -0,0 +1,354 @@
+# -*- coding:utf-8 -*-
+import os
+from UIT_PathManage import UITPathManage
+from BaseLog import CBaseLog
+from ExtraData import CExtraData
+from OptionExcel import COptionExcel
+from OptionConfig import COptionConfig
+from OptionFocus import COptionFocus
+from OptionOCR import COptionOCR
+from ssat_sdk.tv_detect import *
+from ssat_sdk.device_manage.capturecard_manager import CCardManager
+from ssat_sdk.utils.string_util import strcmp
+
+g_level = ['First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth',
+           'Seventh', 'Eighth', 'Ninth', 'Tenth', 'Eleventh', 'Twelfth']
+
+
+# 注意:所有不对外暴露的变量和函数需要私有化,以明确哪些接口和参数是对外的。
+# 这样便于后期维护时,根据对外的变量和函数来做处理。
+class COptionAction(CBaseLog):
+    # ==============设备对象============== #
+    # 红老鼠遥控对象;
+    __redRat3 = TvOperator()
+    # 创建视频采集对象
+    __ccard = CCardManager()
+    # 图片切割对象
+    __imgCMP = ImageCMP()
+
+    # 发送鲜活键;
+    @staticmethod
+    def __sendAliveKey(aliveKey):
+        if aliveKey is not None:
+            COptionAction.__redRat3.sendKey(aliveKey, 1, 0.1)
+
+    def __init__(self, optionName, optionValue, optionConfig, optionExcel):
+        # 层级位置;
+        self.__pos = 0
+        self.__optionName = optionName
+        # __optionValue可空;
+        self.__optionValue = optionValue
+        self.__optionExcel = optionExcel
+        self.__optionConfig = optionConfig
+        # 焦点定位及文字识别;
+        self.__optionFocus = COptionFocus(optionConfig)
+        self.__optionOCR = COptionOCR(optionConfig, optionExcel)
+        if self.__optionExcel is None:
+            self.error(u"表格对象空")
+        # ==============常用对象数据==============;
+        self.__optionPaths = self.__optionExcel.getOptionPaths(self.__optionName)
+        # 如果__optionValue空则不取value表任何内容;
+        if self.__optionValue != "":
+            self.__optionValues = self.__optionExcel.getOptionValueInfo(self.__optionName, self.__optionValue)
+        self.__optionInfo = self.__optionExcel.getOptionInfo(self.__optionName)
+        # 当前状态下的变量
+        self.__curOptionName = ''
+        self.__curOptionInfo = None
+
+    '''
+    函数:
+    参数:
+    注意:
+    返回:
+    
+    测试:。
+    '''
+
+    def strSplit(self, text):
+        ret = []
+        str_int = ''
+        str_ch = ''
+        ch_last = ' '
+        for ch in text:
+            if 47 < ord(ch) < 58:
+                str_int += ch
+                if str_ch.__len__():
+                    ret.append(str_ch)
+                    str_ch = ''
+            else:
+                if 47 < ord(ch_last) < 58 and ch == '.':
+                    str_int += ch
+                    if str_ch.__len__():
+                        ret.append(str_ch)
+                        str_ch = ''
+                else:
+                    str_ch += ch
+                    if str_int.__len__():
+                        ret.append(str_int)
+                        str_int = ''
+            ch_last = ch
+        if str_ch.__len__():
+            ret.append(str_ch)
+        if str_int.__len__():
+            ret.append(str_int)
+        return ret
+
+    # 截图;
+    def takePicture(self):
+        pic = os.path.join(getSATTmpDIR(), "menutree_runpath.png")
+        COptionAction.__ccard.takePicture(pic)
+        return pic
+
+    # 调用根节点快捷键(中间节点不需要快捷键;);
+    def callFirstOptionShortCutKey(self):
+        if 'shortcut_key' in self.__optionPaths['First']:
+            COptionAction.__redRat3.sendKey(self.__optionPaths['First']['shortcut_key'])
+        else:
+            COptionAction.__redRat3.sendKey(self.__optionPaths['First']['parent'])
+            self.warn(u"表格没有shortcut_key字段,执行默认的parent按键:%s" % self.__optionPaths['First']['parent'])
+
+    # 调用当前结点的toparent_key;
+    def callCurOptionBackKey(self, curOptionName):
+        curOptionInfo = self.__optionExcel.getOptionInfo(curOptionName)
+        if 'toparent_key' in self.__optionPaths[curOptionInfo['level']]:
+            COptionAction.__redRat3.sendKey(self.__optionPaths[curOptionInfo['level']]['toparent_key'])
+        else:
+            self.error(u"表格没有toparent_key字段,执行默认按键return")
+            COptionAction.__redRat3.sendKey('return')
+
+    '''
+    函数:打开指定的option(到达option后,执行enter_key进入)。
+    参数:
+    返回:
+    示例:
+
+    测试:。
+    '''
+
+    def openOption(self, optionName):
+        pass
+
+    '''
+    函数:是否在父节点菜单上。一般在执行了callFirstOptionShortCutKey后调用;
+    参数:
+    返回:
+    注意:由于所有父节点上的子项都共用一个图片定位参数,所以只要随意一个父节点的子项option即可获取定位参数;
+    示例:
+    
+
+    测试:。
+    '''
+
+    def isOnFirstOption(self):
+        pic = self.takePicture()
+        return self.__optionFocus.findFocusByIcon(pic, self.__optionPaths['First']['option'])[0]
+
+    '''
+    函数:是否在目标节点(移动时,每一个目标option,并不仅是终点目标option)上.
+    说明:
+        每次移动到下一目标节点(option)上时,self.__pos + 1,表示移动到下一层路径。
+        当self.__pos >= self.__optionPaths.__len__()时,表示到达value表格;
+        所以,该类的重点在self.__pos的移动;
+    参数:
+    返回:Boolean, 识别的文本/数字;
+    示例:
+    
+    测试:。
+    '''
+
+    def isOnTargetOption(self):
+        # 析出参数;
+        curLevel = g_level[self.__pos]
+        curParent = self.__optionPaths[curLevel]['parent']
+        curOption = self.__optionPaths[curLevel]['option']
+        curOthers = json.loads(self.__optionPaths[curLevel]['others'])
+        firstParent = self.__optionPaths['First']['option']
+        # 是否在value表中;
+        if self.__optionValue == "":
+            isValueSheet = False
+        else:
+            isValueSheet = True if self.__pos >= self.__optionPaths.__len__() else False
+
+        # 获取文本识别的参数;
+        ocrConfigList = self.__optionConfig.getOptionOCRConfig(curOption)
+        ocrThreshold = self.__optionConfig.getThresholdDict(firstParent)  # 注意,此处使用firstParent;
+        # 获取当前option的ocr值/value name下所有ocr值;
+        if isValueSheet:
+            optionTextList = self.__optionExcel.getOptionValueText(curOption)
+        else:
+            optionTextList = self.__optionExcel.getOptionText(curOption)
+        # 获取option下所有兄弟项的ocr:option字典内容;
+        siblingTextDict = self.__optionExcel.getOptionAllSiblingItemDict(curOption, not isValueSheet)
+        # 获取所有option兄弟项(包括自己)的ocr值;
+        siblingTextList = list(siblingTextDict.keys())
+
+        # 是否获取数值文本;
+        isNumberText = False
+        # 如果是value表,且兄弟项文本为range
+        # 注:value表中的option实际并没有兄弟项,取的是所有value项
+        if isValueSheet and siblingTextList.__len__():
+            if siblingTextList[0].startswith('range('):
+                isNumberText = True
+
+        # 是否为静态焦点识别(动态则为跑马灯);
+        if curOthers.__len__() and 'marquee' in curOthers:
+            pic = self.takePicture()
+            return self.__getDynamicPicText(pic, curOption, optionTextList, siblingTextList, ocrConfigList, ocrThreshold, curOthers['marquee'],
+                                            isNumberText, isValueSheet)
+        else:
+            return self.__getStaticPicText(curOption, optionTextList, siblingTextList, ocrConfigList, ocrThreshold,
+                                           isNumberText, isValueSheet)
+        # endif
+
+    # 获取静态图片文本内容;
+    def __getStaticPicText(self, pic, optionName, optionTextList, siblingTextList, ocrConfigList, ocrThreshold, isNumberText,
+                           isValueSheet, aliveKey=None):
+        # 获取图片焦点框;
+        found, focusBox = self.__optionFocus.findFocusByIcon(pic, optionName, isValueSheet)
+        if found is False:
+            self.debug(u"未找到[%s]聚集框" % optionName)
+            return False, None
+
+        # 如果有鲜活键;
+        COptionAction.__sendAliveKey(aliveKey)
+
+        # 获取文本区域框;
+        textBox = self.__optionFocus.getFocusTextBox(optionName, focusBox, isValueSheet)
+        # 配置文本图片路径,保存文本区域截图;
+        text_pic = os.path.join(getSATTmpDIR(), "meuttree_area_text.png")
+        self.__imgCMP.saveCropImage(pic, text_pic, textBox)
+        if not os.path.exists(text_pic):
+            self.error(u"%s截取文本图片失败:%s" % (optionName, text_pic))
+            return False, None
+
+        # 是否在某个兄弟项中;
+        isOnSibling = False
+        # 遍历所有ocr识别选项;
+        for ocrConfig in ocrConfigList:
+            # 如果有鲜活键;
+            COptionAction.__sendAliveKey(aliveKey)
+            # 识别出当前聚焦文本;
+            curFocusText = self.__optionOCR.getImageText(text_pic, ocrConfig, ocrThreshold)
+            # 判断识别文本是来正常;
+            if curFocusText == "ERR<Exp>" or curFocusText.__len__() == 0:
+                continue
+
+            self.info("[%s]当前识别出的文本=%s" % (optionName, curFocusText))
+
+            # 是否取数字文本;
+            if isNumberText is True:
+                # 特殊情况处理:某些情况下,会将包含数字以外的区域一起识别;
+                curFocusText = curFocusText.strip('>')
+                # 将数字分组
+                numberTextList = self.strSplit(curFocusText)
+                # 只判断最后一位是否为数字;
+                if numberTextList.__len__() < 1:
+                    self.error(u"当前识别的文本不是数字文本:%s" % curFocusText)
+                    continue
+
+                try:
+                    numberText = numberTextList[numberTextList.__len__() - 1]
+                    return True, float(numberText)
+                except Exception:
+                    continue
+            else:
+                # 当前option识别的文本与所有兄弟项文本比较;
+                for siblingText in siblingTextList:
+                    # 转为小写,保证所有比较都是小写;
+                    siblingText = siblingText.lower()
+                    # 兄弟项文本是否被包含在curFocusText中或相同;
+                    if siblingText in curFocusText or strcmp(siblingText, curFocusText):
+                        isOnSibling = True
+                        self.info(u"当前焦点在[%s], 目标焦点为[%s]" % (siblingText, optionName))
+                        # 再判断,该兄弟项是否为目标节点(curOption);
+                        for optionText in optionTextList:
+                            optionText = optionText.lower()
+                            # 若当前兄弟项为目标option返回True、文本;
+                            if strcmp(optionText, siblingText):
+                                return True, curFocusText
+                            # endif
+                        # endfor
+                        # 在兄弟项中,退出循环;
+                        break
+                    # endif
+                # endfor
+
+                if isOnSibling is False:
+                    self.error(u"未聚集到任何[%s]的兄弟项中" % optionName)
+                else:
+                    self.info("未聚集到目标节点[%s],当前文本=%s" % (optionName, curFocusText))
+                    return False, curFocusText
+            # endif
+        # endfor
+
+        # 默认返回;
+        return False, 0 if isNumberText else ""
+
+    # 获取动态图片文本内容;
+    def __getDynamicPicText(self, optionName, optionTextList, siblingTextList, ocrConfigList, ocrThreshold, marqueeDict, isNumberText, isValueSheet):
+        # 判断图片是否动态:截图两次,判断两次文本内容是否相同;
+        firstRetsult, firstText = self.__getStaticPicText(self.takePicture(), optionName, optionTextList, siblingTextList, ocrConfigList,
+                                                          ocrThreshold, isNumberText, isValueSheet)
+        if firstRetsult is False:
+            self.error(u"[%s]第一次截图未识别出聚焦框" % optionName)
+            return False, None
+
+        # 发送鲜活键, 保证界面鲜活;
+        COptionAction.__sendAliveKey(marqueeDict['alive_key'])
+        # 第二次截图;
+        secondRetsult, secondText = self.__getStaticPicText(self.takePicture(), optionName, optionTextList, siblingTextList, ocrConfigList,
+                                                            ocrThreshold, isNumberText, isValueSheet)
+        if secondRetsult is False:
+            self.error(u"[%s]第二次截图未识别出聚焦框" % optionName)
+            return False, None
+
+        # 发送鲜活键, 保证界面鲜活;
+        COptionAction.__sendAliveKey(marqueeDict['alive_key'])
+        # 比较两文本是否相同;
+        if firstText.__len__() and firstText == secondText:
+            return True, firstText
+
+        # 文本不相同,为动态图片;
+        menuList = marqueeDict['menu']
+        # 如果只有一项跑马灯,且目标option亦在跑马灯列表中,则直接返回成功结果
+        if menuList.__len__() == 1 and (optionName in menuList):
+            return True, firstText
+
+        picList = []
+        # 如果有多项同级option都是跑马灯, 要成功识别文本需要间隔截图5次(大概会成功截图到最全的文本);
+        for i in range(0, 5):
+            picList.append(self.takePicture())
+            # 间隔多久截图;
+            time.sleep(marqueeDict['sleep_time'])
+            # 发送鲜活键;
+            COptionAction.__sendAliveKey(marqueeDict['alive_key'])
+
+        ocrTextList = []
+        # 对截图进行文本识别分析;
+        for pic in picList:
+            result, text = self.__getStaticPicText(pic, optionName, optionTextList, siblingTextList, ocrConfigList, ocrThreshold, isNumberText, isValueSheet, marqueeDict['alive_key'])
+            if result is True:
+                ocrTextList.append(text)
+            # 发送鲜活键;
+            COptionAction.__sendAliveKey(marqueeDict['alive_key'])
+
+
+        return False, 0 if isNumberText else None
+
+    def move2NextSiblingOption(self, optionName):
+        pass
+
+    def move2PrevSiblingOption(self, optionName):
+        pass
+
+    def back2ParentOption(self):
+        pass
+
+
+if __name__ == "__main__":
+    exData = CExtraData()
+    optionExcel = COptionExcel(exData)
+    optionConfig = COptionConfig(exData, optionExcel)
+    optionAction = COptionAction('picture', '', optionConfig, optionExcel)
+    # ====================================== #
+    optionAction.callFirstOptionShortCutKey()

+ 45 - 4
ssat_sdk/MenuTree3/OptionExcel.py

@@ -294,10 +294,11 @@ class COptionExcel(CBaseLog):
         pass
 
     '''
-    函数:获取指定option/value_name下的所有兄弟项(相同parent)的 ocr:option 字典值;
+    函数:获取指定option/value_name下的所有兄弟项(包括自己,相同parent)的 ocr:option 字典值;
     参数:
         optionName      指定的option节点(也可以是value name);
         isOption        是否为路径节点,True路径节点,False为value表的value name节点;
+    注:value表中的option实际并没有兄弟项,取的是该option(value name)所有value项
     返回:字典
     示例:
         {
@@ -407,6 +408,40 @@ class COptionExcel(CBaseLog):
         # 返回结果;
         return list_ocr
 
+    def getOptionAllSiblingItemTextList2d(self, optionName):
+        # 编码转换;
+        if type(optionName) == str:
+            optionName = unicode(optionName)
+
+        found = False
+        list_ocr = []
+        # 首先,字典不排序,需要倒序;
+        paths = reversed(self.__pathParams.paths)
+        for level in paths:
+            for parent in self.__pathParams.paths[level]:
+                for vals in self.__pathParams.paths[level][parent]["value"]:
+                    if vals['option'].lower() == optionName.lower():
+                        found = True
+                        break
+                # endfor
+                # 找到退出;
+                if found is True:
+                    break
+            # endfor
+            # 找到退出;
+            if found is True:
+                break
+        # endfor
+
+        # 遍历value列表;
+        if found is True:
+            for val in self.__pathParams.paths[level][parent]["value"]:
+                list_ocr.append(val['option_for_ocr'].split(';'))
+        # 按长度排序;
+        list_ocr.sort(key=lambda i: len(i), reverse=True)
+        # 返回结果;
+        return list_ocr
+
     '''
     函数:获取指定option的ocr文本描述,以list返回
     参数:optionName   要返回文本描述的option节点
@@ -510,16 +545,22 @@ class COptionExcel(CBaseLog):
     
     测试:通过。对应UIT_tree中的getValueTextList。
     '''
-    def getOptionValueText(self, optionName, value):
+    def getOptionValueText(self, optionName, value=""):
         valueTextList = []
         if optionName in self.__valueParams.values:
             valueDictList = self.valueParams.values[optionName]["value"]
             for valueDict in valueDictList:
-                if valueDict["value"] == value:
+                if value == "":
+                    value_for_ocr = valueDict["value_for_ocr"]
+                    valueTextList = value_for_ocr.split(';')
+                elif valueDict["value"] == value:
                     value_for_ocr = valueDict["value_for_ocr"]
                     valueTextList = value_for_ocr.split(';')
                     break
-
+                #endif
+            #endfor
+        #endif
+        # 返回结果;
         return valueTextList
 
     '''

+ 22 - 18
ssat_sdk/MenuTree3/OptionFocus.py

@@ -12,24 +12,28 @@ import cv2 as cv
 import json
 from BaseLog import CBaseLog
 from OptionConfig import COptionConfig
+from ExtraData import CExtraData
+from OptionConfig import COptionConfig
+from OptionExcel import COptionExcel
 
 # 测试加头文件;
 from UIT_PathManage import UITPathManage
 
 
 class COptionFocus(CBaseLog):
-    def __init__(self, configManager):
+    __rgbColor = RGBColor()
+    __CIE = CIEluvCaculator()
+    __fd = FeatureDetect()
+
+    def __init__(self, optionConfig):
         # CConfigManager对象;
-        self.__configManager = configManager
-        if self.__configManager is None:
+        self.__optionConfig = optionConfig
+        if self.__optionConfig is None:
             self.error("configManger对象空")
-        self.__rgbColor = RGBColor()
-        self.__CIE = CIEluvCaculator()
-        self.__fd = FeatureDetect()
         # 当前电视机分辨率(通过截图查看图片大小);
         self.__tvResolution = None
         # icon原始分辨率;
-        self.__iconResolution = self.__configManager.getICONResolutionConfig()
+        self.__iconResolution = self.__optionConfig.getICONResolutionConfig()
         '''
         dir.png的用法:
         每个dir图片,必定会有一个icon图片。而icon实际上是dir的二次截图,从里抠出来的一块颜色图片。
@@ -80,12 +84,12 @@ class COptionFocus(CBaseLog):
             return False, None
 
         # 获取icon平均bgr值;
-        icon_bgr = self.__rgbColor.getAvgBGR(icon_img)
+        icon_bgr = COptionFocus.__rgbColor.getAvgBGR(icon_img)
 
         # 返回查找结果,失败返回 False, None; 成功返回(焦点的坐标点) True, [l,t,r,b]
-        return self.__fd.findCurrentFoucsByColor(src_pic, [], icon_bgr, icon_cfg['offset'],
-                                                 icon_cfg['minPeri'], icon_cfg['maxPeri'],
-                                                 icon_cfg['minArea'], icon_cfg['maxArea'], morphology)
+        return COptionFocus.__fd.findCurrentFoucsByColor(src_pic, [], icon_bgr, icon_cfg['offset'],
+                                                         icon_cfg['minPeri'], icon_cfg['maxPeri'],
+                                                         icon_cfg['minArea'], icon_cfg['maxArea'], morphology)
 
     '''
     函数:根据Option的icon配置来查找聚集框;
@@ -102,9 +106,9 @@ class COptionFocus(CBaseLog):
     def findFocusByIcon(self, src_pic, curOptionName, isValueSheet=False):
         result, opc_cfg = False, {}
         if isValueSheet:
-            result, opc_cfg = self.__configManager.getValueICONConfig(curOptionName)
+            result, opc_cfg = self.__optionConfig.getValueICONConfig(curOptionName)
         else:
-            result, opc_cfg = self.__configManager.getOptionICONConfig(curOptionName)
+            result, opc_cfg = self.__optionConfig.getOptionICONConfig(curOptionName)
 
         # 根据源图获取当前电视分辨率;
         self.__getTvResolution(src_pic)
@@ -132,9 +136,9 @@ class COptionFocus(CBaseLog):
     def getFocusTextBox(self, curOptionName, curFocusBox, isValueSheet=False):
         result, opc_cfg = False, {}
         if isValueSheet:
-            result, opc_cfg = self.__configManager.getValueICONConfig(curOptionName)
+            result, opc_cfg = self.__optionConfig.getValueICONConfig(curOptionName)
         else:
-            result, opc_cfg = self.__configManager.getOptionICONConfig(curOptionName)
+            result, opc_cfg = self.__optionConfig.getOptionICONConfig(curOptionName)
 
         if result is False:
             self.warn(u"获取【%s】的icon配置失败,将使用聚集框作为文本框坐标" % curOptionName)
@@ -183,9 +187,9 @@ class COptionFocus(CBaseLog):
 
 
 if __name__ == "__main__":
-    tData = CTData()
-    upath = UITPathManage(tData)
-    opcfg = COptionConfig(r'D:\SAT\resource\MenuTree\RT2851\2851', upath)
+    exData = CExtraData()
+    optionExcel = COptionExcel(exData)
+    opcfg = COptionConfig(exData, optionExcel)
     opfocus = COptionFocus(opcfg)
 
     res, Box = opfocus.findFocusByIcon("", "picture")

+ 9 - 7
ssat_sdk/MenuTree3/OptionOCR.py

@@ -15,6 +15,11 @@ from UIT_PathManage import UITPathManage
 
 
 class COptionOCR(CBaseLog):
+    # 创建OCR对象
+    __ocr = OCRConvert()
+    # 图片切割对象
+    __imgCMP = ImageCMP()
+
     def __init__(self, optionConfig, optionExcel):
         # COptionConfig对象;
         self.__optionConfig = optionConfig
@@ -22,10 +27,7 @@ class COptionOCR(CBaseLog):
             self.error("configManger对象空")
         # 路径对象;
         self.__optionExcel = optionExcel
-        # 创建OCR对象
-        self.__ocr = OCRConvert()
-        # 图片切割对象
-        self.__imgCMP = ImageCMP()
+
 
     '''
     函数:获取指定原图中指定的文本区域内的文本内容;
@@ -69,7 +71,7 @@ class COptionOCR(CBaseLog):
 
         # 配置文本图片路径,保存文本区域截图;
         text_pic = os.path.join(getSATTmpDIR(), "meuttree_area_text.png")
-        self.__imgCMP.saveCropImage(src_img, text_pic, text_box)
+        COptionOCR.__imgCMP.saveCropImage(src_img, text_pic, text_box)
         # 判断文本图片是否存在;
         if not os.path.exists(text_pic):
             self.error(u"【%s】保存文本区域截图失败" % optionName)
@@ -80,7 +82,7 @@ class COptionOCR(CBaseLog):
         threshold = self.__optionConfig.getThresholdDict(optionName)
 
         # 识别文本图片内容;
-        optionText = self.__ocr.getStrWithImgProcess(text_pic, threshold, ocr_config['lan'], ocr_config['type'],
+        optionText = COptionOCR.__ocr.getStrWithImgProcess(text_pic, threshold, ocr_config['lan'], ocr_config['type'],
                                                      reconTimes=1)
 
         self.info(u"【%s】识别结果=%s" % (optionName, optionText))
@@ -103,7 +105,7 @@ class COptionOCR(CBaseLog):
             return None
 
         # 识别文本图片内容;
-        imgText = self.__ocr.getStrWithImgProcess(text_pic, threshold, ocr_config['lan'], ocr_config['type'],
+        imgText = COptionOCR.__ocr.getStrWithImgProcess(text_pic, threshold, ocr_config['lan'], ocr_config['type'],
                                                   reconTimes=1)
 
         self.info(u"【%s】识别结果=%s" % (text_pic, imgText))

+ 3 - 86
ssat_sdk/MenuTree3/TMenu.py

@@ -394,13 +394,13 @@ class CTMenu():
         str_ch = ''
         ch_last = ' '
         for ch in str:
-            if ord(ch) > 47 and ord(ch) < 58:
+            if 47 < ord(ch) < 58:
                 str_int += ch
                 if str_ch.__len__():
                     ret.append(str_ch)
                     str_ch = ''
             else:
-                if ord(ch_last) > 47 and ord(ch_last) < 58 and ch == '.':
+                if 47 < ord(ch_last) < 58 and ch == '.':
                     str_int += ch
                     if str_ch.__len__():
                         ret.append(str_ch)
@@ -1477,90 +1477,7 @@ class CTMenu():
                     str(option), str(value_excel), str(error_uiPic)))
                 return False
 
-    # 对外接口:信源设置接口;本方法(先识别再切换)NT72项目由于界面消失太快不适用,下面封的接口逻辑(先切换再识别)
-    # def setSourceValue(self, option, value, sourceWaitTime=1.0, Max_Try=10):
-    #     printLog(u"开始执行setSourceValue。option:%s  value:%s" % (str(option), str(value)))
-    #     # self.get_ocr_list('First', 'source')
-    #     # 获取menu path;
-    #     value_params, path_params = self.xlsparser.get_menu_paths(option, value)
-    #     # print "value_params:", value_params
-    #     printLog(u"获取设置信源value:%s的值字典value_params:%s" % (str(value), str(value_params)))
-    #     value_for_ocr = value_params['value_for_ocr']
-    #
-    #     old_text = "init_old_text"
-    #
-    #     enter_key = value_params["enter_key"]
-    #     move_key = value_params["move_key"]
-    #     if str(move_key) == str([u'up', u'down']):
-    #         findDirection = "down"
-    #         findReverseDirection = "up"
-    #     else:
-    #         findDirection = "right"
-    #         findReverseDirection = "left"
-    #     # 正向寻找的次数计数和最大次数
-    #     count = 0
-    #     Max_Try = Max_Try
-    #     # 反向寻找的次数计数和最大次数
-    #     Reversecount = 0
-    #     Reverse_Max_Try = Max_Try * 2
-    #     sourceWaitTime = self.tconfig.get_value("waitTime", "sourceWaitTime")
-    #     if not sourceWaitTime:
-    #         sourceWaitTime = 1.0
-    #     while True:
-    #         if count >= Max_Try and Reversecount >= Reverse_Max_Try:
-    #             return False
-    #         time.sleep(2)
-    #         self.redRat3.sendKey('source')
-    #         time.sleep(sourceWaitTime)
-    #         isFind, text = self.getCurrentFocusTextEx('First', 'source', 'source', option, value_for_ocr, True)
-    #         if isFind == -1:
-    #             # 6586自研机芯USB进入之后无法唤出信源 按return再一次按source呼出界面
-    #             self.redRat3.sendKey("return")
-    #             self.redRat3.sendKey('source')
-    #             time.sleep(0.2)
-    #             isFind, text = self.getCurrentFocusTextEx('First', 'source', 'source', option, value_for_ocr, True)
-    #             if isFind == -1:
-    #                 printLog(u"当前界面找不到焦点!即source没有调出信源界面")
-    #                 return False
-    #
-    #         if isFind == 1:
-    #             printLog(u"聚焦到目标option:%s,设置信源value:%s选项成功!" % (str(option), str(value)))
-    #             # 聚焦成功发送enter_key
-    #             self.redRat3.sendKey('ok')
-    #             return True
-    #             # 判断两次识别
-    #         print "text:", text, "old_text:", old_text, self.ocr.cmpOcrStr(text, old_text)
-    #
-    #         # 判断信源界面有没有消失  如果消失再次按出信源界面
-    #         isFind_source, text = self.getCurrentFocusTextEx('First', 'source', 'source', option, value_for_ocr, True)
-    #         if isFind_source == -1:
-    #             self.redRat3.sendKey('source')
-    #             time.sleep(sourceWaitTime)
-    #
-    #         # 判断两次识别的text是否相等来判断是否到达边界
-    #         if self.ocr.cmpOcrStr(text, old_text):
-    #             # 如果已经到达边界则不再正方向寻找焦点
-    #             count = Max_Try
-    #             old_text = "init_old_text"
-    #         else:
-    #             old_text = text
-    #
-    #         if count < Max_Try:
-    #             count = count + 1
-    #             self.redRat3.sendKey(findDirection)
-    #             self.redRat3.sendKey('ok')
-    #         else:
-    #             Reversecount = Reversecount + 1
-    #             self.redRat3.sendKey(findReverseDirection)
-    #             self.redRat3.sendKey('ok')
-    #
-    #     errorPngName = "menutree_error_" + str(option) + '_' + str(value) + self.currentTime() + ".png"
-    #     error_uiPic = os.path.join(getSATTmpDIR(), errorPngName)
-    #     self.ccard.takePicture(error_uiPic)
-    #     printLog(u"设置信源值时,正向遍历%s次,和反向遍历%s次都没有聚焦到option:%s的value:%s选项中,截图为%s" % (
-    #         str(Max_Try), str(Reverse_Max_Try), str(option), str(value), str(error_uiPic)))
-    #     return False
-
+    
     # 对外接口:信源设置接口;  先切换再识别
     '''
     不允许切换信源,在MenuTree.ini文件中配置:source={"offset":20,"minPeri":0,"maxPeri":0,"minArea":0,"maxArea":0,"enable":0}。