01-08-2010 12:22 AM
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
Solved! Go to Solution.
01-08-2010 01:06 AM
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
01-08-2010 04:18 AM
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
01-08-2010 06:26 PM
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
01-08-2010 06:48 PM
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
01-11-2010 12:58 AM
Hi,
Yes that's the container.
01-13-2010 07:44 PM
Speaking of scopes, am I right to assume:
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
01-14-2010 11:18 AM
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
01-15-2010 10:44 AM
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
01-15-2010 01:44 PM
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