DEFINITION MODULE StructModAux;
(*******************************************************************
Module StructModAux (Version 1.3)
Copyright (c) 1994-2006 by Andreas Fischlin and ETH Zurich.
Purpose Utilities for working with structured
ModelWorks models.
Remarks This module imports from the ModelWorks client
interface.
Implementation restriction: Assumes a single
Master Model Definition Program (MDP), i.e. it can
not support simultaneously more than one MDP!
Programming
o Design
Andreas Fischlin 04/01/1994
o Implementation
Andreas Fischlin 04/01/1994
ETH Zurich
Systems Ecology
CHN E 35.1
Universitaetstrasse 16
8092 Zurich
SWITZERLAND
URLs:
<mailto:RAMSES@env.ethz.ch>
<http://www.sysecol.ethz.ch>
<http://www.sysecol.ethz.ch/SimSoftware/RAMSES>
Last revision of definition: 11/06/1998 AF
*******************************************************************)
FROM DMMenus IMPORT Menu, Command;
FROM SimBase IMPORT MWWindowArrangement;
TYPE
StructModelSet = BITSET;
BooleanFct = PROCEDURE (): BOOLEAN;
VAR
customM: Menu; (* may be used to install more commands *)
chooseCmd: Command;
PROCEDURE InstallCustomMenu(title, chooseCmdTxt, chooseAlChr: ARRAY OF CHAR);
(*
Installs a menu with the title 'title', and as the first
command (i.e. 'chooseCmd') a command with the text
'chooseCmdTxt'. The latter menu command is associated with
procedure 'ChooseModel' and can also be activated with the
alias char (keyboard equivalent) 'chooseAlChr'.
Typical usage: InstallCustomMenu("Models","Activation…","L");
executed from within a InitSimEnv procedure.
See also example at the end of this definition!
*)
PROCEDURE ChooseModel;
(*
'ChooseModel' is the procedure associated with the menu command
'chooseMCmd' which allows the simulationist to activate
previously installed sub models (see procedure
'AssignSubModel') dynamically. Note that this routine
calls implicitely 'SetSimEnv'.
*)
PROCEDURE AssignSubModel(VAR which: INTEGER; descr: ARRAY OF CHAR;
act,deact: PROC; isact: BooleanFct);
(*
Installs a sub model with the descriptor 'descr' and uses
the routines 'act', 'deact' respectively 'isact' to
activate or deactivate respectively to investigate the
current presence of the sub model. Upon successful assign
the submodel gets the number 'which'; use it when calling
procedure 'SetSimEnv', e.g. to denote those submodels you
want to be active by default. NOTE: Implementation
restriction, only up to a maximum of 16 sub models can be
assigned. Submodels can't be deassigned individually,
unless they have been assigned by a subprogram level which
is to be terminated. In the latter case this module
automatically deassignes any disappearing submodel. There
is one exception: Routine DeassignAllSubModels (see below)
can deassign all currently installed submodels, allowing
for a reinstallation from scratch.
*)
PROCEDURE InstallMyGlobPreferences(myPrefs: PROC);
(*
Installs routine 'myPrefs' which is used to define defaults of
global parameters such as default window positions (e.g. by a
call to routine 'PlaceGraphOnSuperScreen') or global simulation
parameters (e.g. by a call to the routine 'SetDefltGlobSimPars'
from module 'SimBase').
*)
PROCEDURE SetSimEnv(sms: StructModelSet);
(*
Sets the defaults (i.e. executes the previously installed
routine 'myPrefs' whenever needed) and activates all the models
specified in 'sms' according to the sequence in which
sub models were installed by calls to the routine 'AssignSubModel'.
*)
PROCEDURE GetSysConfig(VAR sms: StructModelSet);
(*
Returns the current system configuration in sms by calling
for all known submodels its isact routine.
*)
PROCEDURE DeassignAllSubModels;
(*
Discards all submodel assignments at once. This allows for
a reinstallation of a new set of submodels.
*)
(* ========================================================================
Typical example of a master module collecting several sub models by
means of above routines:
...
...
VAR
atmos, bios, obs: INTEGER;
PROCEDURE InitSimEnv;
BEGIN
InstallCustomMenu("Models","Activation…","L");
SetSimEnv({atmos,obs}); (* default activation *)
END InitSimEnv;
PROCEDURE SetMyGlobPreferences;
BEGIN
SetDefltGlobSimPars(1900.0, 2300.0, 0.5, 0.0001, 1.0, 10.0);
PlaceGraphOnSuperScreen(tiled);
END SetMyGlobPreferences;
BEGIN (* body MyMaster *)
InstallMyGlobPreferences(SetMyGlobPreferences);
AssignSubModel(atmos, atmosModelDescr,
ActivateAtmosModel, DeactivateAtmosModel, AtmosModelIsActive);
AssignSubModel(bios, biosModelDescr,
ActivateBiosModel, DeactivateBiosModel, BiosModelIsActive);
AssignSubModel(obs, obsModelDescr,
ActivateObsModel, DeactivateObsModel, ObsModelIsActive);
RunSimEnvironment( InitSimEnv );
END MyMaster;
======================================================================== *)
END StructModAux.