Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Papyrus/UserGuide/fUML ALF Moka"
(Created page with "== Overview == In this report, we tried to implement part of the executable model in fUML with Action Language (ALF). This report is based on Eclipse Oxygen and Papyrus Mod...") |
m (→Import a basic sample of fUML with Moka to start with) |
||
(12 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | == | + | == Report on How to Use ALF Action Language and fUML execution/debugging with Moka == |
In this report, we tried to implement part of the executable model in fUML with Action Language (ALF). This report is based on Eclipse Oxygen and Papyrus Modeling environment and the process of installation and execution of ALF action language in this environment. | In this report, we tried to implement part of the executable model in fUML with Action Language (ALF). This report is based on Eclipse Oxygen and Papyrus Modeling environment and the process of installation and execution of ALF action language in this environment. | ||
Line 7: | Line 7: | ||
== Preparing Steps for Papyrus == | == Preparing Steps for Papyrus == | ||
− | === Installing ALF Extension for Eclipse Oxygen | + | === Installing ALF Extension for Eclipse Oxygen === |
1. Click on “help”, “install new software” then add the link below and install all ALF plug-ins on your Eclipse. The address for the update the sources. | 1. Click on “help”, “install new software” then add the link below and install all ALF plug-ins on your Eclipse. The address for the update the sources. | ||
---- | ---- | ||
− | [[File:ALF_Prep_01.jpg]] | + | [[File:ALF_Prep_01.jpg|600px]] |
---- | ---- | ||
''Figure 1- ALF installation for papyrus'' | ''Figure 1- ALF installation for papyrus'' | ||
Line 17: | Line 17: | ||
2. From top toolbar select “help” then “Eclipse MarketPlace”, search ALF and install “Integrated ALF Editor”. | 2. From top toolbar select “help” then “Eclipse MarketPlace”, search ALF and install “Integrated ALF Editor”. | ||
---- | ---- | ||
− | [[File:ALF_Prep_02.jpg]] | + | [[File:ALF_Prep_02.jpg|300px]] |
---- | ---- | ||
''Figure 2 - Integrated ALF Editor inside Papyrus additional Components'' | ''Figure 2 - Integrated ALF Editor inside Papyrus additional Components'' | ||
Line 23: | Line 23: | ||
3. From top toolbar on “preference” search ALF and active all Supports for it. | 3. From top toolbar on “preference” search ALF and active all Supports for it. | ||
---- | ---- | ||
− | [[File:ALF_Prep_03.jpg]] | + | [[File:ALF_Prep_03.jpg|600px]] |
---- | ---- | ||
''Figure 3 - Enable ALF Support for Foundational UML | ''Figure 3 - Enable ALF Support for Foundational UML | ||
'' | '' | ||
− | === Installing Moka and Nebula updates | + | === Installing Moka and Nebula updates=== |
1. On “help”, “install new software” add this link below and install all Nebula. | 1. On “help”, “install new software” add this link below and install all Nebula. | ||
---- | ---- | ||
− | [[File:ALF_Prep_04.jpg]] | + | [[File:ALF_Prep_04.jpg|600px]] |
---- | ---- | ||
''Figure 4 - Get Nebula Updates | ''Figure 4 - Get Nebula Updates | ||
Line 38: | Line 38: | ||
2. On “help”, “install new software” add this link below and install all Moka cores. | 2. On “help”, “install new software” add this link below and install all Moka cores. | ||
---- | ---- | ||
− | [[File:ALF_Prep_05.jpg]] | + | [[File:ALF_Prep_05.jpg|600px]] |
---- | ---- | ||
''Figure 5 - Moka core for execution and debugging models | ''Figure 5 - Moka core for execution and debugging models | ||
Line 46: | Line 46: | ||
- web address: https://wiki.eclipse.org/File:BasicActiveObjectExample.zip | - web address: https://wiki.eclipse.org/File:BasicActiveObjectExample.zip | ||
---- | ---- | ||
− | [[File:ALF_Prep_06.jpg]] | + | [[File:ALF_Prep_06.jpg|600px]] |
---- | ---- | ||
''Figure 6 - a Basic sample of fUML in Moka | ''Figure 6 - a Basic sample of fUML in Moka | ||
Line 56: | Line 56: | ||
1. we will make a new papyrus project then import the sample project (that we download it before). We called the project “ALF_PAPYRUS”. | 1. we will make a new papyrus project then import the sample project (that we download it before). We called the project “ALF_PAPYRUS”. | ||
---- | ---- | ||
− | [[File:Moka_Debug_FUML_01.jpg]] | + | [[File:Moka_Debug_FUML_01.jpg|400px]] |
---- | ---- | ||
Figure 7 - Create new project with the name of ALF_Papyrus | Figure 7 - Create new project with the name of ALF_Papyrus | ||
---- | ---- | ||
− | [[File:Moka_Debug_FUML_02.jpg]] | + | [[File:Moka_Debug_FUML_02.jpg|600px]] |
---- | ---- | ||
Figure 8 - Import downloaded sample into the environment | Figure 8 - Import downloaded sample into the environment | ||
Line 66: | Line 66: | ||
2. when you open the project, you should have all these diagrams attached to it. | 2. when you open the project, you should have all these diagrams attached to it. | ||
---- | ---- | ||
− | [[File:Moka_Debug_FUML_03.jpg]] | + | [[File:Moka_Debug_FUML_03.jpg|600px]] |
---- | ---- | ||
Figure 9 - First view of the imported project | Figure 9 - First view of the imported project | ||
---- | ---- | ||
− | [[File:Moka_Debug_FUML_04.jpg]] | + | [[File:Moka_Debug_FUML_04.jpg|600px]] |
---- | ---- | ||
Figure 10 - Increment Class Diagram in Project | Figure 10 - Increment Class Diagram in Project | ||
---- | ---- | ||
− | [[File:Moka_Debug_FUML_05.jpg]] | + | [[File:Moka_Debug_FUML_05.jpg|600px]] |
---- | ---- | ||
Figure 11 - Increment method in the behaviors | Figure 11 - Increment method in the behaviors | ||
---- | ---- | ||
− | [[File:Moka_Debug_FUML_06.jpg]] | + | [[File:Moka_Debug_FUML_06.jpg|600px]] |
---- | ---- | ||
Figure 12 - Increment classifier behavior | Figure 12 - Increment classifier behavior | ||
Line 84: | Line 84: | ||
3. The behaviors associated with this class (i.e., IncrementClassifierBehavior, which is the classifier behavior, and incrementMethod, are the implementations of operation increment) are specified by activity diagrams. Corresponding activities are executable, according to the semantics given in OMG standards fUML and PSCS. Anyway, in fUML and PSCS, the execution of a model usually starts by executing a kind of "main" activity, which is responsible for instantiating objects, and stimulate them if needed (through signals or operation calls). Moka provides some facilities to generate this kind of activities. Just right click on class Increment, then go to Moka - Modeling Utils - Generate Factory. | 3. The behaviors associated with this class (i.e., IncrementClassifierBehavior, which is the classifier behavior, and incrementMethod, are the implementations of operation increment) are specified by activity diagrams. Corresponding activities are executable, according to the semantics given in OMG standards fUML and PSCS. Anyway, in fUML and PSCS, the execution of a model usually starts by executing a kind of "main" activity, which is responsible for instantiating objects, and stimulate them if needed (through signals or operation calls). Moka provides some facilities to generate this kind of activities. Just right click on class Increment, then go to Moka - Modeling Utils - Generate Factory. | ||
---- | ---- | ||
− | [[File:Moka_Debug_FUML_07.jpg]] | + | [[File:Moka_Debug_FUML_07.jpg|600px]] |
---- | ---- | ||
Figure 13 - Generate factory for Increment Class Behavior | Figure 13 - Generate factory for Increment Class Behavior | ||
Line 90: | Line 90: | ||
4. You should also check the execution engine from “preferences”. | 4. You should also check the execution engine from “preferences”. | ||
---- | ---- | ||
− | [[File:Moka_Debug_FUML_08.jpg]] | + | [[File:Moka_Debug_FUML_08.jpg|600px]] |
---- | ---- | ||
Figure 14 - Moka preferences for run and debug | Figure 14 - Moka preferences for run and debug | ||
Line 96: | Line 96: | ||
5. After checking the engine, hit “Debug Configurations…” and add new configuration as below. | 5. After checking the engine, hit “Debug Configurations…” and add new configuration as below. | ||
---- | ---- | ||
− | [[File:Moka_Debug_FUML_09.jpg]] | + | [[File:Moka_Debug_FUML_09.jpg|600px]] |
---- | ---- | ||
Figure 15 - Run Project in debug mode | Figure 15 - Run Project in debug mode | ||
---- | ---- | ||
− | [[File:Moka_Debug_FUML_09.jpg]] | + | [[File:Moka_Debug_FUML_09.jpg|600px]] |
---- | ---- | ||
Figure 16 - Debug configuration and add Moka Configs | Figure 16 - Debug configuration and add Moka Configs | ||
---- | ---- | ||
− | [[File:Moka_Debug_FUML_10.jpg]] | + | [[File:Moka_Debug_FUML_10.jpg|600px]] |
− | [[File:Moka_Debug_FUML_11.jpg]] | + | [[File:Moka_Debug_FUML_11.jpg|600px]] |
---- | ---- | ||
Figure 17 - Steps to initial configurations for Moka | Figure 17 - Steps to initial configurations for Moka | ||
+ | ---- | ||
+ | [[File:Moka_Debug_FUML_12.jpg|600px]] | ||
---- | ---- | ||
Figure 18 – set element for execution of Model | Figure 18 – set element for execution of Model | ||
Line 114: | Line 116: | ||
6. Start debugging by click on Debug icon in the top-right corner of the screen. | 6. Start debugging by click on Debug icon in the top-right corner of the screen. | ||
---- | ---- | ||
− | [[File: | + | [[File:Moka_Debug_FUML_13.jpg|200px]] |
---- | ---- | ||
Figure 19 - the Debugging environment in the eclipse | Figure 19 - the Debugging environment in the eclipse | ||
Line 120: | Line 122: | ||
7. You will see the debug start when the action diagram becomes green | 7. You will see the debug start when the action diagram becomes green | ||
---- | ---- | ||
− | [[File: | + | [[File:Moka_Debug_FUML_14.jpg|600px]] |
---- | ---- | ||
Figure 20 - Debugging a Model in eclipse | Figure 20 - Debugging a Model in eclipse | ||
---- | ---- | ||
− | [[File: | + | [[File:Moka_Debug_FUML_15.jpg|600px]] |
---- | ---- | ||
Figure 21 - Possibility to add a breakpoint and see the simulation of the execution for model | Figure 21 - Possibility to add a breakpoint and see the simulation of the execution for model | ||
Line 130: | Line 132: | ||
8. By Adding breakpoints in different steps, you can monitor debugging completely. | 8. By Adding breakpoints in different steps, you can monitor debugging completely. | ||
---- | ---- | ||
− | [[File: | + | [[File:Moka_Debug_FUML_16.jpg|600px]] |
---- | ---- | ||
Figure 22 - Adding Breakpoint in each step to check the object instance values of the class | Figure 22 - Adding Breakpoint in each step to check the object instance values of the class | ||
Line 136: | Line 138: | ||
9. As you see in the pictures, the counter will increase each time the cycle finishes. | 9. As you see in the pictures, the counter will increase each time the cycle finishes. | ||
---- | ---- | ||
− | [[File: | + | [[File:Moka_Debug_FUML_17.jpg|600px]] |
---- | ---- | ||
Figure 23 - read values of the attributes of the class in the variables window | Figure 23 - read values of the attributes of the class in the variables window | ||
Line 142: | Line 144: | ||
10. As you see in this photo, there is no command in ALF part, because here we only use Moka to execute this project. Next step we will add another method and write the ALF codes in it. | 10. As you see in this photo, there is no command in ALF part, because here we only use Moka to execute this project. Next step we will add another method and write the ALF codes in it. | ||
---- | ---- | ||
− | [[File: | + | [[File:Moka_Debug_FUML_18.jpg|600px]] |
---- | ---- | ||
Figure 24 - All executed with models and nothing textual for actions | Figure 24 - All executed with models and nothing textual for actions | ||
− | |||
== ALF based Model Execution == | == ALF based Model Execution == | ||
− | === ALF based behavior as part of the diagram | + | === ALF based behavior as part of the diagram === |
1. In the Class, diagram add an operation and call it Multiply | 1. In the Class, diagram add an operation and call it Multiply | ||
---- | ---- | ||
− | [[File:ALF_Debug_FUML_01.jpg]] | + | [[File:ALF_Debug_FUML_01.jpg|600px]] |
---- | ---- | ||
Figure 25 - Add a new operation to the class from palette | Figure 25 - Add a new operation to the class from palette | ||
Line 157: | Line 158: | ||
2. In Model Explorer, right click on Increment and add new activity behavior call it “MultiplyMethod” | 2. In Model Explorer, right click on Increment and add new activity behavior call it “MultiplyMethod” | ||
---- | ---- | ||
− | [[File:ALF_Debug_FUML_02.jpg]] | + | [[File:ALF_Debug_FUML_02.jpg|600px]] |
---- | ---- | ||
Figure 26 - Add activity to the existing class | Figure 26 - Add activity to the existing class | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_03.jpg|600px]] |
---- | ---- | ||
Figure 27 – Multiply Method as a behavior added to the class | Figure 27 – Multiply Method as a behavior added to the class | ||
Line 167: | Line 168: | ||
3. As you see, you will have this class diagram and model Explorer. If you click on MultiplyMethod, it is ready to add your behavior with ALF language. | 3. As you see, you will have this class diagram and model Explorer. If you click on MultiplyMethod, it is ready to add your behavior with ALF language. | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_04.jpg|600px]] |
---- | ---- | ||
Figure 28 - ALF editor inside the eclipse to create behavior | Figure 28 - ALF editor inside the eclipse to create behavior | ||
Line 173: | Line 174: | ||
4. Write ALF codes same as below in “ALF properties” for “MultiplyMethod” | 4. Write ALF codes same as below in “ALF properties” for “MultiplyMethod” | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_05.jpg|600px]] |
---- | ---- | ||
Sample Code: | Sample Code: | ||
Line 186: | Line 187: | ||
We have added the ALF codes but still, we do not have the multiplymethod in our Action diagram. It is possible to Drag and drop the “MultiplyMethod” from Model Explorer to increment class diagram to add it even inside to diagram. | We have added the ALF codes but still, we do not have the multiplymethod in our Action diagram. It is possible to Drag and drop the “MultiplyMethod” from Model Explorer to increment class diagram to add it even inside to diagram. | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_06.jpg|600px]] |
---- | ---- | ||
Figure 29 - Compile and Generate behaviors for multiplyMethod Behavior | Figure 29 - Compile and Generate behaviors for multiplyMethod Behavior | ||
Line 192: | Line 193: | ||
6. Now we need to execute our ALF part in the previous fUML we tested and debugged in the previous section. | 6. Now we need to execute our ALF part in the previous fUML we tested and debugged in the previous section. | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_07.jpg|600px]] |
---- | ---- | ||
7. Choose “Activity as a CallBehaviorAction” second item from the menu. | 7. Choose “Activity as a CallBehaviorAction” second item from the menu. | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_08.jpg|600px]] |
---- | ---- | ||
Figure 30 - Drag MultiplyMethod from Model Explorer inside the increment Method as CallBehaviorAction | Figure 30 - Drag MultiplyMethod from Model Explorer inside the increment Method as CallBehaviorAction | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_09.jpg|600px]] |
---- | ---- | ||
Figure 31 - As you can see the result is our method with two input and one output as we wrote in ALF | Figure 31 - As you can see the result is our method with two input and one output as we wrote in ALF | ||
Line 206: | Line 207: | ||
8. To test the “MultiplyMethod” we will add a constant value (equal to 2) and get the output of incrementing. So, each time we will multiply the increment output. | 8. To test the “MultiplyMethod” we will add a constant value (equal to 2) and get the output of incrementing. So, each time we will multiply the increment output. | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_10.jpg|600px]] |
---- | ---- | ||
Figure 32 - Add value Specification Action to set the inputs of the MultiplyMethod | Figure 32 - Add value Specification Action to set the inputs of the MultiplyMethod | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_11.jpg|400px]] |
---- | ---- | ||
Figure 33 - Add Literal Integer value equal 2 as a second input for Behavior | Figure 33 - Add Literal Integer value equal 2 as a second input for Behavior | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_12.jpg|600px]] |
---- | ---- | ||
Figure 34 - set the value equal 2 to provide the right input for your method | Figure 34 - set the value equal 2 to provide the right input for your method | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_13.jpg|600px]] |
---- | ---- | ||
Figure 35 - Object Flow edge to connect result of value two to input y | Figure 35 - Object Flow edge to connect result of value two to input y | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_14.jpg|600px]] |
---- | ---- | ||
Figure 36 - Object flow from the result of the callMultiplyMethod to the Value of set Counter | Figure 36 - Object flow from the result of the callMultiplyMethod to the Value of set Counter | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_15.jpg|600px]] |
---- | ---- | ||
Figure 37 - Final Modified Diagram with the added ALF part | Figure 37 - Final Modified Diagram with the added ALF part | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_16.jpg|600px]] |
---- | ---- | ||
Figure 38 - Add Breakpoints to Debug and see the values inside the model | Figure 38 - Add Breakpoints to Debug and see the values inside the model | ||
Line 236: | Line 237: | ||
9. When you run the debug, counter is zero and each time it will first increment by 1 and multiply by 2. First step counter is zero. | 9. When you run the debug, counter is zero and each time it will first increment by 1 and multiply by 2. First step counter is zero. | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_17.jpg|600px]] |
---- | ---- | ||
Figure 39 - In the first run value of the counter is zero | Figure 39 - In the first run value of the counter is zero | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_18.jpg|200px]] |
---- | ---- | ||
Figure 40 - Simply hit resume to continue running the diagram | Figure 40 - Simply hit resume to continue running the diagram | ||
Line 246: | Line 247: | ||
10. Second step 0 will increment by1 then multiply by 2. counter: (0+1) *2=2 | 10. Second step 0 will increment by1 then multiply by 2. counter: (0+1) *2=2 | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_19.jpg|600px]] |
---- | ---- | ||
Figure 41 - Second run the value will show the result of two | Figure 41 - Second run the value will show the result of two | ||
Line 252: | Line 253: | ||
11. Third step. Counter: (2+1) * 2=6 | 11. Third step. Counter: (2+1) * 2=6 | ||
---- | ---- | ||
− | [[File: | + | [[File:ALF_Debug_FUML_20.jpg|600px]] |
---- | ---- | ||
Figure 42 - in the third run value will show the 6 as result | Figure 42 - in the third run value will show the 6 as result | ||
− | |||
== Conclusion == | == Conclusion == | ||
Line 261: | Line 261: | ||
In the textual representation of the model, we can see, we have the multiply method as public which is written by ALF and there is no difference in the execution of ALF parts and fUML with Moka. | In the textual representation of the model, we can see, we have the multiply method as public which is written by ALF and there is no difference in the execution of ALF parts and fUML with Moka. | ||
---- | ---- | ||
− | [[File:ALF_fUML_Conc_01.jpg]] | + | [[File:ALF_fUML_Conc_01.jpg|600px]] |
---- | ---- | ||
Figure 43 - Final representation of two different behaviors in the model | Figure 43 - Final representation of two different behaviors in the model | ||
Line 269: | Line 269: | ||
•“incrementMethod” which is implemented with fUML and actions inside the model. | •“incrementMethod” which is implemented with fUML and actions inside the model. | ||
---- | ---- | ||
− | [[File:ALF_fUML_Conc_02.jpg]] | + | [[File:ALF_fUML_Conc_02.jpg|600px]] |
---- | ---- | ||
Figure 44 - Increment method based on the fUML without textual actions | Figure 44 - Increment method based on the fUML without textual actions | ||
Line 275: | Line 275: | ||
•“MultiplyMethod” which is added with ALF action language and compiled as a part of the model execution in the behavior. | •“MultiplyMethod” which is added with ALF action language and compiled as a part of the model execution in the behavior. | ||
---- | ---- | ||
− | [[File:ALF_fUML_Conc_03.jpg]] | + | [[File:ALF_fUML_Conc_03.jpg|600px]] |
---- | ---- | ||
Figure 45 - Added ALF based action for Multiply Method | Figure 45 - Added ALF based action for Multiply Method | ||
+ | |||
+ | == Aknowledgement and Download final sample == | ||
+ | This work is prepared by Matin Maleki and Saeed Shoaraye Nejati in Model Driven Engineering Course of the Concordia University, Montreal, Canada Lectured by Dr. Wahab Hamou-Lhadj. | ||
+ | PDF file of this report: [[File:ALF_fUML_Moka.pdf]] | ||
+ | |||
+ | Sample file which is created at the end of this document can be downloaded from here [[File:ALF_fUML_Moka.zip|ALF_fUML_Moka.zip]] |
Latest revision as of 14:57, 24 April 2018
Contents
Report on How to Use ALF Action Language and fUML execution/debugging with Moka
In this report, we tried to implement part of the executable model in fUML with Action Language (ALF). This report is based on Eclipse Oxygen and Papyrus Modeling environment and the process of installation and execution of ALF action language in this environment. First, we introduce how to Integrate ALF editor in this environment and then we try to add Moka for the purposes of debugging and execution models. In the end, we provide a new sample based on the fUML sample of the Moka for execution of the models to show how we can execute ALF based behaviors inside the modeling environment. Since ALF is supported by the OMG standardization as an action language we started to find out supported tools and modeling environments to use. But the main problem was outdated samples and tutorials to use this important issue in modeling environments. This report is the documentation of how to use ALF language with the help of debugging fUML models in the papyrus environment. We start this tutorial based on what is existed for running fUML in the Moka without textual action language and we add our ALF based actions to the diagram.
Preparing Steps for Papyrus
Installing ALF Extension for Eclipse Oxygen
1. Click on “help”, “install new software” then add the link below and install all ALF plug-ins on your Eclipse. The address for the update the sources.
Figure 1- ALF installation for papyrus
2. From top toolbar select “help” then “Eclipse MarketPlace”, search ALF and install “Integrated ALF Editor”.
Figure 2 - Integrated ALF Editor inside Papyrus additional Components
3. From top toolbar on “preference” search ALF and active all Supports for it.
Figure 3 - Enable ALF Support for Foundational UML
Installing Moka and Nebula updates
1. On “help”, “install new software” add this link below and install all Nebula.
Figure 4 - Get Nebula Updates 2. On “help”, “install new software” add this link below and install all Moka cores.
Figure 5 - Moka core for execution and debugging models
3. download the basic sample of the project use the link below and save it on your system. - web address: https://wiki.eclipse.org/File:BasicActiveObjectExample.zip
Figure 6 - a Basic sample of fUML in Moka
Getting Started with Model Execution
Import a basic sample of fUML with Moka to start with
1. we will make a new papyrus project then import the sample project (that we download it before). We called the project “ALF_PAPYRUS”.
Figure 7 - Create new project with the name of ALF_Papyrus
Figure 8 - Import downloaded sample into the environment
2. when you open the project, you should have all these diagrams attached to it.
Figure 9 - First view of the imported project
Figure 10 - Increment Class Diagram in Project
Figure 11 - Increment method in the behaviors
Figure 12 - Increment classifier behavior
3. The behaviors associated with this class (i.e., IncrementClassifierBehavior, which is the classifier behavior, and incrementMethod, are the implementations of operation increment) are specified by activity diagrams. Corresponding activities are executable, according to the semantics given in OMG standards fUML and PSCS. Anyway, in fUML and PSCS, the execution of a model usually starts by executing a kind of "main" activity, which is responsible for instantiating objects, and stimulate them if needed (through signals or operation calls). Moka provides some facilities to generate this kind of activities. Just right click on class Increment, then go to Moka - Modeling Utils - Generate Factory.
Figure 13 - Generate factory for Increment Class Behavior
4. You should also check the execution engine from “preferences”.
Figure 14 - Moka preferences for run and debug
5. After checking the engine, hit “Debug Configurations…” and add new configuration as below.
Figure 15 - Run Project in debug mode
Figure 16 - Debug configuration and add Moka Configs
Figure 17 - Steps to initial configurations for Moka
Figure 18 – set element for execution of Model
6. Start debugging by click on Debug icon in the top-right corner of the screen.
Figure 19 - the Debugging environment in the eclipse
7. You will see the debug start when the action diagram becomes green
Figure 20 - Debugging a Model in eclipse
Figure 21 - Possibility to add a breakpoint and see the simulation of the execution for model
8. By Adding breakpoints in different steps, you can monitor debugging completely.
Figure 22 - Adding Breakpoint in each step to check the object instance values of the class
9. As you see in the pictures, the counter will increase each time the cycle finishes.
Figure 23 - read values of the attributes of the class in the variables window
10. As you see in this photo, there is no command in ALF part, because here we only use Moka to execute this project. Next step we will add another method and write the ALF codes in it.
Figure 24 - All executed with models and nothing textual for actions
ALF based Model Execution
ALF based behavior as part of the diagram
1. In the Class, diagram add an operation and call it Multiply
Figure 25 - Add a new operation to the class from palette
2. In Model Explorer, right click on Increment and add new activity behavior call it “MultiplyMethod”
Figure 26 - Add activity to the existing class
Figure 27 – Multiply Method as a behavior added to the class
3. As you see, you will have this class diagram and model Explorer. If you click on MultiplyMethod, it is ready to add your behavior with ALF language.
Figure 28 - ALF editor inside the eclipse to create behavior
4. Write ALF codes same as below in “ALF properties” for “MultiplyMethod”
Sample Code: namespace BasicActiveObjectExample::Increment;
activity multiplyMethod(in x:Integer, in y:Integer):Integer { return x*y; }
5. You will have these codes under the “multiplymethod” same as this. Hit Commit. With the commit button inside the ALF editor, these commands will be executed and compiled as behavioral parts which you can see the next picture. The beauty of this process is all the generated parts can be used as an action inside another diagram.
We have added the ALF codes but still, we do not have the multiplymethod in our Action diagram. It is possible to Drag and drop the “MultiplyMethod” from Model Explorer to increment class diagram to add it even inside to diagram.
Figure 29 - Compile and Generate behaviors for multiplyMethod Behavior
6. Now we need to execute our ALF part in the previous fUML we tested and debugged in the previous section.
7. Choose “Activity as a CallBehaviorAction” second item from the menu.
Figure 30 - Drag MultiplyMethod from Model Explorer inside the increment Method as CallBehaviorAction
Figure 31 - As you can see the result is our method with two input and one output as we wrote in ALF
8. To test the “MultiplyMethod” we will add a constant value (equal to 2) and get the output of incrementing. So, each time we will multiply the increment output.
Figure 32 - Add value Specification Action to set the inputs of the MultiplyMethod
Figure 33 - Add Literal Integer value equal 2 as a second input for Behavior
Figure 34 - set the value equal 2 to provide the right input for your method
Figure 35 - Object Flow edge to connect result of value two to input y
Figure 36 - Object flow from the result of the callMultiplyMethod to the Value of set Counter
Figure 37 - Final Modified Diagram with the added ALF part
Figure 38 - Add Breakpoints to Debug and see the values inside the model
9. When you run the debug, counter is zero and each time it will first increment by 1 and multiply by 2. First step counter is zero.
Figure 39 - In the first run value of the counter is zero
Figure 40 - Simply hit resume to continue running the diagram
10. Second step 0 will increment by1 then multiply by 2. counter: (0+1) *2=2
Figure 41 - Second run the value will show the result of two
11. Third step. Counter: (2+1) * 2=6
Figure 42 - in the third run value will show the 6 as result
Conclusion
In the textual representation of the model, we can see, we have the multiply method as public which is written by ALF and there is no difference in the execution of ALF parts and fUML with Moka.
Figure 43 - Final representation of two different behaviors in the model
Next two pictures clearly show that “incrementMethod” which is in Moka has not the ALF commands and “MultiplyMethod” which is written in ALF has the commands and they are working together properly.
•“incrementMethod” which is implemented with fUML and actions inside the model.
Figure 44 - Increment method based on the fUML without textual actions
•“MultiplyMethod” which is added with ALF action language and compiled as a part of the model execution in the behavior.
Figure 45 - Added ALF based action for Multiply Method
Aknowledgement and Download final sample
This work is prepared by Matin Maleki and Saeed Shoaraye Nejati in Model Driven Engineering Course of the Concordia University, Montreal, Canada Lectured by Dr. Wahab Hamou-Lhadj. PDF file of this report: File:ALF fUML Moka.pdf
Sample file which is created at the end of this document can be downloaded from here File:ALF fUML Moka.zip