Syntax:
GRAPH(<initial time>, <final time>, <background color> / <,title> / ; / TIME: <format>, <color> / ; <list of variable descriptors>);It is used to display graphics during the simulation run. When executed for the first time, it constructs the axis, reference lines, numbers on the axis, displays the names given to the variables and scales and marks the initial values of the variables to be graphed. In the following executions it adds a new point to the curves of the variables being graphed and unites the points to the the already displayed curves.
<initial time>
and <final time>
are two real
numbers indicating the simulation time in which the graphic
starts and ends respectively.
<background color>
is the color that is to be assigned to the
background.
<title>
is a string of characters (without ' or ; ). If it is
used, it will appear as a title in the graphic. It may be omitted.
TIME: <format>, <color>
is only used when the independent
variable will be the TIME of the simulation.
<format>
is a Pascal format to write the values of the TIME
along the horizontal axis.
<color>
is the color of the horizontal axis and the values
on it.
<list of variable descriptors>
is a list of items describing
the parameters to represent the variables to be depicted.
If TIME: <format>
, <color>
is omitted, the variable of the
first descriptor is taken as independent variable and its values are
on the horizontal axis. Variable descriptors are separated by ;
<list of variable descriptors>
consists of the
following elements,
separated by commas. They describe the variables to be graphed :
<real expression>
, that expresses the value to be graphed;
it may be a single variable or constant.<format>
gives the format for the values on the axis; it
consists of: <number of places>: <number of decimals>
,<name of the graphed values>
, a name that will appear in
the graph. It is a string of characters without blanks, apostrophes
or commas.<minimum value>
, a real number with the
minimum value expected.<maximum value>
, a real number with the
maximum value expected.<color for the curve>
; color
must be anyone of the following list:
BLUE GREEN CYAN RED MAGENTAFor the background color, the BLACK may also be used.BROWN LIGHTGRAY DARKGREY LIGHTBLUE LIGHTGREEN
LIGHTCYAN LIGHTRED LIGHTMAGENTA YELLOW WHITE
Up to 14 variables may be represented in a graph. GRAPH may be used in any node but it must be executed only one time during each activation. If there are many GRAPH instructions, only one must be executed in a simulation run. When TIME is used as independent variable and a screen is full, the display is stopped half a second, the displayed graph is erased and the display continues in a new screen. The user can use the key PAUSE to stop the graphic and then to re-start the simulation with any key. It is possible to control the horizontal scale by changing the interval of the successive activations of the node that contains the GRAPH instruction. The more frequent the activations the more extended is the graph.
The horizontal axis of the screen is divided in 10 parts. If the total length of the axis is for example 531 pixels (the number of horizontal pixels in the total screen assumed 640 minus 17% for a free space at both sides) each part has 83 pixels. At each new call and execution of the instruction GRAPH the new point is advanced one pixel so it takes 83 time units to advance a part. If successive calls are made each 0.125 time units, the part represents the part of the curve generated in 83 * 0.125 = 6.64 units of simulation time. If the calls are made each 0.0625 time units, the same part of the graph represents the curve generated in only 3.32 units of time. The represented curve appears then stretched twice in the horizontal direction.
This instruction can be used in nodes of any type.
Examples:
Aa :: IT := Dta; Y := SIN(2 * PI / 2.0 * TIME); Ag :: IT := Dtg; GRAPH(0, 20, BLACK; TIME: 7: 1, WHITE; Y: 7: 1, Sinus, -2, 2, LIGHTBLUE); INIT TSIM := 20; ACT(Aa, 0); ACT(Ag, 0); Dtg := 0.00753125; Dta := 0.0150625; DECL VAR Dta, Dtg, Y: REAL;A sinusoidal curve is displayed. Note that each calculated point is displayed two times, because Dtg is half of Dta. As a complete wave takes 2.0 units of time, in a screen as the described above each horizontal division is 53 * 0.00753125 = 0.39915 and in the 10 divisions (3.9915) enter almost 2 waves.
Entrance (I) :: IT := EXPO(TBA); ACT(Gra, 0); Teller (R) :: STAY := EXPO(Tat, 2); Exit (E) :: ACT(Gra, 0); Gra (A) :: GRAPH(0, 18000, BLACK; TIME: 6: 0, WHITE; LL(EL_Taq): 6: 0, Queue, 0, 100, GREEN);The program is a simulation of a simple bank teller and a graphic of the queue is made. Each time a client enters or leaves the Teller. the Gra node is activated and the length of the queue (EL of Teller) is put into the graph.