OPC_RCVBUFFER

When the OPC receive buffer is enabled (by OPC_OPT server_number, 1, "Y"), this command reads the first OPC channel number and its value from the front of the OPC receive buffer queue and removes them from the queue.

Syntax

OPC_RCVBUFFER server_number

The 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 was used by the OPC_CONNECT command to connect to this OPC server.

Return value

If a channel number and its updated value are available in the queue, this command returns the channel number. It also sets the value of MySVar "OPC_RB" to the updated value that is associated with this channel number.

If the queue is empty, this command returns the number 0.

If there is an OPC server error, this command returns a negative number.

Notes

This command will read the channel/value pairs from the queue in the order in which they were added to the queue (first in, first out).

See also: OPC Server Support

Example

OPC_INIT 1, 1, "Card.Node.I01", -1, -1, "Y" :
OPC_INIT 1, 2, "Card.Node.I02", -1, -1, "Y" :
OPC_CONNECT 1, "{C5123F69-65AA-11D1-AE80-00609703A0D6}", "NT_SERVER1" :
OPC_OPT 1, 1, "Y" :
MyNVar "Channel" = OPC_RCVBUFFER 1 :
IF MyNVar "Channel" > 0, MySVar "Value" = MySVar "OPC_RB"

This formula initializes two channels for server_number 1, establishes the connection to server_number 1, and enables the OPC receive buffer for server_number 1.

Then it reads the first channel number from the OPC receive buffer. If this channel number is >0, then this formula sets MySVar "Value" to the new data value on that channel.