title: "X+3 Tutorial" url: doc/examples/xplus3.html ---

# X+3 Tutorial

## Explore an Existing System

This example gives you an overview of how to work with Eclipse 4diac by examining and deploying the System Xplus3 and Application Xplus3Application. The System consists of two Devices, after examining the mapping of the Application parts to the Resources, we will set the preferences required and test it.

- Task of the X+3 example: calculate and display X+3.

- You can get the Xplus3 System from the Eclipse 4diac Examples Github Repository.

- Examines a simple IEC 61499 Application with 2 Devices.

- The communication between the different Devices is integrated within the Resource.

### Explore Existing Application

A IEC 61499 Application is designed independent of Devices and Resources. The Application FBs are mapped to the Resource of a Device they will run on after building the application. Click on the arrow beside the Xplus3 System and double-click to open the Application called Xplus3Application NOTE: depending on your operating system, a single click may be sufficient where double clicks are mentioned in this tutorial.

There are 3 groups of Function Blocks connected. The specific color of a Function Block shows that this block is mapped to a Device. The two different colors of the FBs indicate that they are mapped to two different Devices, so the Application is distributed. The dashed line connections are just information. We will see how the data is passed between Devices in Resources.

The Applications IOs are on one Device and the calculation (X+3) is on the 2nd Device. Mouse over often provides extra information like a data variable’s type. When exploring the Application it can be figured out that there are three types of Function Blocks used:

- IN_ANY and OUT_ANY are the input/output, which visualize the input value and the calculation result. The input QI is an input qualifier that allows the Function Block to work if its true. It is used to turn-off Function Blocks when a predecessor Function Block has an error. In our Application the OUT_BOOL.QI is set to 1.

- F_ADD adds two ANY inputs together. One value comes from the input connection and the other is a hard-coded constant

### Explore Existing System Configuration

Within the System called Xplus3 there is the System Configuration. Click once on System Configuration (on left) and keep expanding the System Configuration by clicking the arrows on the left. This shows the Devices and Resources used.

#### Explore Existing Devices

Double click on System Configuration to open the System Configuration model that shows the System, the Devices, their Resources and the communication network the Devices are connected to.

There are two Devices connected via an Ethernet segment. You have to know what Devices you are using. Here it is:

1. MICROCONTROLLER remote device (RMT_DEV) (uses 4diac FORTE). The IEC 61499 system used by this Application Xplus3Application is Posix FORTE on a PC, but it could be a real microcontroller like ARM7 in Lego Mindstorms as well.

2. PC remote frame (RMT_FRAME) (uses FBDK). The IEC 61499 System used by this Application Xplus3Application is FBDK via its runtime, FBRT.

Click on the Device name in main window to look at the Device’s properties bottom window. It is important to set the property Misc/Profile to HOLOBLOC.

#### Explore Existing Resources

In this System each Device has a Manager and 1 Resource, that Applications can be mapped to. If you have not yet done so, click on the arrow at the left side of System Configuration to see the Devices (MICROCONTROLLER; PC). In the same way, expand the Devices (MICROCONTROLLER; PC) to see their Resource(s). Double-click on the Resource names (CALC, VIS) to see what Function Blocks are mapped to the Resource. For the CALC Resource, it looks like this: System Configuration → MICROCONTROLLER → CALC

And for the VIS Resource, like this: System Configuration → PC → VIS

Note the PUBLISH_1 and SUBSCRIBE_1 Function Blocks that are used to send data between Devices or Resources. The _1 is the number of data items being sent / received. INT2INT is used multiple times. You may ask yourself: Why convert an INT to an INT - isn’t that the same thing!?

1. Do a mouse over of the data output IN_ANY.OUT in VIS. Note its type: It is ANY.

2. Do a mouse over of the data output PUBLISH_1_0.SD_1. Note its type: It is ANY.

So, when the output type is ANY and the input type is ANY, how can the actual data type be known? This is why we need a conversion Function Block like INT2INT with ANY input and an actual data type for output. Function Blocks using an ANY type for input or output have to tell the Function Blocks the type in and the following Function Blocks the type out. For regular Function Blocks the input type must match its type. Look back at the Application, where all 3 parts Input, Output and calculation appear together. Notice that the Publish and Subscribe Function Blocks used to exchange data between Resources of a Device are in the Resource directly. This makes the Application less cluttered and more clearly understandable.

### Deploy Your Application

Switch to the Deployment perspective and set the runtime preferences. The following settings are under Window → Preferences → 4diac IDE. For further details on setting these locations see 4diac IDE Properties. To run the test, the locations of the IEC 61499 executables for the Devices used are required.

- MICROCONTROLLER.CALC uses 4diac FORTE. Therefore, the location of `forte.exe` must be set within the 4diac FORTE preferences. Typically, this is somewhere below `/runtime/FORTE/`. Relative paths do not work in all setups, it is recommended to specify an absolute path here.

- PC.VIS uses FBRT. Therefore, the location of `fbrt.jar` must be set in FBRT preferences. Typically, this path is `./runtime/FBRT/fbrt.jar`.

With the preferences set correctly for the IEC 61499 System on the 2 Devices you can now test. Click the Open perspective button on top of the title bar and add Deployment in the perspective window. The Open Perspective button of the Deployment perspective will be found besides the System perspective Button

To download and test your IEC 61499 Application:

1. Check the System Xplus3 and notice the Devices show up under the System, but not the Application mapped to the Devices.

2. Press the Launch FBRT button. Note that the Device and port number match the properties of the Device using FBRT (i.e., PC) in System Configuration. The console output from the FBRT is shown on the bottom right and an empty Java window will open.

3. Press the Launch FORTE button. Note that the host and port number match the properties of the Device using 4diac FORTE (i.e., MICROCONTROLLER) in System Configuration. Again, console output is shown on the bottom right. The console output of 4diac FORTE is dependent on the log-level that has been configured with CMake. The default configuration is LOGDEBUG. It lists debug information.

4. When launching FBRT or 4diac FORTE for the first time, a system firewall configuration window may pop up. You should allow network access that the 2 Devices are able to communicate with each other over Ethernet.

5. Press Download and notice the Deployment Console output on the right.

6. Click on the Java application window (RMT-FRAME). Resize it if necessary to see the contents. Enter an integer in the top field and press the enter key. The result is shown in the bottom field: It should be the value you entered plus three.

## Where to go from here?

Go back to Examples index:

Examples Index

If you want to go back to the Start Here page, we leave you here a fast access

Start Here page

Go to top