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.
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
if (sim.Person.age >=65)
The Condition Node is called AgeCondition, the test is in Clause1 and the OutputPin for that test is Decider1.
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)
sim.LoopNode1.decider = (sim.LoopNode1.loopVariable>0);