17.2. Data Communication Concepts

These basic concepts of data communications will help you understand how the OPC DataHub works.

17.2.1. Send and Receive Data

    Send/write data: A program sends a value for a data point, and the DataHub records, or writes, the value for that point. This type of communication is synchronous. The send and the write are essentially two parts of a single process, so we use the terms pretty much interchangeably. You can write a value to the DataHub manually using the Data Browser.

    A typical write command from a program using DDE protocol is DDEPoke.

    Receive/read data: A program requests to receive the value of a data point. The DataHub then responds by sending the current value of the point. We call this reading the value from the OPC DataHub. Again, we sometimes use the two terms interchangeably, and again, this type of communication is synchronous.

    A typical read command from a program using DDE protocol is DDERequest.

    'Automatic' Receive: It is possible to set up live data channels, where a program receives updates on data points sent from the OPC DataHub. How it works is the program sends an initial request to the DataHub to register for all changes to a data point. The DataHub immediately sends the current value of the point, and then again whenever it changes. The DataHub can receive data automatically in a similar way. This asynchronous type of communication is sometimes referred to as publish-subscribe.

    A DDEAdvise command sets up this type of connection, which is called an advise loop.

17.2.2. Client - Server

Exchanging data with the OPC DataHub is done through a client-server mechanism, where the client requests a service, and the server provides the service. Depending on the programs it interacts with, the DataHub is capable of acting as a client, as a server, or as both simultaneously.

The client-server relationship itself does not determine the direction of data flow. For example, a client may read data from the server, or it might write data to the server. The data can flow either way; the client might initiate a read or a write, and the server would respond.

17.2.3. Synchronous and Asynchronous Communication

Every type of communication, natural or man made, comes in two basic forms: synchronous or asynchronous.

    Synchronous communication means that for each message, the sender expects to get a reply from the receiver, like a telephone call. There is a back-and-forth exchange, so that each party knows that the other is receiving the message. If there is no response, you can be pretty sure that communication didn't occur.

    Asynchronous communication means that a message gets sent but the receiver is not expected to reply, like a radio broadcast or a newspaper.

Each of these communication types has its own value and purpose in data communications, and the OPC DataHub is capable of both. The specific circumstances and application will determine which form of communication you end up using.