SysMLv1: Cameo Simulation Toolkit: Sequence Diagrams: HOWTO Send an asynchronous Signal message and HOWTO handle a Reply message value from a synchronous Operation call message [with mini Video]

Gallery
Tutorial
A simple demonstration of the asynchSignal and synchCall message kinds in Magic Model Analyst® (Cameo Simulation Toolkit®) . The main takeaway is how to handle a Reply value from an Operation call.
Click on the image to view it full size

Some subtle aspects of the setup are worth noting. The Context block has part properties 's1:Sender' and 'r1:Receiver'. These correspond with the Lifelines shown in the Sequence Diagram.

The upper part of the Sequence Diagram for SendAsynchVsSynch shows an asynchSignal for the signal SendAndForget. Because it is asynchronous, the flow can immediately proceed to the call to the keepGoing() Operation.

In the accompanying mini simulation video there's actually a breakpoint so you can see the little StateMachine, then it resume to keepGoing().

Note that consistent with restrictions of fUML, Cameo does not handle Receptions, although the Signal sent can be caught by a StateMachine transition (see also the mini simulation video).

For use with the asynchSignal call to Operation waitForMe(i:Data):Real, the block Sender has an "extra" value property 'val:Real' for handling the return value from the Reply message.

There are two "tricks" you need to know to get this to work:

1. The name of the value property 'val' must be used on the LHS of the Operation call, so here val = waitForMe(i=d), where 'd' is the preinitialised Data with default value 'val=1.1.'

2. The reply Message has 'val' assigned as an 'argument' via an ElementValue. You can't just drag the value property onto the 'argument' field in the specification dialog for the reply Message; you have to select ElementValue and then select the 'val' property from Sender via the ElementValue dialog. It will then appear in parentheses (val) on the reply Message symbol.

The Response block has an Activity waitForMe as method for Operation waitForMe(i:Data):Real, which prints the value received via the i:Data then multiplies it by 2 before returning it.

Cameo will "see" that there is a value property named 'val' within Context and assign the Reply message argument value to it. It can then be printed using the additional Operation echoReceived(i:Real). The simulation shows that the multiplied value 1.1 x 2 = 2.2 has been received.

Up next
Notes
Snippets (quotes/extracts)
Visit also
Visit also (backlinks)
Related slides (includes other tutorials)
Related slides (backlinks, includes other tutorials)
External links