NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Access the Name and Value of a StationGlobals container programatically

Hello,
 
I am having some trouble trying to programmatically write the contents of a container into my HTML report header. The container contains a series of strings and numbers. These are saved into StaionGlobals.
 
Note that I am performing all of these operations in a statment step inside the sequence editor of TestStand
 
I used the following method to access the correct property, which sits inside a for loop. Now this seems to work fine as Locals.PropertyObj contains the element which I wish to access. In the following Locals.PropertyObj is an object. TestSetup is the name of my setup information container

Locals.PropertyObj = StationGlobals.GetNthSubProperty("TestSetup", StationGlobals.ForIterator, 0)

I can access the Name of the parameter simply by using the following code (where Locals.Name is a string):
 
Locals.Name = StationGlobals.GetNthSubPropertyName("TestSetup", StationGlobals.ForIterator, 0)
 
However when I try to access the actual value of the parameter I get an error or the wrong information. The following line gives me back the value "PropertyObject, IID = {8D87....}" which is not the value I am trying to get to.
 
Locals.Val = StationGlobals.GetNthSubProperty("TestSetup", StationGlobals.ForIterator, 0)
 
I must be doing something wrong, and have tried various methods to do this but cannot get my head around the problem. I tried to use the following also, but it resulted in an error:
 
Locals.PropertyObj.AsPropertyObject.GetFormattedValue((Locals.PropertyObj.AsPropertyObject).Name, 0, "", False, "")
 
Note that the following line works fine:
 
(Locals.PropertyObj.AsPropertyObject).Name
 
Also can you tell me why the lookup string needs to be defined in Locals.PropertyObj.AsPropertyObject.GetValueString(), is there a way to not require the lookup string as you are already have the correct property, and just the value is needed to be gotten.
 
One last thing, in Evaluate() how do I make it work with dots, for example the following line  (another attempt to get the value) did not work due to the presence of the . character 
 
Evaluate("StationGlobals.TestSetup." + (Locals.PropertyObj.AsPropertyObject).Name)
 
Many thanks in advance of your response,
Ben Lawler
 
ps. hope that I am not being stupid and missed something very obvious
0 Kudos
Message 1 of 7
(4,290 Views)

Hi Ben,

I keep it short. Please post an example of your StationGlobal and your Callbacks.
One SequenceFile is enough copy an paste your StationGlobal to a Local.StationContainer.
So other users and I can extract it.

Greetings

Juergen



Message Edited by j_dodek on 04-07-2008 01:55 PM
--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 2 of 7
(4,280 Views)
I have included my StationGlobals.ini file and also my sequence file.
 
The problem code lies within the ModifyReportHeader callback. In the Get Object statement I do 3 lines, the last one gives me the wrong data.
 
StationGlobals.TestSetup.TestSetupMode = 3
StationGlobals.TestSetup.ADSPath = "X:\2008\Enstone\VCar\08C13_VCE\D4\
etc...
 
I get the problem of not being able to get the value on the first element of StationGlobals.TestSetup, i.e. TestSetupMode
 
Hope that this is enough info for you.
 
Regards,
Ben
Download All
0 Kudos
Message 3 of 7
(4,262 Views)

Ben,

Just a few comments;

[Locals.PropertyObj = StationGlobals.GetNthSubProperty("TestSetup", StationGlobals.ForIterator, 0)]

This should give you a PropertyObject for the 1st subproperty of StationGlobals.TestSetup if StationGlobals.ForIterator = 0

 
[Locals.Name = StationGlobals.GetNthSubPropertyName("TestSetup", StationGlobals.ForIterator, 0)]
This should give you the name of the 1st subProperty of StationGlobals.TestSetup if StationGlobals.ForIterator = 0

[Locals.Val = StationGlobals.GetNthSubProperty("TestSetup", StationGlobals.ForIterator, 0)]

This is going to return the 1st subproperty of StationGlobals.TestSetup if StationGlobals.ForIterator = 0 as a PropertyObject reference
and Locals.Val should be an ActiveX Reference type which I am guessing it isn't.


[Locals.PropertyObj.AsPropertyObject.GetFormattedValue((Locals.PropertyObj.AsPropertyObject).Name, 0, "", False, "")]

I think this should be Locals.PropertyObj.GetFormattedValue("", 0, "", False, ""), you dont need to specify the lookup string because you have obtained a reference to the actual sub-PropertyObject.

and therefore
Locals.Val = Locals.PropertyObj.GetFormattedValue("", 0, "", False, "")
should give you the value of the 1st subproperty of StationGlobals.TestSetup if Locals.PropertyObj was obtained as above.

I will try to check out your sequencefile later when I have access to TestStand 4.x.

Regards

Ray Farmer


 

Regards
Ray Farmer
0 Kudos
Message 4 of 7
(4,250 Views)

Fantastic. That works nicely. Thanks Ray.

Yeah seems that the need to use the lookup string was confusing me as it wasn't needed.

Regards,

Ben

0 Kudos
Message 5 of 7
(4,241 Views)
Hi Ben,
 
Check out the example (I have delete all "uninterresting" stuff. I have only focused on the Header Callback)
 
Greetings
 
Juergen
 
 
 
--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 6 of 7
(4,237 Views)

Thanks for the sequences Juergen. They are clear and concise and will come in useful.

Regards,

Ben

0 Kudos
Message 7 of 7
(4,215 Views)