From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Closing ActiveX references correctly in Simple UI

Solved!
Go to solution

Hi,

 

I am currently trying to modify the Simple UI provided with Teststand 2013 in order to access global station variables through LabVIEW.  As a simple test, I am trying to access the LastUserName value.  When I run the VI for the first time after opening LabVIEW, I get no error messages and the program runs as required.  Stopping the VI execution returns no errors, but when I try to run the VI and run the Teststand sequence again, the execution stalls and I get a waiting status.  I must then close the VI execution by killing all Teststand threads  I believe the PropertyObjects are not released properly and I find the event structure quite puzzling to deal with.

 

My attempt at closing the references within the while loop looks like this : 

 

Capture.PNG

 

The rest of the program is exactly as provided with Teststand 2013.

 

Any input on how to properly close the ActiveX references and retrieving station globals within LabVIEW would be much apreciated.

 

Thank you for your help,

 

Christian

 

 

0 Kudos
Message 1 of 4
(4,485 Views)

If you are getting the references repeatedly inside of the loop don't you also need to close them in the loop? I'm not that familiar with labview so maybe you are already doing so, but it looks like you might not be. It looks like they might only be getting closed when you close the panel. Perhaps the code shouldn't even be inside of the loop in the first place though.

 

-Doug

0 Kudos
Message 2 of 4
(4,433 Views)
Solution
Accepted by topic author NutaqTestDept

Christian,

 

Doug is correct that if you open references in a loop, you should also be closing them in the loop. For example, in this code you are opening a reference to the Engine and to the Globals PropertyObject. Both of these references should be closed every time the loop executes with the current code.

 

One way you might be able to improve this code is to put your LastUserName querying code elsewhere. This LastUserName seems like something that would only happen when a user logs in or logs out, so perhaps this code could be registered as an event callback for the UserChanged event. You would do this in the Configure Event Callbacks VI of the user interface.

 

If you do need this code to constantly update, you could put it in the Timeout event of the event structure in your screenshot, and set a reasonable timeout (perhaps 100-200 ms). 

 

Hope it helps, and let us know if you have any more questions about it!

0 Kudos
Message 3 of 4
(4,423 Views)

First of all, I would like to thank you for your answer.

 

I understand that repeatedly opening a reference inside the while loop does not represent a viable solution.  This morning I found a very handy reference that explains how to pass data from the Teststand API through custom UI user messages.  This allows a more elegant and robust way of handling data that is retrieved from Teststand.  I'll use a custom event call back that will trigger on any custom message.

 

Here are the references ( which are IMO clear enough for someone with very little LabVIEW experience) : 

 

http://www.ni.com/white-paper/4532/en/

 

https://decibel.ni.com/content/docs/DOC-21047

 

So far, I have been able to create a dummy Teststand sequence that sends a custom UI message containing the string ''Hello, world!''. The UI can accordingly retrieve the string and display it in a dialog box.

 

I still have to find a way to pass the data from the subVI to my UI.  I am investigating the use of global variables, but there may be a better solution that I am not aware of.  Any input on how to pass information between two active VIs would be much appreciated!

 

Christian

0 Kudos
Message 4 of 4
(4,418 Views)