ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 www.aschome.com

CPC – TCP Talker and Listener Date: 5/12/12, Mason The following topic sheet discusses the TCPTalker and TCPListener object in CPC and how they can be used for remote communications between independent remote CPC systems.

Table of Contents CPC – TCP Talker and Listener.............................................................................................................................................. 1 Communicate between CPC systems ................................................................................................................................. 2 What is a socket? ................................................................................................................................................................ 2 What is the TCPListener object? ......................................................................................................................................... 2 How to add a TCPListener object ........................................................................................................................................ 2 Configuring the TCPListener object .................................................................................................................................... 4 Connect the TCPListener to the main tasker ...................................................................................................................... 6 Initialize the TCPListener object at startup .......................................................................................................................... 7 TCPTalker object ................................................................................................................................................................. 8 Using TCPVariableList object to get information from the listener ...................................................................................... 9 Using TCPVariableList object to set remote CPC properties ............................................................................................ 12 rd

How to communicate to CPC from a 3 party application................................................................................................. 13

Document: CPC - TCP Talker and Listener Page #1

ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 www.aschome.com

Communicate between CPC systems If a facility or plant has multiple CPC systems, it is often useful to pass information between these systems. The TCPTalker and TCPListener objects are used to provide direct communications between independent CPC systems in a facility. The objects use TCPIP socket communications to directly pass information from one CPC system to the other.

What is a socket? A socket is the mechanism that most popular operating systems provide to give programs access to the network. It allows messages to be sent and received between applications (unrelated processes) on different networked machines.

What is the TCPListener object? The TCPListener object opens a socket on a specific TCP/IP port on the computer. Once created, the socket is put in listening mode where it awaits incoming connections from external computers and/or CPC systems. Once external systems are connected, they can issue requests to the Listener for information from the local CPC system and can also set properties of the CPC system.

How to add a TCPListener object Here’s how to add a TCPListener object.

Document: CPC - TCP Talker and Listener Page #2

ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 www.aschome.com

Document: CPC - TCP Talker and Listener Page #3

ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 www.aschome.com

Configuring the TCPListener object The TCPListener object is normally placed on the root of the CPC object configuration.

Document: CPC - TCP Talker and Listener Page #4

ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 www.aschome.com

The object has the following properties:

Enabled –

Sets whether the object is enabled.

IPAddress –

The IP address of the local CPC system computer.

IPPort –

Identifies the port to use for listening. You can search for available ports on the web, however in most cases 50000-60000 are available.

Status – Indicates the status of the object and socket. Here are some values: Closed – Socket is closed and unregistered Initialized – Socket is initialized Listening – Socket is in listening mode DevicesConnected – Number indicating the number of external connections to the socket. The listender can support multiple external CPC talkers. SendText -

This property holds the last information sent to the talker.

ReceiveText - This property holds the information received from the external talker. Socket-

This is the socket number created by the listener.

CommLog -

This is the log of listener operations that have occurred.

Calculate

Method to calculate the object. Should be run by the MainTasker

Initialize

Method to initialize and create the listening socket.

Disconnect

Method that disconnects all external connections

Send

Method to send text information to all connections

BeforeCalculate Quick-script which runs before the Calculate method.

Document: CPC - TCP Talker and Listener Page #5

ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 www.aschome.com

AfterCalculate Quick-script which runs after the Calculate method. AfterReceive Quick-script which runs after a request is received from an external connection or TCPTalker.

Connect the TCPListener to the main tasker The TCPListener object must be connected to the MainTasker using a Task object. The Task object should execute the “Calculate” method of the TCPListener.

The task object should point to the Calculate method of the TCPListener.

Document: CPC - TCP Talker and Listener Page #6

ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 www.aschome.com

Initialize the TCPListener object at startup Once the TCPListener is configured, you can double-click on “Initialize” method to open the socket and start listening. For automatically initializing the object, you’ll want to put the Initialize method in the “OnStartup” script in the Server object.

Edit the script to add the Initialize method.

Document: CPC - TCP Talker and Listener Page #7

ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 www.aschome.com

TCPTalker object The TCPTalker object handles all communications to a remote CPC system. In order for the TCPTalker to work, the remote CPC system must have an active TCPListener configured and in “Listening” mode. The following properties are offered:

Enabled –

Sets whether the object is enabled.

RemoteIPAddress –

The IP address of the remote CPC system computer.

RemoteIPPort –

Identifies the port of the CPC’s TCPListener on the remote PC.

Socket-

This is the socket number created by the taker.

Status – Indicates the status of the object and socket. Here are some values: Closed – Socket is closed and unregistered Initialized – Socket is initialized Connected – Socket is connected to the remote listening socket. SendText -

This property holds the information sent to the listener.

ReceiveText - This property holds the information received from the listener. CommLog -

This is the log of talker operations that have occurred.

Calculate

