NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I create a constant in TestStand?

For example, if the symbolic value for the reverse gear on an automotive bus is 2, then I need a constant, REVERSE, that is accessible from all of the sequences in a file and cannot be changed from 2.  It is not obvious how to do this in the Variables tab.

Actually, I would like a way to share the constant among files - so it only has to be set in one place - and without using a Station Global because other projects may not use the same value for reverse, but I gather from my colleagues that NI's software doesn't normally offer that kind of flexibility.

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

Maybe a resource string?

 

http://zone.ni.com/devzone/cda/tut/p/id/3650

 

Not sure if that will fix your issue of people needing to override it though.

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

Unfortunately TestStand doesn't have constant so you are left with using a variable.

Use the FileGlobals if you want it accessible to all sequences in a sequencefile.

 

One way would be to set the attribute flag so that you cant edit it but once set then the only way to change it is by deleting the variable.

Regards
Ray Farmer
0 Kudos
Message 3 of 9
(4,886 Views)

Thanks.  File globals that are set to Not Editable seem the easiest, but as I said this value will need to be accessed my multiple files without being a Station Global.  Is all of the functionality for accessing text files built in to Test Stand?

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

Yes it is.  In fact I would recommend you look into property object files.  You can read about them in the help and if you have any questions let me know.

 

Unfortunately by setting a variable flag to not editable doesn't mean that you can't change the runtime value of that variable.  Because you can!  So that doesn't really buy you anything.

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

Thanks for the heads up.  I am just getting started with TestStand, so right now I only have a handful of sequence files.  I will look into the property object files while the the library is still small.

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

As a follow up to my previous question, is it easy to accidentally assign a value to a variable in TestStand?  I'm used to programming in a C like language where it was beneficial to have constants because it was very easy to accidentally change something.

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

Unfortunately TestStand doesn't have the ability to do constants unless you use a resource string.  But then you are stuck with a string type which is always easy to convert.

 

However, if you never assign that variable to anything and always just read it then you'll be fine.  But you have to have the wherewithal to assure that you don't assign it.  It actually is pretty easy to assign variables (e.g. Locals.Foo = 5)  And the thing is you can do this in any expression (which are scattered all over TestStand).  For instance each step has at least 3 expressions in the Pre, Post and Status.  So somebody could assign it and it wouldn't be easily recognized without doing searches and the like.

 

You are more than welcome to suggest this in the idea exchange: http://forums.ni.com/t5/NI-TestStand-Idea-Exchange/idb-p/teststandideas

 

Not sure if a product suggestion was ever made but you can also do that as well: http://forums.ni.com/t5/NI-TestStand/is-there-a-way-to-define-my-own-constants-in-teststand/td-p/735...

 

 

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

Hi,

 

Just an other solution...

If I have the requierement to share variables over sequence files i am using a queue.

http://forums.ni.com/t5/NI-TestStand/passing-information-between-callbacks/m-p/1261228#M30467

 

Hope this helps

 

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 9 of 9
(4,799 Views)