Socket Message Protocol
TCP Socket Server Message Format
Overview
The TCP socket server receives and processes messages from PLCs. Each message follows a predefined format to ensure proper parsing and processing.
Message Size Constraint
- The total size of each message must be exactly 46 bytes.
- 2 bytes represent a single hexadecimal value.
Message Structure
Each message consists of structured fields with fixed byte allocations:
| Field | Size (Bytes) | Description |
|---|---|---|
| PressId | 2 | Unique identifier for the press sending the message. |
| Machine Counter | 4 | A counter tracking machine operation cycles. |
| Message Type Id | 2 | Identifier linking the message to a predefined type. |
| NumberOfItems | 2 | Number of items contained in the message. |
| Item1 | 6 | Structured item data (see Item Structure below). |
| Item2 | 6 | Structured item data. |
| Item3 | 6 | Structured item data. |
| Item4 | 6 | Structured item data. |
| Item5 | 6 | Structured item data. |
| Item6 | 6 | Structured item data. |
Item Structure
Each item in the message consists of two fields:
| Field | Size (Bytes) | Description |
|---|---|---|
| Item Type Id | 2 | Identifier specifying the type of item. |
| Value | 4 | The recorded value associated with the item. |
Example Message
PressId|Machine Counter|Message Type Id|NumberOfItems|Item1|Item2|Item3|Item4|Item5|Item6
Processing Steps
- Read Press ID - Identify the sender of the message.
- Parse Machine Counter - Extract operational cycle count.
- Validate Message Type ID - Ensure it matches a predefined type.
- Read Number of Items - Specify how many items are included.
- Extract Item Data - Read and store the item values according to the defined Item Structure.
- Validate Message Structure - Ensure the total message size is exactly 46 bytes.
- Store & Process Data - Pass valid messages to the aggregator.
Error Handling
- Malformed Messages - If the message does not conform to expected format, it is discarded.
- Invalid Message Type ID - If an unrecognized type is found, it is flagged for review.
- Incorrect Message Size - Messages that do not meet the 46-byte requirement are rejected.
Known Issues
Connectivity Issues and Message Loss
Due to intermittent connectivity issues between presses and the server, messages can be lost during transmission. This leads to several problems:
- Missing messages in the sequence can cause gaps in the data
- Aggregation errors occur when critical messages (like start/stop events) are lost
- Incomplete shift data may result in inaccurate statistics
The system implements error detection and logging to identify these issues. When message loss is detected, error messages will be displayed in the shift console.