def test_stimulus_steps_legacy(): #Every test should have a user variable that have a test ID number to ensure that you are running the correct test configuration. TEST_ID = 12000 wks = NIVeriStand.Workspace2() #print(statement take a string and it is piped out to a single trace file in the background, for your tracing needs.) print("") SYSDEFFILE = os.path.join(configutilities.get_autotest_projects_path(), "ProfileTest", "Profile Test.nivssdf") print("Deploying %s" % SYSDEFFILE ) wks.ConnectToSystem(SYSDEFFILE,1,60000) print("System Definition deployed") try: #Verify the TEST_ID var on test file. test_ID = wks.GetSingleChannelValue("TEST_ID") assert(test_ID == TEST_ID), "Deployed wrong test file" stm = NIVeriStand.Stimulus() assert run_test(wks, stm, "Ramp Test.nivstest", 120) sleep() assert run_test(wks, stm, "Conditional Test.nivstest", 120) sleep() assert run_test(wks, stm, "Dwell Test.nivstest", 120) finally: #Always stop the engine. wks.DisconnectFromSystem("", 0)
def run_test(wks, stimulus, test_name, wait_time): TESTFILE = os.path.join(configutilities.get_autotest_projects_path(), "ProfileTest", test_name) result = -1 print("") print("Running stimulus profile %s" % test_name) print("File Path: %s" % TESTFILE) print("...") LOGDIR = os.path.join(configutilities.get_autotest_projects_path(), "ProfileTest", "Logs") stimulus.RunStimulusProfile(TESTFILE,LOGDIR,60000,1,1) timeout = wait_for_test(stimulus, 120) assert not timeout, "Timed out waiting for test to complete!" print("Stimulus Profile completed.") result = wks.GetSingleChannelValue("Gen 1 Pass Fail") print("Result = %d" % result) print("") return result
def run_test(wks, stimulus, test_name, wait_time): TESTFILE = os.path.join(configutilities.get_autotest_projects_path(),"ProfileTest", test_name) print("") print("Running stimulus profile %s" % test_name) print("File Path: %s" % TESTFILE) print("...") import tempfile stimulus.RunStimulusProfile(TESTFILE,"",60000,1,1) timeout = wait_for_test(stimulus, wait_time) assert not timeout, "Test %s timed out." % test_name print("Stimulus Profile completed.") result = wks.GetSingleChannelValue("Gen 1 Pass Fail") print("Result = %d" % result) print("") return result
def test_expected_profile_failures_legacy(): #Every test should have a user variable that have a test ID number to ensure that you are running the correct test configuration. TEST_ID = 12000 #Getting a handle to the workspace API #Other API: Model, Alarm, AlarmManager, SoftwareForcing, ModelManager wks = NIVeriStand.Workspace2() try: #print(statement take a string and it is piped out to a single trace file in the background, for your tracing needs.) print("") #standard way of running a configuration file. VSTANDPROJECTDIR is configured to the location where test project files get sync. So just append your folder and rig file. SYSDEFFILE = os.path.join(configutilities.get_autotest_projects_path(), "ProfileTest", "Profile Test.nivssdf") print("Deploying %s" % SYSDEFFILE ) wks.ConnectToSystem(SYSDEFFILE,1,60000) print("System Definition deployed") #Verify the TEST_ID var on test file. test_ID = wks.GetSingleChannelValue("TEST_ID") assert(test_ID == TEST_ID), "Deployed wrong test file" stm = NIVeriStand.Stimulus() with pytest.raises(NIVeriStandException): gens_error = run_test(wks, stm, "Too Many Gens.nivstest", 120) assert (gens_error == 4294659383) with pytest.raises(NIVeriStandException): steps_error = run_test(wks, stm, "Too Many Steps.nivstest", 120) assert (steps_error == 4294659395) with pytest.raises(NIVeriStandException): aux_error = run_test(wks, stm, "Aux Buffer Overflow.nivstest", 120) assert (aux_error == 4294659393) with pytest.raises(NIVeriStandException): chan_error = run_test(wks, stm, "Invalid Channel.nivstest", 120) assert (chan_error == 4294659387) finally: #Always stop the engine. wks.DisconnectFromSystem("", 0)
def test_custom_devices_legacy(): import random #Getting a handle to the workspace API #Other API: Model, Alarm, AlarmManager, SoftwareForcing, ModelManager wks = NIVeriStand.Workspace2('localhost') #print(statement take a string and it is piped out to a single trace file in the background, for your tracing needs.) print("") #standard way of running a configuration file. VSTANDPROJECTDIR is configured to the location where test project files get sync. So just append your folder and rig file. SYSDEFFILE = os.path.join(configutilities.get_autotest_projects_path(), "CustomDevices", "CustomDevices.nivssdf") print("[b] Deploying %s" % SYSDEFFILE) wks.ConnectToSystem(SYSDEFFILE, 1, 60000) try: #Verify the TEST_ID var on test file. #Every test should have a user variable that have a test ID number to ensure that you are running the correct test configuration. TEST_ID = 10239 # Verify the TEST_ID var on test file. test_ID = wks.GetSingleChannelValue("TEST_ID") assert (test_ID == TEST_ID), "Deployed wrong test file" #Get Parameter from test system if necessary, if you are being passed an argument from the test system then you will need to get the parameters. The following #python code is recommended practice: #Declare variable to store the parameter with a default value since you will always want to trouble shoot your test script without running the full LabVIEW auto test. #TEST_PARAM_IPADDRESS = "localhost" #set default IP address to localhost for manual run. #if EnvVars.ARG_LIST.has_key( "IPADDRESS"): # TEST_PARAM_IPADDRESS = EnvVars.ARG_LIST["IPADDRESS"] #repeat the above process for all parameters you expect to be passed in by the LabVIEW test system. _test_device(wks, "Async", 100 * random.random()) _test_device(wks, "HW", 200 * random.random()) _test_device(wks, "Mdl", 300 * random.random()) print("Test PASSED") finally: #Always stop the engine. wks.DisconnectFromSystem("", 1)
def test_alarm2_api(): wks = NIVeriStand.Workspace2("localhost") print("") SYSDEFINITION = os.path.join(configutilities.get_autotest_projects_path(), "TestAlarmAPI", "TestAlarmAPI.nivssdf") print("Deploying %s" % SYSDEFINITION) wks.ConnectToSystem(SYSDEFINITION, 1, 80000) try: # Verify the TEST_ID var on test file. test_ID = wks.GetSingleChannelValue("TEST_ID") assert (test_ID == TEST_ID), "Deployed wrong test file" print("Testing Alarm manager Get Alarm List") alarmMgr = NIVeriStand.AlarmManager2("localhost") result = alarmMgr.GetAlarmList("Controller") assert (len(result) == 3), "Expected 3 alarms returned from the system" with pytest.raises(NIVeriStandException): alarmMgr.GetAlarmList("Invalid Controller") print("Testing Alarm manager Read Alarm Data") alarms = ('Alarm Group/AlarmTest1', 'Alarm Group/AlarmTest2', 'ConstantBoundAlarm') result = alarmMgr.GetMultipleAlarmsData("Controller", alarms, 60000) print("Verifying alarm data returned") assert (len(result) == 3), "Expected to get 3 alarms data back" with pytest.raises(NIVeriStandException): alarmMgr.GetMultipleAlarmsData("INVALID CONTROLLER", alarms, 60000) print("Verifying Alarm Data") alarmTest1 = result[0] alarmTest2 = result[1] constantBoundAlarm = result[2] print(alarmTest1) assert (alarmTest1['WatchChannel'] == r"AlarmChannel1" ), "Fail to confirm alarm channel" assert ((alarmTest1['HighLimitIsConstant'] == 0) or (alarmTest1['HighLimitChannel'] == r"AlarmChannel1High")), "Fail to confirm high limit" assert ((alarmTest1['LowLimitIsConstant'] == 0) or (alarmTest1['LowLimitChannel'] == r"AlarmChannel1Low")), "Fail to confirm low limit" assert (alarmTest1['DelayDuration'] == 0.5 ), "Fail to confirm delay duration" assert (alarmTest1['ProcedureName'] == r"ResetAlarmTest1" ), "Fail to confirm procedure" assert (alarmTest1['Priority'] == 2 ), "Fail to confirm priority (deprecated)" assert (alarmTest1['PriorityNumber'] == 5 ), "Fail to confirm priority number" assert (alarmTest1['State'] == 1), "Fail to confirm state" assert (alarmTest1['Mode'] == 0), "Fail to confirm mode" assert (alarmTest1['GroupNumber'] == 1), "Fail to confirm alarm group" print("Test alarm interface") print("Test Alarm constructor mode") Constructor1 = NIVeriStand.Alarm('Alarm Group/Alarm Test2') Constructor2 = NIVeriStand.Alarm('Alarm Group/Alarm Test2', 'Controller') Constructor3 = NIVeriStand.Alarm('Alarm Group/Alarm Test2', None, 'localhost') Constructor4 = NIVeriStand.Alarm('Alarm Group/Alarm Test2', 'Controller', 'localhost') print("Test access to alarm") BoundAlarmRef = NIVeriStand.Alarm('ConstantBoundAlarm', 'Controller', 'localhost') result = BoundAlarmRef.GetAlarmData(30000) assert (result == constantBoundAlarm ), "Alarm data from alarm interface differ from alarm manager" print("Test modifying alarm data") modAlarmData = result modAlarmData['HighLimit'] = 3 modAlarmData['LowLimit'] = -3 BoundAlarmRef.SetAlarmData2(modAlarmData) sleep() result = BoundAlarmRef.GetAlarmData(30000) assert (result == modAlarmData), "Alarm data set cannot be confirmed" print("Test modifying alarm state and mode") BoundAlarmRef.SetEnabledState(0) #indicate only BoundAlarmRef.SetAlarmMode(1) sleep() result = BoundAlarmRef.GetAlarmData(30000) assert (result['State'] == 0), "Alarm Mode is wrong" assert (result['Mode'] == 1), "Alarm Mode is wrong" BoundAlarmRef.SetEnabledState(1) BoundAlarmRef.SetAlarmMode(0) sleep() sleep() wks.SetSingleChannelValue(r"Controller/User Channel/AlarmChannel1", 20) wks.SetSingleChannelValue(r"Controller/User Channel/AlarmChannel2", 10) sleep() sleep() print("Testing alarm mutual exclusion within a group") AlarmTest2Ref = NIVeriStand.Alarm('Alarm Group/AlarmTest2') AlarmTest1Ref = NIVeriStand.Alarm('Alarm Group/AlarmTest1') result = AlarmTest1Ref.GetAlarmData(30000) result2 = AlarmTest2Ref.GetAlarmData(30000) assert (result['State'] == 2), "Alarm should be tripped" assert ( result2['State'] != 2 ), "Alarm should not be running due to an execution of a higher priority." print("Testing Alarm Execution Across Groups") result = BoundAlarmRef.GetAlarmData(30000) result2 = AlarmTest2Ref.GetAlarmData(30000) assert ((result['State'] == 2) and (result2['State'] == 2)), " Two alarms should be tripped simulteneously." print("Test PASSED") print("") finally: wks.DisconnectFromSystem("", 1)
def test_calculated_channel_legacy(): TEST_ID = 1112 wks = NIVeriStand.Workspace() print("") SYSDEFINITION = os.path.join(configutilities.get_autotest_projects_path(), "CalculatedChannelTest", "CalculatedChannelTest.nivssdf") print("Deploying %s" % SYSDEFINITION) wks.RunWorkspaceFile(SYSDEFINITION, 0, 1, 60000, "", "") try: #Verify the TEST_ID var on test file. test_ID = wks.GetSingleChannelValue("TEST_ID") assert (test_ID == TEST_ID), "Deployed wrong test file" print("Checking Get Constant") channels = ("MaxConstant", "MinConstant") expectedResults = [5, -5] results = wks.GetMultipleChannelValues(channels) for i in range(0, len(expectedResults)): assert (results[i] == expectedResults[i] ), "%s Expected %f Return Value %f not expected" % ( channels[i], expectedResults[i], results[i]) print("Checking Max Min Mode") channels = ("MaxUV1", "MaxUV2", "MinUV1", "MinUV2") channelsValues = (-1000, -1000.1, 1000, 1000.1) wks.SetMultipleChannelValues(channels, channelsValues) sleep() #verifying the value get set on these channels results = wks.GetMultipleChannelValues(channels) for i in range(0, len(results)): assert (results[i] == channelsValues[i] ), "%s Expected %f Return Value %f not expected" % ( channels[i], channelsValues[i], results[i]) #verifying the new max min value is correct outchannels = ("MaxUV1ToConstVal5", "MaxUV2ToConstVal10", "MinUV1ToConstVal2", "MinUV2ToConstVal3", "Max2Var", "Min2Var") expectedResults = [5, 10, 2, 3, -1000, 1000] results = wks.GetMultipleChannelValues(outchannels) for i in range(0, len(expectedResults)): assert (results[i] == expectedResults[i] ), "%s Expected %f Return Value %f not expected" % ( outchannels[i], expectedResults[i], results[i]) #verifying that the new max min value take the value of the variable. channelsValues = (10, 15, 1, -1) wks.SetMultipleChannelValues(channels, channelsValues) sleep() results = wks.GetMultipleChannelValues(outchannels) expectedResults = [10, 15, 1, -1, 15, -1] for i in range(0, len(expectedResults)): assert (results[i] == expectedResults[i] ), "%s Expected %f Return Value %f values not expected" % ( outchannels[i], expectedResults[i], results[i]) print( "Checking Acceleration Mode - assuming delta T for low priority loop is .2" ) channels = ("AccelerationOnDistanceChannel", "VelocityChan", "DistanceChannel", "VelocityChanPrevIteration", "DistanceChannelPrevIteration") results = wks.GetMultipleChannelValues(channels) accelerationCalculated = round((results[1] - results[3]) / .2) assert (accelerationCalculated == round(results[0]) ), "%s Expected %f Return Value %f value not expected" % ( channels[0], accelerationCalculated, results[0]) print("Computing velocity") velocityCalculated = round((results[2] - results[4]) / 0.2) assert (velocityCalculated == round(results[1]) ), "%s Expected %f Return Value %f value not expected" % ( channels[1], velocityCalculated, results[1]) print("Checking Averaging Mode") #Get a list of the last 6 points. if we take a sum of the complete 3 elements we are bound to find the correct average. channels = ("3PointAverager", "ChanToAverage", "ChanToAverageMin1Step", "ChanToAverageMin2Step", "ChanToAverageMin3Step", "ChanToAverageMin4Step", "ChanToAverageMin5Step", "ChanToAverageMin6Step") results = wks.GetMultipleChannelValues(channels) i = 0 for channel in channels: print(("%s value is %f" % (channel, round(results[i], 3)))) i = i + 1 possibleAverages = [] for i in range(0, 4): temp = 0 for y in range(0, 3): temp = temp + results[1 + i + y] possibleAverages.append(temp / 3) found = 0 for potentialAverage in possibleAverages: print(("Potential Averages %f" % round(potentialAverage, 3))) if (round(potentialAverage, 3) == round(results[0], 3)): found = 1 assert (found == 1), "Fail to auto check averaging module" print("Test PASSED") finally: wks.StopWorkspaceFile("")
def test_calculated_channel_ut_legacy(): wks = NIVeriStand.Workspace() print("") SYSDEFFILE = os.path.join(configutilities.get_autotest_projects_path(), "CalcChanUnitTest", "CalcChanUnitTest.nivssdf") print("Deploying %s" % SYSDEFFILE) wks.RunWorkspaceFile(SYSDEFFILE,0,1,60000,"","") try: # Compute Machine Epsilon: The smallest floating point number when # added to one is greater than one. eps = 1.0 while ((1.0 + eps) > 1.0): epsLast = eps eps = eps / 2.0 eps = epsLast print("Machine Epsilon = %g" % (eps)) # We will be testing NaNs and Infs as well NaN = float('nan') Inf = float('inf') # Sleep until the first Time (a calculated channel) is greater than # zero. This will be either the first or second time the calculated # channels are computed. In VeriStand 2010, the first time the # channels are calculated is at Delta T. At any rate, we do not want # to proceed until we have performed some calculations. result=0 while (result <= 0): sleep() result = wks.GetSingleChannelValue("Time") # All formulas in VeriStand must have input values. Zero is computed # so that it can be used as an input to certain formulas. The way # it is computed, it should be precisely zero. No epsilon logic should # be used to ensure that it is in fact zero. print("Checking Zero channel is 0.0") expectedResult = 0. result = wks.GetSingleChannelValue("Zero") assert(result == expectedResult), "Time-Time (%g) does not match calculated (%g)" % (expectedResult, result) print("...Pass") # Test functions of one variable TestFct = ["abs", "int", "sign", "sin", "cos", "tan", "asin", "acos", "atan", "exp", "sqrt"] TestChan = ["Abs(X)", "Int(X)", "Sign(X)", "Sin(X)", "Cos(X)", "Tan(X)", "Asin(X)", "Acos(X)", "Atan(X)", "Exp(X)", "Sqrt(X)"] # Input and expected output values for the calculated channels ## NOTE: abs(-Inf) == Inf in Xmath ## NOTE: abs( Inf) == Inf in Xmath absIn = [-1., 0., 1., NaN, Inf, Inf ] absOut = [ 1., 0., 1., NaN, NaN, NaN ] ## NOTE: (int)(-2.718) == -2 in the c language ## NOTE: (int)(-3.142) == -3 in the c language ## NOTE: (int)(-1.500) == -1 in the c language ## NOTE: (int)(-1.500) == -1 in the c language ## NOTE: (int)(-Inf) == -Inf in Xmath ## NOTE: (int)( Inf) == Inf in Xmath intIn = [ -math.pi, -math.e, -1.5, 1.5, math.e, math.pi, NaN, -Inf, Inf ] intOut = [ -4., -3., -2., 1., 2., 3., NaN, NaN, NaN ] signIn = [ -math.pi, 0., math.pi, NaN, -Inf, Inf ] signOut = [ -1., 0., 1., NaN, -1., 1. ] sinIn = [ -math.pi/2., math.pi/6., math.pi/2., NaN, -Inf, Inf ] sinOut = [ -1., 0.5, 1., NaN, NaN, NaN ] cosIn = [ math.pi, math.pi/3., 0., NaN, -Inf, Inf ] cosOut = [ -1., 0.5, 1., NaN, NaN, NaN ] tanIn = [ math.pi, math.pi/4., 0., NaN, -Inf, Inf ] tanOut = [ 0., 1., 0., NaN, NaN, NaN ] asinIn = [ -1., 0., 1., NaN, -Inf, Inf ] asinOut = [ -math.pi/2., 0., math.pi/2., NaN, NaN, NaN ] acosIn = [ -1., 0., 1., NaN, -Inf, Inf ] acosOut = [ math.pi, math.pi/2., 0., NaN, NaN, NaN ] atanIn = [ -1., 0., 1., NaN, -Inf, Inf ] atanOut = [ -math.pi/4., 0., math.pi/4., NaN, -math.pi/2., math.pi/2. ] ## NOTE: exp(Inf) == Inf in Xmath expIn = [ -1., 0., 1., NaN, -Inf, Inf ] expOut = [ 1./math.e, 1., math.e, NaN, 0., NaN ] ## NOTE: sqrt(Inf) == Inf in Xmath sqrtIn = [ 0., 1., 2., NaN, -Inf, Inf ] sqrtOut = [ 0., 1., math.sqrt(2.), NaN, NaN, NaN ] # Loop through the various calculated channels to test TestIn = (absIn, intIn, signIn, sinIn, cosIn, tanIn, asinIn, acosIn, atanIn, expIn, sqrtIn) TestOut = (absOut, intOut, signOut, sinOut, cosOut, tanOut, asinOut, acosOut, atanOut, expOut, sqrtOut) abstol = eps reltol = math.sqrt(eps) for j in range(0,len(TestOut)): Fct = TestFct[j] Chan = TestChan[j] In = TestIn[j] Out = TestOut[j] for i in range(0,len(Out)): print("Testing: %g = %s(%g) ..." % (Out[i], Fct, In[i])) wks.SetSingleChannelValue("X",In[i]) sleep() result = wks.GetSingleChannelValue(Chan) if(math.isnan(Out[i]) and not math.isnan(result)): assert False, "%s(%g): Expected %g Return Value %g not expected" % (Chan, In[i], Out[i], result) elif(math.isinf(Out[i]) and not math.isinf(result)): assert False, "%s(%g): Expected %g Return Value %g not expected" % (Chan, In[i], Out[i], result) elif(math.isinf(Out[i]) and math.isinf(result)): if(math.copysign(1,Out[i]) and not math.copysign(1,result)): assert False, "%s(%g): Expected %g Return Value %g not expected" % (Chan, In[i], Out[i], result) else: tol = abstol + reltol*abs(Out[i]) if((result < Out[i] - tol) | (result > Out[i] + tol)): assert False, "%s(%g): Expected %g Return Value %g not expected" % (Chan, In[i], Out[i], result) else: print("...Pass") # Test operators: functions of two variables ## NOTE: The following formulas can be entered in the SystemExplorer ## and do not report parsing errors, but, they do not deploy. ## X * -Y ## -X * -Y ## X / -Y ## -X / -Y ## X ^ -Y ## -X ^ -Y ## ## NOTE: The SystemExplorer allows you to create aliases with '/' in ## them even though this interferes with the path description. ## Rejected by the API: ## X / Y ## -X / Y TestMinus1 = [ "", "-", "", "-", "", "-", "", "-", "", "-", "", "-", "", "-" ] TestMinus2 = [ "", "", "-", "-", "", "", "-", "-", "", "", "", "", "", "" ] TestOp = [ "+", "+", "+", "+", "-", "-", "-", "-", "*", "*", "/", "/", "^", "^" ] TestChan = [ "X + Y", "-X + Y", "X + -Y", "-X + -Y", "X - Y", "-X - Y", "X - -Y", "-X - -Y", "X * Y", "-X * Y", "X div Y", "-X div Y", "X ^ Y", "-X ^ Y" ] # Input and expected output values for the calculated channels # Inf + Inf should be Inf XplusYIn1 = [ -5., 0., 2., Inf, Inf ] XplusYIn2 = [ -2., 0., 5., Inf, -Inf ] XplusYOut = [ -7., 0., 7., NaN, NaN ] minusXplusYIn1 = [ -5., 0., 2. ] minusXplusYIn2 = [ -2., 0., 5. ] minusXplusYOut = [ 3., 0., 3. ] XplusMinusYIn1 = [ -5., 0., 2. ] XplusMinusYIn2 = [ -2., 0., 5. ] XplusMinusYOut = [ -3., 0.,-3. ] minusXplusMinusYIn1 = [ -5., 0., 2. ] minusXplusMinusYIn2 = [ -2., 0., 5. ] minusXplusMinusYOut = [ 7., 0., -7. ] XminusYIn1 = [ -5., 0., 2., Inf ] XminusYIn2 = [ -2., 0., 5., Inf ] XminusYOut = [ -3., 0., -3., NaN ] minusXminusYIn1 = [ -5., 0., 2. ] minusXminusYIn2 = [ -2., 0., 5. ] minusXminusYOut = [ 7., 0., -7. ] XminusMinusYIn1 = [ -5., 0., 2. ] XminusMinusYIn2 = [ -2., 0., 5. ] XminusMinusYOut = [ -7., 0., 7. ] minusXminusMinusYIn1 = [ -5., 0., 2. ] minusXminusMinusYIn2 = [ -2., 0., 5. ] minusXminusMinusYOut = [ 3., 0., 3. ] # (2 * Inf) should be Inf # (2 * -Inf) should be -Inf XtimesYIn1 = [ -5., 0., 2., 0., 2., 0., 2. ] XtimesYIn2 = [ -2., 0., 5., 24., Inf, Inf, -Inf ] XtimesYOut = [ 10., 0., 10., 0., NaN, NaN, NaN ] minusXtimesYIn1 = [ -5., 0., 2. ] minusXtimesYIn2 = [ -2., 0., 5. ] minusXtimesYOut = [ -10., 0., -10. ] XdivYIn1 = [ -5., 0., 2., 0., 1., -1. ] XdivYIn2 = [ -2., 0., 5., 24., 0., 0. ] XdivYOut = [ 2.5, NaN, 0.4, 0., Inf, -Inf ] minusXdivYIn1 = [ -5., 0., 2., 0., 1., -1. ] minusXdivYIn2 = [ -2., 0., 5., 24., 0., 0. ] minusXdivYOut = [ -2.5, NaN, -0.4, 0., -Inf, Inf ] # Most languages return NaN for 0^0 XtoTheYIn1 = [ -5., 0., 2. ] XtoTheYIn2 = [ -2., 0., 5. ] XtoTheYOut = [ .04, 1., 32. ] # Most languages return NaN for -(0^0) minusXtoTheYIn1 = [ -5., 0., 2., 1. ] minusXtoTheYIn2 = [ -2., 0., 5., 2. ] minusXtoTheYOut = [ -.04, -1., -32., -1. ] # Loop through the various calculated channels to test TestIn1 = [ XplusYIn1, minusXplusYIn1, XplusMinusYIn1, minusXplusMinusYIn1, XminusYIn1, minusXminusYIn1, XminusMinusYIn1, minusXminusMinusYIn1, XtimesYIn1, minusXtimesYIn1, XdivYIn1, minusXdivYIn1, XtoTheYIn1, minusXtoTheYIn1 ] TestIn2 = [ XplusYIn2, minusXplusYIn2, XplusMinusYIn2, minusXplusMinusYIn2, XminusYIn2, minusXminusYIn2, XminusMinusYIn2, minusXminusMinusYIn2, XtimesYIn2, minusXtimesYIn2, XdivYIn2, minusXdivYIn2, XtoTheYIn2, minusXtoTheYIn2 ] TestOut = [ XplusYOut, minusXplusYOut, XplusMinusYOut, minusXplusMinusYOut, XminusYOut, minusXminusYOut, XminusMinusYOut, minusXminusMinusYOut, XtimesYOut, minusXtimesYOut, XdivYOut, minusXdivYOut, XtoTheYOut, minusXtoTheYOut ] abstol = eps reltol = math.sqrt(eps) for j in range(0,len(TestOut)): Chan = TestChan[j] Out = TestOut[j] Minus1 = TestMinus1[j] In1 = TestIn1[j] Op = TestOp[j] Minus2 = TestMinus2[j] In2 = TestIn2[j] for i in range(0,len(Out)): print("Testing: %g = %s(%g) %s %s(%g) ..." % (Out[i], Minus1, In1[i], Op, Minus2, In2[i])) wks.SetSingleChannelValue("X",In1[i]) wks.SetSingleChannelValue("Y",In2[i]) sleep() result = wks.GetSingleChannelValue(Chan) if(math.isnan(Out[i]) and not math.isnan(result)): assert False, "%s(%g) %s %s(%g): Expected %g Return Value %g not expected" % (Minus1, In1[i], Op, Minus2, In2[i], Out[i], result) elif(math.isinf(Out[i]) and not math.isinf(result)): assert False, "%s(%g) %s %s(%g): Expected %g Return Value %g not expected" % (Minus1, In1[i], Op, Minus2, In2[i], Out[i], result) elif(math.isinf(Out[i]) and math.isinf(result)): if(math.copysign(1,Out[i]) and not math.copysign(1,result)): assert False, "%s(%g) %s %s(%g): Expected %g Return Value %g not expected" % (Minus1, In1[i], Op, Minus2, In2[i], Out[i], result) else: tol = abstol + reltol*abs(Out[i]) if((result < Out[i] - tol) | (result > Out[i] + tol)): assert False, "%s(%g) %s %s(%g): Expected %g Return Value %g not expected" % (Minus1, In1[i], Op, Minus2, In2[i], Out[i], result) else: print("...Pass") # All operations at the same precedence are evaluated left to right # Precedence (highest is 1) # 1 -- Functions # 2 -- Power # 3 -- Unary minus # 4 -- Multiplication and division # 5 -- Addition and subtraction print(" ") print("Checking Operator Precedence...") channels = ("P", "Q", "R", "X", "Y", "Z") channelsValues= (16.0, 9.0, 3.0, 5.0, 0.125, 4.0) wks.SetMultipleChannelValues(channels,channelsValues) sleep() print("Using:") for i in range(0,6): print(" %s = %g" % (channels[i], channelsValues[i]) ) print(" ") channels = ("P+(Q*(R^2))", "(P*Q) + (X*Z)", "(P ^ Z) ^ Y", "(Q div R) div Y", "(P - Q) - R", "P + Z*((Q^4)^Y)*R + (P^2)^Y", "(P+R)*(Q^(Y*Z)+21)") expectedResults = [ 97.0, 164.0, 4.0, 24.0, 4.0, 54.0, 456.0 ] abstol = eps reltol = math.sqrt(eps) results = wks.GetMultipleChannelValues(channels) for i in range(0,len(expectedResults)): print("Testing: %g = %s ..." % (expectedResults[i], channels[i])) tol = abstol + reltol*abs(expectedResults[i]) if((results[i] < expectedResults[i] - tol) | (results[i] > expectedResults[i] + tol)): assert False, "%s: Expected %g Return Value %g not expected" % (channels[i], expectedResults[i], results[i]) else: print("...Pass") print("Test PASSED") finally: wks.StopWorkspaceFile("")
def test_worspace_api(): TEST_ID = 124123 wks = NIVeriStand.Workspace() print("") SYSDEFINITION = os.path.join(configutilities.get_autotest_projects_path(), "TestWorkspaceAPI", "TestWorkspaceAPI.nivssdf") print("Deploying %s" % SYSDEFINITION) wks.RunWorkspaceFile(SYSDEFINITION, 0, 1, 80000, "", "") try: # Verify the TEST_ID var on test file. test_ID = wks.GetSingleChannelValue("TEST_ID") assert test_ID == TEST_ID, "Deployed wrong test file" result = wks.GetEngineState() assert result[ 'systemdefinition_file'] == SYSDEFINITION, "Workspace file is not the same as deployed" wks.LockWorkspaceFile("", 'LOCK_PASSWORD') with pytest.raises(NIVeriStandException): wks.StopWorkspaceFile("") with pytest.raises(NIVeriStandException): wks.UnlockWorkspaceFile("") wks.UnlockWorkspaceFile('LOCK_PASSWORD') print("Get System Node Childern") result = wks.GetSystemNodeChildren( r"Controller/Simulation Models/Models/sinewave/Execution") assert len(result) == 4, "Model Exceution should return 4 nodes" print("Get System Node Channel List") result = wks.GetSystemNodeChannelList('') assert len( result) >= 100, "At the very least we always have 100 channel" print(result[2]) print("Get Alias List") result = wks.GetAliasList() assert len( result ) == 3, "Expected 3 alias but get something different %d" % len(result) assert result[ 'TEST_ID'] == r"Targets Section/Controller/User Channel/TEST_ID", "Expected an alias for TEST_ID incorrect" nodes = ('Controller/User Channel', 'Controller/User Channel/TEST_ID') result = wks.GetMultipleSystemNodesData(nodes) assert len(result) == 2, "Ask for 2 node info get no info" print("Validating channels") section = result[0] print(section) assert section['isChannel'] is False, "Expecting a section to returned" testNode = result[1] print(testNode) assert testNode['isChannel'] is True, "Expecteing a node to returned" print("Test PASSED") print("") # Report your result here assert True finally: wks.StopWorkspaceFile("")
def test_procedures_legacy(): wks = NIVeriStand.Workspace2("localhost") SYSDEFINITION = os.path.join(configutilities.get_autotest_projects_path(), "ProceduresTest", "ProceduresTest.nivssdf") print("Deploying %s" % SYSDEFINITION) wks.ConnectToSystem(SYSDEFINITION, 1, 60000) try: #Verify the TEST_ID var on test file. test_ID = wks.GetSingleChannelValue("TEST_ID") assert (test_ID == TEST_ID), "Deployed wrong test file" print("") print("Test ID =", TEST_ID) #Now do your test #Sample common operation #Give some time for the startup procedure to finish setting the initial variables time.sleep(2) print("") #Check that we skipped the first procedure and executed the Startup Procedure assert (wks.GetSingleChannelValue("Test Channel 6") >= 0), "Invalid procedure executed before Startup!" print( "Successfully skipped initial procedure. Checking Startup Procedure was invoked..." ) channelValues = wks.GetMultipleChannelValues( ("Test Channel 0", "Test Channel 1", "Test Channel 2", "Test Channel 3", "Test Channel 4", "Test Channel 7", "Test Channel 10", "Test Channel 11")) print("Startup channel values =", channelValues) assert (channelValues == [1000, 2000, 20000, 30000, 40000, 0, 10, 11]), "Startup Test Data Errors!" print("Startup Procedure invoked successfully") print( "Checking that Startup Procedure is waiting on Test Channel 5 before continuing" ) #Check that AfterStartupProcedure hasn't run yet. StartupProcedure should be waiting for TC5 >= 50000 assert (wks.GetSingleChannelValue("Test Channel 5") != -50000), "After Startup Procedure premature execution!" print("Startup Procedure successfully waiting") #Set Test Channel 5 to 50000 so that the Startup Procedure ends and proceeds to After Startup Procedure print("Triggering After Startup Procedure") wks.SetSingleChannelValue("Test Channel 5", 50000) time.sleep(2) assert (wks.GetSingleChannelValue("Test Channel 5") == -50000 ), "Failed to move onto After Startup Procedure" print("After Startup Procedure Executed Successfully") #Check that we don't move onto Also Should Not Run Procedure, because After Startup ends with End time.sleep(1) assert (wks.GetSingleChannelValue("Test Channel 6") >= 0), "Invalid procedure executed after After Startup!" print("Procedure execution ended successfully") #Test triggering alarms #Set number of alarm triggers. Each triggered alarm procedure should increment its trigger count variable. x = 5 print("Triggering Alarm 1 and 2 and 3", x, "times") for i in range(x): wks.SetSingleChannelValue("Alarm Channel 1", 1) time.sleep(2) wks.SetSingleChannelValue("Alarm Channel 2", 1) time.sleep(2) wks.SetSingleChannelValue("Alarm Channel 3", 1) time.sleep(2) a1TrigCount = wks.GetSingleChannelValue("Alarm 1 Trigger Count") a2TrigCount = wks.GetSingleChannelValue("Alarm 2 Trigger Count") a3TrigCount = wks.GetSingleChannelValue("Alarm 3 Trigger Count") print("Alarm 1 Trigger Count =", a1TrigCount) print("Alarm 2 Trigger Count =", a2TrigCount) print("Alarm 3 Trigger Count =", a3TrigCount) assert ((a1TrigCount == x) and (a2TrigCount == x)), "Alarms failed to trigger Alarm Procedures!" print("Alarm procedures successfully triggered") assert (a3TrigCount <= 0), "Alarm 3 triggered while disabled!" print("Alarm 3 successfully disabled, did not trigger") print("Triggering Procedure 4 which should enable Alarm 3") wks.SetSingleChannelValue("Alarm Channel 4", 1) time.sleep(1) print("Attempting to trigger Alarm 3...") wks.SetSingleChannelValue("Alarm Channel 3", 1) time.sleep(1) a3TrigCount = wks.GetSingleChannelValue("Alarm 3 Trigger Count") assert (a3TrigCount == 1), "Alarm 3 not successfully enabled!" print("Alarm 3 Trigger Count =", a3TrigCount) print("Alarm 3 successfully triggered") print( "Attempting to retrigger Alarm 3, which should now be disabled again after Alarm 3 Procedure executed" ) wks.SetSingleChannelValue("Alarm Channel 3", 1) time.sleep(1) a3TrigCount = wks.GetSingleChannelValue("Alarm 3 Trigger Count") assert (a3TrigCount == 1 ), "Alarm 3 failed to be set to disabled and was triggered!" print("Alarm 3 Trigger Count =", a3TrigCount) print("Alarm 3 successfully disabled and not triggered") #Alarms 5 and 6 test resetting multiple alarms in same sub-procedure using "Reset This Alarm". #Alarms 7 and 8 test the "Triggered alarm" checkbox of an Alarm command by having one sub-procedure which can reset any calling alarm. #(Using a sub-procedure tests to make sure that the triggered alarm is correctly passed to sub-procedures) x = 3 print("Triggering Alarm 5, 6, 7 and ", x, "times") for i in range(x): wks.SetSingleChannelValue("Alarm Channel 5", 1) time.sleep(2) wks.SetSingleChannelValue("Alarm Channel 6", 1) time.sleep(2) wks.SetSingleChannelValue("Alarm Channel 7", 1) time.sleep(2) wks.SetSingleChannelValue("Alarm Channel 8", 1) time.sleep(2) a5TrigCount = wks.GetSingleChannelValue("Alarm 5 Trigger Count") a6TrigCount = wks.GetSingleChannelValue("Alarm 6 Trigger Count") a7TrigCount = wks.GetSingleChannelValue("Alarm 7 Trigger Count") a8TrigCount = wks.GetSingleChannelValue("Alarm 8 Trigger Count") print("Alarm 5 Trigger Count =", a5TrigCount) print("Alarm 6 Trigger Count =", a6TrigCount) print("Alarm 7 Trigger Count =", a7TrigCount) print("Alarm 8 Trigger Count =", a8TrigCount) #Testing the alarm call stack with alarms 9, 10, and 11. Each alarm waits 5 seconds, then calls "Reset Triggered Alarm Sub-Procedure". #During this test, procedure 9 starts and is interrupted by procedure 10, which is interrupted by procedure 11. #The whole thing is run twice and makes sure that preempted alarms are properly reset once they resume. x = 2 print("Triggering Alarm 9, 10, 11 and ", x, "times") for i in range(x): wks.SetSingleChannelValue("Alarm Channel 9", 1) time.sleep(2) wks.SetSingleChannelValue("Alarm Channel 10", 1) time.sleep(2) wks.SetSingleChannelValue("Alarm Channel 11", 1) time.sleep(20) a9TrigCount = wks.GetSingleChannelValue("Alarm 9 Trigger Count") a10TrigCount = wks.GetSingleChannelValue("Alarm 10 Trigger Count") a11TrigCount = wks.GetSingleChannelValue("Alarm 11 Trigger Count") print("Alarm 9 Trigger Count =", a9TrigCount) print("Alarm 10 Trigger Count =", a10TrigCount) print("Alarm 11 Trigger Count =", a11TrigCount) assert ((a9TrigCount == x) and (a10TrigCount == x) and (a11TrigCount == x)), "Alarms failed to trigger Alarm Procedures!" print("Alarm procedures successfully triggered") print("Test PASSED") finally: #Always stop the engine. wks.StopWorkspaceFile("")
def test_alarm_api(): wks = NIVeriStand.Workspace() print("") SYSDEFINITION = os.path.join(configutilities.get_autotest_projects_path(), "TestAlarmAPI", "TestAlarmAPI.nivssdf") print("Deploying %s" % SYSDEFINITION) wks.RunWorkspaceFile(SYSDEFINITION, 0, 1, 80000, "", "") try: test_ID = wks.GetSingleChannelValue("TEST_ID") assert (test_ID == TEST_ID), "Deployed wrong test file" print("Testing Alarm manager functionality") alarmMgr = NIVeriStand.AlarmManager() result = alarmMgr.GetAlarmList() assert (len(result) == 3), "Expected 3 alarms returned from the system" print("Testing support for deprecated GetAlarmStatus() function") result = alarmMgr.GetAlarmsStatus() print(result) assert ( result['HighAlarm'] == 0), "Not expecting any alarm to be trigger" assert (result['MediumAlarm'] == 0 ), "Not expecting any alarm to be trigger" assert ( result['LowAlarm'] == 0), "Not expecting any alarm to be trigger" print("Testing Read Alarm Data") alarms = ('Alarm Group/AlarmTest1', 'Alarm Group/AlarmTest2', 'ConstantBoundAlarm') result = alarmMgr.GetMultipleAlarmsData(alarms, 60000) print("Verifying alarm data returned") assert (len(result) == 3), "Expected to get 3 alarms data back" print("Verifying Alarm Data") alarmTest1 = result[0] alarmTest2 = result[1] constantBoundAlarm = result[2] print(alarmTest1) assert (alarmTest1['WatchChannel'] == r"AlarmChannel1" ), "Fail to confirm alarm channel" assert ((alarmTest1['HighLimitIsConstant'] == 0) | (alarmTest1['HighLimitChannel'] == r"AlarmChannel1High")), "Fail to confirm high limit" assert ((alarmTest1['LowLimitIsConstant'] == 0) | (alarmTest1['LowLimitChannel'] == r"AlarmChannel1Low")), "Fail to confirm low limit" assert (alarmTest1['DelayDuration'] == 0.5 ), "Fail to confirm delay duration" assert (alarmTest1['ProcedureName'] == r"ResetAlarmTest1" ), "Fail to confirm procedure" assert (alarmTest1['Priority'] == 2 ), "Fail to confirm priority enum (deprecated)" # TODO: PriorityNumber not found key assert (alarmTest1['PriorityNumber'] == 5 ), "Fail to confirm priority number" assert (alarmTest1['State'] == 1), "Fail to confirm state" assert (alarmTest1['Mode'] == 0), "Fail to confirm mode" # TODO: GroupNumber not found key assert (alarmTest1['GroupNumber'] == 1), "Fail to confirm group number" print("Test alarm interface") BoundAlarmRef = NIVeriStand.Alarm('ConstantBoundAlarm') result = BoundAlarmRef.GetAlarmData(30000) assert (result == constantBoundAlarm ), "Alarm data from alarm interface differ from alarm manager" print("Test modifying alarm data") modAlarmData = result modAlarmData['HighLimit'] = 3 modAlarmData['LowLimit'] = -3 print("Testing support for deprecated SetAlarmData() function") BoundAlarmRef.SetAlarmData(modAlarmData) sleep() result = BoundAlarmRef.GetAlarmData(30000) assert (result == modAlarmData ), "Alarm data set cannot be confirmed on deprecated function" # TODO: SetAlarmData2 not implemented. print("Testing support using SetAlarmData2() function") BoundAlarmRef.SetAlarmData2(modAlarmData) sleep() result = BoundAlarmRef.GetAlarmData(30000) assert (result == modAlarmData ), "Alarm data set cannot be confirmed on function" print("Test modifying alarm state and mode") BoundAlarmRef.SetEnabledState(0) #indicate only BoundAlarmRef.SetAlarmMode(1) sleep() result = BoundAlarmRef.GetAlarmData(30000) assert (result['State'] == 0), "Alarm Mode is wrong" assert (result['Mode'] == 1), "Alarm Mode is wrong" BoundAlarmRef.SetEnabledState(1) BoundAlarmRef.SetAlarmMode(0) sleep() sleep() wks.SetSingleChannelValue(r"Controller/User Channel/AlarmChannel1", 20) wks.SetSingleChannelValue(r"Controller/User Channel/AlarmChannel2", 10) sleep() sleep() print("Testing alarm mutual exclusion within a group") AlarmTest2Ref = NIVeriStand.Alarm('Alarm Group/AlarmTest2') AlarmTest1Ref = NIVeriStand.Alarm('Alarm Group/AlarmTest1') result = AlarmTest1Ref.GetAlarmData(30000) result2 = AlarmTest2Ref.GetAlarmData(30000) assert (result['State'] == 2), "Alarm should be tripped" assert ( result2['State'] != 2 ), "Alarm should not be running due to an execution of a higher priority." print("Testing Alarm Execution Across Groups") result = BoundAlarmRef.GetAlarmData(30000) result2 = AlarmTest2Ref.GetAlarmData(30000) assert ((result['State'] == 2) and (result2['State'] == 2)), " Two alarms should be tripped simulteneously." print("Test PASSED") print("") finally: wks.StopWorkspaceFile("")
def test_calculated_channel_latch_legacy(): wks = NIVeriStand.Workspace() print("") SYSDEFFILE = os.path.join(configutilities.get_autotest_projects_path(), "CalcChanLatchTest", "CalcChanLatchTest.nivssdf") print("Deploying %s" % SYSDEFFILE) wks.RunWorkspaceFile(SYSDEFFILE,0,1,60000,"","") try: # Compute Machine Epsilon: The smallest floating point number when # added to one is greater than one. eps = 1.0 while ((1.0 + eps) > 1.0): epsLast = eps eps = eps / 2.0 eps = epsLast print("Machine Epsilon = %g" % (eps)) # This test suite latches the first eleven data points into conditional # calculated channels. We must wait for the counter to become 10. The # steps are enumerated 0..10 (eleven points). result=0 while (result < 10): sleep() result = wks.GetSingleChannelValue("Counter") # This test is sensitive to the system Delta T. Ensure that it is 0.1. print("Checking (Delta T)=0.1") expectedResult = 0.1 result = wks.GetSingleChannelValue("Delta T") assert(result == expectedResult), "Delta T (%g) does not match expected (%g)" % (result, expectedResult) print("...Pass") print("Checking first 11 latched time points") channels = ("Latch_T_0", "Latch_T_1", "Latch_T_2", "Latch_T_3", "Latch_T_4", "Latch_T_5", "Latch_T_6", "Latch_T_7", "Latch_T_8", "Latch_T_9", "Latch_T_10") results = wks.GetMultipleChannelValues(channels) expectedResults = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0] abstol = eps reltol = math.sqrt(eps) for i in range(0,len(expectedResults)): tol = abstol + reltol*abs(expectedResult) assert(expectedResults[i] - tol <= results[i] <= expectedResults[i] + tol), "%s => Expected %g. Return Value %g not expected." % (channels[i], expectedResults[i], results[i]) print("...Pass") channels = ("P", "Q", "R", "S") results = wks.GetMultipleChannelValues(channels) print("Input waveform: X = P*sin(Q*(Time+DeltaT) + R) + S") print("with P=%g, Q=%g, R=%g, S=%g" % (results[0], results[1], results[2], results[3])) print("Testing 11 stage latch of the first 11 points") channels = ("Latch_fT_0", "Latch_fT_1", "Latch_fT_2", "Latch_fT_3", "Latch_fT_4", "Latch_fT_5", "Latch_fT_6", "Latch_fT_7", "Latch_fT_8", "Latch_fT_9", "Latch_fT_10") results = wks.GetMultipleChannelValues(channels) channels = ("Exact_fT_0", "Exact_fT_1", "Exact_fT_2", "Exact_fT_3", "Exact_fT_4", "Exact_fT_5", "Exact_fT_6", "Exact_fT_7", "Exact_fT_8", "Exact_fT_9", "Exact_fT_10") expectedResults = wks.GetMultipleChannelValues(channels) for i in range(0,len(expectedResults)): assert(results[i] == expectedResults[i]), "%s => Expected %g. Return Value %g not expected." % (channels[i], expectedResults[i], results[i]) print("...Pass") print("Test PASSED") print("") finally: wks.StopWorkspaceFile("")
def test_model_manager2_legacy(): #Getting a handle to the workspace API #Other API: Model, Alarm, AlarmManager, SoftwareForcing, ModelManager wks = NIVeriStand.Workspace2('localhost') mmgr = NIVeriStand.ModelManager2('localhost') SYSDEFINITION = os.path.join(configutilities.get_autotest_projects_path(), "ModelParameterAPI_AUTOTEST", "ModelParameterAPI_AUTOTEST.nivssdf") print("Deploying %s" % SYSDEFINITION) wks.ConnectToSystem(SYSDEFINITION, 1, 60000) try: #Verify the TEST_ID var on test file. test_ID = wks.GetSingleChannelValue("TEST_ID") assert (test_ID == TEST_ID), "Deployed wrong test file" #declaring known and expected system values models = [ "VectMod", "VectModWorkspace", "VectModWorkspace2", "clocktest", "sinewave" ] sinewaveParams = ["Amplitude", "Bias", "Frequency", "Gain", "Phase"] workspaceList = ["CONST1by5", "CONST2by3", "CONST5by1"] paramList = [ "VectMod/1by5Param/Value", "VectMod/2by3Param/Value", "VectMod/5by1Param/Value" ] vectorParamList = workspaceList + paramList nonVectorParamList = sinewaveParams allParamInSystem = vectorParamList + nonVectorParamList CONST_1by5_initValue = [[1, 2, 3, 4, 5]] CONST_2by3_initValue = [[1, 2, 3], [10, 20, 30]] CONST_5by1_initValue = [[1], [2], [3], [4], [5]] CONST_VALUES = [ CONST_1by5_initValue, CONST_2by3_initValue, CONST_5by1_initValue ] #Now do your test print("Testing GetModelList") sysmodels = mmgr.GetModelList("Controller") for model in models: assert model in sysmodels, "Missing model expected to be returned by system" with pytest.raises(NIVeriStandException): mmgr.GetModelList("NON_EXISTING_CONTROLLER") print("Testing GetParameterList") sysparamlist = mmgr.GetParametersList("Controller") for param in allParamInSystem: assert param in sysparamlist, "Missing parameter expected to be returned by system %s" % param with pytest.raises(NIVeriStandException): mmgr.GetParametersList("NON_EXISTING_CONTROLLER") print("Testing Get Single Parameter Value") result = mmgr.GetSingleParameterValue("Controller", workspaceList[1]) assert ( result == CONST_1by5_initValue[0][0] ), "Error on getting single parameter value get %f and expected %d" % ( result, CONST_1by5_initValue[0][0]) with pytest.raises(NIVeriStandException): mmgr.GetSingleParameterValue("NON_EXISTING_CONTROLLER", workspaceList[1]) print("Testing Get Multiple Parameter Values") result = mmgr.GetMultipleParameterValues("Controller", vectorParamList) expresult = [1, 1, 1, 1, 1, 1] for i in result: assert ( i == 1 ), "Error on getting multiple parameter value get %d and expected 1" % i with pytest.raises(NIVeriStandException): mmgr.GetMultipleParameterValues("NON_EXISTING_CONTROLLER", vectorParamList) print("Testing Get Parameter Vector Values") for i in range(0, 3): result = mmgr.GetParameterVectorValues("Controller", workspaceList[i]) assert (result == CONST_VALUES[i] ), "Error verifying vector values %s" % workspaceList[i] with pytest.raises(NIVeriStandException): mmgr.GetParameterVectorValues("NON_EXISTING_CONTROLLER", workspaceList[1]) print("Testing Get Parameter Vector Values 2") for i in range(0, 3): result = mmgr.GetParameterVectorValues("Controller", paramList[i]) assert (result == CONST_VALUES[i] ), "Error verifying vector values %s" % paramList[i] print("Test Set Single Parameter Value") for param in nonVectorParamList: print(("Set parameter " + param)) mmgr.SetSingleParameterValue("Controller", param, 2) sleep() with pytest.raises(NIVeriStandException): mmgr.SetSingleParameterValue("NON_EXISTING_CONTROLLER", nonVectorParamList[1], 2) for param in nonVectorParamList: print(("Verifying Set Paramater " + param)) result = mmgr.GetSingleParameterValue("Controller", param) assert (result == 2 ), "Error verifying set single parameter value %s %d" % ( param, result) print("Test Set Multiple Parameter Values") newValue = (3, 3, 3, 3, 3) mmgr.SetMultipleParameterValues("Controller", nonVectorParamList, newValue) sleep() result = mmgr.GetMultipleParameterValues("Controller", nonVectorParamList) for i in result: assert ( i == 3 ), "Error verifying set multiple parameter value get %d and expected 3" % i with pytest.raises(NIVeriStandException): mmgr.SetMultipleParameterValues("NON_EXISTING_CONTROLLER", nonVectorParamList, newValue) print("Test Set Single Vector Values") CONST_1by5_modValue = [[6, 7, 8, 9, 10]] CONST_2by3_modValue = [[4.25, 5.25, 6.25], [7.5, 8.5, 9.5]] CONST_5by1_modValue = [[6], [7], [8], [9], [10]] CONST_MODVALUES = [ CONST_1by5_modValue, CONST_2by3_modValue, CONST_5by1_modValue, CONST_1by5_modValue, CONST_2by3_modValue, CONST_5by1_modValue ] for i in range(0, 6): print("Set Parameter Vector for " + vectorParamList[i]) mmgr.SetParameterVectorValues("Controller", vectorParamList[i], CONST_MODVALUES[i]) sleep() for i in range(0, 6): print("Verifying Set Parameter Vector for " + vectorParamList[i]) result = mmgr.GetParameterVectorValues("Controller", vectorParamList[i]) assert ( result == CONST_MODVALUES[i] ), "Error verifying set parameter vector values %s" % vectorParamList[ i] print("Test Set Parameters Values") TESTPARAMS = ["Amplitude", "CONST1by5", "VectMod/2by3Param/Value"] SINGLE_PARAM_TESTVALUE = [[10]] CONST_1by5_TestValue = [[100, 200, 300, 400, 500]] CONST_2by3_TestValue = [[1000.25, 2000.25, 3000.25], [4000.5, 5000.5, 6000.5]] TESTVALUES = [ SINGLE_PARAM_TESTVALUE, CONST_1by5_TestValue, CONST_2by3_TestValue ] mmgr.SetParameterValues("Controller", TESTPARAMS, TESTVALUES) sleep() sleep() assert (mmgr.GetSingleParameterValue("Controller", "Amplitude") == 10 ), "Error verifying set parameter values to a single parameter" assert ( mmgr.GetParameterVectorValues("Controller", "CONST1by5") == CONST_1by5_TestValue ), "Error verifying set parameter vector values to a 1 by 5 parameter" assert ( mmgr.GetParameterVectorValues( "Controller", "VectMod/2by3Param/Value") == CONST_2by3_TestValue ), "Error verifying set parameter vector values to a 2 by 3 parameter" print("Test Set and Get Vector Channel Values") #VectModWorksace_2by3Out value = VectModWorkspace_2by3In value + CONST2by3 param value #VectModWorksace2_2by3Out value = VectModWorkspace2_2by3In value + CONST2by3 param value CONST_2by3_VECTOR = [[1, 2, 3], [10, 20, 30]] CONST_2by3_VECTOR_TIMES2 = [[2, 4, 6], [20, 40, 60]] CONST_2by3_VECTOR_ZEROES = [[0, 0, 0], [0, 0, 0]] inports = ["VectModWorkspace_2by3In", "VectModWorkspace2_2by3In"] outports = ["VectModWorkspace_2by3Out", "VectModWorkspace2_2by3Out"] wks.SetChannelVectorValues(inports[0], CONST_2by3_VECTOR_ZEROES) wks.SetChannelVectorValues(inports[1], CONST_2by3_VECTOR) mmgr.SetParameterVectorValues("Controller", "CONST2by3", CONST_2by3_VECTOR) sleep() result = wks.GetChannelVectorValues(outports[0]) print(result) assert ( result == CONST_2by3_VECTOR ), "Error verifying get channel vector value for %s" % outports[0] result = wks.GetChannelVectorValues(outports[1]) print(result) assert ( result == CONST_2by3_VECTOR_TIMES2 ), "Error verifying get channel vector value for %s" % outports[1] print("Test Set Channel Values") CONST_2by3_VECTOR_Hundreds = [[100, 200, 300], [400, 500, 600]] CONST_2by3_VECTOR_Thousands = [[1000, 2000, 3000], [4000, 5000, 6000]] wks.SetChannelValues( inports, [CONST_2by3_VECTOR_Hundreds, CONST_2by3_VECTOR_Thousands]) sleep() result = wks.GetChannelVectorValues(outports[0]) print(result) assert (result == [[101, 202, 303], [ 410, 520, 630 ]]), "Error verifying get channel vector value for %s" % outports[0] result = wks.GetChannelVectorValues(outports[1]) print(result) assert (result == [[1001, 2002, 3003], [ 4010, 5020, 6030 ]]), "Error verifying get channel vector value for %s" % outports[1] print("Test Model Set State") print("Test various constructor mode") Constructor1 = NIVeriStand.Model("VectMod") Constructor2 = NIVeriStand.Model("VectMod", "Controller") Constructor3 = NIVeriStand.Model("VectMod", None, "localhost") model = NIVeriStand.Model("VectMod", "Controller", "localhost") #return 'time' : 'state' #Running = 0 Paused = 1 Resetting = 2 Idle = 3 Stopped = 4 Restoring = 5 Stopping = 6 #Start = 0, Pause = 1, Reset = 2 result = model.GetModelExecutionState() assert (result['state'] == 0), "Expected the model to be running" model.SetModelExecutionState(1) sleep() result = model.GetModelExecutionState() assert (result['state'] == 1), "Expected the model to be paused" model.SetModelExecutionState(2) sleep() result = model.GetModelExecutionState() assert (result['state'] == 3), "Expected the model to be idle" model.SetModelExecutionState(0) sleep() result = model.GetModelExecutionState() assert (result['state'] == 0), "Expected the model to be running" print("Test Save and Restore Model state") import tempfile SAVE_STATE_LOC = os.path.join(tempfile.mkdtemp(), 'saveModelState.txt') clock = NIVeriStand.Model("clocktest") print("Pause and get clock time") clock.SetModelExecutionState(1) sleep() result = clock.GetModelExecutionState() timeAtSave = result['time'] print("Time At Save %d" % timeAtSave) clock.SaveModelState(SAVE_STATE_LOC) sleep() print("Set model running") clock.SetModelExecutionState(0) sleep() sleep() sleep() sleep() sleep() print("Check if save state file exist on disk") assert ( (os.path.isfile(SAVE_STATE_LOC)) == 1 ), "Error verifying that the save parameter state file is on disk %s" % SAVE_STATE_LOC print("Pause and restore model state") clock.SetModelExecutionState(1) sleep() result = clock.GetModelExecutionState() currentTime = result['time'] print("Current Model Time %d" % currentTime) clock.RestoreModelState(SAVE_STATE_LOC) sleep() clock.SetModelExecutionState(0) sleep() result = clock.GetModelExecutionState() timeRestored = result['time'] print("Time Restored %d" % timeRestored) assert timeAtSave <= timeRestored <= currentTime, "Error verifying restore parameter state" print("Test PASSED") finally: #Always stop the engine. wks.StopWorkspaceFile("")
def test_calculated_channel_formula_legacy(): wks = NIVeriStand.Workspace() print("") SYSDEFFILE = os.path.join(configutilities.get_autotest_projects_path(), "CalcChanFormulaTest", "CalcChanFormulaTest.nivssdf") print("Deploying %s" % SYSDEFFILE) wks.RunWorkspaceFile(SYSDEFFILE, 0, 1, 60000, "", "") try: # Compute Machine Epsilon: The smallest floating point number when # added to one is greater than one. eps = 1.0 while ((1.0 + eps) > 1.0): epsLast = eps eps = eps / 2.0 eps = epsLast print("Machine Epsilon = %g" % (eps)) # Sleep until the first Time (a calculated channel) is greater than # zero. This will be either the first or second time the calculated # channels are computed. In VeriStand 2010, the first time the # channels are calculated is at Delta T. At any rate, we do not want # to proceed until we have performed some calculations. result = 0 while (result <= 0): sleep() result = wks.GetSingleChannelValue("Time") # All formulas in VeriStand must have input values. Zero is computed # so that it can be used as an input to certain formulas. The way # it is computed, it should be precisely zero. No epsilon logic should # be used to ensure that it is in fact zero. print("Checking Zero=(Time - Time)") expectedResult = 0 result = wks.GetSingleChannelValue("Zero") assert (result == expectedResult ), "Time-Time (%g) does not match calculated (%g)" % ( expectedResult, result) print("...Pass") # All formulas in VeriStand must have input values. MinusOne is computed # so that it can be used as an input to certain formulas. The way # it is computed, it should be precisely -1. No epsilon logic should # be used to ensure that it is in fact -1. print("Checking MinusOne=(Zero - 1)") expectedResult = -1 result = wks.GetSingleChannelValue("MinusOne") assert (result == expectedResult ), "Zero-1 (%g) does not match calculated (%g)" % ( expectedResult, result) print("...Pass") # This computation of Pi should be accurate to all bits in the mantissa. # We only use epsilon logic to allow for difference between the transfer # between C# and Python. print("Checking Pi=acos(-1) Computation") expectedResult = math.pi abstol = 0 reltol = eps result = wks.GetSingleChannelValue("Pi") tol = abstol + reltol * abs(expectedResult) assert ((result >= expectedResult - tol) and (result <= expectedResult + tol) ), "Pi=acos(-1) (%g) does not match calculated (%g)" % ( expectedResult, result) print("...Pass") # Exponentiation is higher precedence than multiplication and # multiplication is higher precedence than addition. The floating # point values contain integers. Therefore no epsilon logic is # needed. print("Checking Operator Precedence with P+Q*R^2 == P+(Q*(R^2))") channels = ("P", "Q", "R") channelsValues = (12, 6, 3) wks.SetMultipleChannelValues(channels, channelsValues) channels = ("PplusQtimesRsq", "PplusQtimesRsq_Exact") expectedResults = [66, 66] results = wks.GetMultipleChannelValues(channels) for i in range(0, len(expectedResults)): assert (results[i] == expectedResults[i] ), "%s Expected %g Return Value %g not expected" % ( channels[i], expectedResult, result) print("...Pass") # Testing against zero; don't use reltol; only use abstol. print("Testing T-acos(cos(T)) where T=(Time modulo Pi)") expectedResult = 0 abstol = eps reltol = 1 result = wks.GetSingleChannelValue("ZeroEqualsTMinusAcosCosT") tol = abstol + reltol * abs(expectedResult) assert (expectedResult - tol <= result <= expectedResult + tol), "T-acos(cos(T)) (%g) does not match calculated (%g)" % ( expectedResult, result) print("...Pass") # Testing against zero; don't use reltol; only use abstol. print("Testing T-asin(sin(T)) where T=(Time modulo Pi) - (Pi/2)") expectedResult = 0 abstol = eps reltol = 1 result = wks.GetSingleChannelValue("ZeroEqualsTMinusAsinSinT") tol = abstol + reltol * abs(expectedResult) assert (expectedResult - tol <= result <= expectedResult + tol), "T-asin(sin(T)) (%g) does not match calculated (%g)" % ( expectedResult, result) print("...Pass") # Testing against one; don't use abstol; only use reltol. print("Testing Sin^2(T)+Cos^2(T) [should be one]") expectedResult = 1.0 abstol = 0 reltol = eps result = wks.GetSingleChannelValue("OneEqualsSinSqTPlusCosSqT") tol = abstol + reltol * abs(expectedResult) assert (expectedResult - tol <= result <= expectedResult + tol ), "Sin^2(T)+Cos^2(T) (%g) does not match calculated (%g)" % ( expectedResult, result) print("...Pass") # This computation of Pi should be accurate to all bits in the mantissa. # We only use epsilon logic to allow for difference between the transfer # between C# and Python. print("Checking Pi=4*atan(1) Computation") expectedResult = math.pi abstol = 0 reltol = eps result = wks.GetSingleChannelValue("PiEquals4TimesAtan1") tol = abstol + reltol * abs(expectedResult) assert (expectedResult - tol <= result <= expectedResult + tol), "Pi=4*atan(1) (%g) does not match calculated (%g)" % ( expectedResult, result) print("...Pass") # Each value in the subtraction should be plus or minus one. # The result should be precisely zero. The only value for this # equation that is not zero happens when Time=0. print("Checking (-1)^int(Time/Pi) - sign(sin(Time)); Should be zero") expectedResult = 0 result = wks.GetSingleChannelValue("AnotherFormulaForZero") assert (result == expectedResult ), "Test value (%g) does not match calculated (%g)" % ( expectedResult, result) print("...Pass") # To check the properties of random numbers, we must wait # until we have at least 100 data points. print( "Checking mean and variance of a uniform random number between 0 and 1." ) print("Mean should be 1/2 and the variance should be 1/12.") result = 0 while (result < 100): sleep() result = wks.GetSingleChannelValue("RandCount") # We must be sloppy in our checks here. We cannot expect the # underlying pseudo random number generator to be precisely white. channels = ("RandRunningMean", "RandRunningVariance", "RandErrorInVariance") expectedResults = [0.5, 1. / 12., 0.0] abstol = 0.03 reltol = 0.2 results = wks.GetMultipleChannelValues(channels) print("...Got mean=%g, variance=%g, errorInVariance=%g" % (results[0], results[1], results[2])) for i in range(0, len(expectedResults)): tol = abstol + reltol * abs(expectedResults[i]) assert (expectedResults[i] - tol <= results[i] <= expectedResults[i] + tol), "%s Expected %g Return Value %g not expected" % ( channels[i], expectedResults[i], results[i]) print("...Pass") # In order to test Peak & Valley, we must wait for at least # one cycle time of our input waveform. The time period for # the cosine is 2*Pi. We will wait for 10 seconds to allow # the waveform to be filtered and the peak detection's offset # algorithm to complete. print("Input waveform: X = 2*sin(30*Time) + 0.5*cos(Time) + 4") print("Applied lowpass Butterworth filter at 3Hz") print("Expected output waveform: 0.5*cos(Time) + 4") result = 0 while (result < 10): sleep() result = wks.GetSingleChannelValue("Time") # Be a bit sloppy on these checks. print("Checking error (tol) and offset (4.0) of output waveform") channels = ("ErrorInFilterOutMinusFour", "Z") channelNames = ("Error", "Offset") expectedResults = [0.0, 4.0] abstol = 0.05 reltol = 0.1 results = wks.GetMultipleChannelValues(channels) print("...Got offset=%g, acceptable error=%g" % (results[1], results[0])) for i in range(0, len(expectedResults)): tol = abstol + reltol * abs(expectedResults[i]) assert (expectedResults[i] - tol <= results[i] <= expectedResults[i] + tol), "%s Expected %g Return Value %g not expected" % ( channelNames[i], expectedResults[i], results[i]) print("...Pass") # Wait a lot more for the peak detection algorithm to publish # the peak and valley of our expected sinusoidal channel. result = 0 while (result < 30): sleep() result = wks.GetSingleChannelValue("Time") print("Checking peak (4.5) and valley (3.5) of output waveform") channels = ("PeakAndValleyOfFilterOut", "Y") channelNames = ("Peak", "Valley") expectedResults = [4.5, 3.5] abstol = 0.0001 reltol = 0.01 results = wks.GetMultipleChannelValues(channels) print("...Got peak=%g, valley=%g" % (results[0], results[1])) for i in range(0, len(expectedResults)): tol = abstol + reltol * abs(expectedResults[i]) assert (expectedResults[i] - tol <= results[i] <= expectedResults[i] + tol), "%s Expected %g Return Value %g not expected" % ( channelNames[i], expectedResults[i], results[i]) print("...Pass") # Be a bit sloppy in the following test. We have filtered the # two tone input and subtracted its offset and we are now # integrating the waveform using Simpson's rule. print("Applied Simpson's rule integration formula") print("Expected output waveform: 0.5*sin(Time)") expectedResult = 0 abstol = 0.05 reltol = 0.5 result = wks.GetSingleChannelValue("ErrorInIntegral") print("...Got acceptable error=%g" % (result)) tol = abstol + reltol * abs(expectedResult) assert ( expectedResult - tol <= result <= expectedResult + tol ), "Integral of (FilterOut - 4) does not match expected. Error is %g " % ( result) print("...Pass") # VeriStand computes all calculated channels in one time step. # We check here that it did just that. print( "Checking final calculated channels time equals initial calculated channels time" ) channels = ("Time", "FinalTime") results = wks.GetMultipleChannelValues(channels) assert ( results[0] == results[1] ), "Final Calculated Channels Time (%g) does not equal Initial (%g)" % ( results[1], results[0]) print("...Pass") print("Test PASSED") print("") finally: wks.StopWorkspaceFile("")
def test_worksspace2_api(): wks = NIVeriStand.Workspace2("localhost") print("") SYSDEFINITION = os.path.join(configutilities.get_autotest_projects_path(), "TestWorkspaceAPI","TestWorkspaceAPI.nivssdf") print("Deploying %s" % SYSDEFINITION) wks.ConnectToSystem(SYSDEFINITION,True,60000) try: #Verify the TEST_ID var on test file. test_ID = wks.GetSingleChannelValue("TEST_ID") assert(test_ID == TEST_ID), "Deployed wrong test file" result = wks.GetSystemState() assert(result['systemdefinition_file'] == SYSDEFINITION), "System definition file is not the same as deployed" wks.LockConnection("",'LOCK_PASSWORD') with pytest.raises(NIVeriStandException): wks.DisconnectFromSystem("",0) with pytest.raises(NIVeriStandException): wks.UnlockConnection("") wks.UnlockConnection('LOCK_PASSWORD') print("Get System Node Children") result = wks.GetSystemNodeChildren(r"Controller/Simulation Models/Models/sinewave/Execution") assert(len(result) == 4), "Model Exceution should return 4 node" #test we can still get system node children with full path. result = wks.GetSystemNodeChildren(r"Targets Section/Controller/Simulation Models/Models/sinewave/Execution") assert(len(result) == 4), "Model Exceution should return 4 node" print("Get System Node Channel List") result = wks.GetSystemNodeChannelList('') assert(len(result) >= 100), "At the very list we always have 100 channel" print(result[2]) print("Get Alias List") result = wks.GetAliasList() assert(len(result) == 3), "Expected 3 alias but get something different %d" % len(result) assert(result['TEST_ID'] == r"Targets Section/Controller/User Channel/TEST_ID"), "Expected an alias for TEST_ID incorrect" #Mix up different mode of how we look up system nodes data: full path and also relative to Targets Section. nodes = ('Targets Section/Controller/User Channel', 'Controller/User Channel/TEST_ID') result = wks.GetMultipleSystemNodesData(nodes) assert(len(result) == 2), "Ask for 2 node info get no info" print("Validating channels") section = result[0] print(section) assert(section['isChannel'] == 0), "Expecting a section to returned" testNode = result[1] print(testNode) assert(testNode['isChannel'] == 1), "Expecteing a node to returned" print("Test PASSED") print("") finally: wks.DisconnectFromSystem("",1)
def test_stimulus_api_legacy(): wks = NIVeriStand.Workspace() print("") SYSDEFFILE = os.path.join(configutilities.get_autotest_projects_path(), "TestStimulusAPI", "TestStimulusAPI.nivssdf") print("Deploying %s" % SYSDEFFILE) wks.RunWorkspaceFile(SYSDEFFILE, 0, 1, 60000, "", "") try: #Verify the TEST_ID var on test file. test_ID = wks.GetSingleChannelValue("TEST_ID") assert (test_ID == TEST_ID), "Deployed wrong test file" STIMULUSPROFILES_DIR = os.path.join( configutilities.get_autotest_projects_path(), "TestStimulusAPI") AutoStepTestStimulusAPI = os.path.join( STIMULUSPROFILES_DIR, "AutoStepTestStimulusAPI.nivstest") stimTest1 = NIVeriStand.Stimulus() stimTest2 = NIVeriStand.Stimulus() print("Test Reserve and Unreserve") stimTest1.ReserveStimulusProfileManager() print("Done reserving stimulus test 1") with pytest.raises(NIVeriStandException): stimTest2.ReserveStimulusProfileManager() print("Start unreserving") stimTest1.UnreserveStimulusProfileManager() stimTest2.ReserveStimulusProfileManager() stimTest2.UnreserveStimulusProfileManager() print("Run and get test state") result = stimTest1.GetStimulusProfileManagerState() assert (result == 0), "Test state not expected" print("Running Test " + AutoStepTestStimulusAPI) stimTest1.RunStimulusProfile(AutoStepTestStimulusAPI, STIMULUSPROFILES_DIR, 60000, 1, 1) sleep() result = stimTest1.GetStimulusProfileManagerState() assert (result == 2), "Test expected to started already" print("Test Getting back the file we are running") file = stimTest1.GetStimulusProfileFile() assert (file == AutoStepTestStimulusAPI), "Test file are not expected" print("Wait untill stimulus is done") time.sleep(40) result = stimTest1.GetStimulusProfileResult() result = stimTest1.GetStimulusProfileManagerState() assert (result == 0), "Test should have finished by now" stimTest1.RunStimulusProfile(AutoStepTestStimulusAPI, STIMULUSPROFILES_DIR, 60000, 1, 1) sleep() result = stimTest1.GetStimulusProfileManagerState() assert (result == 2), "Test expected to started already" stimTest1.StopStimulusProfile() sleep() result = stimTest1.GetStimulusProfileManagerState() assert (result == 0), "Test expected to stop" print("Test PASSED") print("") finally: wks.StopWorkspaceFile("")
def test_fault_api_legacy(): TEST_ID = 1879 wks = NIVeriStand.Workspace() print("") SYSDEFFILE = os.path.join(configutilities.get_autotest_projects_path(), "FaultChannelTest", "FaultChannelTest.nivssdf") print("Deploying %s" % SYSDEFFILE) wks.RunWorkspaceFile(SYSDEFFILE, 0, 1, 60000, "", "") try: #Verify the TEST_ID var on test file. test_ID = wks.GetSingleChannelValue("TEST_ID") assert (test_ID == TEST_ID), "Deployed wrong test file" faultChannel0 = 'FaultChannel0' chanfault = NIVeriStand.ChannelFaultManager() result = chanfault.GetFaultList() assert (len(result) == 0), "No channel should be faulted on startup" result = chanfault.GetFaultValue(faultChannel0) assert (result['faulted'] == 0), "Channel should not be faulted" nonFaultValue = wks.GetSingleChannelValue(faultChannel0) channel = chanfault.SetFaultValue(faultChannel0, 512) sleep() faultedValue = wks.GetSingleChannelValue(faultChannel0) assert (faultedValue == 512 ), "Channel is faulted and not returning expected value" result = chanfault.GetFaultValue(faultChannel0) assert (result['faulted'] == 1), "Channel should have been faulted" chanfault.ClearFault(faultChannel0) sleep() newValue = wks.GetSingleChannelValue(faultChannel0) assert (newValue == nonFaultValue ), "Channel should have return to original value" result = chanfault.GetFaultList() assert (len(result) == 0), "All channel should have been cleared" print("Test multiple channel faults") FaultValues = [('FaultChannel2', 12231), ('FaultChannel4', 123235), ('FaultChannel5', 1238945)] checkChannel = [] checkValues = [] for toFault in FaultValues: print("Set Fault %s" % (toFault[0])) chanfault.SetFaultValue(toFault[0], toFault[1]) checkChannel.append(toFault[0]) checkValues.append(toFault[1]) wks.SetSingleChannelValue(toFault[0], 11) sleep() result = chanfault.GetFaultList() assert (result == FaultValues), "Channel faulted does not match" chanValues = wks.GetMultipleChannelValues(tuple(checkChannel)) assert (checkValues == chanValues ), "Get Channel Value differ from Get Fault List result" print("Done test multiple channel faults") chanfault.ClearAllFaults() result = chanfault.GetFaultList() assert (len(result) == 0), "Fault channels should have been cleard" chanfault.ClearAllFaults() print("Test PASSED") finally: wks.StopWorkspaceFile("")