NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the full location of an aliased PropertyObject

Solved!
Go to solution

Hi all,

 

I've been searching around and experimenting, but I haven't been able to figure this out yet. Maybe I'm just not using the right search terms.

 

I've written a sequence that returns an alias to a PropertyObject, the actual location of which may vary.

Parameters.SetPropertyObject("MyAlias",PropOption_NotOwning,RunState.Root.Locals.SomeDeeplyNestedVariable[6].foo)

Now, from outside this sequence, is there any way to get the full location of the aliased PropertyObject given the alias?

 

Thanks as always,

 

Mr. Jim

0 Kudos
Message 1 of 9
(1,659 Views)

Hi Mr. Jim! 

 

  1. What ADE are you interfacing with the TestStand API from (Visual Studio, LABWINDOWS/CVI, etc)? 
  2. When you say "from outside this sequence," do you mean to another sequence contained within the same workspace or a different sequence file all together? 
  3. Is this a property object you defined or something packaged within TestStand? 
  4. What "full location" are you looking for? A directory on the computer, some registry information, an address, something different? 

 

Bear with me as I try to understand what you are asking here!

 

 

 

 

Clint T.
Applications Engineer
National Instruments
Message 2 of 9
(1,611 Views)

Have you tried to walk up the object tree using the Parent property?

0 Kudos
Message 3 of 9
(1,606 Views)

Hi Clint, thanks for getting back to me!

 

Okay - so I'm guessing I didn't really give enough information.  (It sure made sense to me, why can't others make sense of it?  Smiley Very Happy)

 

Here's some more detail about what I'm trying to do:

This is all in TestStand using expressions - there's no external ADE being used for the subject matter in question.  What I'm doing is developing model plugins to implement customizations to model functionality and result processing. I wrote a sequence in one of my plugins that returns an alias to a certain run-time variable.  For example, often the following variable is aliased, otherwise very cumbersome:

RunState.Root.Parameters.ModelPluginConfiguration.Plugins[Locals.i].PluginSpecific.RuntimeVariables

The alias is useful when, for instance, my report generation plugin needs a timestamp stored in the model customization plugin, which owns the variables above.  Depending on the model in use and the context of where the sequence is called, the above variable may be in

RunState.Root.Locals.ModelPluginConfiguration...

...or it may be referenced relative to a sequence context I feed in as a parameter.  The alias to the RunTime variables is returned as a parameter, so I then I have the variables to work with.  ...But it would also sometimes be useful to know the full path to the actual variable being aliased.  (What's the index of my model plugin, etc.?)  If I could get the first code snippet above as a string, that would sometimes be useful for the calling code in discerning where the model plugins live.

 

This is tough to articulate, but hopefully the picture is becoming clearer?

 

Thanks very much for your help

 

Mr. Jim

0 Kudos
Message 4 of 9
(1,605 Views)

@James_Grey wrote:

Have you tried to walk up the object tree using the Parent property?


Hi James, thanks for your reply.  I did try that the other day, but I didn't have much luck. If my alias is Locals.RunTimeVariables, the parent I was getting was always "Locals."  (Was I missing a PropertyOption flag? I played around with some of the alias related ones)

 

I had stared at it for quite some time, so it's possible I missed something obvious.  I could try it again...

0 Kudos
Message 5 of 9
(1,604 Views)

Hmm... Okay I'm trying this again.

 

The actual full path that I'm trying to obtain is:

RunState.Root.Parameters.ModelPluginConfiguration.Plugins[0].PluginSpecific.RuntimeVariables

In my report generation plugin I have an alias to the variables above, Locals.RutimeVariables.

 

If I enter as a watch expression,

Locals.RunTimeVariables.Parent.Parent

I get the following:

watchPane.png

...I can see the plugin, but I can't figure out a way to get the path where it actually lives:

RunState.Root.Parameters.ModelPluginConfiguration.Plugins[0]

I'm looking for a property or method that gives me that. I'm sorry if I'm missing something obvious. (Other than the increasingly obvious signs that I probably shouldn't be doing this.  Smiley Wink Maybe I should just resign myself to writing a separate sequence to give me that string.) 

0 Kudos
Message 6 of 9
(1,601 Views)
Solution
Accepted by topic author Mr._Jim

As a test, I created a TestReport callback and added this statement to create a local alias to a property:

Locals.SetPropertyObject("IncludeLimits", PropOption_InsertIfMissing | PropOption_NotOwning, Parameters.ModelPlugin.PluginSpecific.Options.IncludeLimits)

I set a breakpoint just past the statement and ran single pass with a report enabled.

At the breakpoint I entered the following watch expressions:

Locals.IncludeLimits.Parent.Name
Locals.IncludeLimits.Parent.Parent.Name
Locals.IncludeLimits.Parent.Parent.Parent.Name
Locals.IncludeLimits.Parent.Parent.Parent.Parent.Name
Locals.IncludeLimits.Parent.Parent.Parent.Parent.Parent.Name
Locals.IncludeLimits.Parent.Parent.Parent.Parent.Parent.Parent.Name
Locals.IncludeLimits.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Name
Locals.IncludeLimits.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent

I got the following values:

"Options"
"PluginSpecific"
""
"Plugins"
"ModelPluginConfiguration"
"Locals"
"Single Pass"
Nothing

This is the correct path, in reverse, to where the property resides. The reason the third string is empty is that it is an unnamed element in an array. To complete that element of the property path, you'd need to search the array and use the index that you find the item at as a subscript.

Message 7 of 9
(1,586 Views)

Thanks James - much appreciated.  I'm now questioning my judgment in going down this path, but now I know it can be done.  (I'm guessing you might have been thinking, "Now why does he want to do that, anyway?")

 

Really, thanks for taking the time to investigate this, and also thanks to Clint for replying as well.

0 Kudos
Message 8 of 9
(1,582 Views)

Wish I could have been more helpful! Great job to James for figuring that out. 

 

Best of luck in your project, Mr. Jim

 

 

Clint T.
Applications Engineer
National Instruments
0 Kudos
Message 9 of 9
(1,577 Views)