OPC_INIT

Syntax

Example

Description/Remarks

OPC_INIT server_number, channel_number, item name,
update rate,
dead band,
receive mode

OPC_INIT 1, 1,
"d1.c1.r1", -1, -1, "N"

 

See OPC Server Support for a sample template showing how the OPC commands work together.

 

Note: Typically the OPC_INIT command is used to set up channels before the OPC_CONNECT command is used. However, you can initialize new channels (OPC_INIT) after the connection has been made (OPC_CONNECT) if the channel is not in receive mode.

This command initializes a channel for an OPC Server connection.

Returns a 1 if successful. Returns -997 if a blank item name was given. Returns -994 if it is already connected. Returns -992 if no items set up or invalid server number

Server_number is an integer from 1 to 10 assigning a number to the OPC server connection. It should be the same server_number that will be used by the OPC_CONNECT command to connect to this OPC server.

Channel_number is any positive integer.

Item name (also called a tag) is usually case-sensitive! Example: "d1.c1.Register23"

For update rate, use -1 for the default value, which is 100 milliseconds. Or, send in a number between zero and 2 billion

For dead band, use -1 for the default, which is zero. Or, send in a number between zero and 100.

Receive mode can be either "Y" or "N". "N" is the default. Setting receive mode to "Y" turns on receive mode for this channel. Other terms to describe receive mode are asynchronous or subscription mode.

  • Use "Y" if you want the client to subscribe to the data. This minimizes CPU and network resources. The corresponding OPC calls are IAdviseSink and IOPCDataCallback. In this mode, the data is sent whenever the data value changes. Use this mode if you are accessing the data frequently, e.g. every 15 seconds.

  • Use "N" if you want to access the data in synchronous mode. This is more efficient if you are dealing with small amounts of data on an infrequent basis, e.g. once every five minutes.

See MYSVAR and DE_OPT for information about potential popup error messages.