![]() |
Beyond Code: An Introduction to Model-Driven Software Development (CISC 844, Winter 2025)
UML-RT Sample Models
|
Instructions on how to import these models into Model RealTime can be found on the Assignment 1 page.
Pinger
uses exit()
(in transition to state End
); for this to be possible Implementation Preface
of Pinger
(select Pinger
and under Properties
click C++ General
) must contain #include <stdlib.h>
rand()
and time()
from C++ library time.h
, the Implementation Preface
of Top (select Top and under Properties
look for C++ General
) must contain #include <stdlib.h>
and #include <time.h>
inc(x)
and doub(x)
in alternating fashion; server responds with result(x)
waitingForInc
)
timeout2
in Client
), unexpected messages (due to state Interupt
in Client
)
INTERRUPTS_ENABLED
in Client to true
t
from Interrupt
to Error
with result
as trigger
t
from ever being enabled by adding a guard that always evaluates to false
t
ending at the boundary of a composite state s
always takes the state machine to the initial state of s
, whereas in UML-RT they are treated as an implicit return to history, i.e., t
takes the machine back to the most recently active subset of s
and only to the intial state of s
if s
has not been entered before.
h
to the capsule
part c
means that a fixed sequence of messages will be
fed into c
. Alternatively, messages can be fed into
c
with the model debugger via the relay
capsule part r
. To this end,
c
must be connected to r
and, after
starting the model debugger, essages be fed
into r
's relayControlPort
.
Args
packages all parameters for message init
from Top
to Pinger
Top
and Pinger
, dependency to class Args
must be set with Kind In Header
set to none
and Kind in Implementation
set to inclusion
p
to 'n..m', select p
, then click Advanced
under Properties
. Find Lower
and Upper
and set them to n
and m
, respectively. Setting the multiplicity of a capsule part is similar (select the part and set Lower
and Upper
under Properties
and Advanced
.
Changer
state machine makes the 3 stages of the process (giving toonies, giving loonies, and checking for zero) visible; tick
messages necessary to advance the computation; Changer
capsule does not contain any structure
Changer
capsule contains three parts (toonies
, loonies
, and zerocheck
), one for each of the states of the process
b
and c
should be run on the same thread (argument same
) or on different threads (argument different
); the second determines how long the execution of the transition in capsule part b
will take; e.g., ./executable.exe -URTS_DEBUG=quit -UARGS "different" 25000
InputInt
upon request from the TrafficLight
capsule and then used when setting the timers used to transitions between the states. Project comes with two transformation configurations: one single-threaded and another in which capsule InputInt
runs in its own thread. In single-threaded executions, the traffic light 'freezes' while capsule InputInt
is waiting for input, while in the multi-threaded executions the traffic light continues to operate
Active
in traffic light to receive the user input
Number
randomly picks a secret number within an interval that a collection of optional Guesser
capsules have to guess. The Top
capsule gives the guessers a turn in a round-robin fashion. To guess, a guesser plugs in an instance of Number
, and then asks for a hint. A hint is an indication whether or not the secret number is less than or greater than the previously guessed number, thus narrowing the interval that the secret number must be in. The guesser then issues a guess to the Number
capsule by picking the number in the middle of the interval. If the guess is correct, the game ends. If the guess is not correct, the interval is updated and the next guesser gets a turn
Top
can continue to communicate with Number
even when Number
is plugged in: during the guessing, Top
can send a reset
message which will cause the plugged-in capsule to change its secret. Sending of reset
depends on random choice made by Top
whenever number connects to a guesser (reset probability 10%)
numberPlusCheat
) has an additional port (cheatP
) which is used through additional transitions in the state machine. Which kind of capsule (basic: Number
, cheating possible: NumberPlusCheat
) is used is determined by Top
which in its initial transition incarnates one of these and then passes the id to the importing guesser. The guesser uses this id for the import, but also to determine which class the instance is an instances of (using classOf()
and className()
) and, thus, to see if the instance plugged in supports cheating or not.
./executable.exe -URTS_DEBUG=quit -UARGS <max>
or ./executable.exe -URTS_DEBUG=quit
in which case <max>=100 by default. Current multiplicity constraints allow for the creation of 10,000 instances of the Factor
capsule (in which case <max>=104729)
incarnate
and made available as rtdata
in the initial transition of the incarnated capsule).
factor[i]
in Top
with 0<i<10000) form a pipeline whose first element is connected to a generator capsule (called gen
) that outputs the numbers between 2 and <max>. Each capsule checks if the incoming number is divisible by one of the prime numbers already found. If a number n reaches the end of the pipeline (i.e., the right-most factor capsule), n is prime and passed to Top
for output; Top
will also create a new capsule which will use n as factor and be linked into the pipeline as new last (right-most) element.
fib[i]
in Top
with 0<i<10000) form a tree whose root element is connect to Top
. Each fib[i]
first checks the number n
it is to compute. If n
is 0 or 1, the result is returned right away. Else, it asks Top
to create two new instances (one to compute fib(n-1) and the other to compute fib(n-2)), waits for the results produced by these instances, and then returns their sum.
i
of each instance fib[i]
is passed into the instance as argument to incarnate
; id is used to compute SPP/SAP topic used to connect instance with its parent and two children (if any).
n
, i.e., number to compute the Fibonacci number of
tick
messages that a capsule sends to itself to trigger the next transition (as in GiveChange v1)
PickUpStrategy
), dependencies (Phil
using PickUpStrategy
), random number generation, and getName()
to determine name of capsule instance.
msg->sap()
to determine port that triggering message came in on.
incarnate
(received in initial transition of incarnated instance).
TopABP_conn
uses an instance of ConnectorABP
to send messages from port inP
to outP
. The instance is configured via an initialization message init
that contains the probability of the loss of a message (lossProbability
) and the retransmission delay (rtxDelay
) as argument.
Last modified: Sun Jan 05 2025 12:18:18