Professional Documents
Culture Documents
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 modify javac.txt inserting there the path to the compiler in the first line:
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 the lamp) 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 can start 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 double click 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 UNSUPPORTED TYPE. If you switch to the Java command line window, you will see the same message (picture below).
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 data output 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:
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_COMP 2. 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.
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 <ECAction > 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.
Checkpoint 2:
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 delete the transition from REQ to START.
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 and if you press XYZ, then there will be reaction: value 6.0 for OUT2 and output event CNF2. Checkpoint 3: 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.
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:
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].
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.
Checkpoint 5:
Change any of the inputs and press ENTER. You will see the result computed by your version of MY_X2Y2_J !
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 IP address or DNS name of the remote computer is required to be set as MGR_ID parameter of the FLASHER device prior to starting the system.
1.
10
2.
Checkpoint 6:
3. 4. 5.
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. Modify the MGR_ID of the FLASHER device to the address of your neighbor. Start the FLASHER_TESTR in truly distributed configuration. 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 is no /ita folder in /lib/fb/rt, so you need to create it there before compiling your modified blocks.
Checkpoint 7:
11