LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Datasocket loses connection when in separate VIs

Hello,
I´m using Labview 8.2.1 in XP_SP2.
Currently I created a test-vi with Datasockets. (Open, Get, Set, Close). In my Demo-vi where everthing is in one Vi inside a loop everything works fine. That means i can set a URL which is sent to the "Datasocket_Open". Then i see that my OPC-Server (external program) goes active (this is shown by getting a new icon next to the clock in the taskbar).
The Open returns a connection-ID which i can use to "send" and "get" values from the opened URL / Item.

Now i did the same with separate VIs. One VI for Open, one for send, one for get and one for close.
The Open-Vi opens a URL and stores the returned connection ID in a global variable.
Then i wanted to use this ID from the global in the other three VIs (send, get, close)

But the problem is, that after i executed OPEN, that the connection doesnt keep alive. The icon (in the taskbar) is only visible as long as the VI is running. That means, when i create a breakpoint at the end of the open-vi and start then my GET-vi then i can read values with the connection id from the global. But as soon as the vi (which opended the datasocket) is finished the connection is lost.

So the big question is: Is this normal that the connection is only valid during runtime of the vi which created this connection ID? What can i do to solve this problem so that the id is not lost after the vi is finished?

Thank you very much for your help
0 Kudos
Message 1 of 5
(2,582 Views)
Yes, what you are seeing is normal behavior. How to work with this depends on what it is that you are trying to do. Can you explain a bit more about what you are trying to accomplish and how you would like to see it work?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 5
(2,579 Views)
Hello.
thanks for teh answer.
I want to run the VIs in TestStand:
1.) Datasocket_Open-Teststep
2.) Datadocket_Read-Teststep
3.) Datasocket_Write-Teststep
4.) Datasocket_Close-Teststep

The Open-Teststep should get a list of Items/URLs and Opens Datasocket-Connections. The returned Connection-IDs should be saved in a global variable for later use
Then i call from time to time the Read-Teststep and and use there the Connections-IDS from Open.

It would be also possible to create a teststep that always makes a Open+Read+Close or a Open +Write+Close, but this needs to much time so i thought i open all needed connections a the beginning of my testplan (like an initilize) an later i only use the connection-ids.

So the only problem is how to keep the IDs alive.
0 Kudos
Message 3 of 5
(2,570 Views)
Hello.
meanwhile i found  solution i think.
1. In my VI Open_Datasocket i´m calling now a "HoldReferences-Vi"  (see attachment) with "Wait until Done == False"
2. Inside of this VI i´m first creating a queue, then doing now all the Open-Stuff and at the end i´m waitung for a queue to end this VI
So this VI runs endless until i send end-queue-element to the queue
3. Now alle my connections stays alive

There is only one more question:
How can i pass parameters to a vi that i have opened like in the screenshot? Can i only pass with global variables?
The Open-reference opens a reference to HoldReferences.vi and i want to pass some parameters to this vi.

Thnx

Message Edited by OnlyOne on 07-05-2007 04:01 AM

0 Kudos
Message 4 of 5
(2,563 Views)
There are other VI methods for setting the value of front panel controls on the VI that you are opening. Call these before executing the Run VI method.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 5
(2,553 Views)