Page History
Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
The Alf code in your project is not executed directly. Rather, it is translated by the Alf compiler into UML Activities within the larger model containing the Alf code. These Activities can then be executed using Cameo Simulation Toolkit (CST), as part of an overall simulation of your UML model.
Warning |
---|
If an active Class is instantiated using an Alf instance creation expression, then the classifier behavior for the Class is explicitly started on the newly created instance after the completion of initialization of the instance. However, the default MagicDraw option is to Autostart Active Objects, in which case the classifier behavior for an active object will be automatically started as soon as the object is created. While MagicDraw will ensure that any Properties with default values are properly initialized before the classifier behavior is started, if you have initialization code in a constructor for an active Class, then this will not execute before the classifier behavior starts. Therefore, if you intend to instantiate an active Class from Alf code using a constructor that carries out initialization on which the classifier behavior depends, it is important to make sure that the classifier behavior waits for the constructor execution to complete. You can do this by having the classifier behavior wait for a special Start Signal before carrying out any other behavior, and having the constructor invoke this.Start() when it is done with its initialization behavior. (If the classifier behavior is an activity, then use an Accept Event Action to wait for the Start signal. If the classifier behavior is a State Machine, have the State Machine transition from its initial Pseudostate to a Waiting State that is exited by a Transition triggered by the Start Signal.) Alternatively, you can turn off the Autostart Active Objects option:
However, doing this will turn off the option globally for all projects, which may cause some other simulation projects to not work. You can turn this option off for just a specific project if you use a simulation configuration, by setting the Autostart Active Objectsproperty to false in your configuration. |
A simulation of a model that contains Alf code is run as for any other executable model using CST. Either click on an executable element in your model and select Simulation > Run (or Run in Context, as appropriate) or create a simulation configuration and run that.
Note |
---|
CST has a general Animation Speed property, used to slow down execution so it can be graphically animated on Activity and State Machine diagrams. The Activity models that are generated from Alf code do not have any diagrams that can be animated. However, the Animation Speed property affects all Activity execution, whether it is actually being graphically animated or not. Alf-generated Activities are often quite complicated, so, if the Animation Speed is less than 100%, these Activities may take a long time to execute. It is therefore recommended to set the Animation Speed to 100% whenever you are running a simulation of a model with Alf code. To set the Animation Speed
|
Info |
---|
If you wish to use an Animation Speed slowdown in the animation of a specific diagram, set a breakpoint within that diagram. Then, when the run stops at the breakpoint, use the slider to lower the Animation Speed, and continue the run. Once the execution leaves the diagram of interest, set the Animation Speed back to 100%. Note, however, that if the diagram includes any Behaviors specified using Alf code (e.g., State Behaviors on State Machine diagrams), these Behaviors may run slowly while the Animation Speed is set to less than 100%. (If you are using a simulation configuration, then silent must be false for this to work.) |
Panel | ||
---|---|---|
| ||
|