def T_02_powerTest_A(product): u"功率测试-测试功率值是否达标,并记录功率值" manulCheck(u"操作提示", u"请将阅读器天线接口连接到频谱仪上,点击OK开始测试", "ok") sa = __getSpecAnlzr() sa.resetForRead() rd201 = __getReader() rd201.setting = True start_new_thread(__asynInven, (rd201, )) time.sleep(0.5) power = sa.readPowerValue() rd201.setting = False res = {u"阅读器发射功率": power} product.addBindingCode(u"发射功率", power) if not (SP("hr.reader.power.low", 34) <= power <= SP( "hr.reader.power.high", 35)): raise TestItemFailException(failWeight=10, message=u'发射功率值不合格', output=res) sa.setForIdleRead() time.sleep(0.5) idlePower = sa.readPowerValue() uiLog(u"空闲时功率:%f" % idlePower) if idlePower > 0: raise TestItemFailException(failWeight=10, message=u'空闲状态依然有功率值:%f' % idlePower, output=res) return res
def T_19_staticCurrent_A(product): u'''静态电流测试-判断静态电流值是否在正常范围内''' try: sc = board_digital.__askForPlateDeviceCom() iob = __getIoBoard() # v = sc.testStaticCurrent() try: device = sc.bslDevice device.make_obu_enter_sleep() iob.output(GS11IOBoardDevice.UART_TX_OUTPUT, True) #切换OBU的UART串口 iob.output(GS11IOBoardDevice.UART_RX_OUTPUT, True) time.sleep(0.5) device.set_small_current_switch(0) current_val = device.read_adc_current() if current_val > 10: print "current_val=", current_val superUiLog("small_current_switch = 0,current_val=" + str(current_val)) raise device.set_small_current_switch(1) current_val = device.read_adc_current() v = sc.convertAdcToCurrent(current_val) finally: iob.output(GS11IOBoardDevice.UART_TX_OUTPUT, False) iob.output(GS11IOBoardDevice.UART_RX_OUTPUT, False) device.set_small_current_switch(0) resultMap = {u"静态电流": v} if v < SP('gs11.staticCurrent.low', 2) or v > SP( 'gs11.staticCurrent.high', 18): raise TestItemFailException(failWeight=10, message=u'静态电流测试不通过,正常阈值4-18', output=resultMap) return resultMap except TestItemFailException, e: raise e
def T_01_readObuId_A(product): u"读取OBU内部标识-通过ICP方式读取OBU的内部标识" nul = board.__getNuLink() try: __switchToNulink() infos = nul.readInfo() superUiLog(u"信息区" + infos) currentSoftVersion = infos[18:26] vf = SP("gs11.vatVersion.filename", "GS11-VAT-09.00.00.version", str) targetVatSoftwareVersion = "".join( vf.split("-")[2].split(".")[:3]) + "00" if currentSoftVersion != targetVatSoftwareVersion: uiLog(u"整机内非测试版本,下载测试版本:" + vf) #下载测试版本 vf = getVersionFile( SP("gs11.vatVersion.filename", "GS11-VAT-09.00.00.version", str)) nul.downloadVersion(vf) #写入测试版本号 CONFIG_BUILD_INFO = infos[:32] CONFIG_RF_PARA = infos[128:154] CONFIG_BUILD_INFO = CONFIG_BUILD_INFO[: 18] + targetVatSoftwareVersion + CONFIG_BUILD_INFO[ 26:] nul.writeToInfo(CONFIG_BUILD_INFO, CONFIG_RF_PARA) except Exception, e: print e raise AbortTestException(u"无法读取内部标识及版本号")
def T_06_esam_A(product): u'''ESAM测试-判断地区分散码是否正确''' sc = __askForPlateDeviceCom() response = sc.sendAndGet(request ='TestESAM').strip() if response.startswith("TestESAMOK"): esam = response[11:] districtCode = esam[-16:-8] esamId = esam[22:30] targetDistrictCode = SP("gs11.esamDistrictCode."+product.getTestingSuiteBarCode()[:2],"",str) if product.getTestingSuiteBarCode()!= "" and districtCode != SP('gs11.esam.defaultDistrict','45544301',str) \ and districtCode != targetDistrictCode(): raise TestItemFailException(failWeight = 10,message = u'ESAM异常,值:'+esam,output={"ESAM":esam}) if esam[22:26] == 'FFFF': raise TestItemFailException(failWeight = 10,message = u'ESAM异常,值:'+esam,output={"ESAM":esam}) return {"ESAM":esam,"ESAMID":esamId} elif response == "ResetFail": raise TestItemFailException(failWeight = 10,message = u'ESAM复位失败,可能是焊接不良') elif response == "SelectMFFail": raise TestItemFailException(failWeight = 10,message = u'ESAM选择MF文件失败,可能是焊接不良') elif response.startswith("SelectMFErrCode"): code = response[-2:] raise TestItemFailException(failWeight = 10,message = u'ESAM选择MF文件错误,错误码:'+code) elif response == "ReadSysInfoFail": raise TestItemFailException(failWeight = 10,message = u'ESAM读系统信息失败') elif response.startswith("ReadSysInfoErrCode"): code = response[-2:] raise TestItemFailException(failWeight = 10,message = u'ESAM读系统信息返回错误,错误码:'+code) elif response == "SelectDFFail": raise TestItemFailException(failWeight = 10,message = u'ESAM选择DF文件失败') elif response.startswith("SelectDFErrCode"): code = response[-2:] raise TestItemFailException(failWeight = 10,message = u'ESAM选择DF文件返回错误,错误码:'+code)
def T_06_initFactoryData_A(product): u"初始化出厂数据-出厂数据及MAC写入Flash" info40000 = SP("cpc.info40000", "55555555000000000200020001000000", str) info40040 = SP("cpc.info40040", "55555555011A090F2000020B0E05013C000302FF", str) info40080 = SP("cpc.info40080", "0102", str) #将MAC写入到中间 info40000 = info40000[:8] + product.param["mac"] + info40000[16:] board = __downloadBoard() uiLog(u"开始初始化单片机信息区") board.writeInfo(product.productSlot, info40000, info40040, info40080) info40000_r, info40040_r, info40080_r = board.readInfo(product.productSlot) if info40000_r.upper() != info40000.upper() or info40040.upper( ) != info40040_r.upper() or info40080.upper() != info40080_r.upper(): raise TestItemFailException(failWeight=10, message=u"初始化信息写入失败") uiLog(u"开始将MAC写入ESAM") board.writeMacToEsam(product.productSlot, product.param["mac"]) targetMac = board.readMacFromEsam(product.productSlot, chooseDf01=False) if targetMac.upper() != product.param["mac"].upper(): raise TestItemFailException(failWeight=10, message=u"MAC写入ESAM失败,读出结果不符") #检测ESAM是否成功创建目录 t_esam = board.test_esam(product.productSlot) if t_esam == 0: uiLog(u"槽[%d] , 刷ESAM目录成功!" % int(product.productSlot)) else: raise TestItemFailException(failWeight=10, message=u"刷ESAM目录失败!") return { "info40000": info40000, "info40040": info40040, "info40080": info40080 }
def T_15_staticCurrent_A(product): u"静态电流测试-读取静态电流值,并判断是否在阈值范围内" try: #staticCurrentRLock.acquire() __stateAtSerial(product) __getIVB().obuTest(product.productSlot).OBUEnterSleep() __getIVB().peripheralCtrl(product.productSlot).channelSelect(0x03) __getIVB().peripheralCtrl(product.productSlot).obuPowerCtrl(0x02) uiLog(u"切换到休眠状态,关闭串口") time.sleep(0.5) vtg = __getIVB().peripheralCtrl( product.productSlot).readObuCurrentVoltage(100) #staticCurrent = (vtg*100)/14.99/1000.0 staticCurrent = (vtg / 1000.0) / 166375.0 resultMap = {u"静态电流": staticCurrent} sl, sh = SP('gs11.staticCurrent.low', 0), SP('gs11.staticCurrent.high', 12e-6) if staticCurrent < sl or staticCurrent > sh: raise TestItemFailException( failWeight=10, message=u'静态电流测试不通过,值:%.2e,正常阈值%.2e-%.2e' % (staticCurrent, sl, sh), output=resultMap) return resultMap except IntegratedVATBoard.DeviceNoResponseException, e: raise AbortTestException(message=u'工装板通信失败,无法继续测试')
def T_03_capacityVoltage_A(product): u'''电容电路电压测试-根据电容电路电压值判断是否满足要求''' r = __askForPlateDeviceCom().assertAndGetNumberParam(request='TestCapPower',response="TestCapPower") result = {u"电容电路电压":r} cl,ch = SP('gs11.overall.capPower.low',2500),SP('gs11.overall.capPower.high',3900) if r < cl or r > ch: raise TestItemFailException(failWeight = 10,message = u'电容电压异常,正常阈值%d-%d'%(cl,ch),output=result) return result
def setup(product): global CURRENT_TESTING_READER try: CURRENT_TESTING_READER.open( 0, SP("rd40.defaultClientIp", "192.168.0.10", str), SP("rd40.defaultClientPort", 5000, int)) except Exception, e: raise AbortTestException(failWeight=10, message=u'打开设备网口失败')
def T_05_batteryVoltage_A(product): u'''电池电路电压测试-判断电池电路电压是否满足要求''' r = __askForPlateDeviceCom().assertAndGetNumberParam(request='TestBattPower',response="TestBattPower") result = {"电池电路电压":r} bl,bh = SP('gs11.batteryPower.overall.low',3200),SP('gs11.batteryPower.overall.high',3900) if r < bl or r > bh: raise TestItemFailException(failWeight = 10,message = u'电池电路电压异常,正常阈值%d-%d'%(bl,bh),output=result) time.sleep(0.1) #这个必须要,否则下面的顺不下去 return result
def T_04_solarVoltage_A(product): u'''太阳能电路电压测试-判断太阳能电路电压是否满足要求''' r = __askForPlateDeviceCom().assertAndGetNumberParam(request='TestSolarPower',response="TestSolarPower") result = {u"太阳能电路电压":r} sl,sh = SP('gs11.solarBatteryPower.overall.low',3300),SP('gs11.solarBatteryPower.overall.high',3800) if r < sl or r > sh: raise TestItemFailException(failWeight = 10,message = u'太阳能电路电压异常,正常阈值%d-%d'%(sl,sh),output=result) time.sleep(0.1) #这个必须要,否则下面的顺不下去 return result
def T_04_BatteryVoltage_A(product): u'''电池电路电压测试-返回电池电路电压值,后台根据配置判定''' with ServerBusiness(testflow=True) as sb: pass product.addBindingCode(u"印刷卡号", "88888") sl, sh = SP('gs11.deepStaticCurrent.low', 2), SP('gs11.deepStaticCurrent.high', 18) return {"sl": sl, "sh": sh} time.sleep(1)
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_02_port4Test_A(product): u"端口4测试-测试端口4的S11/S22/S21的值" manulCheck(u"操作提示",u"请确认功分器单板公共端(7)连接矢网仪1端口,1-6口与工装板连接正确,点击OK开始测试","ok") res = __T_portTest_A(product,4) # 加判S11 s11 = res[u"端口4-S11回损"] product.addBindingCode(u"端口7-S11回损",s11) if not ( SP("hr.divider.port7.S11.low",0) < s11 < SP("hr.divider.port7.S11.high",0)): raise TestItemFailException(failWeight = 10,message = u'端口7-S11回损值不合格',output=res) return res
def __getDistrictCodeFromBarCode(barCode): '''从条码获取ESAM地区分散码,当前只有重庆(50)''' pfx = SP("gs10.boardBarPrefix", "50", str) disCode = SP("gs10.esamDistrictCode." + pfx, "D6D8C7EC", str) if len(barCode) == 12: return "D6D8C7EC" #为兼容12位单板条码,后续都改为14位了 if barCode.startswith(pfx): return disCode else: raise AbortTestException(message=u"单板条码与ESAM地区分散码不匹配,测试终止")
def T_02_wakeupSensitivity_A(product): u'''唤醒灵敏度测试-判断高低灵敏度是否满足标准''' low_level_power = SP('gs10.wakeup.power.low', -40) #低唤醒功率 high_level_power = SP('gs10.wakeup.power.high', -42) #高唤醒功率 sc = __askForPlateDeviceCom() try: lowWakenSensiResult = sc.adjustWakenSensi(low_level_power) except TestItemFailException, e: e.message = u"低灵敏度测试失败" raise e
def T_05_staticCurrent_A(product): u'''静态电流测试-判断静态电流值是否在正常范围内''' try: sc = __askForPlateDeviceCom() v = sc.testStaticCurrent() resultMap = {u"静态电流":v} if v < SP('gs10.staticCurrent.low',4) or v > SP('gs10.staticCurrent.high',18): raise TestItemFailException(failWeight = 10,message = u'静态电流测试不通过,正常阈值4-18',output=resultMap) return resultMap except TestItemFailException,e: raise e
def T_07_marker4_A(product): u"Marker5测试-频率14.32M" vna = __getVNA() s, d2, freq = vna.readMarkerAntFreq(5, 14320000) res = __T_markerJudge(product, s, freq, 5) if not (SP("hr.antenna.marker5.s.low", 0) < s < SP( "hr.antenna.marker5.s.high", 0)): raise TestItemFailException(failWeight=10, message=u'频点5-S值不合格', output=res) return res
def T_03_capacityVoltage_A(product): u'''电容电路电压测试-根据电容电路电压值判断是否满足要求''' sc = __askForPlateDeviceCom() r = sc.assertAndGetNumberParam(request='TestCapPower', response="TestCapPower") result = {"电容电路电压": r} if r < SP('gs10.capPower.low', 3300) or r > SP('gs10.capPower.high', 3800): raise TestItemFailException(failWeight=10, message=u'电容电压异常', output=result) return result
def T_05_marker3_A(product): u"Marker3测试-频率13.56M" vna = __getVNA() s, d2, freq = vna.readMarkerAntFreq(3, 13560000) res = __T_markerJudge(product, s, freq, 3) if not (SP("hr.antenna.marker1.s.low", 0) < s < SP( "hr.antenna.marker1.s.high", 0)): raise TestItemFailException(failWeight=10, message=u'频点3-S值不合格', output=res) return res
def T_02_port4Test_A(product): u"端口4测试-测试端口4的S11/S22/S21的值" res = __T_portTest_A(product, 4) # 加判S11 s11 = res[u"端口4-S11回损"] product.addBindingCode(u"端口7-S11回损", s11) if not (SP("hr.divider.port7.S11.low", 0) < s11 < SP( "hr.divider.port7.S11.high", 0)): raise TestItemFailException(failWeight=10, message=u'端口7-S11回损值不合格', output=res) return res
def T_02_receiveSensitivity_A(product): u'''接收灵敏度测试-记录灵敏度的值''' power_db = SP('gs10.receiveSensitivity.power', -48) frame_num = SP('gs10.receiveSensitivity.frameNum', 500) #发送帧总数 try: sc = __askForPlateDeviceCom() v = sc.testObuRecvSensi(power_db, frame_num) uiLog(u"功率值:%d,唤醒次数:%d" % (power_db, v)) __saveRecordToLocalFile(u"接收灵敏度.txt", str(v)) except Exception, e: print e __saveRecordToLocalFile(u"接收灵敏度.txt", u'失败')
def T_04_solarVoltage_A(product): u'''太阳能电路电压测试-判断太阳能电路电压是否满足要求''' sc = board_digital.__askForPlateDeviceCom() r = sc.assertAndGetNumberParam(request='TestSolarPower', response="TestSolarPower") result = {"太阳能电路电压": r} if r < SP('gs11.solarBatteryPower.overall.low', 3400) or r > SP( 'gs11.solarBatteryPower.overall.high', 3900): raise TestItemFailException(failWeight=10, message=u'太阳能电路电压异常', output=result) return result
def T_03_marker1_A(product): u"Marker1测试-频率12.8M" manulCheck(u"操作提示", u"请确认天线单板与矢网仪连接正确,点击OK开始测试", "ok") vna = __getVNA() s, d2, freq = vna.readMarkerAntFreq(1, 12800000) res = __T_markerJudge(product, s, freq, 1) if not (SP("hr.antenna.marker1.s.low", 0) < s < SP( "hr.antenna.marker1.s.high", 0)): raise TestItemFailException(failWeight=10, message=u'频点1-S值不合格', output=res) return res
def T_06_capacityVoltage_A(product): u"电容电路电压测试-根据电容电路电压值判断是否满足要求" r = __getObuSerial(product.productSlot).assertAndGetNumberParam( request='TestCapPower', response="TestCapPower") result = {"电容电路电压": r} cl, ch = SP('gs11.capPower.board.low', 2500), SP('gs11.capPower.board.high', 3500) if r < cl or r > ch: raise TestItemFailException(failWeight=10, message=u'电容电压异常,正常阈值%d-%d' % (cl, ch), output=result) return result
def T_05_batteryVoltage_A(product): u'''电池电路电压测试-判断电池电路电压是否满足要求''' sc = __askForPlateDeviceCom() r = sc.assertAndGetNumberParam(request='TestBattPower', response="TestBattPower") result = {"电池电路电压": r} if r < SP('gs10.batteryPower.low', 3300) or r > SP( 'gs10.batteryPower.high', 4000): raise TestItemFailException(failWeight=10, message=u'电池电路电压异常', output=result) return result
def T_03_checkEsamDistrictCode_A(product): u'''验证ESAM匹配-验证地区分散码与整机条码''' sc = __askForTrader() pfx = product.getTestingSuiteBarCode()[:2] assertDisCode = SP("gs10.esamDistrictCode." + pfx, "xxxxxxxx", str) defaultDisCode = SP('gs10.esam.defaultDistrict', '45544301', str) dc = sc.readEsamDistrictCode() uiLog(u"整机条码开头:%s,拟验证的地区分散码:%s,实际地区分散码:%s" % (pfx, assertDisCode, dc)) if dc != defaultDisCode and dc != assertDisCode: raise TestItemFailException(failWeight=10, message=u'地区分散码不匹配整机条码', output={u"地区分散码": dc}) return {u"地区分散码": dc}
def T_12_setInitServerIp_A(product): u"设置初始服务IP-设置默认初始服务IP" global CURRENT_TESTING_READER, TC ip = SP("rd40.defaultServerIp", "192.168.0.200", str) port = SP("rd40.defaultServerPort", 5000, int) serverAddrStr = binascii.hexlify(socket.inet_aton(ip)) CURRENT_TESTING_READER.setServerIp(serverAddrStr, port) ret = CURRENT_TESTING_READER.queryServerIp() addr = socket.inet_ntoa(ret[0:4]) port = ord(ret[4]) * 256 + ord(ret[5]) TC.assertEqual(addr, ip) TC.assertEqual(port, port) return {u"初始服务IP": ip}
def T_07_batteryVoltage_A(product): u'''电池电路电压测试-判断电池电路电压是否满足要求''' sc = __askForPlateDeviceCom() r = sc.assertAndGetNumberParam(request='TestBattPower', response="TestBattPower") result = {"电池电路电压": r} if r < SP('gs10.batteryPower.low', 3200) or r > SP( 'gs10.batteryPower.high', 3600): raise TestItemFailException(failWeight=10, message=u'电池电路电压异常,正常阈值3200-3600', output=result) time.sleep(0.1) #这个必须要,否则下面的顺不下去 return result
def T_06_solarVoltage_A(product): u'''太阳能电路电压测试-判断太阳能电路电压是否满足要求''' sc = __askForPlateDeviceCom() r = sc.assertAndGetNumberParam(request='TestSolarPower', response="TestSolarPower") result = {"太阳能电路电压": r} if r < SP('gs10.solarBatteryPower.board.low', 0) or r > SP( 'gs10.solarBatteryPower.board.high', 1000): raise TestItemFailException(failWeight=10, message=u'太阳能电路电压异常,正常阈值0-1000', output=result) time.sleep(0.1) #这个必须要,否则下面的顺不下去 return result
def T_08_batteryVoltage_A(product): u'电池电路电压测试-判断电池电路电压是否满足要求' r = __getObuSerial(product.productSlot).assertAndGetNumberParam( request='TestBattPower', response="TestBattPower") result = {"电池电路电压": r} bl, bh = SP('gs11.batteryPower.board.low', 3200), SP('gs11.batteryPower.board.high', 3600) if r < bl or r > bh: raise TestItemFailException(failWeight=10, message=u'电池电路电压异常,正常阈值%d-%d' % (bl, bh), output=result) time.sleep(0.1) #这个必须要,否则下面的顺不下去 return result