NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I use RunState.ProcessModelClient.Data.Seq[0].Locals.MyVariable in batch model to set variables in a client sequence?

I have used RunState.ProcessModelClient.Data.Seq["MainSequence"].Locals.MyVariable to set Locals variables in client sequences running in a sequential model but it doesn't seem to work with the batch model. Using a breakpoint I found that RunState.ProcessModelClient.Data.Seq is a container listing all of the sequences in the client sequence with the Main Sequence being index 0.
 
I tried using RunState.ProcessModelClient.Data.Seq[0].Locals.MyVariable to set the variables in my client sequence and it worked fine.
 
My question: is this method reliable or am I doing something that might cause problems down the road?
 
Thanks,
Steve
0 Kudos
Message 1 of 6
(3,873 Views)

A few issues from doing it this way-

1- You should try an make your process model such that it can handle almost any sequence file thrown at it.  MainSequence may not a) contain that local variable and b) be at array element 0.  Unless you do some serious error checking then using your process model elsewhere will be a problem because it will throw errors.

2- It all depends on where you are changing that variable at.  Remember with the Batch Model that you are dealing with multiple copies of your client sequence.  If you change a Locals in the process model which threads does it actually affect?

3- Locals is to be used for the sole purpose of the sequence it resides in.  Just like in text based programming where you have a function call:

MyFunc(int x, int y){

string foo;

}

foo is local and really shouldn't be changed outside of MyFunc.  x and y are parameters and should be how data is shared among different sequences in TestStand.  There are variables for bigger scopes as well (i.e. StationGlobals, FileGlobals). 

I recommend using either a StationGlobal or passing the data as a parameter. 

In the end you are the engineer and the flexibility that TestStand gives you makes it so you can do things however you want. 

My 2 Cents,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 2 of 6
(3,850 Views)

Sam,

Thanks for your comments. I am relatively new to TestStand and this is the only method I could find to get my variables copied from the batch model to my client sequence. I understand the comments about scope. 

I just tried RunState.ProcessModelClient.Data.Seq[0].Parameters.MyVariable and that also works fine but of course I'm still calling Seq at the array index 0.

I tried to pass parameters through the subsequence calls but was unable to get past the subsequence calls that use variables for the called subsequence name (Create Test Socket Execution which calls the Test UUTs-Test Socket Entry Point and the MainSequence Callback).

I would appreciate any information concerning a better or more reliable way to get my variables copied from the batch model to my client sequence.

Thanks,

Steve

 

0 Kudos
Message 3 of 6
(3,844 Views)
Hey Steve,
 
When is the data ready? and when do you need to give it to your client sequence file?  Does the data have to be stored to your MainSequence's Locals?  Or can it be stored in the FileGlobals for your client sequence?  If so then one option is to add a callback to your process model.  Add the callback to your client sequence file and pass it the data as a parameter.  Then in the callback set the data to FileGlobals which can then be used by your MainSequence later.  This is just one idea. 
 
The problem I have personally with the RunState or Array based lookup strings is that they depend on so much.  (i.e. execution, elements in the array, threads, etc...).
 
TIP: After execution using the Parallel or Batch models you may have a bunch of execution windows open.  To close them all at once hit Ctrl-D
 
Regards,
jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 4 of 6
(3,829 Views)
Steve,

I'm not sure why you had problems with passing the parameter through subsequence calls, can you be more specific about what the problem was. Also, if you provide more details about what exactly you are trying to do we might be better able to suggest an alternative solution.

As far as passing an additional parameter from Create Test Socket Execution to Test UUTs-Test Socket Entry Point, you might not be aware that when a sequence call is specified by expression you can update the parameters list to specify a new prototype using the load prototype button. I'm not sure this is the best way to accomplish what you are trying to do, but it is possible to passing everything as parameters through the subsequences if that is ultimately what you want to do.

Hope this helps,
-Doug
Message 5 of 6
(3,817 Views)

Guys,

Thanks for the suggestions, I've got my code working now. Í'll explain what I did in case it may help someone else.

I was not aware that I needed to set the shared flag for FileGlobal variables so they would be available throughout a file. The shared flag I'm talking about is accessed through the advanced menu item when right-clicking on the variable.

I use a UImessage to load several arrays and variables from our user interface. The UI message is the 1st step in the Test UUTs Main of my modified batch process model. I place the variables in the batch process model FileGlobals so they can be available for various initialization steps in the process model.

Next, I built a custom callback (although one of the existing callbacks would work) in my batch model. Then in my client sequence I added the callback to the subsequence list and set it up to receive parameters from the batch model per Sam's suggestion. I then copy the variables into the FileGlobals in the client sequence, set the shared flag for each variable and they are available in all sequences in the file.  Eureka!

I also spent some time working with the load prototype button when the target sequence is specified by expression, I was able to get that working as well.

Thanks for the help!

Steve

0 Kudos
Message 6 of 6
(3,809 Views)