Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "Papyrus/UserGuide/ModelExecution/ActiveObjectController"

(Registering active objects)
 
(20 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Documentation under construction...
 
 
 
= A generic controller for Active Objects =
 
= A generic controller for Active Objects =
 
This model library provides some facilities which allow to stimulate active objects and observe their reactions. It's based on the Moka framework and available in the Eclipse's Debug perspective. The controller UI looks as follows:
 
This model library provides some facilities which allow to stimulate active objects and observe their reactions. It's based on the Moka framework and available in the Eclipse's Debug perspective. The controller UI looks as follows:
Line 26: Line 24:
 
[[File:classDiagram.png]]
 
[[File:classDiagram.png]]
  
'''''[To be clarified]''''' The first active class has the other one as a property and it classifier behavior starts the ActiveObjectController and registers it property. The second one has a reception for a signal and it classifier behavior is waiting for that signal.  
+
In this example, there are two active classes. The active class Launcher has a property typed by the other active class (A). Its classifier behavior starts the ActiveObjectController and registers an object of type A.
  
 
As illustrated in the model explorer screenshot bellow, the behaviors associated with those classes are specified by activities.
 
As illustrated in the model explorer screenshot bellow, the behaviors associated with those classes are specified by activities.
Line 33: Line 31:
  
 
== Importing the library ==
 
== Importing the library ==
First of all, to use the library you need to import it. To do so, right click on the root object called model, then go to Import / Import Registered Package / Select ActiveObjectControllerModelLibrary.
+
First of all, to use the library you need to import it (the import is already done in the model example). To do so, right click on the root object called model, then go to Import / Import Registered Package / Select ActiveObjectControllerModelLibrary.
  
 
[[File:Import_Library.png]]
 
[[File:Import_Library.png]]
Line 42: Line 40:
  
 
== Registering active objects ==
 
== Registering active objects ==
To observe the reaction of an active object, you need to register it in the controller. This can be done by calling StartActiveObjectController activity (available in the model library under package Utils), as illustrated in the figure bellow. This activity returns an instance of the controller, which can be used as the target of a SendSignalAction for signal Register. Use the object you want to register as an argument for the SendSignalAction. '''''[To be clarified: Where should this behavior be specified? is it a separate activity or a classifier behavior of something?]'''''.
+
To observe the reaction of an active object, you need to register it in the controller. This action is illustrated in the figure bellow which represents the classifier behavior of the Launcher. To do so, call the StartActiveObjectController activity (available in the model library under package Utils). This activity returns an instance of the controller, which can be used as the target of a SendSignalAction for signal Register. Then, use the object you want to register as an argument for the SendSignalAction.
  
 
[[File:how_to_register_classifierBehavior.png]]
 
[[File:how_to_register_classifierBehavior.png]]
  
== Starting an execution ==
+
== Controlling an object ==
To start the execution, just follow the first tutorial on Moka. Cf 2.4.
+
To start the execution, define a launch configuration for the Launcher_Factory activity, as explained here [[https://wiki.eclipse.org/Papyrus/UserGuide/ModelExecution#Starting_an_execution_with_a_launch_configuration]]. Please note that this library works only with the PSCS - multithread execution engine. Make sure that this engine is selected in the Papyrus/Moka preferences before launching the configuration (cf. [[https://wiki.eclipse.org/Papyrus/UserGuide/ModelExecution#Selecting_the_execution_engine]] for explanations on the selection of an execution engine).
  
But for the moment, there is a limit on the using. This framework works only with the PSCS and multithread execution engines, so you should make sure that one of them is selected.
+
When the execution is started, the controller view is awaken. As depicted in the figure below, the objects list shows the registered active objects. When you select one of them, the list of ports is updated (to show ports available on the selected object) as well as the list of signals it can receive.  
 
+
== Using the component ==
+
When the execution is started, the controller view is awake. Then, the active objects are on the objects list. When you select one of them, you’ll know if it has ports and which signals it could receive.  
+
  
 
[[File:awakeController.png]]
 
[[File:awakeController.png]]
  
Moreover, you can show all signals containing in the model and try to use them. To do so, deselect the checkbox with “Hide signals without explicit receptions” label.
+
The list of signals only displays signals for which a reception is explicitly defined (either receptions on the object, or receptions on provided interfaces of the selected port). If you don't want to restrict the list (i.e., display all the signals availble in the scope of this model), just disable the checkbox “Hide signals without explicit receptions”. If the selected signal has no attribute, just press the Send button to send the selected signal to the selected object.
  
 
[[File:hiding_signals.png]]
 
[[File:hiding_signals.png]]
  
If a signal has attributes, you could edit them only if they are primitives (Integer, Boolean, etc…). The editor will shows you if the value that you will have entered is correct.
+
If a signal has attributes, arguments have to be specified. This can be done using the arguments table (only for primitive types). The editor will check if specified arguments are valid.
  
 
[[File:WRONGTableEdition.png]]
 
[[File:WRONGTableEdition.png]]
Line 68: Line 63:
 
[[File:SendButton.png]]
 
[[File:SendButton.png]]
  
== Observing system reactions ==
+
If the target object was not waiting for this signal, a message like the following one will be displayed in the console:
When you send a signal to the selected object, there are two types of reaction. The first one is that the object was waiting for this signal, so you could observe it behavior.
+
 
+
[[File:classifierBehavior_edge.png]]
+
 
+
The other is that the object was expected another signal, so it will be a warning message into the console that it’ll tell you which kind of signal it was expected.
+
 
+
Then, nothing is going to happen, so you could correct your choice and observe behaviors again.
+
  
 
[[File:fUMLConsoleWarning_losting_signals.png]]
 
[[File:fUMLConsoleWarning_losting_signals.png]]

Latest revision as of 05:46, 25 November 2014

A generic controller for Active Objects

This model library provides some facilities which allow to stimulate active objects and observe their reactions. It's based on the Moka framework and available in the Eclipse's Debug perspective. The controller UI looks as follows:

EmptyControllerView.png

Content of the library

The library contains two classes: ActiveObjectController and ConrollerUI. ActiveObjectController is an active class which enables particular objects (instantiated during the execution of a model) to register with the controller. ControllerUI represents the UI of the controller.

In order to enable registration of objects with the controller, the library introduces signal “Register”, which has an untyped property called object. The argument corresponding to this property can be any active object that needs to be observed.

Library structure.png

Please note that the controller must be explicitly started by the application model. This can be done using the StartActiveObjectController activity, availlable in the Utils package. This activity creates an instance of the controller and starts the UI.

Model explorer behavior.png

Once an instance of ActiveObjectController is created, its classifier behavior is started. The behavior is depicted in the activity diagram below. It waits for the reception of Register signals. When a signal is received, operation Register is called on the ControllerUI, using the object received with the signal as an argument for the operation call. The effect of this call is that the argument object is added to the Objects list of the UI. User can then select an object from the UI, and stimulate it with signals.

RegisterActivity.png

Model example

Let us illustrate the usage of this library with a simple model example. The corresponding Papyrus model is available here File:ActiveObjectControllerUserExample.zip. Download it, define a project in your workspace, and then import the model in this project. It consists in two active classes, with classifier behavior.

ClassDiagram.png

In this example, there are two active classes. The active class Launcher has a property typed by the other active class (A). Its classifier behavior starts the ActiveObjectController and registers an object of type A.

As illustrated in the model explorer screenshot bellow, the behaviors associated with those classes are specified by activities.

ModelStructure.png

Importing the library

First of all, to use the library you need to import it (the import is already done in the model example). To do so, right click on the root object called model, then go to Import / Import Registered Package / Select ActiveObjectControllerModelLibrary.

Import Library.png

There are a lot of libraries in this window, so you can filter by name to get it easily.

LibrariesToImportWizard.png

Registering active objects

To observe the reaction of an active object, you need to register it in the controller. This action is illustrated in the figure bellow which represents the classifier behavior of the Launcher. To do so, call the StartActiveObjectController activity (available in the model library under package Utils). This activity returns an instance of the controller, which can be used as the target of a SendSignalAction for signal Register. Then, use the object you want to register as an argument for the SendSignalAction.

How to register classifierBehavior.png

Controlling an object

To start the execution, define a launch configuration for the Launcher_Factory activity, as explained here [[1]]. Please note that this library works only with the PSCS - multithread execution engine. Make sure that this engine is selected in the Papyrus/Moka preferences before launching the configuration (cf. [[2]] for explanations on the selection of an execution engine).

When the execution is started, the controller view is awaken. As depicted in the figure below, the objects list shows the registered active objects. When you select one of them, the list of ports is updated (to show ports available on the selected object) as well as the list of signals it can receive.

AwakeController.png

The list of signals only displays signals for which a reception is explicitly defined (either receptions on the object, or receptions on provided interfaces of the selected port). If you don't want to restrict the list (i.e., display all the signals availble in the scope of this model), just disable the checkbox “Hide signals without explicit receptions”. If the selected signal has no attribute, just press the Send button to send the selected signal to the selected object.

Hiding signals.png

If a signal has attributes, arguments have to be specified. This can be done using the arguments table (only for primitive types). The editor will check if specified arguments are valid.

WRONGTableEdition.png

If everything is ok, the controller allows you to send the signal.

SendButton.png

If the target object was not waiting for this signal, a message like the following one will be displayed in the console:

FUMLConsoleWarning losting signals.png

Back to the top