Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Slow Datasocket Connection to Siemens OPC Server

Hello There,

Hoping someone may be able to help with a problem I am experiencing using the Datasocket control (v4.00 (375)) connecting to various tags using Siemens OPC on a local PC in a custom VB project (phew!). I'm finding that the actual initial connection takes a very very long time, once connected, the tags update at a speed I would expect and run very nicely. At present I am connecting and disconnecting tags when changing between screens as. The code I'm using for the actual connection is:

For Repeat = 0 To UBound(URL)
If ((CurrentDataSocketForm.CWDataSocket.Count - 1) < UBound(URL)) Then Load CurrentDataSocketForm.CWDataSocket(CurrentDataSocketForm.CWDataSocket.ubound + 1)
CurrentDataSock
etForm.CWDataSocket(Repeat).ConnectTo URL(Repeat), cwdsReadWriteAutoUpdate
Next

and the disconnect (on form_unload):

For Repeat = 0 To NumberOfDataSocketsToDisconnect
CurrentDataSocketForm.CWDataSocket(Repeat).Disconnect
Next

I have one datasocket control on each screen (set as an array) and dynamically add a new one (or more) at run-time if needed. It doesn't seem to be the dynamic adding of the control (as I have tried by using the correct amount of controls on the screen) but rather the line that connects the URL and activates it. The URL(Repeat) is an array of addresses stored as : "opc://localhost/OPCServer.WinAC/"Q10.0" for example and as I said when connected they work great.

Is there something I'm doing obviously wrong here? This is the first time we are using a datasocket control over using code created by myself to connect, if I connect using my old code, then the connection speed is alot better. Any help would be very appreciated!

Thanks
,

Dan
0 Kudos
Message 1 of 4
(3,713 Views)
Dan,

CWDataSocket requires that the application using it to be processing Windows messages in order for it to connect. One thing that could affect connection speed is doing something in your application that delays or stops the processing of Windows messages such as having a very long form load function, wait loops, or other things like that. If you have long or slow functions that might be running while waiting for the DataSockets to connect, you can put a call (or several) to DoEvents in the long function to force processing Windows messages and allow the DataSockets to connect.

I hope that helps.

Tony
Measurement Studio
0 Kudos
Message 2 of 4
(3,713 Views)
Thanks for the response Tony,

I basically exported the code and put it into a straight simple form so that it is just the datasocket connecting to the OPC server with nothing else actually happening, there are no other loops or functions happening. I can also step through each part of the program and you can see that the actual line that connects the tag is taking some time ie. you can see the program stops and processes that line before moving onto the next.

Have you got any other ideas - I could always post the simplified basic code if it's any use!

Many thanks in advance!

Dan
0 Kudos
Message 3 of 4
(3,713 Views)
Dan,

Having a look at the code can't hurt, especially if you already have it in a simplified form. Please go ahead and post it.

Tony
0 Kudos
Message 4 of 4
(3,713 Views)