Prev | Next |
Activity Return Value Simulation
An Activity is likely to produce a return value as the output of the process it represents. You can simulate how that return value is passed on to the next stage in the process, under three scenarios:
- The Activity simply produces a return value, which is passed directly to the next Action
- The Activity has one or more Activity Parameters - represented on a diagram by Activity Nodes - that accept input values to or hold output values from the child Actions of the Activity, and the output Activity Parameter collects and passes on the return value
- The Activity is instantiated by a CallBehavior Action that replicates the behavior of the Activity and passes the return value onwards
Activity Return Value Pass Out
(This method is unique to Enterprise Architect simulation, mimicking the effect of an Activity Parameter without one having to exist.)
The Activity has a return value, which is transferred from the Activity element to an Action Pin on the next Action in the process via an Object Flow connector.
You can simulate this by setting a simple JavaScript statement to set the return value in the Activity's child element (such as this.return=12;) and, running the simulation, see the value transferred to the Action Pin in the Locals window.
Activity Parameter Pass Out
If the Activity has an Activity Parameter, its value passes to the corresponding Activity Node and then, via an Object Flow connector, to the Input ActionPin of the next Action in the process, as shown:
In the Locals window, you can either observe the Parameter's default value pass through to the ActionPin, or you can use JavaScript in the Activity's child Actions to simulate an update of the value within the Activity. For example:
this.ActivityParameter1=20;
CallBehavior Action
An Activity might be used a number of times in a process, in which case you might want to generate a separate instance of the Activity each time. You can do this using a CallBehavior Action to create an object of the Activity and execute its behavior. The input and output Activity Parameters are bound to corresponding input and output Action Pins (arguments) on the CallBehavior Action.
When you simulate the part of the process containing the Activity, you provide an input value (as in Action 1) that passes into the input Action Pin on the CallBehavior Action, which creates an Object of the Activity. The CallBehavior executes the behavior of the Activity, using the input Action Pin to act as the input Activity Parameter, and the Output Action Pin to receive the return as the output Activity Parameter. The Activity return value is then passed to an Action Pin on the next Action, as above, using an Object Flow connector. You can provide JavaScript statements in the Actions of the Activity to act on the input value and generate a return value, such as:
sim.buf=this.inParam; and
this.outParam=sim.buf + 11:
Learn more