User Init and User Quit
The file
user_activities.a
containsUSER_INIT
procedure templates for the main module and for every generic module.
For example:separate (g_ACST_G)
procedure g_acst_g_USER_INIT is
begin
null;
end g_acst_g_USER_INIT;
with ac_mongo; use ac_mongo;
package body user_activities is
procedure USER_INIT is
begin
null;
end USER_INIT;
procedure USER_QUIT is
begin
null;
end USER_QUIT;
end user_activitiesYou can use the generic USER_INIT function to initialize local variables into generic module.
The code calls this procedure before the very first step is taken in the translated statecharts. Therefore, you can use it for many types of initializations.
For example, you can add an actual piece of code to initialize various global structures in the code supplied for primitive activities, to open windows, etc.
Another important option is to initialize specification elements. Recall that all events, conditions and data-items used in the specification have the following default values:
● events - not active
● conditions - false
● textual data-items - blank stringThe default value is used when there is no explicit initialization of an element before it is referenced in an expression. However, you might wish to intentionally leave an element uninitialized in the specification because you do not know the precise initial value. In such a case, you want to be able to run the same prototype code with different initial values of the element and to choose an appropriate one in a “trial and error” process. Once you choose an initial value, you can add it to the specification. In other words, you tune the system specification by working with the prototype derived from it.
For example, if you want to assign an initial value of true to the condition FAULT, and a value of 50 to the integer data-item LOW_BOUND which both belong to the chart EWS, you transform the template into the following
USER_INIT
procedure:Execution of the code may come to a point where all activities of the prototyped system become non-active and thus the system must finish its work. This may be caused by various reasons: self-termination of activities, explicit or implied actions stop or the command QUIT entered when running the prototype Debugger.
In all cases where the system stops, the code performs a call to the procedure
user_quit
, intended to support a graceful termination of the user extensions. The template of this procedureUSER_QUIT
resides in theuser_activity.a
file:Consider an example in which the prototype code is connected to a graphical mock-up of the operator display. Suppose that among the user’s extensions there is a task responsible for I/O interface between the code and the display. When a soft button is “pushed” on the display, the task accepts an interrupt from the mouse and translates it into generation of an event sent to the prototype code. When the system stops, this task must terminate. To achieve this goal, place an abort statement for this task in the template
USER_QUIT
.