NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Help needed, how to pass variables in Model callbacks

Solved!
Go to solution

Hi guys,

I have a special problem. An important Index (something like the socket number) is needed everywhere during the execution of tests (in "call sequence" steps, in Model Options Callbacks, etc.). When the sequence is in the same file, I can use file globals to share the varaible, when the called sequence is in an other file I could propagate the variable or use a parameter. But parameters are seen only in the main sequence of the sequence file so how can I see a parameter from the caller in i.e the Model Options Callback? It is from a different file, so file globals do not work here!!!

 

Background: I need to define the Result directory for the report before or in the Report Options Model callback. So if I have a wrapper, which knows only by runtime which Test to call, this important index should come from the wrapper and should be handled before the Report Options Model callback is called (i.e. Model Options Callback would be my favorite, as this one is called only twice even with when two Reports are generated)....

Are there any ideas of how this parameter could be passed?

For me it is verry complicated to have such a lot of different methods to pass or share parameters, but still I haven't found a single one for my needs....

 

Thanks for your help.

 

Best Regards

Matthias  

0 Kudos
Message 1 of 8
(3,202 Views)

Not ideal, but have you looked into Station Globals? You should have access there from any file within TestStand.

0 Kudos
Message 2 of 8
(3,132 Views)
Solution
Accepted by topic author run321

Hi Matthias,

It may be that you can use file globals for this purpose. For an execution, Runstate.Main.FileGlobals will give you access to the file globals variables of the sequence file that contained the MainSequence that was called by the process model. So you could put shared globals into that file and have access to them in all sequence files. If you have control of the Process Model, you can also use Runstate.Root.FileGlobals and you'll be able to see everything in the Process Model's file globals from any file.

 

Alternatively, if you know which of your callers has the data you need, you can use Runstate.Caller.Fileglobals (or anything that the Caller can see). Note you can go up the call stack by nesting Runstate.Caller.Runstate.Caller... etc.

 

I hope this helps!

-Jack

 

Message 3 of 8
(3,128 Views)

Hi Jack,

thanks for your post. In the meantime I was able to pass the parameter into the sequence call of a new execution, even into the model options callback. It was not needed at all to change the parameter list of the callback!!!!!

 

But your approach is very interresting. I wonder if this would also be possible for a call of a sequence in a new execution. Normally with Runstate.Caller.Runstate.Caller.Runstate..... you can only step up the stack inside one execution and not higher :).

To use station globals does not help here, as I have 4 parallel executions, each with a different index (something like the Testsocket Index). 

 

Best regards

Matthias  

0 Kudos
Message 4 of 8
(3,125 Views)

RunState.Caller will not work in a sequence called in a new execution.  The call stack is reset for that execution.

 

Your only option is to parameterize this somehow when you kick off the new execution.

 

The attached sequence file demonstrates this.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 5 of 8
(3,118 Views)

Hi jiggawax,

thanks for your post. That's what I expected. Hope to find some time to check your sequence as the problem is solved already and I have a lot of time pressure right now.

 

I have no Xmas BBQ here so I give you a Kudo Smiley LOL

 

Best regards

Matthias

0 Kudos
Message 6 of 8
(3,115 Views)

Hi Jack,

I found a solution with file globals in the Sequence file (some time ago). The modell callbacks where in the same file so there was no problem in sharing the variables.

 

As these callbacks could change and then needs to be updated to all sequence files,... I thought it would be a good idea to generate a StationCallbacks.seq file to keep all callbacks. Unfortunately then I use another file so the link between the callbacks (all using file globals) and the main sequence in the sequence file is broken.... I would need to read the file globals from the StationGlobals.seq file. Then I tried to copy this variable into the Runstate.Main.FileGlobals..... but when I set a breakpoint, this new value of the variable does not appear......

The reason might be that the main is not jet started and RunState.Main. is still "nothing".

 

I hate to give up so close to the solution 🙂

 

Do you have any suggestion?

 

Thanks a lot.

 

Best regards

Matthias      

0 Kudos
Message 7 of 8
(2,945 Views)

Hi Jack,

this is just to tell you that I made it Smiley Happy

 

I created  a fileGlobals variable in the SequentialModel during runtime, so I can read it from the Main sequence.

The only thing I'm not so shure that it works would be after the deployement.

As I'm forced to work with environments (here different pathes) I wonder if it works when putting the StationCallbacks in the same relative (but not absolute) directory....

 

Hope it works.

 

Best regards

Matthias 

0 Kudos
Message 8 of 8
(2,943 Views)