AnsweredAssumed Answered

vrf Want example how to connect VEE to OPC server

Question asked by VRFuser on May 13, 2003
Bill -

> Does anyone out there know
> how to connect VEE to an OPC
> server?

Set server = CreateObject("OPCServer");
server.Connect("<servername>");

> If so could you share an
> example how to set up?

Now *there's* a loaded question

Seriously though - I'm sorry! I'm not familiar at all with this technology.
I just now looked it up, and I found that OPC means "OLE for Process
Control." It sounds like a great idea. The server is a COM+ data
"publisher/subscriber". The example I downloaded from NI, VBOPCAPI.ZIP from

http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3EC9
756A4E034080020E74861&p_node=DZ52130&p_submitted=N&p_rank=&p_answer=&p_sourc
e=External

looks pretty straightforward. You connect to a server, add a group, set the
group's update rate and mark it as subscribed. Then you setup string arrays
for read and write items (which I imagine one would have set to things like
motors and switches in a process control scenario) and call the Validate
method of the OPCItems property of the group passing the number of items,
the item array, and an array of int32 for error return. The length of the
return is unspecified, but in VEE probably 1 error per item would be
sufficient.

Provided there are no errors, you then call the AddItems method of the
group's OPCItems property with the number of items, an int32 array of who's
purpose I'm not sure, an int32 array for returned handles and the error
array.

This Validate/AddItem deal must be done once for read items and once for
write items. I suppose a read item is incoming status data and a write item
is outgoing control data. In the case of write items, you set a global
OPCItem var for each write item added.

Then, you just wait for DataChange events from the group object (to receive)
and use the group object's Write method to change write items.

Man, this is simple! No more PITA SCADA. Bill, thanks for prompting me to
look this up.
-SHAWN-


---
You are currently subscribed to vrf as: rsb@soco.agilent.com
To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list,  email "vrf@it.lists.it.agilent.com". 
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".

Outcomes