def __T_01_scanBarCode_M(product): u'''扫描条码-扫描环保卡上面印刷的条码''' barCode = askForSomething(u"扫描条码", u"请扫描卡片表面的条码",autoCommit=False) while re.match(BAR_CODE_REGX, barCode) is None: barCode = askForSomething(u"扫描条码", u"条码扫描错误,请重新扫描",autoCommit = False) product.addBindingCode(u"条码",barCode) product.setTestingSuiteBarCode(barCode) return {u"条码":barCode}
def T_01_scanBarCode_M(product): u'''扫描整机条码-扫描整机条码''' barCode = askForSomething(u"扫描条码", u"请扫描整机条码", autoCommit=False) while not __checkBarCode(barCode): barCode = askForSomething(u"扫描条码", u"整机条码扫描错误,请重新扫描", autoCommit=False) product.setTestingSuiteBarCode(barCode) product.addBindingCode(u"整机条码", barCode) return {u"整机条码": barCode}
def __paramSetting(): '''基础参数设置:包含EPC长度、USER长度、EPC固定值''' PARAM["gs15epcLength"] = int(askForSomething(u"EPC长度设置",u"请输入EPC区长度,单位:字(WORD,1WORD = 2Byte = 16bit)",autoCommit=False,defaultValue=PARAM["gs15epcLength"])) PARAM["fixEpc"] = askForSomething(u"固定EPC内容",u"请输入要写入EPC区的固定内容,16进制表示",autoCommit=False,defaultValue=PARAM["fixEpc"]).upper() while not __checkHexAvailable(PARAM["gs15epcLength"],PARAM["fixEpc"]): PARAM["fixEpc"] = askForSomething(u"固定EPC内容",u"输入有误!\n请输入要写入EPC区的固定内容,16进制表示",autoCommit=False,defaultValue=PARAM["fixEpc"]).upper() PARAM["gs15userLength"] = int(askForSomething(u"USER区长度设置",u"请输入USER区长度,单位:字(WORD,1WORD = 2Byte = 16bit)",autoCommit=False,defaultValue=PARAM["gs15userLength"])) SESSION["configed"] = True
def T_00_scanBarCode_A(product): u'''扫描条码-扫描条码,成功后合上夹具''' barCode = askForSomething(u"扫描条码", u"请扫描单板条码") while not __checkBarCode(barCode): barCode = askForSomething(u"扫描条码", u"条码扫描错误,请重新扫描") uiLog(u'单板条码扫描结果:' + barCode) product.setTestingSuiteBarCode(barCode) __closeClapFinallyAndStartTest(product)
def T_01_scanAllCode_A(product): u'扫码条码并写入MAC-扫码单板、整机条码分配MAC并写入' barCode1 = askForSomething(u'扫描条码', u'请扫描RSDB0单板条码', autoCommit=False) __checkManualFinished(barCode1) barCode3 = askForSomething(u'扫描条码', u'请扫描整机条码', autoCommit=False) while not __checkBarCodeAll(barCode3): barCode3 = askForSomething(u"扫描条码", u"整机条码扫描错误,请重新扫描", autoCommit=False) product.setTestingProductIdCode(barCode3) product.setTestingSuiteBarCode(barCode1) with ServerBusiness(testflow=True) as sb: getMac = sb.getBindingCode(productName=u"RD50C_RSU", idCode=barCode3, bindingCodeName=u"MAC") if getMac is not None and getMac != "": mac = getMac else: mac = serialCode(PARAM["macName"]) if int(mac, 16) > int(PARAM["macMax"], 16): raise AbortTestException(message=u"MAC地址超出范围,没有可分配mac") product.addBindingCode(u"MAC", mac) getMac2 = sb.getBindingCode(productName=u"RD50C_RSU", idCode=barCode3, bindingCodeName=u"MAC2") if getMac2 is not None and getMac2 != "": mac2 = getMac2 else: mac2 = serialCode(PARAM["macName"]) if int(mac2, 16) > int(PARAM["macMax"], 16): raise AbortTestException(message=u"MAC地址超出范围,没有可分配mac") product.addBindingCode(u"MAC2", mac2) for i in range(10): pingResult = pingIPOpen(PARAM["defaultNetOneIp"]) if pingResult == "ok": break time.sleep(5) else: raise TestItemFailException(failWeight=10, message=u"连接失败有可能是网口通信问题") macoffset = 0x46 myWriteMac(macoffset, mac) macstrRead = myReadMac(macoffset) macoffset2 = 0x40 myWriteMac(macoffset2, mac2) macstrRead2 = myReadMac(macoffset2) if macstrRead.upper() == mac and macstrRead2.upper() == mac2: return { u"单板条码": barCode1, u"整机条码": barCode3, u"MAC1地址": mac, u"MAC2地址": mac2 } else: TestItemFailException(failWeight=10, message=u"写入与分配mac不一致,写入mac失败")
def T_01_scanBare_M(product): u"扫码条码-扫描单板条码" barCode = askForSomething(u"扫描条码", u"请扫描单板条码", autoCommit=False) while len(barCode) != 10: barCode = askForSomething(u"扫描条码", u"条码扫描错误,请重新扫描", autoCommit=False) product.setTestingSuiteBarCode(barCode) product.setTestingProductIdCode(barCode) product.addBindingCode(u"单板条码", barCode) return {u"单板条码": barCode}
def T_01_scanCode_A(product): u'扫码条码3-扫描条码' barCode1 = askForSomething(u'扫描条码', u'请扫描单板条码', autoCommit=False) barCode2 = askForSomething(u'扫描条码', u'请扫描灯板条码', autoCommit=False) __checkManualFinished(barCode1) product.setTestingProductIdCode(barCode1) product.setTestingSuiteBarCode(barCode2) return {u"扫描单板条码结果": barCode1, u"扫描灯板条码结果": barCode2}
def T_01_scanBarCode_M(product): u'''扫描镭雕条码-扫描镭雕条码''' barCode = askForSomething(u"扫描条码", u"请扫描镭雕条码", autoCommit=False) while re.match("X|[0-9]\d{15}", barCode) is None: barCode = askForSomething(u"扫描条码", u"条码扫描错误,请重新扫描", autoCommit=False) product.setTestingSuiteBarCode(barCode) product.addBindingCode(u"镭雕条码", barCode) return {u"镭雕条码": barCode}
def T_01_scanCode_A(product): u'扫码条码-扫描RSDB0单板条码' barCode = askForSomething(u'扫描条码', u'请扫描RSDB0单板条码', autoCommit=False) while not __checkBarCode(barCode): barCode = askForSomething(u'扫描条码', u'RSDB0单板条码扫描错误,请重新扫描', autoCommit=False) product.setTestingSuiteBarCode(barCode) product.setTestingProductIdCode(barCode) return {u"RSDB0单板条码": barCode}
def __paramSetting(): '''参数设置,在固定EPC、不镭雕的设置基础上,增加关于可变EPC的设置''' SESSION["nowTimes"] = 0 #当前这个EPC已经写入了几次了 PARAM["variableEpcStart"] = askForSomething(u"可变EPC起始设置",u"请输入起始EPC编码(16进制表示)\n\ 系统将在此前设置的固定EPC基础上,将变化内容写入末尾\n\ 例如: 固定EPC为112233440000000000000000,可变内容为3005,则最终写入的值为: 112233440000000000003005,并递增 \ ",autoCommit=False,defaultValue=PARAM["variableEpcStart"]) PARAM["carryType"] = int(askForSomething(u"可变EPC进制选择",u"请写入EPC的可变内容的进制:\"10\"表示10进制,\"16\"表示16进制",autoCommit=False,defaultValue=PARAM["carryType"])) PARAM["repeatTimes"] = int(askForSomething(u"同EPC写入次数",u"同一EPC重复多少标签?例如4表示,待同一个EPC写够4个标签后,再进位到下一个EPC",autoCommit=False,defaultValue=PARAM["repeatTimes"])) SESSION["nowVariableEpc"] = PARAM["variableEpcStart"] #开始起始EPC
def T_02_initFactorySetting_A(product): u'''出厂信息写入-写入MAC地址,唤醒灵敏度参数等,通过BSL方式写入并自动判断信息一致''' barCode = askForSomething(u"扫描条码", u"请扫描单板条码", autoCommit=False) while not __checkBarCode(barCode): barCode = askForSomething(u"扫描条码", u"条码扫描错误,请重新扫描", autoCommit=False) __initFactorySetting(product, barCode) return { u"软件版本号": SP("gs10.initParam.softwareVersion"), u"硬件版本号": SP("gs10.initParam.hardwareVersion") }
def T_01_paramSetting_M(product): u'''参数设置-首次运行进行参数设置''' if "configed" not in SESSION: SESSION["nowTimes"] = 0 SESSION["nowCarveTimes"] = 0 __loadCsvFile() lineStart = askForSomething(u"从哪一行开始操作?", u"您需要从该文件的哪一行开始操作?", autoCommit=False, defaultValue='1') SESSION["currentLineInFile"] = int(lineStart) nn, ee = __readEpcAndCarveCodeFromFile() while not manulCheck(title=u"请确认即将开始的内容", content=u"镭雕码:%s\nEPC:%s\n是否确认" % (nn, ee)): global g_csvFile, currentLine g_csvFile.close() currentLine = -1 __loadCsvFile() lineStart = askForSomething(u"从哪一行开始操作?", u"您需要从该文件的哪一行开始操作?", autoCommit=False, defaultValue='1') SESSION["currentLineInFile"] = int(lineStart) nn, ee = __readEpcAndCarveCodeFromFile() SESSION["nowVariableCarve"], SESSION[ "toWriteEpc"] = __readEpcAndCarveCodeFromFile() PARAM["repeatTimes"] = int( askForSomething(u"同EPC写入次数", u"同一EPC重复多少标签?例如4表示,待同一个EPC写够4个标签后,再进位到下一个EPC", autoCommit=False, defaultValue=PARAM["repeatTimes"])) PARAM["gs15userLength"] = int( askForSomething(u"USER区长度设置", u"请输入USER区长度,单位:字(WORD,1WORD = 2Byte = 16bit)", autoCommit=False, defaultValue=PARAM["gs15userLength"])) SESSION["nowTimes"] = 1 PARAM.dumpParameterToLocalFile() SESSION["nowVariableCarve"], SESSION["toWriteEpc"] = nn, ee SESSION["configed"] = True if SESSION["nowTimes"] > PARAM["repeatTimes"]: SESSION["nowTimes"] = 1 SESSION["nowVariableCarve"], SESSION[ "toWriteEpc"] = __readEpcAndCarveCodeFromFile() showDashboardMessage(u"即将写入EPC内容:%s\n \ 即将镭雕的内容:%s,第%d次/共%d次\n\ USER区长度:%d字" % \ (SESSION["toWriteEpc"], SESSION["nowVariableCarve"], SESSION["nowTimes"],PARAM["repeatTimes"], PARAM["gs15userLength"])) SESSION["nowTimes"] += 1
def __paramSetting(): '''参数设置,在普通固定EPC基础上,设置镭雕序列''' PARAM["carvingTidStart"] = int( askForSomething(u"设置镭雕", u"设置镭雕起始TID位数(从0开始,包含)", autoCommit=False, defaultValue=PARAM["carvingTidStart"])) PARAM["carvingTidEnd"] = int( askForSomething(u"设置镭雕", u"设置镭雕终止TID位数(不包含)", autoCommit=False, defaultValue=PARAM["carvingTidEnd"]))
def __scan_box(product, index): nowBar = product.param["nowBoxBarCode"] boxBar = askForSomething(u"扫描条码", u"请扫描第【%d】个位置的条码\r\n应当为:%d" % (index, nowBar), autoCommit=False) while int(boxBar) != nowBar: boxBar = askForSomething(u"扫描条码", u"装配错误,应当装配的小盒条码为:%d" % nowBar, autoCommit=False) __checkBoxTestStatus(boxBar) product.param["nowBoxBarCode"] = product.param["nowBoxBarCode"] + 1 product.addBindingCode(u"位置%d小盒条码" % index, boxBar) return {u"小盒条码": boxBar}
def __scan_obu(product, index): nowBar = product.param["nowObuBarCode"] obuBar = askForSomething(u"扫描镭雕条码", u"请扫描第【%d】个位置的条码\r\n应当为:%d" % (index, nowBar), autoCommit=False) while int(obuBar) != nowBar: obuBar = askForSomething(u"扫描条码", u"装配错误,应当装配的产品镭雕条码为:%d" % nowBar, autoCommit=False) __checkObuTestStatus(obuBar) product.param["nowObuBarCode"] = product.param["nowObuBarCode"] + 1 product.addBindingCode(u"位置%d镭雕条码" % index, obuBar) return {u"镭雕条码": obuBar}
def T_01_scanBoxBarCode_M(product): u'''扫描盒体条码-扫描盒体条码''' if "nextBoxBarCode" in SESSION and SESSION["nextBoxBarCode"] is not None: #前面已经扫描过盒体,直接开始的 boxBarCode = SESSION["nextBoxBarCode"] del SESSION["nextBoxBarCode"] else: boxBarCode = askForSomething(u"扫描条码", u"请扫描盒体条码", autoCommit=False) while re.match(BOX_BAR_CODE_REGX, boxBarCode) is None: boxBarCode = askForSomething(u"扫描条码", u"条码扫描错误,请重新扫描", autoCommit=False) product.setTestingProductIdCode(boxBarCode) product.addBindingCode(u"盒体条码",boxBarCode) product.param["itemBarCodeList_should"] = __generateItemBarCodeSet(boxBarCode) #理论上应该包含的个体条码集合 product.param["itemBarCodeList_actual"] = [] #实际包含的个体条码列表 return {u"盒体条码":boxBarCode}
def __loadCsvFile(): from PyQt4 import QtCore, QtGui, uic fn = askForSomething(u"输入文件名路径", u"请输入您要读取的文件名", autoCommit=False) if fn == "": raise AbortTestException(message="用户取消了设置") uiLog(u"加载写码记录文件:" + fn) global g_csvFile g_csvFile = open(fn, 'r')
def T_02_updateMac_A(product): u'''更新MAC地址-获取新的MAC地址并BSL写入''' manulCheck(u"操作提示", u"请连接整机和工装板的U口线,然后点击确定", "ok") if SESSION["testor"] != u"单机": obuid = serialCode("mac") else: obuid = "" while re.match("^([0-9]|[A-F]|[a-f]){8}$", obuid) is None: obuid = askForSomething(u"MAC地址", u"请输入MAC地址", autoCommit=False, defaultValue="24") uiLog(u"分配测试产品标识:" + obuid) sc = __askForPlateDeviceCom() product.setTestingProductIdCode(obuid) try: sc.startBslWriting(passwordFile) uiLog(u"开始写入MAC地址") sc.save_obu_id(__toBytesarray(obuid)) finally: sc.finishBslWritten() time.sleep(1) sc.clearSerialBuffer()
def T_01_saomiaoCode_A(product): u'扫描条码-RD52整机MAC写入测试' print "准备函数是否清空:", SESSION["AllBarcode"] barCode = askForSomething(u'扫描条码', u'请扫描整机条码', autoCommit=False) SESSION["AllBarcode"] = barCode product.setTestingProductIdCode(barCode) product.setTestingSuiteBarCode(barCode)
def T_01_scanCode_A(product): u'扫码条码4-扫描条码' barCode1 = askForSomething(u'扫描条码', u'请扫描单板条码', autoCommit=False) barCode2 = askForSomething(u'扫描条码', u'请扫描灯板条码', autoCommit=False) barCode3 = askForSomething(u'扫描条码', u'请扫描整机条码', autoCommit=False) barCode4 = askForSomething(u'扫描条码', u'请扫描MAC', autoCommit=False) product.setTestingProductIdCode(barCode3) __checkManualFinished(barCode2) product.setTestingSuiteBarCode(barCode4) product.addBindingCode(barCode3, barCode1) product.addBindingCode(barCode3, barCode2) return { u"扫描单板条码结果": barCode1, u"扫描灯板条码结果": barCode2, u"扫描整机条码结果": barCode3 }
def T_01_scanCode_A(product): u'扫码条码-扫描条码' barCode = askForSomething(u'扫描条码', u'请扫描RSDB0单板条码', autoCommit=False) __checkManualFinished(barCode) product.setTestingProductIdCode(barCode) product.setTestingSuiteBarCode(barCode) return {u"RSDB0单板条码": barCode}
def T_01_initFactorySetting_A(product): u'''出厂信息写入-出厂信息写入(包括MAC地址,唤醒灵敏度参数)''' mac = serialCode("mac") barCode = askForSomething(u"扫描条码", u"请扫描条码", autoCommit=False) product.setTestingSuiteBarCode(barCode) product.setTestingProductIdCode(mac) time.sleep(1) return {"扫描条码结果": barCode, "写入MAC地址": mac}
def T_02_indicateFirstMac_M(product): u'''指定初始MAC地址-首次运行指定MAC地址''' if "localMac" not in SESSION: SESSION["localMac"] = askForSomething(u"确定MAC地址", u"请输入起始MAC地址(只需一次)", autoCommit=False, defaultValue="24FF0001") else: SESSION["localMac"] = "24%.6X" % (int(SESSION["localMac"][2:], 16) + 1) uiLog(u'即将写入的MAC地址:' + SESSION["localMac"]) if "directIndicator" not in SESSION: SESSION["directIndicator"] = askForSomething(u"确定方向", u"请输入按键方向指示(只需一次)", autoCommit=False, defaultValue="00") uiLog(u'方向指示写入:' + SESSION["directIndicator"])
def T_01_scanChestBarCode_M(product): u'''扫描大箱条码''' boxBarCode = askForSomething(u"扫描条码", u"请扫描箱体条码") if re.match("\d{20}", boxBarCode) is None: raise AbortTestException(message=u'扫描盒体条码错误') product.param["startBarCode"] = int(boxBarCode[:18]) product.param["num"] = int(boxBarCode[-2:]) product.param["nowBoxBarCode"] = product.param["startBarCode"] product.setTestingProductIdCode(boxBarCode)
def __paramSetting(): '''参数设置,在普通固定EPC基础上,设置镭雕序列''' PARAM["carvingCode"] = askForSomething(u"镭雕内容", u"请输入起始镭雕内容", autoCommit=False, defaultValue=PARAM["carvingCode"]) PARAM["carveCarryType"] = int( askForSomething(u"镭雕进制选择", u"请写入镭雕内容的进制:\"10\"表示10进制,\"16\"表示16进制", autoCommit=False, defaultValue=PARAM["carveCarryType"])) PARAM["repeatTimes"] = int( askForSomething(u"同号码镭雕次数", u"同一镭雕号码重复多少标签?例如4表示,待该编码镭雕够4个标签后,再进位到下一个编码", autoCommit=False, defaultValue=PARAM["repeatTimes"])) SESSION["nowVariableCarve"] = PARAM["carvingCode"] #开始起始镭雕号码 SESSION["nowCarveTimes"] = 0 #当前已经镭雕了几次了
def T_01_indicateVersionFile_M(product): u'''指定版本文件-首次运行指定版本文件''' if "versionFileName" not in SESSION: SESSION["versionFileName"] = askForSomething( u"确定版本文件", u"请输入版本文件名(只需一次)", autoCommit=False, defaultValue="obu-formal.txt") uiLog(u'即将下载版本文件:' + SESSION["versionFileName"])
def T_01_scanBoxBarCode_M(product): u'''扫描盒体条码''' boxBarCode = askForSomething(u"扫描条码", u"请扫描箱体条码", autoCommit=False) if re.match("\d{18}", boxBarCode) is None: raise AbortTestException(message=u'扫描盒体条码错误', autoCommit=False) product.param["startBarCode"] = int(boxBarCode[:16]) product.param["num"] = int(boxBarCode[-2:]) product.param["nowObuBarCode"] = product.param["startBarCode"] product.setTestingProductIdCode(boxBarCode)
def T_04_laserCarve_M(product): u'''补充镭雕卡面编号-输入卡面编号并进行镭雕''' global carvingCode carvingCode = askForSomething(u"镭雕卡面号", u"输入需要镭雕的内容", defaultValue=carvingCode, autoCommit=False) return uhf_card_overall_with_serial_carving.__carveTest( carvingCode, product)
def __scanAllBarCodes(): # 扫描全部条码 for slot in PARAM["productSlots"].split(","): #if lastSlot is not None:sc.setIndicatorLight(slot,False) #sc.setIndicatorLight(slot,True) try: barCode = askForSomething(u"扫描条码", u"请扫描槽位[%s]的单板条码" % slot, autoCommit=False) except AbortTestException, e: barCode = u"人工中止" BARCODE_CONTAINER[slot] = barCode
def T_01_scanCode_A(product): u'扫码条码-扫描条码' barCode1 = askForSomething(u'扫描条码', u'请扫描RSDB5数字单板条码', autoCommit=False) __checkRSDB5Finished(barCode1) barCode2 = askForSomething(u'扫描条码', u'请扫描RSRB4射频单板条码', autoCommit=False) __checkRSRB4Finished(barCode2) barCode3 = askForSomething(u'扫描条码', u'请扫描整机条码', autoCommit=False) while not __checkBarCode(barCode3): barCode3 = askForSomething(u"扫描条码", u"整机条码扫描错误,请重新扫描", autoCommit=False) product.setTestingProductIdCode(barCode3) product.setTestingSuiteBarCode(barCode1) with ServerBusiness(testflow=True) as sb: getMac = sb.getBindingCode(productName=u"RD52_RSU", idCode=barCode3, bindingCodeName=u"MAC") if getMac is not None and getMac != "": mac = getMac else: mac = serialCode(PARAM["macName"]) if int(mac, 16) > int(PARAM["macMax"], 16): raise AbortTestException(message=u"MAC地址超出范围,没有可分配mac") product.addBindingCode(u"MAC", mac) # mac = serialCode(PARAM["macName"]) # if int(mac, 16) > int(PARAM["macMax"], 16): # raise AbortTestException(message=u"MAC地址超出范围,没有可分配mac") # product.addBindingCode(u"MAC", mac) return { u"RSDB5数字单板条码": barCode1, u"RSRB4射频单板条码": barCode2, u'整机条码': barCode3, u"MAC地址": mac }