Graphical Simulation of SIGNAL programs

advertisement
Graphical Simulation of SIGNAL programs
Aims:
 To simulate graphically the execution of a SIGNAL program
 To make portable (UNIX/Windows) the simulation program. The graphical part is written in JAVA.
Principles:
You have to write everything in SIGNAL, that means:
 The creation of graphical objects (buttons, checkboxes, canvas, sliders, text areas)
 Their position
 The writing of the entries
 The showing of outputs by calling some external functions or SIGNAL processes in the library.
These processes are defined in a predefined library called libGraphics.LIB.
To use it, you have to include this library in your SIGNAL program by adding the line: "use libGraphics;"
You have no Java code to write, except if you want to complete the SIGNAL graphical library. For example,
if you add a graphical component in the SIGNAL library, or if you add a color mechanism (that would not
be useless), you will need to modify the Java code.
Description of the directories:
 SimuSignal that contains:





The pace-maker program on graphical form "PACE-MAKER.sig" and on textual form
PACE_MAKER.SIG. This SIGNAL model is included in libGraphics.lib
The Java code for the creation of different buttons, canvas, panels, cursors … and the showing or
reading methods: Files Simu.java, SimuCanvas.java, SimuButton.java
The html documentation obtained by javadoc. To consult it, click here .
The C code that allows to make the interface between C and Java: Files Simu.c and
simuSignal_Simu.h
These files are necessary only if the code generated by the SIGNAL compiler is C or C++. If you
generate Java code, the files will be useless. Be careful: simuSignal_Simu.h is generated automatically
by the Makefile. Don't modify it manually.
Notice: I don't advise you to change the name of this directory, that is also the name of the package of all
the Java files. If you want to do that, you have to modify the name of the package in each Java file,
recompile all, and verify if the file simuSignal_Simu.h automatically generated by the command javah
(see the Makefile) is renamed.

Doc: contains this documentation and the documentation of the Java classes used.
1. Description of the graphic library libGraphics.LIB
2. The functions of creation of graphical components:

CreateFrame: create a frame, where all the graphics will be built (buttons, canvas).



Input parameters: the width and the height of the frame (type integer)

Output parameters: the number associated to this object (type TWindow)
The call to createFrame is obligatory; if you use the pacemaker, this call is already done.
CreatePanel: create a panel, that means a window where we can put others graphical
components, both vertically and horizontally.

Input parameters: the number of the mother window, and the direction (horizontal and
vertical). (type TWindow, type Direction)

Output parameters: The number of this object (type TWindow)
CreateBorder: create a blank area (allows to align and separate some objects)

Input parameters: the number of the mother window, the width of the area, its height (type
TWindow, type integer, type integer)

Output parameters: the number of this object (type TWindow)
___________________________________________________________________________________



CreateButton: create a button

Input parameters: the number of the mother window (type TWindow)

Output parameters: the number of this object. (type TWindow).
CreateCheckBox: create a button with a box to check.

Input parameters: the number of the mother window, its initial state (check or uncheck)
(type TWindow, type boolean)

Output parameters: the number associated to this object
CreateSlider: create a slider (or cursor)

Input parameters: the number of the mother window, the minimum value, the maximum
value, the initial value, the width, the height, the distance between 2 ticks drawn (type
TWindow, type integer, type integer, type integer, type integer, type integer, type integer,
type integer)

Output parameters: the number associated to this object
_________________________________________________________________________________



CreateLabel: create a label, that means a text area that cannot be modified.

Input parameters: the number of the mother window, (type TWindow)

Output parameters: the number associated to this object (type TWindow)
CreateCanvas: create a canvas (to draw curves or patterns)

Input parameters: the number of the mother window, the width of the canvas, its height,
(type TWindow, type integer, type integer).

Output parameters: the number associated to this object (type TWindow)
CreateTextArea: create a text area that can be modify.

