02-21-2008 09:23 PM
Hi, I am new to TestStand and I am still a bit puzzled about:
1. The differences between using Locals / Parameters / FileGlobals / StationGlobals in practices. (Especially between Locals and FileGlobals, I can’t notice any differences when using them)
2. When and how you would use a “Object Reference” / “ Container” variable.
I am hoping that someone can share some demonstrating examples or readings.
I am also interested to know the most common way/best practice to pass&share variable between sequences.
I want to avoid using “StationGlobals” because it appears to me that a StationGlobals variable is attached to a particular station/PC, if I run the same sequence file on another machine I will then need to redefine all StationGlobals variables. (Am I right about this?)
To get around, I have been using “Parameters” and “Locals”, however I have to say it is tedious and easy to make mistake to pass a top level variable to a subsequence at several levels down.
It got to be a better way… A variable type that is global to all sequences but not hardware dependent?
Thanks a lot.
Phillip
02-22-2008 01:23 AM
I am going to reply in several posts because I hit the 1000 character boundary .
1. The differences between using Locals / Parameters / FileGlobals / StationGlobals in practices. (Especially between Locals and FileGlobals, I can’t notice any differences when using them)
Locals are in scope (visible) for the Sequence they are defined in and in all three Groups Setup, Main and Cleanup. There are out of scope to other Sequences.
Parameters are the arguments defined for the Sequence so that when you call that Sequence using the SequenceCall Adapter in other sequences / Sequence Files you can pass data too. Its the interface to that sequence. A bit like the parameters of a function call in any other language. You can make the parameter so it allows any modications to the value within the sequence to be returned back to the caller, or you can set it so that does return a value.
FileGlobals are variables that are in scope for the Sequence File and visible to all Sequences within that SequenceFile. By default FileGlobals are out of scope (not visible ) to Sequences contained in another SequenceFile. You can change this to make Sequence Files use a common FileGlobals by changing a property in the Sequence FIle.
StationGlobals are in scope for everything. The one difference between StationGlobals and FileGlobals ( the other) is that Station Globals are retained after the execution has completed. Where as the others revert but to the static values when the execution completes.
Regards
Ray Farmer
02-22-2008 01:25 AM
Hi Phillip,
part 2
2. When and how you would use a “Object Reference” / “ Container” variable.
I am hoping that someone can share some demonstrating examples or readings.
You would use Object Reference when you obtain an activeX handle from some of the TestStand API functions. Look in the Programmers Reference Help Manual for snippets of use.
Containers are like structure in C/C++. If you browse the Sequence Context most of the Properties you see are contained in a Container. The Sequence Context is a Container. So a container is a place holder for difference variable types, whereas an array can only hold one type.
There are plenty of examples in the TestStand example folder, but if there is a specific task or example, then I or any other fellow member of the community would be only to glad to help.
I am also interested to know the most common way/best practice to pass&share variable between sequences.
I personnel think the best way is to use the Parameters of the Sequences. Try to limit the number of FileGlobals and StationGlobals. Use the StationGlobals for holding information about the Station / system. Use FileGlobals like constants.
I want to avoid using “StationGlobals” because it appears to me that a StationGlobals variable is attached to a particular station/PC, if I run the same sequence file on another machine I will then need to redefine all StationGlobals variables. (Am I right about this?)
You are right about StationGlobals, but if you use the TestStand API PropertyObject.SetVal methods, you can use the option to "InsertIfMissing". This allows you setup StationGlobals on other system very easily when you execute you Sequences. You could use one of the Callback Sequence to setup any Station Globals eg SequenceFileLoad to setup and SequenceFileUnload to remove any StationGlobals.
To get around, I have been using “Parameters” and “Locals”, however I have to say it is tedious and easy to make mistake to pass a top level variable to a subsequence at several levels down.
I can really comment other than to say maybe your sequence structure needs looking at if you are going down top many levels.
It got to be a better way… A variable type that is global to all sequences but not hardware dependent?
I dont know about a better way but there is a worst way and that is really too much on Globals variables. Too much relance on Globals variables is a big headache for later on in the softwares life when you are trying to maintain it. Especially if it a large set of Sequence / SequenceFiles.
Regards
Ray Farmer
02-22-2008 03:10 AM
02-24-2008 10:26 PM
Hi Ray,
It is much appreciated for your thorough answer, it was very good.
However I had trouble to implement some of suggested solutions.
*Using FileGlobals with “All Executions Share the Same File Globals”:
Maybe explaining the application I want to achieve will help.
I have Sequence A, B and C. Sequence A is the top level sequence.
In A.seq, a “Sequence Call” is used to call B.seq in which a VI is called to initialize a instrument and pass its handle back to A.seq. (Using a parameter)
Later in A.seq, another “Sequence Call” is used to call C.seq in which another VI is called to request for a measurement.
Basically what I am trying to do is to store the instrument handle into a global variable so it can be used by any other subsequences/vi inside A.seq.
I have tried A.seq with either “Separate File Globals of Each Execution” and “All Executions Share the Same File Globals” under the properties setup. In both cases, the “File Globals” I created in A.seq, is not available in C.seq.
(From reading the helps, I think this option is for the situation where I have parallel sequences running.)
*Using TestStand
I used “Set Property Value.VI” to create a StationGlobals with the “InsertIfMissing” set to true. It works fine normally but the problem is that the StationGlobals I want to insert is a custom type and “New Value” input only accepts a string/numeric/Boolean.
Regards
Phillip
02-25-2008 03:39 AM
Hi Phillip,
You need to have all sequence files that share set to “All Executions Share the Same File Globals” .
eg a.seq, b.seq, and c.seg
As regards to the PropertyObject.SetVal, this sounds like to need to use the SetValByOffset.
Regards
Ray
02-25-2008 03:36 PM
Hi Phillip,
Sorry but I have lead you up the garden path here.
“All Executions Share the Same File Globals” setting only really works for Parallel or Batch Sequence File. For all other types its does apply.
Therefore, this means for your sequences to share the FileGlobals must be in the same Sequence File or you must transfer the fileglobals from one sequence file to the another before executing any steps that would use those FileGlobals.
Regards
Ray Farmer
02-25-2008 06:04 PM
Hi Ray
So if B.seq and C.seq are both inside A.seq, it would be expected that a FileGloabls variable can be seen/shared along all files. Is this what you mean by “sequences to share the FileGlobals must be in the same Sequence File?”
However it does not seem to be the case in the example I attached here. To me, the “FileGloabls_Handle” inserted in A.seq behaves just as a local variable and C.seq can’t see it.
How exactly do I need to do?
Thanks.
Phillip
02-26-2008 01:13 AM
02-26-2008 01:34 AM
Phillip,
I cannot actually read your sequence files at the moment because of the binary format that ver 4.0 generates. ( Early versions I could read the seq files in notepad to get the gist of what they are doing). So I will look at them this evening. But I can see from your zip file that you have A.seq, B.seq and C.seq. I would have expect only one sequence file.
But in the mean time:-
If you have a Sequence File called 'A.seq' which contain a set of sequences and a FileGLobals variable
you have a number variable in FileGlobals called "MyNumber" = 0
a MainSequence,
a sequence called 'B' - in this sequence it reads FileGlobals.MyNumber and displays this
a sequence called 'C' - in this sequence it sets FileGlobals.MyNumber with a new value
In Main of MainSequence
Step 1 - a Statement step sets the value of FileGlobals.MyNumber = 5
Step 2 - A MessagePopup displays the value 5 using the expression Str(FileGlobals.MyNumber)
Step 3 - a SequenceCall calls sequence "B" in the current Sequence File (eg A.seq)
Step 4 - a SequenceCall calls sequence "C" in the current Sequence File (eg A.seq)
Step 5 - A MessagePopup displays the value 6 using the expression Str(FileGlobals.MyNumber)
In Main of 'B' Sequence
Step 1 - A MessagePopup displays the value 5 using the expression Str(FileGlobals.MyNumber)
In Main of 'C' Sequence
Step 1 - a Statement step sets the value of FileGlobals.MyNumber = 6
When you execute MainSequence of A.seq
Step 1 - FileGlobals.MyNumber = 5
Step 2 - a MessagePopup displays the value of 5 - your press OK
Step 3 - calls B Main in A.seq
Step 1 - a MessagePopup displays the value of 5 - your press OK
<end>
Step 4 - calls C Main in A.seq
Step 1 - FileGlobals.MyNumber = 6
<end>
Step 5 - a MessagePopup displays the value of 6 - your press OK
<end>
Hope this explains the process.
Regards
Ray Farmer