Writing a TCP/IP template for data entry

Sample TCP/IP template:

The following template makes 2 connections to the devices that are on the network. The first one is with Zumbach and the second with GageWay 5.   Upon the first successful connection, it sends the Zumbach command to receive the data.  Once the data is received, it is stored in the data field.  The next row makes the second connection to GageWay 5 which is gathering data from gage connected to it. Upon successful connection, a command is sent to read channel A. Since it is in a listener mode, a separate command is sent to receive the value read in channel A. The value received in response box is then stored in a data cell. See Template Commands for more information on the commands used in the formulas.

Note: It is important to note that when using the TCP/IP Communication Utility to read data from Zumbach, users must check “Append   CR and LF” check box, otherwise the system will time out waiting for a response.

Sample Template Flow:

Connection 1:

1. Make the first connection to Zumbach

2. On error display error number and description

3. Send the command to read data

4. Store the third field of the response gotten as a numeric variable (NVar)

5. Store the NVar in data field and save data

Connection 2:

6. Make the second connection to GageWay5 which reads data from the gage

7. On error, display the error number and description

8. Upon successful connection, sends the command to read channel A

9. Since GageWay is in a receive mode, the next cell sends the command to receive the value read from channel A

10. Second field of the value received is stored as nvar and later saved into data cell

11. Connections 1 and 2 are simultaneously disconnected
 

Sample template use

Cell

Column

Method

Formula

Description

A1

Part Number

Keyboard

 

 

B1

Calculated

Formula

if (TCPIP_CONNECT 1, "192.168.4.99", 100, -30," "), GOTO [C1] , GOTO [G1]

This command connects to the Zumbach using its IP address and port number. On error gives an error message.

C1

Calculated

Formula

TCPIP_DEBUG 1

This brings up the TCP/IP communication utility dialog and runs in the background while other commands are being executed.

D1

Calculated

Formula

if (TCPIP_SENDRCV 1, (CONCAT "d2000", chr 13, chr 10)), goto[E1], goto[G1]

This command sends the Zumbach command to receive the data from the machine. On error, give error number and description.

F1

Calculated

Formula

nvar1=field3 : GOTO [H1]

Storing the received value as nvar.

G1

Calculated

Formula

MESSAGE  CONCAT, TCPIP_ERROR 1,  TCPIP_ERRORDESC 1

Displaying error number and description

H1

Data

Formula

Nvar1: SAVEROW

Saving the data value

B2

Calculated

Formula

if (TCPIP_CONNECT 2, "192.168.4.98", 5000, -30," "), GOTO [C2] , GOTO [G2]

Makes the second connection to GageWay 5. On error displays error number and message

C2

Calculated

Formula

TCPIP_DEBUG 2

Display the utility for the second connection

D2

Calculated

Formula

if (TCPIP_SEND 2,  "<RA"), goto[E2], goto[G2]

This is a GageWay command to read port A .

E2

Calculated

Formula

TCPIP_RCV 2

Command to receive the value that it read from port A.

F2

Calculated

Formula

Nvar2=field 2 : GOTO [H2]

Storing field 2 which consists of data value as nvar2.

G2

Calculated

Formula

MESSAGE CONCAT, TCPIP_ERROR 2,  TCPIP_ERRORDESC 2

Displaying error number and message for connection 2.

H2

Data

Formula

Nvar2: SAVEROW

Storing the data value

I2

Calculated

Formula

TCPIP_DISCONNECT 1 : TCPIP_DISCONNECT 2

Disconnecting both connection 1 and connection 2