# SEW SimInterface (Pro)

{% hint style="warning" %}
Please note that this interface is only included in realvirtual.io Professional
{% endhint %}

The `SEWSimInterface` is used to communicate with [SEW MOVI-C Controller](https://www.sew-eurodrive.de/movi-c-controller/). As a basis communication protocol MQTT is used.

### Overview

The **SEW SimInterface** component is responsible for managing communication between realvirtual.io and an external SEW controller via MQTT. It connects to a broker and receives signals (e.g. Drive Positions, Inputs and Outputs) from the SEW Controller.

<figure><img src="https://260262196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpYxFg97YnJX96UzNNTSd%2Fuploads%2Fgit-blob-31ed9d81c75ffbe05fa5654bb89376409a765ea0%2Fsewmqttinterface.png?alt=media" alt=""><figcaption><p>SEW Sim Interface properties</p></figcaption></figure>

### SEW SimInterface properties

#### General Settings

* **Active**: Controls when the SEW interface is active.
* **Broker**: The IP address or hostname of the MQTT broker.

  Example: `127.0.0.1`
* **Port**: The MQTT broker’s port number. This is typically `1883` for standard non-secure MQTT communication.

  Example: `1883`
* **Use W String**: A checkbox indicating whether to use a "W" string format when parsing incoming data. This option should be usually turned on.
* **Receive Topic PLC Outputs**: The MQTT topic that the SEW SimInterface will subscribe to in order to receive data from the SEW controller (PLC outputs).

  Example: `SEW/SimOUT`
* **Send Topic PLC Inputs**: The MQTT topic that the SEW SimInterface will publish to, sending data to the SEW controller (PLC inputs).

  Example: `SEW/SimIN`
* **Debug Mode**: A checkbox enabling detailed logging for debugging purposes. This is useful for development and troubleshooting MQTT connections and data exchange.
* **Symbol Table**: The path to the symbol table file that maps SEW controller variables to Unity-readable variables. This is essential for interpreting the data coming from the SEW system and mapping it to corresponding actions or values in Unity.

  Example: `E:/realvirtual-release/game4automation/realvirtual/Assets/realvirtual/`
* **Split Char**: Defines the character used to split incoming data fields. This is usually set based on the data format from the SEW system.

  Example: `;` (semicolon)

#### Inputs/Outputs

* **Num Inputs**: Displays the number of inputs being managed by the SEW SimInterface, corresponding to the number of PLC inputs from the SEW controller.
* **Num Outputs**: Displays the number of outputs being managed by the SEW SimInterface, corresponding to the number of PLC outputs to the SEW controller.

#### Thread Status

* **Thread Status**: The status of the communication thread managing data exchange. This will indicate whether the connection to the SEW system is active, and whether data exchange is functioning correctly.

### Symbol Table

The symbol table used in the **SEW SimInterface** component is a CSV file that defines the mapping between signals from the SEW controller and **realvirtual** Inputs and Outputs. Each row in the table corresponds to a signal, specifying its name, data type, and direction (whether the signal is an input to or output from Unity).

{% hint style="info" %}
**The CSV can be generated automatically via the SEW MKC SimInterface in the IEC-Editor**
{% endhint %}

#### Importing a Symbol Table

To import a symbol table:

1. Select the symbol table file using the **"Select Symbol Table"** button.
2. After selecting, click on **"Import Symbol Table"** to load and apply the mappings.

#### Format

The CSV file has the following columns:

* **Name**: The name of the signal in the SEW system, which is used in Unity to identify the signal.
* **Type**: The data type of the signal, which can be one of the following:
  * **REAL**: For real or float values (used for PLC inputs and outputs).
  * **BOOL**: For boolean signals (true/false).
  * **INT**: For integer signals.
  * **TEXT**, **STRING**, **WSTRING**: For text signals.
* **Direction**: Specifies whether the signal is an input to Unity or an output from Unity.
  * **PLC\_IN**: Input signal (data received from the SEW system).
  * **PLC\_OUT**: Output signal (data sent to the SEW system).

#### Example Symbol Table

Below is an example of a symbol table that could be used in the **SEW SimInterface**:

```
Name;Type;Direction
Stacker_Crane_x_Achse_SimlrActualVelocity;REAL;PLC_OUT
Stacker_Crane_x_Achse_SimlrActualPosition;REAL;PLC_OUT
Stacker_Crane_y_Achse_SimlrActualVelocity;REAL;PLC_OUT
Stacker_Crane_y_Achse_SimlrActualPosition;REAL;PLC_OUT
z_Achse_SimlrActualVelocity;REAL;PLC_OUT
StackerCrane_ExecuteOrder;BOOL;PLC_OUT
StackerCrane_Ready;BOOL;PLC_OUT
StackerCrane_PickBox;BOOL;PLC_OUT
z_Achse_SimlrActualPosition;REAL;PLC_OUT
```

```csv
```
