Zum Inhalt

TCP-Server-Protokoll

Das Scada3k-System stellt einen TCP-Server auf Port 8001 für die Maschinenkommunikation bereit. Das Protokoll ist textbasiert, zeilenorientiert und auf Einfachheit ausgelegt.

(Der Rest des Inhalts ist vorerst auf Englisch)

Connection Details

  • Host: api (internal docker network) or the server's public IP.
  • Port: 8001
  • Encoding: UTF-8

Message Format

A message consists of multiple lines. The connection is kept open for a single request-response cycle and then closed by the server.

Request (Machine -> Server)

  1. Header: The first line must identify the machine. machine_id <UUID>
  2. Data: Subsequent lines contain node updates. The <node_id> is a user-defined string that uniquely identifies the data point for that machine. <node_id> <value>

Example Request: A machine sending temperature and status updates.

machine_id 550e8400-e29b-41d4-a716-446655440000
motor_temp 123.45
valve_status true

Response (Server -> Machine)

The server responds with the current state of all nodes that the machine should know about (nodes with WRITE, READ_WRITE, or READ access level). This allows the machine to synchronize its state or receive commands from the user.

  1. Header: Echoes the machine ID. machine_id <UUID>
  2. Data: Current values of nodes. <node_id> <value>

Example Response: The server sends back the current values, including a command to set the conveyor speed.

machine_id 550e8400-e29b-41d4-a716-446655440000
motor_temp 123.45
valve_status true
conveyor_speed 50

Data Types & Validation

The server strictly validates incoming data against the node's configured DataType.

Type Description Valid Examples Invalid Examples
Boolean True/False state true, false, 1, 0, on, off (case-insensitive) yes, open
Byte 8-bit unsigned integer 0, 255, 128 -1, 256, abc
Integer Signed integer 123, -50 12.5, abc
Float Floating point number 12.34, -0.5 abc
String Text string Any text N/A
Computed Value calculated from a formula (see the Dashboard Guide) N/A — not writable via this protocol N/A

Note: Don't send a value for a Computed node's node_id over this protocol — it would overwrite the node's configured formula instead of setting a value. Computed nodes have no meaningful state to send back either, since their value isn't evaluated for this protocol's response.

Error Handling

  • If a value is invalid, the server:
    1. Updates the node's value with the raw input.
    2. Sets a Warning flag on the node with a description of the error (e.g., "Value '300' is out of range for Byte").
    3. This warning is displayed on the dashboard.
  • If the machine_id is invalid or not found, the server returns an error message and closes the connection.