Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Mulitiple FP DataSockets in an array?

I am trying to make a VB. NET  module to Monitor FP-AI-111 (16 channel AI).
 
Instead of hardcoding OPC urls and dragging 16 Datasockets into my Form - My initial approach was to programtically create 16 DataSockets in an Array.

--------------
Public

dataS(16) As CWDSLib.CWDataSocket


Sub dsSetup16()
'Fill DataS Array with the 16 DataSocket objects

Dim i As Short
Dim Index As Short = 0
For i = 1 To 16
dataS(Index) =
CType(CreateObject("cwdslib.CWDataSocket"), CWDSLib.CWDataSocket)
Index += 1
Next i
End Sub
--------------

Then later update and retrieve DataSocket vaules like this.

oDataSocket(1).Update()
myValue = oDataSocket(1).Data.Value

Great idea - but not so great in reality as nothing happens?

Any suggestions/ corrections - someone must have tried to do this before.

Tia,

Jeppe

0 Kudos
Message 1 of 4
(3,530 Views)

Hi Jeppe,

Im not sure what may be happening here but I wanted to ask a couple questions.  If you create just one datasocket (and not an array) do you get any data?  Second, if not, do receive any data when you use the actual datasocket control instead of creating it programmatically?  Finally, what version of Measurement Studio are you using?

The more we can narrow the problem down, the faster we can figure out a solution.

 

Thanks,
Caroline Tipton
Data Management Product Manager
National Instruments
0 Kudos
Message 2 of 4
(3,510 Views)

Hi Caroline,

Thanks for getting involved.

My Mstudio is version 7.1 plugged into VS2003.

From my local Sales rep I received a FieldPoint demo app written VS2003. It was based on the above COM code structured in a module and a form.vb. The form has no DataSocket control. During run-time you call the SelectUrl and browse to read 1 opc item/ 1 channel. The demo works but is based on 1 OPC item and a form in which an item is selected by the user.

The ultimate goal for me is to have a configurable back-end windows service - reading up to 8 FP-AI-111(16ch)  and logging their values in a SQL database.

A front-end app is to provide visualization, reporting, configuration features etc. - but the back end datalogger would need to run regardless.

It should not be that difficult - but with multiple datasockets in an array I am not sure how to call the Constructor and ID each instance. Or if I would need to write a new class to create what in VB6 is an 'Array of Controls'?

Tia,
Jeppe

 

 

 

0 Kudos
Message 3 of 4
(3,507 Views)
Hi Jeppe,
 
I would suggest using the Datasocket functions created for using within .NET as opposed to the older COM functions.  These functions will greatly simplify your programming.  You can see the code for creating the datasocket connection by just dropping a datasocket control onto the form.  You can remove this control but still retain the code so that you do not have to have an actual control if you do not want one.  The code would be as follows:
 

Friend WithEvents DataSocket1 As NationalInstruments.Net.DataSocket

You can create an array of these datasockets. Any propperties you would like to change.  You can change them within the properties page of the control and then just copy the code from what is autogenerated when you change the property.

Hope this helps.

Thanks,
Caroline Tipton
Data Management Product Manager
National Instruments
0 Kudos
Message 4 of 4
(3,487 Views)