def T_02_sensiSwitchLocationVerify_A(product): u'''灵敏度开关位置判断-进行测试需要确认灵敏度开关在L档''' sc = __askForPlateDeviceCom() r = sc.assertAndGetNumberParam(request='TestSensiSwitch', response='TestSensiSwitch') if r != 0: raise TestItemFailException(failWeight=10, message=u'灵敏度开关不在初始档')
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 setup(product): '''准备函数,同射频相同,读取MAC地址并设置''' SESSION["autoTrigger"].pause() closeAsynMessage() iob = __getIoBoard() if iob.checkClampState() == True: #OBU未插到位 raise AbortTestException(message=u'OBU未插入到位,请检查硬件') iob.releaseDemolishButton() #合上防拆下电按键,使其上电 time.sleep(1) #return uiLog(u"正在读取产品标识...") sc = __askForPlateDeviceCom() try: try: macBytes = sc.read_obu_id(VAT_VERSION_FILE) except Exception, e: if "BSL password error" in e.message: #如果因密码不对读取不到MAC地址,证明版本不是测试版本,且已经被擦除,重新下载测试版本 uiLog(u"OBU中非测试版本,正在下载测试版本...") sc.downloadVersion(version_file=VAT_VERSION_FILE) macBytes = sc.read_obu_id(VAT_VERSION_FILE) else: raise e mac = "".join(["%.2X" % i for i in macBytes]) product.setTestingProductIdCode(mac) uiLog(u"测试产品标识:" + mac) if not SESSION["isMend"]: __checkBoardFinished(mac) iob.pressDemolishButton() time.sleep(0.5) iob.releaseDemolishButton() #合上防拆下电按键,使其上电 time.sleep(0.5)
def T_03_updateInfoFields_A(product): u'''更新信息区数据-更新信息区数据''' sc = __askForPlateDeviceCom() readResult = sc.read_INFO( os.path.dirname(os.path.abspath(__file__)) + os.sep + "versions\\" + SESSION["versionFileName"], 0x1880) print "old CONFIG_BUILD_INFO:" + "".join(["%.2x" % c for c in readResult]) mac = bytearray([ int(SESSION["localMac"][i] + SESSION["localMac"][i + 1], 16) for i in range(0, len(SESSION["localMac"]), 2) ]) readResult[4] = mac[0] readResult[5] = mac[1] readResult[6] = mac[2] readResult[7] = mac[4] readResult[8] = int(SESSION["directIndicator"], 16) CONFIG_BUILD_INFO = readResult[:24] uiLog(u"开始写入CONFIG_BUILD_INFO,值:%s" % "".join(["%.2x" % c for c in CONFIG_BUILD_INFO])) sc.save_CONFIG_BUILD_INFO(CONFIG_BUILD_INFO) sc.finishBslWritten()
def T_15_oled_M(product): u'''OLED屏幕测试-人工判断OLED屏幕是否全白''' sc = __askForPlateDeviceCom() sc.asynSend('TestOLED') if not manulCheck(u"OLED屏幕测试", u"请确认屏幕全白。"): raise TestItemFailException(failWeight=10, message=u'OLED屏幕测试人工判断不通过!') sc.asynReceiveAndAssert('TestOLEDOK')
def T_03_transmittingPower_A(product): u'''发射功率测试-记录发射功率的值''' try: sc = __askForPlateDeviceCom() v = sc.getObuSendPower() __saveRecordToLocalFile(u"功率.txt", str(v)) except Exception, e: print e
def T_02_downloadNewVersion_A(product): u'''下载新版本-自动下载新版本''' manulCheck(u"操作提示",u"请连接整机和工装板的U口线,然后点击确定","ok") sc = __askForPlateDeviceCom() try: sc.downloadVersion(version_file = os.path.dirname(os.path.abspath(__file__))+os.sep+"versions\\"+SESSION["versionFileName"]) except Exception,e: raise e
def T_07_reset_A(product): u'''复位测试-单板上电后返回数据,系统自动判断是否正确''' sc = __askForPlateDeviceCom() iob = __getIoBoard() sc.asynSend("TestReset") iob.triggerResetButton() sc.asynReceiveAndAssert("PowerOnSuccess") time.sleep(0.5)
def T_13_greenLight_M(product): u'''绿色LED灯检测-人工判定绿LED灯是否正常亮起''' sc = __askForPlateDeviceCom() sc.assertSynComm(request='TestGreenLedPara 1000', response='TestGreenLedParaOK') mcr = manulCheck(u"声光指示测试", u"请确认绿色指示灯正常亮起,蜂鸣器响声正常。") if not mcr: raise TestItemFailException(failWeight=10, message=u'绿色LED指示测试人工判断不通过!')
def T_16_displayDirKey_A(product): u'''显示方向控制键测试-屏幕显示倒转,检查是否通过''' sc = __askForPlateDeviceCom() iob = __getIoBoard() iob.triggerDisplayConvertButton() time.sleep(1) sc.assertSynComm(request='TestDirection', response='TestDirectionOK') time.sleep(1) sc.assertSynComm(request='ReadButtonStatus', response='ButtonisRelease')
def T_02_initFactorySetting_A(product): u'''出厂信息清零-维修工位勾选此项,抹去产品旧标识''' sc = board_digital.__askForPlateDeviceCom() try: sc.startBslWriting(board_digital.versionFile) uiLog(u"开始写入MAC地址") sc.save_obu_id(board_digital.__toBytesarray("FFFFFFFF")) finally: sc.finishBslWritten() time.sleep(1)
def T_12_redLight_M(product): u'''红色LED灯测试-人工判断指示红色灯显示、蜂鸣器响声是否正常''' sc = __askForPlateDeviceCom() sc.assertSynComm(request='TestLedLight', response='TestLedLightOK') sc.assertSynComm(request='TestRedLedPara 1000', response='TestRedLedParaOK') mcr = manulCheck(u"声光指示测试", u"请确认红色指示灯正常亮起,蜂鸣器响声正常。") if not mcr: raise TestItemFailException(failWeight=10, message=u'红色LED指示测试人工判断不通过!')
def T_02_sensiSwitchLocationVerify_A(product): u'''灵敏度开关位置判断-进行测试需要确认灵敏度开关在L档''' sc = __askForPlateDeviceCom() r = sc.assertAndGetNumberParam(request='TestSensiSwitch', response='TestSensiSwitch') if r != 0: autoCloseAsynMessage( u"操作提示(提示框会自动关闭)", u"请将灵敏度开关拨至另一侧", lambda: sc.assertAndGetNumberParam( request='TestSensiSwitch', response='TestSensiSwitch') == 0, TestItemFailException(failWeight=10, message=u'灵敏度开关测试不通过'))
def T_10_formalVersionDownload_A(product): u'''正式版本下载-下载正式版本''' sc = __askForPlateDeviceCom() try: downloadFileName = SP("gs10.formalVersion.filename", "obu-formal.txt", str) sc.downloadVersion( version_file=os.path.dirname(os.path.abspath(__file__)) + os.sep + "versions\\" + downloadFileName) except Exception, e: raise e
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_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_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_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 = __askForPlateDeviceCom() r = sc.assertAndGetNumberParam(request='TestSolarPower', response="TestSolarPower") result = {"太阳能电路电压": r} if r < SP('gs10.solarBatteryPower.overall.low', 3400) or r > SP( 'gs10.solarBatteryPower.overall.high', 3900): raise TestItemFailException(failWeight=10, message=u'太阳能电路电压异常', output=result) return result
def T_02_capacityOpen_A(product): u'''电容开路电压-返回电压数据,后台根据配置判断''' try: sc = __askForPlateDeviceCom() v = sc.testCapPower() resultMap = {"电容开路电压ADC": v} if v < SP('gs10.capOpenPower.low', -1) or v > SP( 'gs10.capOpenPower.high', 4.0): raise TestItemFailException(failWeight=10, message=u'电容开路电压异常', output=resultMap) return resultMap except TestItemFailException, e: raise e
def T_01_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) __saveRecordToLocalFile( u"低灵敏度.txt", "%.2x\t%.2x" % (lowWakenSensiResult[0], lowWakenSensiResult[1])) except Exception, e: e.message = u"低灵敏度测试失败" __saveRecordToLocalFile(u"低灵敏度.txt", u'失败')
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 setup(product): '''准备函数,获取MAC地址''' if SESSION["isMend"]: return #维修测试不需要读MAC uiLog(u"正在读取产品标识...") sc = __askForPlateDeviceCom() try: macBytes = sc.read_obu_id(passwordFile) mac = "".join(["%.2X" % i for i in macBytes]) product.setTestingProductIdCode(mac) uiLog(u"测试产品标识:" + mac) __checkDigitalCheckFinished(mac) except Exception, e: print e raise AbortTestException(message=u'BSL方式读取产品标识失败:' + e.message)
def T_04_transmittingPower_A(product): u'''发射功率测试-判断发射功率''' power_border_low = SP('gs10.sendPower.low', -3.5) power_border_high = SP('gs10.sendPower.high', 5) try: sc = __askForPlateDeviceCom() v = sc.getObuSendPower() resultMap = {u"发射功率": v} if v < power_border_low or v > power_border_high: raise TestItemFailException(failWeight=10, message=u'发射功率异常', output=resultMap) return resultMap except TestItemFailException, e: raise e
def T_17_testSensiSwitch_M(product): u'''灵敏度条件开关测试-测试灵敏度调节开关拨动并确保其出厂在L位置''' sc = __askForPlateDeviceCom() iob = __getIoBoard() failException = TestItemFailException(failWeight=10, message=u'灵敏度开关测试不通过') iob.sensiSwitchToRight() time.sleep(1) if sc.assertAndGetNumberParam(request='TestSensiSwitch', response='TestSensiSwitch') != 1: raise failException iob.sensiSwitchToLeft() time.sleep(1) if sc.assertAndGetNumberParam(request='TestSensiSwitch', response='TestSensiSwitch') != 0: raise failException
def T_01_wakeupSensitivity_A(product): u'''唤醒灵敏度测试-高低灵敏度分别计入两个文件''' low_level_power = -45 high_level_power = -35 grade = 0x03 level = 0x0e sc = __askForPlateDeviceCom() for power in range(low_level_power,high_level_power+1): try: if sc.testWakenSensiWithFixedPowerAndSensi(power,grade,level): __saveRecordToLocalFile(u"唤醒功率.txt", str(power)) break except Exception,e: print e
def T_02_receiveSensitivity_A(product): u'''接收灵敏度测试-记录灵敏度的值''' low_power_db = -55 high_power_db = -45 frame_num = SP('gs10.receiveSensitivity.frameNum',500) #发送帧总数 gate = 485 sc = __askForPlateDeviceCom() for power in range(low_power_db,high_power_db+1): try: v = sc.testObuRecvSensi(power,frame_num) if v >= gate: __saveRecordToLocalFile(u"接收功率.txt", str(power)) break except Exception,e: print e
def T_06_deepStaticCurrent_A(product): u'''深度静态电流测试-判断深度静态电流值是否在正常范围内''' manulCheck(u"操作提示", u"请按住防拆下电按钮,使其下电", "ok") sc = __askForPlateDeviceCom() sc.assertSynComm(request='CloseObuUart', response='CloseObuUartOK') time.sleep(2) try: v = sc.testDeepStaticCurrent() resultMap = {u"深度静态电流": v} if v < SP('gs10.deepStaticCurrent.low', 0) or v > SP( 'gs10.deepStaticCurrent.high', 3): raise TestItemFailException(failWeight=10, message=u'深度静态电流测试不通过,正常阈值0-3', output=resultMap) return resultMap except TestItemFailException, e: raise e
def __checkBySenser(itemName, timeInSecond, cmd, response, checkFun): '''传感器检测''' sc = __askForPlateDeviceCom() if checkFun(): raise AbortTestException(message=u'%s检测传感器异常,请检查' % itemName) sc.asynSend("%s %d000" % (cmd, timeInSecond)) result = False time.sleep(1) for i in range(timeInSecond): if checkFun(): result = True break time.sleep(1) sc.asynReceiveAndAssert(response) time.sleep(1.5) if not result: raise TestItemFailException(failWeight=10, message=u'%s检测不通过!' % itemName)
def T_21_deepStaticCurrent_A(product): u'''深度静态电流测试-判断深度静态电流值是否在正常范围内''' iob = __getIoBoard() sc = __askForPlateDeviceCom() iob.pressDemolishButton() sc.assertSynComm(request='CloseObuUart', response='CloseObuUartOK') time.sleep(2) try: v = sc.testDeepStaticCurrent() resultMap = {u"深度静态电流": v} if v < SP('gs10.deepStaticCurrent.low', 0) or v > SP( 'gs10.deepStaticCurrent.high', 3): raise TestItemFailException(failWeight=10, message=u'深度静态电流测试不通过', output=resultMap) return resultMap except TestItemFailException, e: raise e