Introduction
SAP Plant Connectivity provides a Socket Source System Agent as part of its standard Source Systems agents. The Socket Agent provides a direct connection between a remote Server that exposes data on a TCP Socket, and PCo as the TCP Client. The Agent supports the Notification in an Agent Instance, but not the Query Interface directly. However, it is possible with the Agents Custom Functions from with SAP MII to open, write to, and close a Socket from an MII BLS Transaction.
Configuration
Agent
Each Socket Agent can be configured to connect to multiple TCP Connections as shown in this example:
Each Connection is identified by the following characteristics:
- Type -- IPV4 or IPV6
- Check Connection -- periodically check to see that the Server Port is open. the Check frequency is defined in the Retry Interval specified in the Reliable Connection Tab for the Agent. Each connection uses the same interval.
- Name -- a unique name for each connection
- Address -- the IP address or host name of the TCP Server
- Port -- the Port to connect to at the IP Address (Note: the IP Address - Port combination must be unique)
- Terminator -- the String of text or control characters that indicate the end of the data stream for a message. Control characters (like the CR LF terminator in the Tester connection above, are entered as HEX bytes prefixed by \.
- Length -- the number of characters that will constitute a message. (Note: Either Terminator or Length can be specified, but not both.)
Agent Instance
After creating an Agent Instance that uses a defined Socket Agent, you can create a Subscription Item for each Connection in the Socket Agent. To do so, simple use the Agent Instance Subscription Items Browse button to browse to the desired named Connection:
Each "tag" is named <connectiionName>.message, where <connectionName> is the name of the Connection in the Source Agent.
Once you have subscribed to the tags, each tag can be used in an Agent Instance Notification to receive the contents of the connection message after the terminator or length extraction has been executed, and then use that value to send to a Destination, such as an MII Transaction.
Writing to a Socket Agent Instance
The Socket Agent does not directly support the Query Interface that MII uses to read and write Tags from PCo. However, the Socket Agent exposes some Custom Functions that can be executed from within an MII BLS Transaction to Access a server socket. These functions are:
- GET_AGENT_STATE
- START (opens a specified IP address and Port)
- SEND (sends a stream of text data to an open IP/Port)
- STOP (closes the IP Address and Port START’ed above)
MII BLS Transactions provide the PCoQuery template for accessing PCo tags, and one of the Modes now supported is TagFixedQuery. This mode is used in a transaction to construct the command to execute an Agent's Custom Function. For details about how this is accomplished, Please see the New MII PCoQuery Fixed Query Mode document in SCN.
Limitations of the Socket Agent
- The data stream that the Socket Agent reads and writes is currently limit to Text.
- There is no security supported for the connection. PCo makes a direct TCP Socket connection to the server.
As always, comments and questions are welcomed.
Steve