fb_lab
TRANSCRIPT
-
8/2/2019 FB_lab
1/11
SOFTENG 701
Semester 1 - 2006
Valeriy Vyatkin 2006 1
Valeriy Vyatkin
Lab: Learning function blocks and FBDK
INTRODUCTION
This lab work will be marked giving 15% of the overall assignment 1 mark.Lab 1 times are: 20, 21, 22 and 24 of March, 10-12 pm at 303.255 (Advanced simulation lab) class
capacity 20. The students will be distributed across 3 sessions on 20th, 21st and 22nd. Time on the 24th is
reserved to resolve some unexpected troubles. Please contact the tutor for bookings on the 24th.
Lab 1 topics:
a) getting the hands on experience on FBDK: how to create, compile, test, modify a basic function blocktype;
b) learning how to use a basic function block type in a composite function block type;c) executing distributed application (FLASHER_TESTD) on one machine and distributed remote
application (FLASHER_TESTR) on two machines;
d) modifying the FLASHER: introduce new flashing mode or increase the number of the flashing LEDs.
Expected outcome: Demonstrated ability of running FBDK and distributed applications in FBDK.
INSTALLATION OF FBDK
You need to copy the FBDK folder locally from Cecil. FBDK is provided in a form of archive file
fbdk.zip. You need to extract this archive to c:\fbdk. In the folder you will find the following
subfolders.
Before running FBDK, make sure that Java virtual machine and Java compiler are installed properly on
your machine. To setup the compiler properly:
1. Map the external drive \\ece-ad\ece-dfs\course-resources\compsys405 (say as drive Y:) and
modifyjavac.txt inserting there the path to the compiler in the first line:
1.MODIFY AN EXISTING FUNCTION BLOCK TYPE
Open function block type X2Y2_J using File/Open (/student/X2Y2_J.fbt).
-
8/2/2019 FB_lab
2/11
SOFTENG 701
Semester 1 - 2006
Valeriy Vyatkin 2006 2
a) b)
Compile the block to Java class by File/Save as/Java or Alt-J. If you see the window (b), then the
compilation was successful!
Run the standalone block in the test environment by Run/Launch/ X2Y2_J. The test environment is
producing a frame in which you can test the block by entering input parameters. Unfortunately, not all of
the input fields have labels, so you need to guess.
Enter X and Y parameters, press the REQ button and see the result: the output event CNF (a flash of thelamp) and the computed value in the OUT field.
Now let us change the function block type name to MY_X2Y2_J.fbt by clicking at the Name/Comment
item in the tree in the left pane of the editor.
Save the block using menu File/Save As/XML. Now you canstart making some modifications. For example, let us change
the formula and compute X2+Y2. For doing that you need to
modify algorithm REQ, which is written in Java. Just doubleclick on it and see the following picture:
Now change the code in the box to
OUT.value = X.value*X.value+Y.value*Y.value;
Note, that all function block variables are objects, that is why
their values are accessed by X.value, Y.value, etc.
Try to run by Run/Launch/MY_X2Y2_J WHAT HAPPENED? You get the message UNSUPPORTEDTYPE. If you switch to the Java command line window, you will see the same message (picture below).
-
8/2/2019 FB_lab
3/11
SOFTENG 701
Semester 1 - 2006
Valeriy Vyatkin 2006 3
Remember that you have changed the blocks name, but have not compiled it with new name yet.
Compile the new block by saving it as Java (Alt-J) and try to run it again.
Make sure that the block computes now X2+Y2!
Now, experiment with adding more inputs and outputs to the function block and with modifying the ECC.
For example, to add new inputs click right Button of mouse on the function block shape and follow the
menu: New/Variable/Input as shown below:
An idea: let us add numeric input Z (of type REAL), event input XYZ, event output CNF2 and dataoutput OUT2. When block is activated by XYZ event, it shall compute OUT2=X+Y+Z and signal at the
event CNF2.
Note: to create an association between an event input and data input position mouse to the left of the
event input (on the word EVENT), hold ALT and press LEFT mouse button. Holding the mouse button
drag to the data input name as illustrated in the next picture. The resultant function block shall look like
the one on the right:
Checkpoint 1:Demonstrate
the result to the
Tutor
-
8/2/2019 FB_lab
4/11
SOFTENG 701
Semester 1 - 2006
Valeriy Vyatkin 2006 4
Now, let us modify the blocks body. In the navigation tree click on the ECC. Go to the Edit pane. Make
right mouse click and select New/Algorithm from the pop-up menu. You will see the following window
(left side). What you need to get is shown on the right side.
For that:
1. Enter algorithm name for example XYZ_COMP2. Check the Java radio button;
3. Enter Java code of the algorithms body;
4. Push OK.
Now you need to add an ECC state which will be calling the algorithm you just created. Again, go to the
ECC in the navigation tree, call the pop-up menu with right click of mouse, select New/State.
After you created the new state, like XYZ_S above, and after it has appeared in ECC click right button of
mouse on it in ECC, Select New/Action and add the action.
-
8/2/2019 FB_lab
5/11
SOFTENG 701
Semester 1 - 2006
Valeriy Vyatkin 2006 5
Attention: There is a bug in the current version of FBDK that does not let to add actions. However it is
even useful, as you will learn a workaround. Modify directly the XML source of the X2Y2_J.fbt file as
follows:
1. Click on the state REQ the corresponding XML element will be highlighted in yellow (Figure
below - left);
2. Copy the nested element and paste it to the element corresponding state XYZ_S;
3. Modify the element: change the algorithm name (to XYZ_COMP) and output event (to CNF2).
4. Parse the edited XML by Alt-P or by pressing the Parse button (two arrows, just above the XML
editor pane).
a) b)
Now you can connect the new state XYZ_S to the state START. Remember the connector works when
Alt is pressed.
Double click on the transition condition from
START to XYZ_S (currently 1) and select the
event XYZ from the menu as follows.
Save the resultant FB, compile it, and run. Check if the block does what you want.
Now let us experiment with changing the ECC. Delete the transition from state START to XYZ_S just
right mouse click on the condition of the transition (XYZ), and select Delete from the menu. Also deletethe transition from REQ to START.
Checkpoint 2:
-
8/2/2019 FB_lab
6/11
SOFTENG 701
Semester 1 - 2006
Valeriy Vyatkin 2006 6
Then connect REQ with XYZ_S with a transition having condition XYZ. The resulting ECC will look as
in the following Figure. Save and compile the block.
BEFORE RUNNING IT YOU NEED TO RESTART FBDK. OTHERWISE FBDK WILL
PROBABLY RUN THE OLD CLASS (with non-modified ECC) WHICH IS STILL LOADED.Enter X, Y, Z values 1,2 and 3 as shown in the
figure below. Then press XYZ. What you see? No
reaction since in the current state the block is not
expecting this event input.
Press then REQ and the OUT result -3.0 will be displayed (12-22 = -3). Now the ECC is in state REQ andif you press XYZ, then there will be reaction: value 6.0 for OUT2 and output event CNF2.
After experimenting with the modified MY_X2Y2_J, modify its ECC back to the previous version!
Save and compile. It will be used in further exercises.
2.USING THE MODIFIED FUNCTION BLOCK TYPE IN A SYSTEM CONFIGURATION
System configuration is the only structure of IEC 61499 that is supposed to be immediately executable. Itdoes not need to be compiled to Java. Provided that all the types used in it (devices, resources and
function blocks) are compiled and stored correctly, a system configuration can be started from FBDK.
If a system configuration includes remote devices, the network connection should exist and the devices
should be activated prior to starting the system configuration.
Open system configuration X2Y2_TESTL. Explore its devices and resources. Run it.
Now you see that this system configuration uses X2Y2 function block and wraps it with HMI andcommunication functions.
In this part of the lab you will need to modify the X2Y2_TESTL system configuration to use there your
MY_X2Y2_J function block type.
Resource 1 of the modified system
Resource 2 of the modified system
Checkpoint 3:
-
8/2/2019 FB_lab
7/11
SOFTENG 701
Semester 1 - 2006
Valeriy Vyatkin 2006 7
The sequence of steps is as follows:
1. Change name of the system to XYZ_TESTL.2. In RES1:
a. Add IN3 (of type IN_ANY)
b. Change the local publisher XY of type PUBL_2 to XYZ of type PUBL_3. Right click
on the instance name and modify instance name. Choose the type name from browsing
in package net.
Adjust connections: remove event link from IN2.INITO to XYZ.INIT, add event link from IN2.INITO to
IN3.INIT, from IN3.INITO to XYZ.INIT, from IN3.IND to XYZ.REQ, add data link IN3.OUT to
XYZ.SD_3.
In RES2:Change TESTEE type to MY_X2Y2_J. Then, change XY type to SUBL_3 and instance name to XYZ
(the block instance name is used as an ID for communication).
Connect XYZ.IND to TESTEE.XYZ, XYZ.RD_3 to TESTEE.Z, TESTEE.CNF2 to OUT.REQ, and
TESTEE.OUT2 to OUT.IN.
Since the new system has three input parameters instead of two, you need to adjust the dimensions of
display frames as follows:
-
8/2/2019 FB_lab
8/11
SOFTENG 701
Semester 1 - 2006
Valeriy Vyatkin 2006 8
For that, in the navigation tree click on the XYZ_TESTL device list and change the dimensions of
devices frames. New dimensions are: for DEV1: [150,150,125,125], for DEV2: [150, 275, 125, 75].
Show the running system to the tutor.
3.CREATING A COMPOSITE FUNCTION BLOCK TYPE AND TESTING IT
Create new, composite function block type USE_XYZ. Refer to [1] Chapter 6 on how to create new
basic FB type or read FBDK Help How to Composite section. For a composite block you need to do
the same things as for the basic: create new, change name, define package (student), save. Since your
block will be referring to other function blocks (in particular to IN_ANY, OUT_ANY, which belong to
the package swing you need to import this package.For that, click on the Compiler Info item in the navigation tree pane and add
import fb.rt.swing.*; as shown below:
Checkpoint 4:
-
8/2/2019 FB_lab
9/11
SOFTENG 701
Semester 1 - 2006
Valeriy Vyatkin 2006 9
Attention: There is another bug in FBDK, so the data entered in that dialog are not getting to the XML
source of the block. Modify the XML element manually as shown above and parse.
Now create the function block body as shown in the following figure.
For entering new function block instances use the pop-up menu (called by a right click) in the Viewport
area.
Save and compile the composite function block USE_XYZ.
Now let us test this block. Create a new system configuration, name it Test_XYZ. Change the device type
to FRAME_DEVICE (in fb.rt.hmi package). The resource type needs to be changed to
PANEL_RESOURCE (same package fb.rt.hmi). Change the device dimensions to [100,100,350,100].
Assign the GRID input of the device to [1,1].
After creation the resource contains only START function block. Add there USE_XYZ and connect its
INIT input to the COLD output of the START. Now you can run it and see the output, as show on the
right part of the figure.
Change any of the inputs and press ENTER. You will see the result computed by your version of
MY_X2Y2_J !
4.RUN DISTRIBUTED FLASHER
Next part of the lab is about distributed applications. Open system configuration
/src/ita/FLASHER_TESTR.sys.
Checkpoint 5:
-
8/2/2019 FB_lab
10/11
SOFTENG 701
Semester 1 - 2006
Valeriy Vyatkin 2006 10
Before running FLASHER_TESTR.sys system configuration in FBEditor it is necessary to start the
remote device. It can be done on the same computer where FBEditor already runs, or on any other
computer connected via network.
To start the remote device you will need to create and start batch command file remote.bat that consists
of the single command line:
This line starts remote device (of RMT_DEV type) with the following parameters:
name of device= RDEVICE,
available packages of function blocks math and ita (i.e. Java classes fb.rt.math and fb.rt.ita),
network socket s 61501.
In the system configuration the value of the device management ID is set to localhost:61501. This
setting is for the case when the remote device is executed on the localhost, i.e. on the same computer
as FBEditor. Otherwise, you need to correct this setting in FLASHER_TESTR.SYS, substituting
localhost by the symbolic name or IP address of the device where the remote copy of FBRT was
started. Thus, several remote devices can be executed simultaneously on the local or on a remote
computer.
The figure below shows execution of FLASHER_TESTR.sys on two networking computers. The IPaddress or DNS name of the remote computer is required to be set as MGR_ID parameter of theFLASHER device prior to starting the system.
1. Run FLASHER_TESTR on your machine.
-
8/2/2019 FB_lab
11/11
SOFTENG 701
Semester 1 - 2006
Valeriy Vyatkin 2006 11
2. Find out IP address of your machine (using ipconfig command in the CMD shell) and of the
machine of your neighbor in the lab room. Ask your neighbor to start the remote.bat as explained
above.
3. Modify the MGR_ID of the FLASHER device to the address of your neighbor.
4. Start the FLASHER_TESTR in truly distributed configuration.
5. Show the running system to the tutor.
5.DEVELOPMENT TASK
Based on the experience gained in the lab, modify FLASHER_TEST.sys to have either:
a) new operating mode (e.g. TWO LEDS moving right or left) OR:
b) change the number of LEDs from 4 to 6.
Hints:1. You obviously need to develop new function block types modifying FLASHER4, LED_HMI.
2. Then, modify (rename, save) the system configuration and use there new function blocks.
3. Make sure that your modified blocks belong to the package ita (not student) ! Probably, there isno/ita folder in/lib/fb/rt, so you need to create it there before compiling your modified blocks.
Checkpoint 6:
Checkpoint 7: