def SimpleTest_001():
    try:
        # log current time
        t1 = time.localtime()
            
        # oids = {
        # 'REBOOT' : '1.3.6.1.4.1.14817.7.4.1.1.8.1.1.0'
        # }

        TESTCASE = 'T10001'
        DSlogName = str(TESTCASE+'stepLvSmryLog.log')
        DSlog = open(DSlogName, 'a')
        # Define the variables to be used in the test case
        RadioIP = glob.Configs['TargetRadioIP']
        BaseStationIP = glob.Configs['BaseStationRadioIP']
        RemoteStationIP = glob.Configs['RemoteIPList']
        baseTermOpMode = 1
        remoteOperMode = 3
        etherMode = 2
        dut1_TxFreq = dut2_RxFreq = 444125000
        dut1_RxFreq = dut2_TxFreq = 450125000
        modulationType = 25
        mtuSize = 1500
        baudRate = 38400
        flowCtrl = 1
        sender = 1
        receiver = 2
        rtscts = 1
        port = 'COM1'
        srlTester = serialTester(port)
        
        # Log Test Case Header
        print('TESTCASE #T10001\n')
        DtilLog = open(glob.DlogName, 'a')
        DtilLog.write("<p>\n")
        log(DtilLog,"===============================================================\n", False, 'RED', 5)
        log(DtilLog,"TESTCASE %s\n\n"%TESTCASE, False, 'RED', 5)
        # DtilLog.close()

        print ('#****************************************************************************')
        print ('#							START OF TEST CASE                               ')
        print ('#****************************************************************************')
        print ('Step 1:	Configure DUT1 Radio as Base Station')

        STEP ("Step 1:	Configure DUT1 Radio as Base Station\n\n1")
        result = term.setTerminalOperMode(BaseStationIP, baseTermOpMode, etherMode)
        validateStep('Configure DUT1 Radio as Base Station\n\n', result, DSlog, TESTCASE)
        
        result = ''
            
    finally:
        # print ('#****************************************************************************')
        # print ('#					CLEANUP OF TEST CASE                                         ')
        # print ('#****************************************************************************')
        print ('cleanup')
        # result = maint.restoreUserDefaults (RemoteStationIP, 1)
        # validateStep('Restoring User Defaults on DUT2\n\n', result, DSlog, TESTCASE)
        
        # result = ''
        
        # result = maint.restoreUserDefaults (BaseStationIP, 1)
        # validateStep('Restoring User Defaults on DUT1\n\n', result, DSlog, TESTCASE)
        
        # result = ''
    print ('#****************************************************************************')
    print ('#					END OF TEST CASE                                         ')
    print ('#****************************************************************************')
    finish (t1, TESTCASE, DSlogName)
    # finish(t1)
def TEST_START():
	
	# Make the results Directory
	if not os.path.exists(glob.resultsDir):
		os.makedirs(glob.resultsDir)

	SmryLog = open(str(glob.SlogName),'w')

	log(SmryLog,'SUMMARISED LOG\n', False, 'RED', 4)
	log(SmryLog,'--------------------------------------------------------------\n', False, 'RED', 4)
	log(SmryLog,'Test Run Title: %s\n'%glob.TestRunTitle, False, 'RED', 4)
	log(SmryLog,'--------------------------------------------------------------\n', False, 'RED', 4)
	log(SmryLog,'Terminal Unit Software Version:%s\n'%glob.version, False, 'RED', 4)
	log(SmryLog,'Test Environment Version: %s\n'%glob.TestEnvironmentVersion, False, 'RED', 4)
	log(SmryLog,'Script Version: %s\n'%glob.ATSProductScriptVersion, False, 'RED', 4)
	log(SmryLog,'EUT Unit Serial Numbers: %s\n'%glob.EUTUnitSerialNumbers, False, 'RED', 4)
	log(SmryLog,'BER Tester Serial Number: %s\n'%glob.BERTesterSerialNumber, False, 'RED', 4)
	log(SmryLog,'Power Meter Serial Number: %s\n'%glob.PowerMeterSerialNumber, False, 'RED', 4)
	log(SmryLog,'Digital Volt Meter Serial Number: %s\n'%glob.DigitalVoltMeterSerialNumber, False, 'RED', 4)
	log(SmryLog,'ATS Operator: %s\n'%glob.ASTOP, False, 'RED', 4)
	log(SmryLog,'--------------------------------------------------------------\n\n\n', False, 'RED', 4)

	# DetilLog.close()
	SmryLog.close()
def TEST_STOP ():

	SmryLog = open(str(glob.SlogName),'a')
	log(SmryLog, '\n\n-----------------------------END---------------------------------\n', False, 'RED', 4)
	log(SmryLog, '\n\n*****************************************************************\n', False, 'RED', 4)
	log(SmryLog, '\n\nTotal Number of Test Cases		:	%s\n' %glob.testCaseCount, False, 'RED', 4)
	log(SmryLog, '\n\nTotal Number of Test Passed		:	%s\n' %glob.testCasePassed, False, 'RED', 4)
	log(SmryLog, '\n\nTotal Number of Test Failed		:	%s\n' %glob.testCaseFailed, False, 'RED', 4)
	log(SmryLog, '\n\n*****************************************************************\n', False, 'RED', 4)
	SmryLog.close()
def finish(t, TESTCASE, testResult):
	# Test Case Finished !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	print('TESTCASE %s Complete'%TESTCASE)
	
	# Calculate testcase duration
	t2 = time.localtime()
	durationsec = time.mktime(t2) - time.mktime(t)
	hours, remainer = divmod(durationsec, 3600)
	minutes, seconds = divmod(remainer, 60)
	duration = '%s Hours, %s Minutes, %s Seconds'%(hours,minutes,seconds)
		
	print ('FINAL RESULTS: %s' %testResult)
	if(testResult == 'PASS'):
		print('Test Case Result: Pass')
		glob.testCasePassed += 1
		sl = open(glob.SlogName, 'a')
		# log(sl, "TestCase %s: Pass\n" %TESTCASE, ColorCode = 'GREEN')
		log(sl, "TestCase : %s\n" %TESTCASE, ColorCode = 'GREEN')
		log(sl, "Objective : %s\n" %glob.testDesc, ColorCode = 'GREEN')
		log(sl, "Result : Pass\n", ColorCode = 'GREEN')
		sl.close()
		DtilLog = open(str(glob.DlogName),'a')
		logMsg(DtilLog,"Test Case %s Passed\n"%TESTCASE)
		logMsg(DtilLog,"Duration: %s\n"%duration)
		logMsg(DtilLog,"===============================================================\n")
		DtilLog.write("\n")
		DtilLog.close()
	else:
		print('Test Case Result: Fail')
		glob.testCaseFailed += 1
		sl = open(glob.SlogName, 'a')
		# log(sl, "TestCase %s: Fail\n" %TESTCASE, ColorCode = 'RED')
		log(sl, "TestCase : %s\n" %TESTCASE, ColorCode = 'RED')
		log(sl, "Objective : %s\n" %glob.testDesc, ColorCode = 'RED')
		log(sl, "Result : Fail\n", ColorCode = 'RED')
		sl.close()
		DtilLog = open(str(glob.DlogName),'a')
		logMsg(DtilLog,"Test Case %s Failed\n"%TESTCASE)
		logMsg(DtilLog,"Duration: %s\n"%duration)
		logMsg(DtilLog,"===============================================================\n")
		DtilLog.write("\n")
		DtilLog.close()