NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Evaluate function in teststand status expression

Solved!
Go to solution

Hello,

I can not understand the meaning of function Evaluate() in below sentence,and can not find the explanation in help files,could someone help me ?

 

Step.DataSource != "Step.Result.PassFail" ? Step.Result.PassFail = Evaluate(Step.DataSource) : False, Step.Result.PassFail ? "Passed" : "Failed" 

0 Kudos
Message 1 of 8
(9,924 Views)

Lets assume In this case step.datasource has a variable stored ex "locals.num"

 

The function Evaluate(Step.DataSource) does the following :

 

Get the variable name stored in step.datasource i.e. locals.num

Return the data stored in locals.num

 

 

0 Kudos
Message 2 of 8
(9,915 Views)

Thank you!

this expression  means below,but I am not clear that the "false" means, means do nothing?

 

if(Step.DataSource != "Step.Result.PassFail" )

{

Step.Result.PassFail = Evaluate(Step.DataSource)

}

else

{

false

}

 

if(Step.Result.PassFail )

{

passed

}

else

{

failed

}

0 Kudos
Message 3 of 8
(9,888 Views)

The step status i.e. step.result.passfail is set to either pass or fail by the expressions.

Slighty modified your steps :

 

if(Step.DataSource != "Step.Result.PassFail" )

{

Step.Result.PassFail = Evaluate(Step.DataSource)

}

else

{

Step.Result.PassFail = false

}

 

if(Step.Result.PassFail )

{

Step.Result.PassFail=passed

}

else

{

Step.Result.PassFail=failed

}

0 Kudos
Message 4 of 8
(9,884 Views)

Sorry,I am still not clear.

as you said,if Step.DataSource == "Step.Result.PassFail" (the default value of pass/fail step), then Step.Result.PassFail = false, then Step.Result.PassFail=failed,then the step fail. it seems wrong, Step.Result.PassFail should be valued by the output parameter.

0 Kudos
Message 5 of 8
(9,877 Views)
Solution
Accepted by tanggio

Sorry to confuse you.

Hope the explanation helps.

 

Step.DataSource != "Step.Result.PassFail" ? Step.Result.PassFail = Evaluate(Step.DataSource) : False, Step.Result.PassFail ? "Passed" : "Failed"

 

if(Step.DataSource != "Step.Result.PassFail" )  // True if user has selected a different data source ( by default its step.result.passfail)

{

Step.Result.PassFail = Evaluate(Step.DataSource)  // Get variable stored in step.datasource.Read the value and store in step.result.passfail

}

else

{

false   // Dont do anything when default data source is present

}

 

if(Step.Result.PassFail )  // It will have the latest value either by default or even if data source is changed.

{

passed  //status is set as passed

}

else

{

failed  //status is set as Failed

}

0 Kudos
Message 6 of 8
(9,872 Views)

Thank you,now I'm clear.

0 Kudos
Message 7 of 8
(9,855 Views)

As an added point of reference, we use the "Evaluate()" function to to parse Variables in a Step Name for TestStand steps.  This makes our steps very readable and FAST to code in TestStand.

 

For example our tests to communicate to a device might be to write a value to a value to a specific parameter, such as writing a Setpoint Value.  So the TestStand step name would look like:

 

[] Write:Setpoint(1)=200

    Where Setpoint is the Parameter Name, (1) represents the Instance, and 200 is the value written

 

However we use the Evaluate() function to parse out variables:

Locals.sParameter = "Setpoint"

Locals.nInstance = 1

Parameters.nValue = 200

 

[]Write:{L.sParameter}({L.nInstance})={P.nValue}

   (We use a shortened version of L. for Locals., P. for Parameters., etc. because it doesn't take up so much space on the Step Name)

 

We have a library subsequence (Check for Curly Brackets to be parsed) that parses out any variables that are enclosed in the {} curly brackets.

  Replace "L." with "Locals.", etc. and then parse out the variables in the Pre-Expression, 

and then EVALUATE the variables in the Post-Expression:

 

Locals.sTemporary ="RunState.Caller.RunState.Caller."& Locals.sVariable,
'If the variable exists, resolve it, if not replace it with '{ERROR}' and continue.
Locals.sTemporary =( PropertyExists(Locals.sTemporary)? Evaluate(Locals.sTemporary)  :"{ERROR}"),
'Put the resolved variable (or error) back in place of its name
Locals.sWorkingString = Locals.sBeforeVar & Locals.sTemporary & Locals.sAfterVar

 

Also, during runtime, if there happens to be an error in the StepName, we can edit it and continue on using a "Set Step Name" tool.

 

Mike

0 Kudos
Message 8 of 8
(9,848 Views)