138 lines
3.1 KiB
Python
138 lines
3.1 KiB
Python
|
# coding:utf-8
|
||
|
import argparse
|
||
|
import os
|
||
|
import sys
|
||
|
import inspect
|
||
|
import time
|
||
|
import random
|
||
|
import datetime
|
||
|
|
||
|
sys.path.append('./base')
|
||
|
import autotest_time as at_time
|
||
|
import autotest_usart as at_usart
|
||
|
|
||
|
sys.path.append('./inst')
|
||
|
import power_agilent_scpi as ag_power
|
||
|
import power_dpm8600_modbus as dpm_power
|
||
|
import temp_modbus as temp_modbus
|
||
|
import oscilloscope_scpi as osc_scpi
|
||
|
|
||
|
sys.path.append('./case')
|
||
|
import case_parser as caseparser
|
||
|
|
||
|
TEMP_PORT='COM45'
|
||
|
TEMP_BANDRATE='9600'
|
||
|
|
||
|
DPM8600_PORT='COM46'
|
||
|
DPM8600_BANDRATE='9600'
|
||
|
DPM8600_CHANNEL=1
|
||
|
|
||
|
AG_POWER_PORT='COM47'
|
||
|
AG_POWER_BANDRATE='9600'
|
||
|
|
||
|
OSC_PORT='COM60'
|
||
|
OSC_BANDRATE='115200'
|
||
|
|
||
|
CSV_PATH='./case/testcase_common.csv'
|
||
|
|
||
|
__version__ = "1.0"
|
||
|
PYTHON2 = sys.version_info[0] < 3 # True if on pre-Python 3
|
||
|
|
||
|
class FatalError(RuntimeError):
|
||
|
def __init__(self, message):
|
||
|
RuntimeError.__init__(self, message)
|
||
|
|
||
|
@staticmethod
|
||
|
def WithResult(message, result):
|
||
|
"""
|
||
|
Return a fatal error object that appends the hex values of
|
||
|
'result' as a string formatted argument.
|
||
|
"""
|
||
|
message += " (result was %s)" % hex(result)
|
||
|
return FatalError(message)
|
||
|
|
||
|
pasttime=datetime.datetime.now()
|
||
|
nowtime=datetime.datetime.now()
|
||
|
|
||
|
def err_exit(args):
|
||
|
nowtime=datetime.datetime.now()
|
||
|
print("test start time :"+pasttime.strftime('%Y-%m-%d %H:%M:%S'))
|
||
|
print("test end time:"+nowtime.strftime('%Y-%m-%d %H:%M:%S'))
|
||
|
print(str(nowtime-pasttime))
|
||
|
sys.exit(args)
|
||
|
|
||
|
def test_temp():
|
||
|
#init for temp control
|
||
|
temp = temp_modbus.inst_temp(TEMP_PORT,TEMP_BANDRATE)
|
||
|
#temp on
|
||
|
#temp.temp_on()
|
||
|
#temp off
|
||
|
#temp.temp_off()
|
||
|
temp.temp_close()
|
||
|
|
||
|
def test_dpm8600():
|
||
|
#init for temp control
|
||
|
dpm8600 = dpm_power.inst_dpm8600(DPM8600_PORT,DPM8600_BANDRATE,DPM8600_CHANNEL)
|
||
|
#dpm8600 on
|
||
|
#dpm8600.dpm8600_on()
|
||
|
#dpm8600 off
|
||
|
#dpm8600.dpm8600_off()
|
||
|
dpm8600.dpm8600_close()
|
||
|
|
||
|
def test_apower():
|
||
|
#init for temp control
|
||
|
apower = ag_power.inst_agilent_power(AG_POWER_PORT,AG_POWER_BANDRATE)
|
||
|
#apower on
|
||
|
apower.power_on()
|
||
|
#apower off
|
||
|
#apower.power_off()
|
||
|
apower.power_close()
|
||
|
|
||
|
def test_soc():
|
||
|
#init for oscillpscope control
|
||
|
oscillpscope = osc_scpi.inst_oscilloscope(OSC_PORT,OSC_BANDRATE)
|
||
|
# oscillpscope.get_id()
|
||
|
# oscillpscope.stop()
|
||
|
# time.sleep(5)
|
||
|
# oscillpscope.single()
|
||
|
# time.sleep(5)
|
||
|
# oscillpscope.run()
|
||
|
# oscillpscope.time_scale('1ms')
|
||
|
# time.sleep(2)
|
||
|
# oscillpscope.time_scale('100us')
|
||
|
# time.sleep(2)
|
||
|
# oscillpscope.time_scale('500ns')
|
||
|
# oscillpscope.channel_scale(1,'2mV')
|
||
|
# time.sleep(2)
|
||
|
# oscillpscope.channel_scale(1,'500mV')
|
||
|
# time.sleep(2)
|
||
|
# oscillpscope.channel_scale(1,'1V')
|
||
|
oscillpscope.measure_period(1)
|
||
|
|
||
|
def test_case():
|
||
|
parser = caseparser.case_parser(CSV_PATH)
|
||
|
parser.parser()
|
||
|
|
||
|
def main():
|
||
|
parser = argparse.ArgumentParser(description='autotest.py v%s - Auto Testing Utility' % __version__, prog='autotest')
|
||
|
print(sys.path)
|
||
|
print("Start time:"+at_time.get_time_stamp())
|
||
|
at_time.time_week_ver()
|
||
|
#list all serial port
|
||
|
#at_usart.list_com()
|
||
|
#test_temp()
|
||
|
#test_dpm8600()
|
||
|
#test_apower()
|
||
|
test_case()
|
||
|
#test_soc()
|
||
|
|
||
|
def _main():
|
||
|
try:
|
||
|
main()
|
||
|
except FatalError as e:
|
||
|
print('\n A fatal error occurred: %s' % e)
|
||
|
err_exit(2)
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
_main()
|