NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting a Steps Precondition only at runstate

Solved!
Go to solution

I am running a sequence in a loop.

 

In the current step's postexpression, I want to set the preconditon for that step, so that it is not executed in the next itteration.

 

What I try now changes the seq file: Runstate.Step.Precondition = "1=0"

 

Is there a simple way to do this? Do I have to use Runstate.Sequence.Main.<> and have to know somehow the step ID?

0 Kudos
Message 1 of 8
(5,058 Views)

Hello,

 

I am not sure to clearly understand why you want to modify the Precondition statement of a Step, from a PostExpression statement of this Step.

 

If you need to conditionaly loop on a Step, why don't you use FlowControl steps? Or looping options? I prefer FlowControl functions in terms of readability, even if it means more steps in the sequence. Simple is better, for you when you write a sequence and for everyone (including you) that maintain this sequence.

 

Best regards,

Message 2 of 8
(5,014 Views)

If you look at the step actions here: http://zone.ni.com/reference/en-XX/help/370052N-01/tsfundamentals/infotopics/step_execution/

 

You will notice that the precondition is outside of the step looping.  So changing it will have no impact on skipping the code module.

 

You are better off doing as Mathieu recommended and using multiple steps.  If you are dead set on using only one step then you could create a custom step and in the call to the module somehow precondition that.

 

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 3 of 8
(5,009 Views)

Hey ChristianL,

 

I agree with both the above responses that the adding this functionality could make your sequence difficult to read. However one way you could do this is to toggle a boolean variable of somekind. In the precondition of the sequence call step you could have it set so the sequence will only run if the boolean is true and then in the post expression set the boolean value to false so that the next iteration that sequence will not run. This would only work if you wanted the sub sequence to run only once.

 

Best,

hfar2

0 Kudos
Message 4 of 8
(5,005 Views)

None of the above is an option for my case.

 

Let me try to add some more clarification.

 

Complexity is not really an issue we do this once and that's it.

 

This is the pseudocode for my sequence: (and this structure has to remain unchanged! and I cannot change the status for InnerSeqCall steps)

 

for

    Seqcall

          {

                 InnerSeqCall1

                 InnerSeqCall2

          }

next

 

So what I want: Once an InnerSeqCall is Passed I never want to execute it again in the subsequent itterations. I was thinking that the easiest way would be to set at Runstate the precondition for InnerSeqCall to false. (and it works well the only problem is that it gets savend inside the sequence!)

0 Kudos
Message 5 of 8
(4,989 Views)

Hi ChristianL,

 

Still a little confused on exactly what functionality you want. So you want your InnerSeqCall1 and InnerSeqCall2 to only get called once? Is there anything else that is happening in that loop or in SeqCall? Would anything happen in the subsequent loop iterations since you only want InnerSeqCall1 and InnerSeqCall2 to execute once?

 

hfar2

0 Kudos
Message 6 of 8
(4,976 Views)

You could have something that iterates through and sets them all back to passed at the beginning of your sequence file.

 

Or you could use a parameter which would be an array of booleans.  Use those as the preconditions.

 

I threw a little example together demonstrating what I'm thinking.

 

Enjoy,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 7 of 8
(4,969 Views)
Solution
Accepted by topic author CristianL.

While trying the solution proposed by ~jiggawax~ I undestood the root cause of my solution failing. Built in properties like Precondition are saved into the seq object.

 

"Built-in properties of sequences are flagged to be shared at run time. Changes to built-in properties within the run-time copy of the sequence also edit the original Sequence object in the sequence file."

 

So now I have created a CUSTOM boolean property for every InnerSeqCall1 called ReRunStep (default = True) and used its value as Precondition

 

1. Evaluate precondition (True by default)

Precondition: RunState.Step.ReRunStep

 

2. Depending on status of the step I set ReRunStep to True or False

Post Expression: (Step.Result.Status != "Failed") ? RunState.Step.ReRunStep = False : True

 

It works because the value of the CUSTOM property Step.ReRunStep is not saved between executions.

 

 

0 Kudos
Message 8 of 8
(4,948 Views)