# Setup PFC Integration ## Overview This feature is responsible for handling the connection setup between our Automation Driver and the PFC Equipment. ### Protocol Overview The Product Flow Controller (PFC+) protocol is a TCP/IP-based communication protocol used to control and validate the movement of products (PCBs) in an automated production line. | Property | Value | | ------------------ | --------------------------------------------- | | Transport Layer | TCP/IP | | Default Port | 1024 | | Connection Model | Single host connection (one client at a time) | | Communication Type | Request/response + event-driven messages | | Message Encoding | Text-based (ASCII) | | Message Terminator | CR+LF (`\r\n`) | The protocol supports board tracking and validation, control of product flow between machines, handshake between PFC and host to authorize or reject transfers, device configuration and monitoring, and keep-alive supervision via Ping/Pong. ## How To Configure To configure the connection between our Automation Driver and the PFC Equipment a set of keys must be configured in the IoTMetadataDefinition Smart Table. ### Relevant Artifacts The table below describes the properties for this entity type: | Name | Type | Is Mandatory | Data Type | Description | | :-------------------- | :--------- | :----------: | :-------- | :----------------------------------------------- | | IoTMetadataDefinition | SmartTable | Yes | | Metadata configuration for equipment integration | ### IoTMetadataDefinition Resource Level Configuration At the **Resource** level, there are several configuration we can make to set our connection with the PFC Equipment. | Resource | Resource Type | Area | Name | Value | Description | | ------------------ | ------------- | ---- | ----------------------- | -------------- | --------------------------------------------------------------------------------------------------------- | | *MES PFC Resource* | | | **PFC_Address** | IP Address | IP address of the PFC Equipment. Default: `0.0.0.0`. | | *MES PFC Resource* | | | **PFC_Port** | Port Number | Port number used to communicate with the PFC Equipment. Default: `1024`. | | *MES PFC Resource* | | | **PFC_Heartbeat_Timer** | Interval in ms | Interval in milliseconds between PING messages sent to the equipment. Default: `30s` | | *MES PFC Resource* | | | **PFC_LocalAddress** | IP Address | Local IP address used by the Automation Driver to communicate with the PFC Equipment. Default: `0.0.0.0`. | --- ## How To Use On Automation startup we will retrieve the information on `IoTMetadataDefinition` related to the linked Resource and set the retrieved configuration parameters as connection values. !!! Warning "Every time you change these values you **must restart** the Automation Controller." ## Implementation Details During **Equipment Setup** we will resolve `IoTMetadataDefinition` and configure the TCP/IP connection parameters to communicate with the PFC Equipment. All resolved keys are saved in persistency for use during processing. !!! Warning "The equipment must be in *STATUS = SCAN* to begin the communication process. If not, the command *MSGBEEP* will be sent to the equipment with message `STATUS NOT SCAN`." ### Driver Configuration The Automation Controller acts as a **Active (Client)** TCP/IP endpoint. On start up Connect IoT will connect to PFC Equipment as a client. | Parameter | Value | Description | | -------------------------------------- | -------- | ------------------------------------------------------------------------------------------------ | | Mode | Active | Controller acts as a TCP Client connecting to the PFC device. | | Keep Alive Time | 10000 ms | Keeps the socket alive between messages. | | Parser Type | Readline | Emits a complete message only when the `\r\n` delimiter is received, handling TCP fragmentation. | | Delimiter | `\r\n` | Matches the CR+LF message terminator used by the PFC protocol. | | Encoding | ASCII | Protocol uses ASCII text encoding. | | Convert Non-Printable ASCII on Send | True | Allows token names such as `\r\n` to be used in configuration fields instead of raw bytes. | | Convert Non-Printable ASCII on Receive | True | Correctly handles non-printable characters in incoming messages. | | Default Command Message Start | `#!` | Automatically prepended to all outgoing command messages. | | Default Command Message End | `\r\n` | Automatically appended to all outgoing command messages. | ### PING/PONG Heartbeat The controller maintains the connection with the PFC Equipment through a PING/PONG handshake mechanism. - After the equipment sends a **STATUS** message, the controller initiates the heartbeat by sending a **PING** message. - The equipment is expected to reply with a **PONG** message. - Subsequent **PING** messages are sent at the interval defined by `PFC_Heartbeat_Timer`. !!! info "The `PFC_Heartbeat_Timer` value defines the interval in milliseconds between consecutive PING messages. A 30000ms default value is set."