Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.
Contents |
Prev | Next |
Structured Activity Simulation
One of the more complex structures in a behavioral model is a Structured Activity, which models a series of actions either in a nested structure or in a process of assessment and execution. The assessment types of Structured Activity are the Conditional Node and Loop Node, both of which you can simulate quite easily.
Conditional Node
A Conditional Node essentially consists of one or more pairs of Test / Body partitions, each pair being referred to as a Clause. The Test partition is composed of Activity diagram elements that test a condition, and if that condition is met further Activity diagram elements in the Body partition are executed to produce a result.
If there is one Clause, the Conditional Node either outputs the result of the Body partition, or no result. If there is more than one Clause, control flows from one Test to the next until either a condition is met and a Body partition is executed to produce a result, or all Tests fail.
Simulation currently supports use of the 'Is Assured' checkbox setting in the 'Condition' page of the 'Properties' dialog. The other two checkbox settings are ignored. If the 'Is Assured' checkbox is:
- Selected, at least one Test must be satisfied, so its Body is executed and a result output; if no Test is satisfied and no result output, the Conditional Node is blocked and processing cannot continue beyond it
- Not selected, a Test can be satisfied and a result output, but if no Test is satisfied and no result output, processing can still continue beyond the Condition Node
You can simulate a range of possible paths and outcomes by typing JavaScript sim. statements that define or lead to specific Test results and Body results, in the 'Effect' fields of the Action elements within each partition of each Clause. These sim. statements must identify the full path of the Conditional Node, Clause and Output Pin being set. For example, in a test to see if a person qualifies as a senior citizen:
if (sim.Person.age >=65)
sim.AgeCondition.Clause1.Decider1=true;
else
sim.AgeCondition.Clause1.Decider1=false;
The Condition Node is called AgeCondition, the test is in Clause1 and the OutputPin for that test is Decider1.
Loop Node
A Loop Structured Activity Node commonly represents the modeling equivalents of While, Repeat and For loop statements. Each Loop Node has three partitions:
- Setup - which initiates variables to be used in the loop's exit-condition; it is executed once on entry to the loop
- Test - which defines the loop exit-condition
- Body - which is executed repeatedly until the Test produces a False value
You define the Loop Nodes by dragging Activity diagram elements from the Toolbox pages into the Setup, Test and Body partitions. The Body partition can contain quite complex element structures, defining what the Loop Node actually produces in the process.
The Loop Node has a number of Action Pins:
- Loop Variable (Input) - the initial value to be processed through the Loop
- Loop Variable (Output) - the changing variable on which the Test is performed
- Decider - an Output Pin within the Test partition, the value of which is examined after each execution of the Test to determine whether to execute the loop Body
- Body Output - the output value of the processing in the Body partition, which updates the Loop Variable Output Pin for the next iteration of the loop, and
- Result - the value of the final execution of the Test partition (which is the value passed back from the last execution of the Body partition)
You can simulate the effects of different actions and outputs through the loop, by typing JavaScript sim. statements that define or lead to specific Test results and Body results, in the 'Effect' fields of the Action elements within each partition. These sim. statements must identify the path of the Loop Node and Output Pin being set. For example, in an Action in the Test partition:
sim.LoopNode1.decider = (sim.LoopNode1.loopVariable>0);
Learn more