NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Station Globals and File Globals Scope in Sequential Model

Solved!
Go to solution

Hi,

 

I am creating some example files to demonstrate the use of station globals and file globals using TestStand 4.2, Sequential Model.  I was assuming that station global value would be persistent to the station and file global values are persistent to the file (as long as the file not deleted, the value will stay).  But, after couple executions, I found that I am wrong. 

 

It looks to to me that, for file globals, the value resetted at each new execution.  I want to ask if this is correct behavior?  If is correct, can I say that: because each execution contains new instance of the file, therefore, at the starting of the new execution, new copy of the file globals are created.  (I am borrowing idea from the logic for batch model execution, but, for my example, I am using sequential model only).

 

Also, from reading other posts, for station globals, the value is not persistent until a file save command issued manually.  How do I issue this command?  And, are there similar command for file globals?

 

Thank you.

 

Peggy

 

0 Kudos
Message 1 of 17
(10,455 Views)
Solution
Accepted by PeggyC

Hi,

 

 

When teststand is closed the StationGlobals file is updated automatically, you dont have to do anything.

 

For FileGlobals, there is a static version, the ones you create at edit time, and there is a runtime version. When you modify the values at runtime, these are not retained when the execution has completed. Therefore if you wanted to retain the runtime values you would have to also change the static values and also save the sequence file.

 

There are examples in this forum for doing just that.

Hope this helps

Regards

Ray Farmer

 

Regards
Ray Farmer
0 Kudos
Message 2 of 17
(10,454 Views)

Hi,

 

If you what to manually save the StationGlobals, then perform a call to Engine.CommitGlobalsToDisk( promptOnSaveConflicts = True)

 

Check the TestStand Programmers Reference for more help.

 

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 3 of 17
(10,443 Views)

Thank you.  The answer is totally different from my understanding, but this is good.  Really appreciate the explanation.

 

One more question to ask.  How do I modify the static version?

 

Thanks.

 

Peggy

 

0 Kudos
Message 4 of 17
(10,419 Views)

One more thing, when you saying the static version, are you referring to "RunState.SequenceFile.Data.FileGlobalDefaults"?

 

I was poking around and found out that modifying the variable in this container is able to get the file global default value resetted.

 

Thank.

 

Peggy

 

 

0 Kudos
Message 5 of 17
(10,416 Views)

Hi,

 

Yes that's the container.

Regards
Ray Farmer
0 Kudos
Message 6 of 17
(10,396 Views)

Speaking of scopes, am I right to assume:

  • StationGlobals : visible in all sequences in all sequence files on the machine; values loaded at Engine startup from StationGlobals.ini file, then possibly different in different processes using the TestStand engine, written back to StationGlobals.ini, whenever an instance of the TestStand engine ends .... so that at the end the values in the file are those from the last TestStand process exiting.
  • FileGlobals : visible in all sequences of a particular sequence file, initialized to default values from the file, when an execution starts; local to an execution, so that they can have different values in every execution. Not automatically persistent.
  • Locals : visible only in the particular sequence, initialized to default values from the file, whenever that sequence is started; local to each call to that sequence. Not automatically persistent.

 

In addition to the above, I would really like to have variables with the same scope as StationGlobals, i.e. visible in all TestStand processes, but not automatically persistent. There are values, like handles to hardware, which should be globally visible over all executions in a process (since the hardware exists only once), but it can be a problem when these are written back with some arbitrary value and then initialized to that value during next startup. Yes, ProcessCleanup can take care of that, but that is not always easy.

 

Regards,

 

Peter

0 Kudos
Message 7 of 17
(10,349 Views)

Peter,

 

You might try Engine.TemporaryGlobals. Though you will need to dynamically create your variables or use one of TestStand's Unserialize/Read APIs to get the initial variable settings from a file or buffer.

 

Or another option might be to make the StationGlobals.ini file read-only if you never want to save it.

 


Also, as an addition to your summary of how the scoping works, File Globals have a setting option to make them shared across all executions. In the Sequence File Properties dialog you can choose All Executions Share the Same File Globals in order to get this behavior on a per sequence file basis.

 

Hope this helps,

-Doug

0 Kudos
Message 8 of 17
(10,334 Views)

Hi Doug,

 

both methods would work for us, I think: TemporaryGlobals as well as "Shared FileGlobals" where we would stuff all the variables to be held global over several executions into one sequence file. An advantage of the shared FileGlobals I see is that you can actually see them in the variable tree. Of course, it is not possible to see TemporaryGlobals during editing as they are created dynamically, but it would be nice if they were visible during runtime for debugging and watching.

 

Thanks

 

Peter

 

0 Kudos
Message 9 of 17
(10,314 Views)

If you are using TestStand 4.0 or higher, you can view the temporary globals in a watch expression using the following expression:

 

RunState.Engine.TemporaryGlobals

 

You can also view them from the StationGlobals or another variables view if you assign them to an Object Reference variable in one of those locations. For example, if you run a statement step containing:

 

StationGlobals.MyObjectReferenceVariable = RunState.Engine.TemporaryGlobals

 

You will then be able to expand MyObjectReferenceVariable in the station globals window to see the variables.

 

Hope this helps,

-Doug

0 Kudos
Message 10 of 17
(10,308 Views)