This variable sends feedback to a connection status indicator on the touch panel. A variable named bConnected keeps track of the client’s connected state.
The OFFLINE event is raised when the connection to the HAL is dropped. The ONLINE event is triggered when an ip_client_open call succeeds in connecting to the HAL. This is the event handler for any data the client receives from the HAL.
The code in the Mainline executes whenever the controller is idle (not processing an event handler).įind the DATA_EVENT handler in the program. The Mainline is located in the DEFINE_PROGRAM section of the program. Ip_client_open(nLocalPort, sRemoteIP, nRemotePort, nTCP)Ĭonnection retries happen in the Mainline when the client is disconnected. It contains the controller’s first attempt to open a client connection upon startup. If you want more simultaneous connections you will need to define more local ports like: FIRST_LOCAL_PORT + 1, FIRST_LOCAL_PORT + 2, etc.įind the DEFINE_START section of the program.
Since this program supports no more than one connection at a time the same local port can be used every time the controller tries to open a connection. A NetLinx controller’s available local ports start at FIRST_LOCAL_PORT. The nLocalPort constant is the local port on the controller that identifies a client connection. The transport protocol is always TCP and the remote port is always 4996 to match the TCP port that the Halogen/HAL Control Server listens on.
We'll assume you will test your control system using Halogen, so change this IP address to match the IP address of your PC for now. This server could be running on a HAL or it could be running on your PC when Halogen is open and not connected to a HAL. The sRemoteIP constant is the IP address of the Control Systems server. There you will see four TCP/IP client-related constants: Their device number is 0 indicating that their ports reside on the NetLinx master controller.įind the DEFINE_CONSTANT section of the program. The dvHAL definition is the device address of the HAL itself. The dvIPClient definition is the device address of the TCP/IP client. There you will see:ĭevice addresses in AMX are comprised of a device number, a port number and a system number. Find the dvIPClient and dvHAL device addresses in the DEFINE_DEVICE section of the program. Open the Main.axs source file in NetLinx Studio.
The example program included in the AMX Support Package provides a reference implementation of such a client. This client exchanges string messages with the HAL using the External Control Message Protocol. You are here: Using External Control Systems with HAL > Integrating AMX Control Systems > TCP/IP Client TCP/IP ClientĪn AMX controller needs a TCP/IP client to communicate with the HAL.