Input parameters: the number of the mother window, the width of the area, its height, (type
TWindow, type integer, type integer).



Output parameters: the number associated to this object (type TWindow)
The reading functions



ReadButton:

Input parameters: the number of the button (type TWindow)

Output parameters: true if the button has been clicked, false otherwise. (type boolean)
ReadCheckBox: reading of the state of a checkbox.

Input parameters: the number of the button to be checked (type TWindow).

Output parameters: true if the button is checked, false otherwise (type boolean).
ReadSlider: reading of the value of a slider.

Input parameters: the number of the cursor (type TWindow).


The showing functions

SetTextArea: show an integer



Input parameters: the number of the canvas, the X-coordinate of the start point, the Xcoordinate of the arrival point, the Y-coordinate (type TWindow, type integer, type integer,
type integer)
DrawString: show an integer in a canvas


Input parameters: the number of the canvas, the X-coordinate of the start point, the Xcoordinate of the arrival point, the height (type TWindow, type integer, type integer, type
integer)
ClearCanvas: re-initialize a rectangular area in a canvas


Input parameters: the number of the canvas, the X-coordinate of the line to be showed, the
Y-coordinate of the start point, the Y-coordinate of the arrival point (type TWindow, type
integer, type integer, type integer)
DrawHorLine: draw a horizontal line in a canvas.


Input parameters: the number of the text area, the value to be showed (type TWindow, type
integer)
DrawVertLine: draw a vertical line in a canvas.

Input parameters: the number of the canvas, the value to be showed, its position en Xcoordinate, its position in Y-coordinate (type TWindow, type integer. type integer, type
integer)
FillRect: show a full rectangle in black color in a canvas


Output parameters: the value of the cursor (type boolean).
Input parameters: the number of the canvas, the X and Y-coordinate of the start point, the X
and Y-coordinate of the arrival point, the value to be showed (type TWindow, type integer,
type integer. type integer, type integer)
The output function

QuitAppli: terminate the simulation
Input parameters: the activation clock (type event)

The pace-maker
Contrary to all the functions just defined that are external functions, PACE-MAKER is a process defined
in Signal, and that calls some external functions above. The principle of the pace-maker is to be able to
have 2 simulation mode:
 Automatic: the simulation is run, the user can interrupt it only by using the step by step mode.
 Step by step: This is the user who give the speed by clicking on the button "TICK" and only one loop
of calcul is done at one time.
Description of example VTIDENTITY.sig
I advise you to open polychrony and to load the file VTIDENTITY.sig. The explanations will be clearer.
A model manage the entries and create all of the graphical objects for the simulation. This is the
CONTEXT model; another one show the output: this is the SCREEN model.
Examples
Here is a very small example. This is the identity case: x:=a .
We want to simulate this program graphically, that means to have a slider to enter the values of the entry a,
a canvas to draw the curve of x, and a pace-maker to regulate the speed of the simulation and to have a
manual and automatic mode.
This directory contains:
 VTIDENTITY.sig and VTIDENTITY.PAR: the graphical SIGNAL program and its parameters file.
 VTIDENTITY_extern.c contains the external functions of the SIGNAL program, for example the
function realtoint or readclock, and 2 necessary functions: initSimu and iterateSimu that will be called
by Java during the execution . These files contain respectively a call to VTIDENTITY_initialize and to
VTIDENTITY_iterate.
 All the VTIDENTITY… files are generated by the SIGNAL compiler.
 Make Simu, that is the command for building the compiler. It calls Makefile_VTIDENTITY.
 LibSimu.so, that is built by the call of makeSimu: this is the dynamic library that will be called by the
Java Virtual Machine during the execution, because here the code generated by the SIGNAL compiler is
C or C++. For a Java code generation, we will have no .so file.
To run the simulation, type:
java -classpath $ADRPACKAGE simuSignal.Simu &, where ADRPACKAGE is the address of the
directory that contains the simuSignal directory.
Download