04-20-2018 11:19 AM - edited 04-20-2018 11:21 AM
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
Solved! Go to Solution.
04-23-2018 04:14 PM
Hi Mr. Jim!
Bear with me as I try to understand what you are asking here!
04-23-2018 04:30 PM
Have you tried to walk up the object tree using the Parent property?
04-23-2018 04:34 PM
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? )
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
04-23-2018 04:36 PM
@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...
04-23-2018 06:10 PM
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:
...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. Maybe I should just resign myself to writing a separate sequence to give me that string.)
04-24-2018 04:27 PM - edited 04-24-2018 04:28 PM
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.
04-24-2018 04:33 PM
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.
04-24-2018 04:59 PM
Wish I could have been more helpful! Great job to James for figuring that out.
Best of luck in your project, Mr. Jim