Method to calculate the object. Should be run by a task in the MainTasker

Connect

Method to connect to the remote listening socket.

Disconnect

Method that disconnects the connection to the listening socket.

Document: CPC - TCP Talker and Listener Page #8

ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 www.aschome.com

Send

Method to send text information to the listener. The information would be entered in the “SendText” property.

BeforeCalculate Quick-script which runs before the Calculate method. AfterCalculate Quick-script which runs after the Calculate method. AfterReceive Quick-script which runs after a request is received from an remote listener socket.

Using TCPVariableList object to get information from the listener Once the TCPTalker is configured, you can easily transfer information from the listener to the talker by adding and configuring a TCPVariableList object. 1.) Add a TCPVariableList object as a child of the TCPTalker object. a. Click on the TCPTalker object. b. Select “TCPVariableList” from the class pull-down list. c.

Depress the “Child” button

d. Click the “Add” button. A new TCPVariableList object will be placed under the TCPTalker. e. Rename the variable list to “ReadValues” or any other relevant name. 2.) Add TCPVariable objects to the list. Each TCPVariable object provides an object path to specific object data from the listener. a. Click on the VariableList object. b. Select “TCPVariable” from the class pull-down listing. c.

Make sure “Child” button is depressed.

d. Click “Add” e. Repeat for multiple variables. If you want to retrieve 5 values, then there must be 5 variables in the list.

Document: CPC - TCP Talker and Listener Page #9

ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 www.aschome.com

3.) Enable the TCPVariableList. Make sure the Enabled property is set to True. 4.) Configure the TCPVariables. As you see below, we name a variable “AirTC” and then configure the path to the AIRTC. Note that the path defines the object path on the remote listening CPC system.

5.) To initiate a request for transfer of values from the listener, simply execute the “Get” method of the TCPVariableList object. This can be done via the Object Editor or can be written into specific scripting.

Document: CPC - TCP Talker and Listener Page #10

ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 www.aschome.com

6.) When the “Get” method is run, the talker will send a request string to the listener. The request string indicates the Get operation and passes a list of paths to the listener. The Listener will then respond with a string containing the resolved values. You can view the two strings in the SendText and ReceiveText of the TCPTalker object.

7.) On receipt of the information, the Talker automatically parses the response into the original variable objects. You’ll find the information stored in each variable’s “Value” property.

Document: CPC - TCP Talker and Listener Page #11

ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 www.aschome.com

Using TCPVariableList object to set remote CPC properties Although most of the communications are Get operations, you can also have one CPC system set properties on the remote CPC system. Here’s a configuration where a TCPVariableList is used to send information. The “SendValues” list has two TCPVariable objects, one called “SetOption1” and one called “SetOption2”. These variables will set specific object properties in the remote CPC system. You can see that the path on SetOption1 is “.Autoclave.Variables.Option1\Value”

In order to set a value on a remote CPC system, use the “Set” method of a specific variable or use the “Set” method of the list. If you run the list’s Set method, all variable values will be transferred to the remote system. Here’s the send and receive strings from the Talker after running the SendValues object’s Set method:

Here’s the send and receive strings from the Talker after running the individual SetOption1’s Set method:

Document: CPC - TCP Talker and Listener Page #12

ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 www.aschome.com

How to communicate to CPC from a 3rd party application You can use any higher-level language to write a custom application to get information from a CPC system. Simply setup a socket connection to the CPC listening system and start communications. Note: teaching socket programming is outside the scope of this document. There are multiple resources on the web for how to setup a client socket. Here is a send and receive string for getting multiple values from CPC. Send string: PathListGet:Name1:ObjectPath1,ObjectPath2,ObjectPath3, etc. Where: Name1 = Identifier of list name. Any name will work ObjectPath1 = path to specific object value. Must start with a period. ObjectPath1 = path to specific object value. Must start with a period. Etc. Example PathListGet:ReadValues:.Autoclave.Inputs.AIRTC\Value,.Autoclave.RecipeProcessor\RunStatus.

Receive string: PathListGet:Name1:Value1,Value2,Value3,etc. Where: Name1 = List name of sender. Value1 = value of first path Value2 = value of second path Etc. Example PathListGet:ReadValues:69.95,False

Document: CPC - TCP Talker and Listener Page #13

ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 www.aschome.com

Here is a send and receive string for getting a single value from CPC. Send string: ValueGet:Name1:Name2:ObjectPath Where: Name1 = Identifier of list name (any name) Name2 = Identifier of variable (any name) ObjectPath = path to specific object value. Must start with a period. Example ValueGet:ReadValues.AirTC:.Autoclave.Inputs.AIRTC\Value

Receive string: ValueGet:Name1:Name2=Value Where: Name1 = Identifier of original list name Name2 = Identifier of original variable Value = value of path

Example ValueGet:ReadValues.AirTC=69.95

Document: CPC - TCP Talker and Listener Page #14