NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Execute step post-expression only if step is exiting

Solved!
Go to solution

I have a step with looping. I would like a post-expression to execute only if the step is done. Is there a step property for that?

0 Kudos
Message 1 of 8
(3,018 Views)

So technically you cannot precondition the post-expression.  However, you could use a conditional to execute your expression.  Something like this:

(Str(Evaluate(Step.LoopWhileExpression)) == "True") ? (Locals.Foo = 5) : False

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 8
(3,004 Views)

jigg, I'm not sure I am following. I would need a conditional in the post expression, but how can I know if the step is about to exit?

 

The goal is to add results to a results array only if the step is completed. If looping is enabled, the post expression is executed multiple times, and then the results array has too many entries.

 

I can accomplish the same in 3 steps, which is a little clunky but works:

 

1. execute multiple numeric limit test.

2. add results to result array

Locals.results += { RunState.PreviousStep.Result.Measurement["measurement_name"].Data }

3. goto end with precondition: RunState.Sequence.Main["test_name"].Result.Status != "Passed"

0 Kudos
Message 3 of 8
(2,990 Views)

As an aside, I just realized I can get rid of the 3rd step by combining it with the 2nd. A statement expression can have a post action on a custom condition, so I can have it exit there if the multiple numeric limit test failed.

 

Hm, the post action step only gets triggered when the step is about to exit, even if looping is enabled. I wonder what triggers that ...

0 Kudos
Message 4 of 8
(2,987 Views)

I'm not sure I follow your need.  At first you simply asked how to procondition a post-expression and now you are wanting to do some stuff with the Multi-Numeric Step where you inject results into the measurement array?

 

On the looping properties there is a Record Result of Each Iteration checkbox.  What is that set to.  Uncheck it and it should just grab the last one.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 5 of 8
(2,984 Views)

I am saving the results of the step into an array of numbers called Locals.results.  This happens in the post expression every time the step is executed, regardless of whether the box to record the results of each iteration is checked. I don't want it to happen if the step is not about to exit.

 

If a step with looping enabled fails twice and then passes, Locals.results will have accumulated 3 sets of values. Since Locals.results will get converted to a row in a CSV file, it will end up with too many columns.

0 Kudos
Message 6 of 8
(2,979 Views)
Solution
Accepted by topic author stephenb2

My bad.  I assumed you were talking Locals.ResultList.  I didn't realize you had made your own array called Locals.results.

 

So correct me if I'm wrong but you just want to capture the results from the last iteration into your array?  If so then delete everything in the Post-Expression and then in your Post Actions check the Use Custom Condition box and place the following in there:

 

Locals.results += { RunState.PreviousStep.Result.Measurement["measurement_name"].Data },
Step.Result.Status == "Passed"

Expressions always evaluate to the last element in the list of expressions which are separated by commas.

 

Let me know if this will work for you.

 

 

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 7 of 8
(2,974 Views)

Perfect. Exactly what I needed.

0 Kudos
Message 8 of 8
(2,971 Views)