NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I overload a sequence?

Solved!
Go to solution

I would like to overload sequences in TestStand the way functions can be overloaded in other programming languages.  By overloading I mean I want multiple sequences with the same name and different parameters.  It makes calling and wrapping the function a lot easier and neater.

 

For example if I need 3 parameters to take a specific action, but I only have 2 and want to use the "standard" value for the 3rd parameter, I take action to get the third parameter inside a function with 2 parameters, then call the function with 3 parameters.

 

I put standard value in quotes because most of the time it won't be a numeric default.  It could be some piece of information obtained from a network, or a field from another parameter, or anything really.

 

0 Kudos
Message 1 of 9
(4,957 Views)

The capability you want isn't inherently built into TestStand.  It's not allowed to have 2 sequences named the same thing in the same sequence file. 

 

They way to get what you want is when you set up your Parameters for the subsequence then set the default values you want for each.  Then when someone places a sequence call to that subsequence they just check the Default value for the parameters they don't want to pass.  So I guess in a way it IS built in.  🙂

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

Can I programmatically determine that the sequence call had the Default box for the parameter checked, and if so how?

 

That way I could use a conditional statement and if necessary take action to get the values for the unspecified parameters.  Most of the time using numeric defaults won't work - I need to determine the value of the unspecified parameter programmatically.

0 Kudos
Message 3 of 9
(4,950 Views)
Solution
Accepted by topic author jaime_c

I think you are misunderstanding what I'm telling you....

 

The defaults for the common datatypes are:

Boolean=False

Numeric=0

String=""

 

However, that is not what I am referring to.  When you add a Parameter to a sequence there are 4 columns: Name, Value, Type, Comment.  Under the Value comment you put a value you want to be the default. Let's say you have a numeric parameter named Foo and you put 10 as the value.  Now when someone places down a sequence call to call that sequence and they check the default box for the Foo parameter the value will be 10 when it enters the subsequence.

 

Edit: If you want to really check if the default was used try:

RunState.CallingStep.Module.AsSequenceCallModule.Parameters.Item(X).UseDefaultValue whre X is the index of the parameter you want to check.

 

Cheers,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 4 of 9
(4,947 Views)

What is the use case for such a feature?

 

I mean, TestStand is no programming language, but a tool for automated testing for "sequences puproses" (simplified statement). So i am not aware of any usecase of overloaded test routines.

I am aware of variable versions of a single UUT type, let's call them 'variations'. So can be handled in TestStand using

- Property loader

- Preconditions and/or If/Switch statements [and/or Goto steps]

- Expressions for SequenceCall steps (the sequence names 'built' there have to point to sequences sharing the same set of parameters though, at least for easy usage)

 

Those three points enable the TestStand developer to cover all use cases i am currently aware of. So i am really eager to see one which would be really more intuitive to solve using "overloading".....

 

thanks,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 9
(4,933 Views)

The current use case is automotive diagnostics.

 

Most of the time to I want send diagnostic requests with the correct number of bytes but sometimes I do not.  So the sequence SendRequest would accept as one parameter a container that has the request information - numeric identifier, name, correct number of bytes, etc. - and as another parameter the actual number of bytes to use.  When i want to send the correct number of bytes, I wrap that SendRequest inside another SendRequest that only accepts the container, then calls the first SendRequest using using the container.correct_length field as the number of bytes to send.  It makes my work much easier if I can use the same name for both sequences.

 

This is just one example of a situation where I would like to overload sequences, but there will be many more.

 

I understand that TestStand is not a programming language, but developing test sequences is programming.  The simpler I can make the mechanics of that task - for example by reusing sequences and overloading sequences if possible :smileyhappy Smiley Happy - the more time I can spend thinking of the best ways to test my product.

 

As a side note, I am aware of the Automotive Diagnostics Command Set, but have been informed by my colleagues that it does not support LIN, which is the protocol I'm working with.

0 Kudos
Message 6 of 9
(4,927 Views)

Thanks, I will try these suggestions soon.  In most cases the first suggestion will work because I can set the default to an impossible value - for example a negative value for data length.

 

If it works I think I prefer the second suggestion because it would determine with certainty whether the caller had a value for the parameter.  I may be showing my ignorance of TestStand here, but how do I determine the index of a parameter?

0 Kudos
Message 7 of 9
(4,924 Views)

From top to bottom the first one is index 0.

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

Thanks!

0 Kudos
Message 9 of 9
(4,907 Views)