Model Description

We will now show an example of an done with the M/M/1/k model. This animation consists of two parts. The packet being sent from the source to the queue, and the increase/decrease of the queue size. The animation of the queue size is done by an rectangle object named ``_BAR_''. This object stretches its size to the appropriate value of its variable $q$. The object Exp_Server has the following Animation attribute:

Animation=
  get_line_in_attr(result1, Watches, 1);
  tokenize(result2, $(result1), "=");
  get_line_in_attr(q, result2, 2);
  assign(_BAR_.n, $(q));
  if("$(__SIMULATION_STEP__.Ani_T_Steps)"==
     "$(__SIMULATION_STEP__.Ani_C_Step)",
       _BAR_.animate, NULL);
This code gets the current value of the queue state variable and sets the variable $n$ in object _BAR_ to this value. If it is the last step in the animation loop then it calls the function _BAR_.animate which animates the object _BAR_. This object has an function ``animate'' that is called by the object Exp_Server, that checks the size of the variable $n$ and executes the corresponding function that resizes the BAR. This is done only at the last animation step.

To animate the movement of the packet from the source to the queue it is necessary to modify the behavior of the object Packet_Source. The can depend only on an object's state variables changes. In order for the animation to occur only when a packet is transmitted, a state variable change must occur. We modify the dummy state variable $S$ to switch between states 0 and 1. Every time a packet is transmitted the state changes. By doing this, the Animation attribute can decide when to play the animation of the packet movement.

 
Animation=
get_line_in_attr(result1, Watches, 1);
tokenize(result2, $(result1), "=");
get_line_in_attr(s, result2, 2);
if("$(s)"!="$(s_ant)", _PAC_.animate, NULL);
if("$(__SIMULATION_STEP__.Ani_T_Steps)" == 
"$(__SIMULATION_STEP__.Ani_C_Step)", Reset_S, NULL);
Reset_S=
  assign(s_ant, $(s));
This code checks to see if the state variable $S$ has changed its value. If so, then it calls the function in object _PAC_ for every animation step.

At the last animation step, it stores the new value for the state variable $S$. The object _PAC_, illustrated in Figure [*], has the animate function which moves the object horizontally to the left. At the first step, this object records its position. For every step it uses the number of the animation step to calculate the new $x$ coordinate and shift the object to the left. At the last step of the animation it restores its original position.

Figure: The Simulation Model with Animation.
\includegraphics[width=4in]{figuras/animation.eps}

Many other complex animations can be specified. The user can basically define any possible graphic command supported by . Sometimes the user will need to modify the behavior of the object in order to get the desired .

Guilherme Dutra Gonzaga Jaime 2010-10-27