![]() |
Beyond Code: An Introduction to Model-Driven Software Development (CISC 836, Fall 2021)
Assignment 3 (MDSD with RSARTE)Due: Thursday, Nov 4
|
As shown in the diagrams, the router consists of nine capsule instances on the top level, while each stage contains another four instances (so, the entire router consists of no less than 22 communicating state machines, resulting in more than 7K lines of generated C++ code!):
The state machine of the parcel router
>> ./Parcelrouter.exe -UARGS <numParcels> <genDelay> <chute1Delay> <chute2Delay> <switchDelay>
determining, respectively,
If only one command line argument is used (>> ./Parcelrouter.exe -UARGS <numParcels>), it is interpreted as the number of parcels and default values are used for the delays (<genDelay>=2, <chute1Delay>=1, <chute2Delay>=1, and <switchDelay>=0). If no argument is provided, the same delay defaults are used and <numParcels> is set to 10. If a different number of arguments is given (2, 3, 4, or more than 5), execution stops with an error message. As in the previous assignments, use the command line option -URTS_DEBUG=quit to bypass the RSARTE command line debugger.
To use the animation, it must be invoked first by right-clicking the 'ParcelRouterAnimation' Java project in the Project Explorer, selecting 'Run As' and then 'Java Application'. Note that:
>> ./Parcelrouter.exe -UARGS 10 1 2 1 0
>> ./Parcelrouter.exe -UARGS 10 0 1 0 2
which, in my implementation, cause 5 and 9 parcels to get lost respectively. Lost parcels will manifest themselves in the execution as 'unexpected messages' preventing it from running to completion. Similarly, the animation will become inconsistent. Note that not all delay settings are problematic. E.g., using
>> ./Parcelrouter.exe -UARGS 10 1 0 0 0
>> ./Parcelrouter.exe -UARGS 10 2 1 1 0
>> ./Parcelrouter.exe -UARGS 10 3 0 1 1
no parcels get lost.
>> ./Parcelrouter.exe -UARGS 10 3 0 1 1
ends in
[ParcelR] total generations: 4 2 1 3
[ParcelR] total correct arrivals: 4 0 0 0, total incorrect arrivals: 6
[ParcelR] delay settings: 3 0 1 1
[ParcelR] duration: 34 sec, 143997000 nsec
[ParcelR] stop
>> ./Parcelrouter.exe -UARGS 100 1 1 1 1
would take slightly more than 600 seconds to complete. Choosing this approach will limit the maximal number of points for this part to 14 (out of the 20 achievable).
>> ./Parcelrouter.exe -UARGS 100 1 1 1 1
finishes after 107 seconds.
In this design, each of the two coin denominations has its own capsule instance (called 'toonies' and 'loonies'). These instances are connected to form the stages of a pipeline in which:
This design now shows us how to come up with a fully general solution, i.e., a version of the changer that is parametric in the number of coins that are used for giving change and their respective denominations. For example, we want the invocation
$ ./executable.exe -URTS_DEBUG=quit -UARGS 81 400 200 100 10 1to dispense one 200-cent coin, one 100-cent coin, one 10-cent coin, and nine 1-cent coins. That is, on the command line, the value of the selected item and the amount of money inserted is followed by a monotonically decreasing list of integers indicating the denominations of the coins to use (the number of coins is given by the length of this list):
$ ./executable.exe -URTS_DEBUG=quit -UARGS <ins> <sel> <denomination of highest value coin> ... <denomination of lowest value coin>For this to be possible, the pipeline needs to be built dynamically (i.e., at runtime) according to the command line arguments provided. E.g., in the invocation above
$ ./executable.exe -URTS_DEBUG=quit -UARGS 1575 2000 200 100 10 5Execute and inspect the model to understand the resulting execution. Draw a sequence diagram showing all the messages exchanged between all capsule instances (i.e., 'Top', 'harness', 'changer', and all pipeline stages) as a result of this invocation. Your diagram should also include calls to the 'incarnate' function, if any. If messages or calls to 'incarnate' carry data, please include them as well.
Put your sequence diagram into your parcel router project from Part I and give it the name Part2.