Interactive Mode Simulation : The Microdebugger Tool : Simulating a Graphical Procedure

Simulating a Graphical Procedure

After adding elements to the Graphical Procedure dialog box, you can simulate it. After the subroutine execution is completed, the execution of the step in the model continues. The simulation can be viewed via the Graphic Editor.

The step semantics for a Graphical Procedure are the same for a Textual procedure. The execution of the procedure appears atomic from the view of the model. From the view of the procedure being called, the execution acts like a GoRepeat.

When a procedure is called, it runs to completion before the model advances. At each occurrence of a procedure calling another procedure, the “caller” does not advance until the procedure being called returns.

If more than one procedure is called in the same compound action, they are treated concurrently. IN and INOUT parameters are read from the value at the beginning of the step. INOUT and OUT parameters should be written at the end of the step. Context variables can be passed as parameters in order to create sequentially.

For example, the following results in racing:

/init (MY_ARRAY);
sort_incr (MY_ARRAY);
sort_decr (MY_ARRAY)

 

 

In the next example, the final value of MY_ARRAY is sorted in decreasing order.

/init ($MY_ARRAY)
sort_incr ($MY_ARRAY)
sort_dcre ($MY_ARRAY)
MY_ARRAY:=$MY_ARRAY

 

In the next example, the final value of I is incremented a single time from the value at the beginning of the step.

/my_incre(I);
my_incre(I):
my_incre(I)

 

In the next example, the final value of I is incremented three times from the value at the beginning of the step.

/$I:=I;
my_incre($I);
my_incre($I);
my_incre($I);
I:=$I

 

Multiple procedures started from the same compound action are debugged sequentially.

Graphical procedures must always run to completion when started, if the procedure reaches a stable situation (no more micro-steps can be taken with the current parameter, local, global values), a runtime error should be generated by the simulation. When this error condition is encountered, within simulation, the procedure immediately returns with the current global and parameter values and the simulation step is interrupted. At this point, you are prompted with an error message and is given the ability to continue the step and simulation.