NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass parameters with Step-Post Actions-'Call Sequence' option

I have a sub-sequence which accepts a single parameter.
Ideally I would like to call this sub-sequence from several Steps, using their Post Actions property , using a Custom Condition Expression and the On Condition False: Call Sequence option.
 
The Call Sequence option, when selected, offers a list of sub-sequences including the one which I wish to execute, if the conditions are correct, but I see no way of passing an argument to the sub-sequence's parameter.
 
Is there a simple way of passing the parameter ?
Is there a syntax I could apply to the sub-sequence selected string ? 
0 Kudos
Message 1 of 6
(4,801 Views)
From the TestStand Help:
Call sequence—TestStand calls a sequence before continuing to the next step. You can select any sequence in the sequence file. TestStand does not pass any arguments to the sequence. If the sequence has parameters, TestStand uses their default values.
 
So I don't think this particular method is going to work for you.  However, there are lots of ways to do this, here are a few I can think of off the top of my head (I'm sure there are more, and possibly better ones):
1.  Just insert a sequence call after every applicable step with an apropriate pre-condition.  This is the easiest method, but kind of messy and requires repeating the call everywhere.
2.  Change the parameter to a sequence file global... ylch, I hate globals... Terrible programming practice, but it's easy :).
3.  Override the SequenceFilePostStep Engine Callback and put a sequence call with an appropriate pre-condition in there.  This keeps you from having to repeat the code, but it will check the condition after every step executes, not just the ones you are interested in, so you may need some additional conditions.
4.  Define a custom step type for these steps and use a substep to call the sequence.
 
Hope that helps,
Ryan K.
Message 2 of 6
(4,801 Views)
A work around would be to use a local or global to pass data.  For example, you could define a local called PostActionParameter and access it in your post action sequence in an expression such as:
 

PropertyExists

("RunState.Caller.Locals.PostActionParameter") ? RunState.Caller.Locals.PostActionParameter : "<default value if post action parameter missing>"

Message 3 of 6
(4,792 Views)

Thanks for looking up the Help File, Ryan.

I will have to re-think my stratedgy.

Cheers,
 
Gary.
0 Kudos
Message 4 of 6
(4,783 Views)

@ryank wrote:
<snip>
4.  Define a custom step type for these steps and use a substep to call the sequence.
 
Hope that helps,
Ryan K.

 

Here I am 20 years later wondering how to call a sequence from a substep in a custom step type. Oh yeah, you still can't.  

0 Kudos
Message 5 of 6
(246 Views)

@motorized_barry wrote:

@ryank wrote:
<snip>
4.  Define a custom step type for these steps and use a substep to call the sequence.
 
Hope that helps,
Ryan K.

 

Here I am 20 years later wondering how to call a sequence from a substep in a custom step type. Oh yeah, you still can't.  


Do this:

eejallen_1-1720720083583.png

// clever way to add variable to the Step container to "pass" it to the Post Action sequence call
// These statements can also be in a Pre or Post Expression  (remove the "== 0"); however, putting it in Precondition also makes the updated Step container available to the PreStep call back
Step.AsPropertyObject().SetPropertyObject("Percent", PropOption_ReferToAlias | PropOption_NotOwning | PropOption_InsertIfMissing, Locals.Percent) == 0 &&
RunState.SequenceFile.GetSequenceByName("SubSeq").Parameters.SetPropertyObject("Step", PropOption_ReferToAlias | PropOption_NotOwning | PropOption_InsertIfMissing, Step) == 0

 

You could add whatever property you want to sequence parameters. As I say in the comment, I chose to add to the Step container since it is also readily passed to other callbacks.  If you don't need to pass the Step container then remove the first statement and update the second statement for your needs.

0 Kudos
Message 6 of 6
(214 Views)