LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing TestStand variables from a subVI

I am maintaining some code in a large development that needs to handle new model numbers (frequencies). There is a scantling of TestStand on top of some deeply nested VIs. If the nesting were shallow it would be easy to pass new variables as parameters but as it is I would need to modify many layers of VIs to get the new variable down to where needed.

 

In short there some way for a deeply nested VI to obtain some file global or station global variables? It looks like the Get Property Value VI may work for this but not sure what to supply to the Sequence Context In terminal. I suspect it is my main sequence file but not sure how to specify it. Get Property Value offers no example.

 

 

Thanks,

 

jvh 

 

0 Kudos
Message 1 of 16
(2,956 Views)

Hello jvh,

 

I believe you are correct in using the Get Property Value VI. I did find an example that uses this VI. It is located in National Instruments»TestStand»Examples»AccessingPropertiesUsingAPI»LabVIEW»AccellLocalVariables. You are going to want to pass in to the Sequence Context In terminal is "ThisContext." It is good practice to pass in the reference to the Top Level VI and keep passing it down through all of the subVIs. Also make sure to close the reference at the end. Let me know if this helps you out and have a great day!

 

Best Regards,

 

Adam G

National Instruments
Applications Engineer
0 Kudos
Message 2 of 16
(2,932 Views)

There is no way around it.  If you subvi is 10 levels deep, you need to pass the sequence context through 10 levels.

Well, hmmm..., maybe you could use a Global Variable to hold the sequence context ( a reference).  You could pass the sequence context to the main, then let the main write it to the Global.  Then your subvi can read the global.  If it works, this would let you avoid passing through 10 levels.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 16
(2,926 Views)
On the Get Property Value.vi, the Sequence Context In terminal allows the creation of a constant. However I am not sure if "ThisContext" is a valid ActiveX reference, which probably wants a handle of sorts. I suspect not as I can find no way to to edit the constant. Perhaps I will have to save it as a global.
0 Kudos
Message 4 of 16
(2,903 Views)

You could not use a constant because every time you run, the This Context will change.  A global is the only way to go.  You have to put code in the main to write This Context to the global every time you run it.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 16
(2,891 Views)
But at least try the correct method of passing the sequence context through the connector pane. If you have followed there recomended style guidelines, you should have spare terminals. I think using a global could cause trouble in the future if you ever use parallel or batch mode.
Message 6 of 16
(2,886 Views)

Of course- a functional global holding the current sequence context referance and a callback to update values is a reasonable option.  But this will take some serious time to test and insert into the sequence (adding an init to the Pre UUT sequence etc...)

 

I'd recommend sticking with the style recommendation of wiring the context through the connector pane unless you really want a maintainence headache.


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 16
(2,881 Views)

Jeff Bohrer wrote:

 

I'd recommend sticking with the style recommendation of wiring the context through the connector pane unless you really want a maintainence headache.


I triple that recommendation.  I only recommended the Global as an alternative.  If I had to wire through 10 levels of terminal panes, I would be tempeted to use a global.  But if it is just a few levels deep, use the terminal pane.  Actually, if you are more than a few levels deep, you might reconsider your architecture.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 16
(2,877 Views)

What variable type should be used to save the context as a global?

 

As to other comments I already have a maintenance nightmare, over 1600 VIs worth. It seems the developer was either a bigger ignoramus than I or he was deliberately making future work for himself to extend his contract. There are 6 levels to reach any VI that does any real work. It ain't pretty but at this point it makes sense to be able to grab some globals (model number for instance) that will be constant for the duration of any test for a particular model.

0 Kudos
Message 9 of 16
(2,868 Views)

jvh75021 wrote:

What variable type should be used to save the context as a global?

 

As to other comments I already have a maintenance nightmare, over 1600 VIs worth. ....


Ouch, I feel your pain.  I have not ever tried to store the context into a variable.  But I suspect it will go into a control reference type.  Try it, let me know if this doesn't work.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 10 of 16
(2,862 Views)