From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

AvtiveX behavior

Hello,
I have an ActiveX Control for a camera system. It uses a telnet connection. I placed into a container and things work fine as long as the program is running. When the vi finishes, the connection is still kept open, even when I destroy the reference - which is the real problem, since running the program again causes a crash. If the container is used in "design mode" the connection is actually closed at the end of the vi, regardless whether or not the reference is closed. If I run similar code from C#, the connection is always closed when the program terminates. Here are my questions: What is exactly the difference between Design Mode and Run Mode? How will it behave in the final application? Is there a way to dispose of the ActiveX control explicetly, not just faking it as the close refernce seems to do (they just write a NULL to the reference or something)? If it is still running, what does closing the reference actually mean? Where does the object go? Is there something like garbage collection? Thanks.
Message 1 of 7
(2,728 Views)
Hi Asche,

How are you determining that the connection is still kept open? Also, what do you mean by "design mode" and "run mode"? Do you mean "edit mode" and "run mode" which are both part of the LabVIEW environment (not applicable to a built executable - exe)? Also, the close reference function should dispose of the reference properly. However, this isn't supposed to do anything more than "close the reference", which frees the memory used to create the reference. If your control needs to be "shut down" properly, then simply closing the reference should and would cause a problem. Also, is it possible that you're leaving your control in a state that causes the VI to fail when run again?

Hope this helps,
Travis H.
LabVIEW R&D
National Instruments
0 Kudos
Message 2 of 7
(2,687 Views)
Hello Travis,
>How are you determining that the connection is still kept >open?
Since it is a simple telnet connection, I can see who is logged on.
>Also, what do you mean by "design mode" and "run mode"?
These are the two possible states of the ActiveX container in the advanced section of the right-click menue on the front panel.
I assumed that the reference behavior was as described. It still seems somehow inconsistent. When lv is shut down and I open it with the vi that has the activex container in it, lv complains that is cannot find one of the components - since the activex object is not running. But, there is no problem running the vi from that state (no changes made to the block diagram or preferences and such). So, the reference IS right and the activex object starts properly, since I have to log on in order to start the session (lv is the client). When the vi runs to the end, the activex object keeps running, but only in the case where design mode is not checked. Which seems to indicate that there is a way to stop the object explicitely. Cheers, Andre
Message 3 of 7
(2,679 Views)
Hey Andre,

What is exactly the difference between Design Mode and Run Mode?
"In design mode, events are not generated and event procedures do not run." <-- This is from LabVIEW help. Maybe this has something to do with the behavior you are seeing.

Is this an ActiveX object that you created? If not, have you contacted the creator to ask why this may be happening?
Travis H.
LabVIEW R&D
National Instruments
0 Kudos
Message 4 of 7
(2,646 Views)
LabVIEW normally keeps controls around between runs. This allows you to see the output from one run when you return to edit mode. It also lets you change the value in edit mode and have it be the initial value when you run the VI again. By default, LabVIEW handles ActiveX controls this way, too. However, this is very different from the typical ActiveX model and causes problems with some ActiveX controls.

The ActiveX container "owns" the reference to the control, meaning that it is responsible for creating and releasing it. The control may actually stay around (hidden) until the VI is closed and LabVIEW sees fit to remove it from memory. Attempting to release the control yourself by closing the refnum could cause nasty things to happen.

When the "Advanced >> Design Mode" option is checked on the ActiveX Container, LabVIEW manages the control in the customary ActiveX way. There are distinct "design" and "run" modes for the control. Each time you run the VI, the design-mode control is destroyed and a new one is created in run-mode in its place. When the VI stops, the run-mode control is destroyed and a new design-mode control is created. In a built application there is no design-mode control; the run-mode control is created when the VI starts and released when it stops.

You want the latter behavior for your control, so you want to turn on the "Advanced >> Design Mode" option.

George Erwin-Grotsky
LabVIEW R&D
National Instruments

Message Edited by Gorg on 05-05-2005 06:27 PM

George Erwin-Grotsky
National Instruments
LabVIEW Research & Development
Message 5 of 7
(2,628 Views)
Nice Posting Gorg!

Please feel free to stop in anytime.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 7
(2,611 Views)
Hello George,
Thank you very much for the detailed, comprehensive reply. Actulally, I was able to recreate the failure in C++ by doing exactly what you described. Maybe, your post could be added to the help section as it is not quite usedful right now (see Travis' post).
Andre.
Message 7 of 7
(2,592 Views)