From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I pass parameters modified by the SequenceFileLoad callback?

I have some parameters in a sequence file that I want modified based on where the test station is located. I do not have that much experience with callbacks and have been reading up but wanted to reach out to the community as well. I know now that whatever is modified in the SequenceFileLoad callback is not passed onto the main sequence as it has not been started at this point. So what I am trying to do is have the operator choose a test facility once and have the parameters set and not have to choose everytime the sequence is initiated. I basically want the paramters set once, like when the fle is opened, and then it is done. Any help in how to implement this would be greatly appreciate.

 

Thanks,

Troy

0 Kudos
Message 1 of 10
(4,620 Views)

If "test facility" is a station-wide setting that you would like to persist between executions (and even persist if you restart the machine), you could store the value in a Station Global. These globals are accessible by any sequence file on the machine and persist their value between executions. We often caution users against over-using these variables because of their wide scope, but if you do have settings which apply to the entire machine, it might make sense to use such a global for this purpose.

0 Kudos
Message 2 of 10
(4,618 Views)

Daniel,

Thanks for the response. I was originally thinking about the station globals but thought there had to be an easier way. What I am trying to do it make this a one shot selection when the sequence is opened. I did not want to make the user have to select this option everytime the sequence was executed. Simply because the station is going to be where it is and that is where the sequence will be executed after opened. Simlpy put depending where the sequence is execute a different set of IP addresses will be used to test. They are all parameters but at each location are the different. So I did not want to make the user select the option everytime the sequence was executed. Of course the easy solution would be to do just that. I am trying to avoid that.

0 Kudos
Message 3 of 10
(4,612 Views)

You could perhaps have your SequenceFileLoad callback check to see if a certain StationGlobal (let's say TestFacility) is set, and only display a prompt to select it if it does not currently have a value. If you wanted to give the user an ability to update this value later (if they moved the test machine) you could add an entry point to the process model to set the variable again manually. That way you aren't nagging the user every time they open the sequence, but if the variable is not set, they will have the chance to set it.

0 Kudos
Message 4 of 10
(4,607 Views)

That is my problem right now. I am trying to figure out how to modify station globals on the fly and have it propagate to my main sequence. Any advice? I thought this would be relatively simple but so far I haven't gotten it to work. Thanks for the help so far.

0 Kudos
Message 5 of 10
(4,589 Views)

Happy to help out! I created an example which is attached to this message. This is what it does:

 

  • In SequenceFileLoad, it first checks to see if StationGlobals.TestFacility exists, and if not, it creates that variable. 
  • If the StationGlobal is set to "" (blank string), a prompt is displayed for the user to enter the facility. A post-expression on the Message Popup step sets the StationGlobals.TestFacility variable with this value.
  • When you execute MainSequence after loading the file, the current TestFacility is displayed.

The code could be simplified a bit if you can guarantee that StationGlobals.TestFacility will always exist as a variable. For example, the #NoValidation tags you see in some of the expressions are there because the StationGlobal may not exist prior to runtime. You could create the station global on your dev machine and deploy StationGlobals.ini to all test machines to ensure all machines have the variable and not need that part of the code, but I prefer the dynamic method because it won't cause an error if the station global is deleted for some reason.

 

I hope this helps clarify things a bit, and let me know if you have any questions about it!

0 Kudos
Message 6 of 10
(4,583 Views)

trosier,

 

StationGlobals are stored in a file so they always propagate to anything on the machine.

 

To invoke a StationGlobal just call:

StationGlobals.<GlobalName>  anywhere in any expression for teststand.

Example: Locals.BenchName = StationGlobals.BenchName

 

To set a StationGlobal just call:

StationGlobals.<GlobalName> = <NewValue>

Example:  StationGlobals.BenchName = Locals.BenchName

NewValue can be a variable or explicit value depending on the type of the station global. 

 

To add a Station Global:

StationGlobals.SetVal<Type>("<GlobalName>", 0x1, <NewValue>)

Example: StationGlobals.SetValString("BenchName", 0x1, "Bench21")

0x1 will force the variable to be inserted.

 

All of these can be placed in any expression in TestStand.

 

Hope this helps,

 

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

Daniel beat me.... 🙂

 

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

Daniel,

Thanks for all of your help. I was meaning to get back to you before you wasted anymore time but I figured out what I was doing wrong. However I am keeping your example for reference if needed later. I like the way you did it as well. After setting the globals dynamically I was referencing the file globals instead of the station globals to set my parameters in my sequence. Comeplete bonehead move but I sat back and took a breath and insisted this has to work based on the definition of a station global and how they propagate through TestStand sequences. Anyway I still like your example as I said and I am keeping it. Thanks again.

0 Kudos
Message 9 of 10
(4,573 Views)

Thanks for your help. This is how I intended it to work. Like I said in my previous post I had the variables wrong. It is all good now.

0 Kudos
Message 10 of 10
(4,572 Views)