ETHZ_Logo RAMSES_Logo_Right   RAMSES   RAMSES_Logo_Left Systems Ecology  
Start    search button      Modules:   A-Z   Function   Layer        QuickRefs:   DM   AuxLib   AuxLibE   SciLib   EasyMW   MW   ISIS   RMSLib

ISIS Quick Reference
ISIS_Logo
SysDatAccess   SysDatAux   SysIODivert   SysModBase   SysModDSBase   SysMsgLingua   SysStrctAux   SysStructure   SysVariants  
                ISIS - Integrative Systems Implementation Software
                              Version 1.2 (May 2002)

    Copyright (c) 1997-2006 by Andreas Fischlin, Dimitrios Gyalistras
    and ETH Zurich.

    mailto://RAMSES@env.ethz.ch                      http://www.sysecol.ethz.ch/

  (******************************************************************************)
  (*#####         C L I E N T   I N T E R F A C E   M O D U L E S          #####*)
  (******************************************************************************)

    The authors reserve the right to make changes, additions, and improvements
    to the software or documentation at any time without notice to any person or
    organization; no guarantee is made that further versions of either will be
    compatible with any  other version.

    The authors hereby disclaim any and all guarantees and warranties on the
    software or its documentation, both expressed or implied.  No liability
    of any form shall be assumed by the authors.  Any user of this sofware uses
    it at his or her own risk and no fitness for any purpose whatsoever nor
    waranty of merchantability are claimed or implied.

    | Marks lines which contain objects which have been added since Version 1.0.


(*==============================     SysModBase     ==============================*)

  CONST sysModBaseErrOffset= userBase+300;

  TYPE
    System;
    ChildSystem = System;

    Model= IDENT; IDENT= ARRAY[0..63] OF CHAR;
    ModelKind=( pseudo, static, IORelation, DESS, SQM, DEVS);

    ModelObject= IDENT;
    MObjType=( stateVar, derivative(*DESS*), newStateVar(*SQM (or DEVS)*), modParam, inVar, outVar, auxVar);
    MObjVar= REAL;
    DataAccess=( private, public);
    StateVar= MObjVar;
    Derivative= MObjVar;
    NewStateVar= MObjVar;
    Parameter= MObjVar;
    InVar= MObjVar;
    OutVar= MObjVar;
    AuxVar= MObjVar;

    StateTransition= SimEvents. StateTransition;

    AtLinkEstabProc= PROCEDURE( String); (* outVarQualIdent|inVarQualIdent *)
    AtLinkBreakProc= PROCEDURE( String); (* outVarQualIdent|inVarQualIdent *)
    Condition= PROCEDURE(): BOOLEAN;
    AnyAttribute= ADDRESS;
    ModelAttribute= AnyAttribute;
    MObjAttribute= AnyAttribute;
    ModelAttrProcedure= PROCEDURE( ModelAttribute);
    MObjAttrProcedure= PROCEDURE( MObjAttribute);

  VAR
    unknownSystem: System; 				(* read only *)
    unknownChildSystem: ChildSystem; 	(* read only *)
    unknownModel: Model; 				(* read only *)
    unknownMObj: ModelObject; 			(* read only *)
    unknownModelAttr: ModelAttribute; 	(* read only *)
    unknownMObjAttr: MObjAttribute; 	(* read only *)
    undefMObjVar: MObjVar; 				(* read only *)
    anyLinkPair: String;                (* read only *)

  (* Invoking ISIS *)
  PROCEDURE InvokeISIS ( atStartUp: PROC );

  (* Declaring Systems *)
  PROCEDURE DeclSystem( VAR s: System; sysDescr: ARRAY OF CHAR);	
  PROCEDURE DeclChildSystem( parentDescr: ARRAY OF CHAR; VAR s: ChildSystem; sysDescr: ARRAY OF CHAR);
  PROCEDURE SystemExists( s: System): BOOLEAN;	
  PROCEDURE UndeclSystem( VAR s: System);

  (* Declaring Models *)
  PROCEDURE DeclModel( s: System; modelIdent: ARRAY OF CHAR; kind: ModelKind;
                       dynamicOrDeclDynamic, initialize, input, output, terminate, about: PROC);
  PROCEDURE SetDEVSDynamic( s: System; modelIdent: ARRAY OF CHAR; stfcts: ARRAY OF StateTransition);
  PROCEDURE NoDynamic;      PROCEDURE NoInitialize;	   PROCEDURE LinkedInput;     PROCEDURE NoInput;	
  PROCEDURE NoOutput;       PROCEDURE NoTerminate;	   PROCEDURE NoAbout;         PROCEDURE DoNothing;	

  PROCEDURE ModelExists( modelIdent: ARRAY OF CHAR): BOOLEAN;
  PROCEDURE UndeclModel( s: System; modelIdent: ARRAY OF CHAR);	
  PROCEDURE UndeclAllMs( s: System);

  (* Declaring Model Objects *)
  PROCEDURE MakeMObjQualifIdent( modelIdent, mObjIdent: ARRAY OF CHAR; VAR mObjQualIdent: ARRAY OF CHAR);
  PROCEDURE SplitMObjQualifIdent( mObjQualIdent: ARRAY OF CHAR; VAR modelIdent, mObjIdent: ARRAY OF CHAR);
  PROCEDURE DeclMObj( s: System; mObjQualIdent: ARRAY OF CHAR; objType: MObjType; VAR obj: MObjVar);
  PROCEDURE MObjExists( mObjQualIdent: ARRAY OF CHAR): BOOLEAN;	
  PROCEDURE UndeclMObj( s: System; mObjQualIdent: ARRAY OF CHAR);
  PROCEDURE UndeclAllMObj( s: System; modelIdent: ARRAY OF CHAR);	

  (* Control of Data Access *)
  PROCEDURE SetDataAccess( s: System; modelIdentOrmObjQualIdent: ARRAY OF CHAR; readDA,writeDA: DataAccess);
  PROCEDURE GetDataAccess( modelIdentOrmObjQualIdent: ARRAY OF CHAR; VAR readDA,writeDA: DataAccess);
  PROCEDURE SetDataAccessForAllMObjs( s: System; modelIdent: ARRAY OF CHAR; readDA, writeDA: DataAccess);
  PROCEDURE SetDataAccessForAllMs( s: System; readDA, writeDA: DataAccess);
  PROCEDURE SetDataAccessForSystem( s: System; readDA, writeDA : DataAccess );

  (* Data Linking among subsystems *)
  PROCEDURE EstablishAllLinks;	
  PROCEDURE BreakAllLinks;

  PROCEDURE DeclLink   ( outVarQualIdent, inVarQualIdent: ARRAY OF CHAR);
  PROCEDURE LinkExists ( outVarQualIdent, inVarQualIdent: ARRAY OF CHAR): BOOLEAN;
  PROCEDURE UndeclLink ( outVarQualIdent, inVarQualIdent: ARRAY OF CHAR);
  PROCEDURE EstablishLink    ( outVarQualIdent, inVarQualIdent: ARRAY OF CHAR);
  PROCEDURE BreakLink        ( outVarQualIdent, inVarQualIdent: ARRAY OF CHAR);
  PROCEDURE LinkEstablished  ( outVarQualIdent, inVarQualIdent: ARRAY OF CHAR): BOOLEAN;
  PROCEDURE AddLinkHandlers  ( outVarQualIdent, inVarQualIdent: ARRAY OF CHAR;
                               atLinkEstablish: AtLinkEstabProc; atLinkBreak: AtLinkBreakProc);
  PROCEDURE VoidLinkHandlers ( outVarQualIdent, inVarQualIdent: ARRAY OF CHAR;
                               atLinkEstablish: AtLinkEstabProc; atLinkBreak: AtLinkBreakProc);
  PROCEDURE IgnoreLinkEvent  ( idents: String);	

  (* Limits and Constraints *)
  PROCEDURE LimitMObjsRange( s: System; mObjQualIdent: ARRAY OF CHAR; min, max: REAL);
  PROCEDURE GetMObjsRange( mObjQualIdent: ARRAY OF CHAR; VAR min, max: REAL);	
  PROCEDURE AssertConstraint( c: Condition; descr: ARRAY OF CHAR);
  PROCEDURE NullifyConstraint( c: Condition);	
  PROCEDURE ConstraintAsserted (c: Condition): BOOLEAN;
  PROCEDURE GetConstraintDescr (c: Condition; VAR descr: ARRAY OF CHAR);
  PROCEDURE Equal( x, y: REAL): BOOLEAN;
  PROCEDURE AllConditionsMet(): BOOLEAN;	

  (* Attaching Attributes *)
  PROCEDURE SetModelAttr( s: System; modelIdent: ARRAY OF CHAR; attr: ModelAttribute; atUndeclModel: ModelAttrProcedure);
  PROCEDURE ModelAttr( s: System; modelIdent: ARRAY OF CHAR): ModelAttribute;	
  PROCEDURE SetMObjAttr( s: System; mObjQualIdent: ARRAY OF CHAR; attr: MObjAttribute; atUndeclMObj: MObjAttrProcedure);
  PROCEDURE MObjAttr( s: System; mObjQualIdent: ARRAY OF CHAR): MObjAttribute;	
  PROCEDURE DummyAtUndeclProc( a: AnyAttribute);

  (* System Utilities *)
  PROCEDURE DescribeSystem( s: System );       PROCEDURE HideSystem( s: System );	

  (* Erorr Handling *)
  PROCEDURE CheckForErrors;

(*  ===============================     E N D     ==============================  *)

                   ISIS may be freely copied but not for profit!


 (*******************************************************************************)
 (*##### O P T I O N A L   C L I E N T   I N T E R F A C E   M O D U L E S #####*)
 (*******************************************************************************)

(*=============================     SysDatAccess     =============================*)

  (* All Data, Monitoring, and Tallying of a System *)
  PROCEDURE LoadAndAssignData(pfn: ARRAY OF CHAR; s: System);

  (* Global Simulation Data *)
  PROCEDURE AssignGlobalSimulationData;	
  PROCEDURE DeassignGlobalSimulationData;

  (* Data of Models *)
  PROCEDURE AssignModelData( s: System; modelIdent: ARRAY OF CHAR);	
  PROCEDURE DeassignModelData( s: System; modelIdent: ARRAY OF CHAR);	
  PROCEDURE AssignSystemsModelData( s: System);	
  PROCEDURE DeassignSystemsModelData( s: System);	
  PROCEDURE AssignAllModelData;
  PROCEDURE DeassignAllModelData;	

  PROCEDURE SetModelData ( s: System; modelIdent: ARRAY OF CHAR;     method: ARRAY OF CHAR);
  PROCEDURE GetModelData ( s: System; modelIdent: ARRAY OF CHAR; VAR method: ARRAY OF CHAR);

  (* Data of Model Objects *)
  PROCEDURE AssignMObjData( s: System; mObjQualIdent: ARRAY OF CHAR);	
  PROCEDURE DeassignMObjData( s: System; mObjQualIdent: ARRAY OF CHAR);	
  PROCEDURE AssignModelsMObjData( s: System; modelIdent: ARRAY OF CHAR);
  PROCEDURE DeassignModelsMObjData( s: System; modelIdent: ARRAY OF CHAR);
  PROCEDURE AssignSystemsMObjData(s: System);
  PROCEDURE DeassignSystemsMObjData(s: System);
  PROCEDURE AssignAllMObjData;	
  PROCEDURE DeassignAllMObjData;	

  PROCEDURE SetMObjData( s: System; mObjQualIdent: ARRAY OF CHAR; value: REAL);
  PROCEDURE MObjData( s: System; mObjQualIdent: ARRAY OF CHAR): REAL;	
  PROCEDURE OutVal( mObjQualIdent: ARRAY OF CHAR): OutVar;

  PROCEDURE CheckMObjData( mObjQualIdent: ARRAY OF CHAR; VAR allOk: BOOLEAN);
  PROCEDURE CheckModelsMObjData( modelIdent: ARRAY OF CHAR; VAR allOk: BOOLEAN);
  PROCEDURE CheckSystemsMObjData( s: System; VAR allOk: BOOLEAN);	
  PROCEDURE CheckAllMObjData( VAR allOk: BOOLEAN);

  (* Monitoring *)
  CONST noMonitoring=0;

  PROCEDURE AssignMObjMonitoring( mObjQualIdent: ARRAY OF CHAR; level: CARDINAL);
  PROCEDURE AssignModelsMonitoring( modelIdent: ARRAY OF CHAR; level: CARDINAL);
  PROCEDURE AssignSystemsMonitoring( s: System; level: CARDINAL);	
  PROCEDURE AssignAllMonitoring( level: CARDINAL);	
  PROCEDURE DeassignMObjMonitoring( mObjQualIdent: ARRAY OF CHAR);
  PROCEDURE DeassignModelsMonitoring( modelIdent: ARRAY OF CHAR);	
  PROCEDURE DeassignSystemsMonitoring( s: System );	
  PROCEDURE DeassignAllMonitoring;

  PROCEDURE CheckMObjMonitoring( mObjQualIdent: ARRAY OF CHAR; VAR allOk: BOOLEAN);
  PROCEDURE CheckModelsMonitoring( modelIdent: ARRAY OF CHAR; VAR allOk: BOOLEAN);
  PROCEDURE CheckSystemsMonitoring( s: System; VAR allOk: BOOLEAN );
  PROCEDURE CheckAllMonitoring( VAR allOk: BOOLEAN);

  (* Tallying of Stochastic Results *)
  CONST noTallying=0;

  PROCEDURE AssignMObjTallying     ( mObjQualIdent: ARRAY OF CHAR; level: CARDINAL);	
  PROCEDURE AssignModelsTallying   ( modelIdent   : ARRAY OF CHAR; level: CARDINAL);
  PROCEDURE AssignSystemsTallying  ( s            : System;        level: CARDINAL);	
  PROCEDURE AssignAllTallying      (                               level: CARDINAL);	
  PROCEDURE DeassignMObjTallying   ( mObjQualIdent: ARRAY OF CHAR);	
  PROCEDURE DeassignModelsTallying ( modelIdent   : ARRAY OF CHAR);
  PROCEDURE DeassignSystemsTallying( s            : System        );	
  PROCEDURE DeassignAllTallying;

  PROCEDURE CheckMObjTallying      ( mObjQualIdent: ARRAY OF CHAR; VAR allOk: BOOLEAN);
  PROCEDURE CheckModelsTallying    ( modelIdent   : ARRAY OF CHAR; VAR allOk: BOOLEAN);
  PROCEDURE CheckSystemsTallying   ( s            : System;        VAR allOk: BOOLEAN );
  PROCEDURE CheckAllTallying       (                               VAR allOk: BOOLEAN);

  PROCEDURE SetMObjsTallyData     ( mObjQualIdent, statFuncs: ARRAY OF CHAR; hTally: INTEGER);
  PROCEDURE GetMObjsTallyData     ( mObjQualIdent: ARRAY OF CHAR; VAR statFuncs: ARRAY OF CHAR;
                                    VAR hTally: INTEGER);

(*==============================     SysDatAux     ===============================*)

  (* Standard User Interface *)
  PROCEDURE InstallSDAMenuCmds( title: ARRAY OF CHAR);	
  PROCEDURE RemoveSDAMenuCmds;
  PROCEDURE SysDatAuxMenu(): Menu;	
  PROCEDURE GetSDAMenuAliasChars( VAR loadDatAlCh, loadDatFromAlCh, sdfAlCh, sasdfAlCh, assgnDatAlCh,
                                      deassignDatAlCh, assgnGloSiPsAlCh, chMLevAlCh, chTLevAlCh,
                                      placeWinsAlCh, chkErrAlCh, editPrefsAlCh, editAlChsAlCh: CHAR);
  PROCEDURE SetSDAMenuAliasChars(     loadDatAlCh, loadDatFromAlCh, sdfAlCh, sasdfAlCh, assgnDatAlCh,
                                      deassignDatAlCh, assgnGloSiPsAlCh, chMLevAlCh, chTLevAlCh,
                                      placeWinsAlCh, chkErrAlCh, editPrefsAlCh, editAlChsAlCh: CHAR);
  (* Preferences *)
  PROCEDURE SetSDAPreferences(     clearAtDeassignMode, showIDsAlways, reportOnCheckFail: BOOLEAN;
                                   packageErrMode: INTEGER;     globLikePkgErrMode: BOOLEAN);
  PROCEDURE GetSDAPreferences( VAR clearAtDeassignMode, showIDsAlways, reportOnCheckFail: BOOLEAN;
                               VAR packageErrMode: INTEGER; VAR globLikePkgErrMode: BOOLEAN);

  CONST suppressAllErrMode=0; (* values used for packageErrMode *)
    warnOnceErrMode=1; immediateErrMode=2; debugErrMode=3;
  PROCEDURE ResetSDAToPresettings;	

  (* Core Functions *)
  PROCEDURE LoadDFFromFileIntoMem;	
  PROCEDURE LoadDFFromOtherFileIntoMem( path, filename: ARRAY OF CHAR);
  PROCEDURE AssignDatFraData;	
  PROCEDURE DeassignData;	
  PROCEDURE AssignGlobSimPars;
  PROCEDURE AssignModelsMonitoringForLevel;	
  PROCEDURE AssignModelsTallyingForLevel;
  PROCEDURE PlaceSimEnvsWindows;	
  PROCEDURE SaveDF;	
  PROCEDURE SaveAsDF;
  PROCEDURE CheckForErrPresence;

(*=============================     SysModDSBase     =============================*)

  (* Declaring Structured Model Objects (Structures) *)
  PROCEDURE DeclMObjStruct( s: System; mObjStructQualId: ARRAY OF CHAR; objStructType: MObjType;
                            structDef: ARRAY OF CHAR; sepDimWithUL: BOOLEAN);
  PROCEDURE MObjStructExists( mObjStructQualId: ARRAY OF CHAR): BOOLEAN;	
  PROCEDURE UndeclMObjStruct( s: System; mObjStructQualId: ARRAY OF CHAR);
  PROCEDURE UndeclAllMObjStructs( s: System);	
  (* Looping In Structures *)
  CONST undefOrd=-1; endOfOrdTuple=-2;
  PROCEDURE GetFrstMObjStructEle( s: System; mObjStructQualId: ARRAY OF CHAR;
                                  VAR mObjQualIdent: ARRAY OF CHAR; VAR ordTuple: ARRAY OF INTEGER);
  PROCEDURE GetNextMObjStructEle( s: System; mObjStructQualId: ARRAY OF CHAR;
                                  VAR mObjQualIdent: ARRAY OF CHAR; VAR ordTuple: ARRAY OF INTEGER);
  PROCEDURE GetEleIdent( s: System; mObjStructQualId: ARRAY OF CHAR; ordTuple: ARRAY OF INTEGER;
                                  VAR mObjQualIdent: ARRAY OF CHAR);
  PROCEDURE BindMObjVar( s: System; mObjQualIdent: ARRAY OF CHAR; VAR obj: MObjVar);
  PROCEDURE GetSubStructIdent( s: System; mObjStructQualId: ARRAY OF CHAR; ordTuple: ARRAY OF INTEGER;
                                  VAR subStructQualId: ARRAY OF CHAR);
  PROCEDURE GetSubStructIdents (s : System; mObjStructQualId : ARRAY OF CHAR;
                                VAR subStructQualIds : ARRAY OF CHAR; VAR n : INTEGER);
  (* Miscellaneous *)
  PROCEDURE OrdTupleToStr( ordTuple: ARRAY OF INTEGER; sep: ARRAY OF CHAR; VAR str: ARRAY OF CHAR);
  PROCEDURE StrToOrdTuple( ordTupleStr: ARRAY OF CHAR; sepCh: CHAR; VAR ordTuple: ARRAY OF INTEGER);

(*=============================     SysMsgLingua     =============================*)

  VAR bulletinBoard: ARRAY [0..2048] OF CHAR;

  (* Publishing Messages (implicit declare) *)
  PROCEDURE PublishInt  ( VAR msg: ARRAY OF CHAR; name: ARRAY OF CHAR; int: INTEGER);	
  PROCEDURE PublishLInt ( VAR msg: ARRAY OF CHAR; name: ARRAY OF CHAR; lint: LONGINT);
  PROCEDURE PublishReal ( VAR msg: ARRAY OF CHAR; name: ARRAY OF CHAR; real: REAL);	
  PROCEDURE PublishLReal( VAR msg: ARRAY OF CHAR; name: ARRAY OF CHAR; lreal: LONGREAL);
  PROCEDURE PublishBool ( VAR msg: ARRAY OF CHAR; name: ARRAY OF CHAR; b: BOOLEAN);	
  PROCEDURE PublishId   ( VAR msg: ARRAY OF CHAR; name, ident: ARRAY OF CHAR);
  PROCEDURE PublishStr  ( VAR msg: ARRAY OF CHAR; name, string: ARRAY OF CHAR);
  (* Interpreting Messages *)
  PROCEDURE IntFrom   ( VAR (*speed-up*) msg: ARRAY OF CHAR; name: ARRAY OF CHAR): INTEGER;
  PROCEDURE LIntFrom  ( VAR (*speed-up*) msg: ARRAY OF CHAR; name: ARRAY OF CHAR): LONGINT;
  PROCEDURE RealFrom  ( VAR (*speed-up*) msg: ARRAY OF CHAR; name: ARRAY OF CHAR): REAL;
  PROCEDURE LRealFrom ( VAR (*speed-up*) msg: ARRAY OF CHAR; name: ARRAY OF CHAR): LONGREAL;
  PROCEDURE BoolFrom  ( VAR (*speed-up*) msg: ARRAY OF CHAR; name: ARRAY OF CHAR): BOOLEAN;
  PROCEDURE GetIdFrom ( VAR (*speed-up*) msg: ARRAY OF CHAR; name: ARRAY OF CHAR; VAR ident: ARRAY OF CHAR);
  PROCEDURE GetStrFrom( VAR (*speed-up*) msg: ARRAY OF CHAR; name: ARRAY OF CHAR; VAR string: ARRAY OF CHAR);
  PROCEDURE IsValDefInMessage(VAR (*speed-up*) msg: ARRAY OF CHAR; name: ARRAY OF CHAR): BOOLEAN;

  (* Declaring Messages *)
  TYPE ValueDefType=( integnum, realnum, boolvar, identstring, charstring);
  PROCEDURE DeclareValDefName( name: ARRAY OF CHAR; type: ValueDefType);	
  PROCEDURE IsValDefNameDeclared(name: ARRAY OF CHAR): BOOLEAN;
  PROCEDURE DiscardValDefName( name: ARRAY OF CHAR);

  (* Replacing/Adding in/to Messages *)
  PROCEDURE SetIntIn  ( VAR msg: ARRAY OF CHAR; name: ARRAY OF CHAR; int: INTEGER);	
  PROCEDURE SetLIntIn ( VAR msg: ARRAY OF CHAR; name: ARRAY OF CHAR; lint: LONGINT);
  PROCEDURE SetRealIn ( VAR msg: ARRAY OF CHAR; name: ARRAY OF CHAR; real: REAL);	
  PROCEDURE SetLRealIn( VAR msg: ARRAY OF CHAR; name: ARRAY OF CHAR; lreal: LONGREAL);
  PROCEDURE SetBoolIn ( VAR msg: ARRAY OF CHAR; name: ARRAY OF CHAR; b: BOOLEAN);	
  PROCEDURE SetIdIn   ( VAR msg: ARRAY OF CHAR; name, ident: ARRAY OF CHAR);
  PROCEDURE SetStrIn  ( VAR msg: ARRAY OF CHAR; name, string: ARRAY OF CHAR);

(*==============================     SysIODivert     =============================*)

  TYPE Redirection;

  VAR noRedirection: Redirection; (* read only *)

  PROCEDURE DivertInputsForSubSys ( VAR r: Redirection; subSystemDescr, pfn: ARRAY OF CHAR);
  PROCEDURE DivertOutputsForSubSys( VAR r: Redirection; subSystemDescr, pfn: ARRAY OF CHAR);
  PROCEDURE DivertInputsForModel ( VAR r: Redirection; model, pfn: ARRAY OF CHAR);
  PROCEDURE DivertOutputsForModel( VAR r: Redirection; model, pfn: ARRAY OF CHAR);
  PROCEDURE DivertInV ( VAR r: Redirection; outVarQualIdent, inVarQualIdent, pfn: ARRAY OF CHAR);
  PROCEDURE DivertOutV( VAR r: Redirection; outVarQualIdent, inVarQualIdent, pfn: ARRAY OF CHAR);
  PROCEDURE RedirectionActive( r: Redirection): BOOLEAN;	
  PROCEDURE GetDivertFile(r: Redirection; VAR path,fn: ARRAY OF CHAR);
  PROCEDURE GetDivertedMObjs( VAR inVQualIds, outVQualIds: ARRAY OF CHAR; VAR noInVs, noOutVs: INTEGER);
  PROCEDURE StopRedirection( VAR r: Redirection);	
  PROCEDURE StopAllRedirections;

(*==============================     SysStrctAux     =============================*)

  (* Subsystem Specific Menu Section *)

  PROCEDURE HandOverSubSysMenuManagement(subSys: SubSystem; installCmdsP, removeCmdsP: PROC);

  (* Using Menu 'System' *)
  PROCEDURE InstallSysMenuAndUtils( menutitle: ARRAY OF CHAR);	(* installs menu 'System' if menutitle = "" *)

  (* Customizing Menu 'System' *)
  PROCEDURE InstallSystemMenu( menutitle: ARRAY OF CHAR);
  PROCEDURE InstallSysConfigCmd( configCmdTxt, configAlCh: ARRAY OF CHAR);	
  PROCEDURE InstallSysUtils( ioLinkCmdTxt, ioLinkAlCh, ioBrkLinkCmdTxt, ioBrkLinkAlCh,
                             stopDivertsCmdTxt, stopDivertsAlCh: ARRAY OF CHAR);
  PROCEDURE SysStructMenu(): Menu;	
  PROCEDURE SysConfigCmd(): Command;	
  PROCEDURE GetSysStructMenuCmds( VAR cmds: ARRAY OF Command);
  PROCEDURE SetSysMenuShortCuts(     chkErrAlCh, editPrefsAlCh, editAlChsAlCh: CHAR);
  PROCEDURE GetSysMenuShortCuts( VAR chkErrAlCh, editPrefsAlCh, editAlChsAlCh: CHAR);

  (* Command Functions of Menu 'System' *)
  PROCEDURE ConfigureSystem;	

  PROCEDURE LinkSubSystems;
  PROCEDURE UnlinkSubSystems;

  PROCEDURE StartRedirections;
  PROCEDURE StopRedirections;

  PROCEDURE AnyErrorsPresent;	
  PROCEDURE EditAliasChars;
  PROCEDURE EditSysStructPrefs;	
  PROCEDURE ResetSysStrctAux;	

  (* Utilities *)
  PROCEDURE ChooseSubSysVariant(subSys: SubSystem);
  PROCEDURE AssignDataToSubSysByDlg;

  (* Preferences *)
  CONST
    suppressAllErrMode = 0;  (* values used for packageErrMode, same as the *)
    warnOnceErrMode    = 1;  (* ones exported by module SysDatAux *)
    immediateErrMode   = 2;
    debugErrMode       = 3;
  PROCEDURE SetSysStructPreferences(    packageErrMode : INTEGER; globLikePkgErrMode,
                                        showSysMode, showModelsMode, showInVsMode, showOutVsMode,
                                        showDerivsMode, showNewStatesMode, showAuxVsMode: BOOLEAN);
  PROCEDURE GetSysStructPreferences(VAR packageErrMode : INTEGER; VAR globLikePkgErrMode,
                                        showSysMode, showModelsMode, showInVsMode, showOutVsMode,
                                        showDerivsMode, showNewStatesMode, showAuxVsMode: BOOLEAN);

(*=============================     SysStructure     =============================*)

  FROM SysModBase IMPORT System, ChildSystem;

  (* Master System *)
  TYPE
    SystemStructure = BITSET;
    DefSysStructProc   = PROCEDURE (VAR SystemStructure);
    MakeMsgProcedure   = PROCEDURE (SubSystem, VAR ARRAY OF CHAR);
  PROCEDURE UseAsMasterSystem(masterSys: System; mainAnchor: ARRAY OF CHAR;
                              defSysStructP: DefSysStructProc;
                              configInitP: PROC;
                              makeVariListP, makeDatAssgnCmdP: MakeMsgProcedure;
                              configTermP: PROC );
  PROCEDURE NoAction;
  PROCEDURE DontSetSysStructure(VAR struct: SystemStructure);
  PROCEDURE NoMakeDataAssignCmd(subSys: SubSystem; VAR datAssgCmd: ARRAY OF CHAR);
  (* SubSystems *)
  TYPE
    SubSystem = INTEGER; (* actually limited to range [0..Cardinality(SystemStructure)]! *)
    SSShortID = ARRAY [0..7] OF CHAR; (* Sub System Short Identifier *)
    BooleanFct         = PROCEDURE (): BOOLEAN;
    SendMsgProcedure   = PROCEDURE (VAR (* In/Out SML message *) ARRAY OF CHAR);

  VAR
    unknownSubSystem: SubSystem; (* read only! *)
    unknownSSShortID: SSShortID; (* read only! *)
  PROCEDURE UseAsSubSystem( childSysName, subsysShortId: ARRAY OF CHAR;
                            VAR subSys: SubSystem; declVariantsP: PROC;
                            activateSubSysP, deactivateSubSysP: PROC;
                            subSysIsActiveP: BooleanFct;
                            setVariantsP: SendMsgProcedure; linkInsP: PROC;
                            assignDataP: SendMsgProcedure; updateSysP: PROC);
  PROCEDURE NoInputs;   PROCEDURE DontLinkIns;   PROCEDURE NoVariants;
  PROCEDURE NoSetVariants(VAR (*In/Out*) setVariantCmd:   ARRAY OF CHAR);
  PROCEDURE NoDataAssign (VAR (*In/Out*) datAssgCmd: ARRAY OF CHAR);
  PROCEDURE NoUpdate;

  (* System Deinstallation *)
  PROCEDURE ForgetSystemUsage;	

  (* Controlling System Structure *)
  PROCEDURE DefineSysStructure ( syss: SystemStructure);
  PROCEDURE SetSysStructure( syss: SystemStructure);
  PROCEDURE GetSysStructure( VAR syss: SystemStructure);	
  PROCEDURE GetSysStructureFromDTF(VAR syss: SystemStructure);

  (* Controlling Subsystem Variants *)
  PROCEDURE SetSubSysVariant( subSys: SubSystem; variantlist: ARRAY OF CHAR);
  PROCEDURE GetSubSysVariant( subSys: SubSystem; VAR variantlist: ARRAY OF CHAR);
  PROCEDURE GetSubSysVariantFromDTF( subSys: SubSystem; VAR vlist: ARRAY OF CHAR);
  PROCEDURE GetDefltSubSysVariant( subSys: SubSystem; VAR vlist: ARRAY OF CHAR);

  (* Assigning Data *)
  PROCEDURE AssignSystemsData( datAssgCmd: ARRAY OF CHAR);
  PROCEDURE AssignSubSysData( subSys: SubSystem; VAR (*In/Out*) datAssgCmd: ARRAY OF CHAR);

  (* Preparation Routines *)
  TYPE PreparationRoutine = PROC;
  PROCEDURE AddPreparationRoutine(rp: PreparationRoutine);
  PROCEDURE VoidPreparationRoutine(rp: PreparationRoutine);
  PROCEDURE ExecuteEntirePreparation;

  (* Utilities *)
  PROCEDURE ShowSubSysVariant(subSys: SubSystem; inAboutW: BOOLEAN);
  PROCEDURE CheckVariantList( subSys: SubSystem; VAR (*speed-up*) vlist: ARRAY OF CHAR;
                              VAR listIsOk: BOOLEAN);
  PROCEDURE VListToOrdTuple( subSys: SubSystem; VAR(*speed-up*) vlist: ARRAY OF CHAR;
                             VAR ordTuple: ARRAY OF INTEGER);
  PROCEDURE GetCurOrdTuple( subSys: SubSystem; VAR ordTuple: ARRAY OF INTEGER);
  PROCEDURE GetMainAnchor(VAR mainAnchor: ARRAY OF CHAR);
  PROCEDURE NoOfSubSystems(): INTEGER;
| PROCEDURE NoOfVSetsInSubSystem(subSys: SubSystem): INTEGER;
  PROCEDURE GetSSShortID(subSys: SubSystem; VAR ssshortid: ARRAY OF CHAR);
| PROCEDURE GetSubSysName(subSys: SubSystem; VAR subSysName: ARRAY OF CHAR);
  PROCEDURE WhileConfiguringFromScratch(): BOOLEAN;

(*=============================     SysVariants     ==============================*)

  TYPE
    VariantSet; VariantOrd= INTEGER;
    VariantAttribute= ADDRESS;
    VSRemoveHandler= PROCEDURE( VariantSet);
    VRemoveHandler= PROCEDURE( VariantAttribute);

  VAR unknownVariantSet: VariantSet; (* read only *)

  CONST undefVariant=0; variDelim="|";

  (* Variant Sets *)
  PROCEDURE CreateVariantSet( VAR vs: VariantSet; vsDescr: ARRAY OF CHAR);	
  PROCEDURE VariantSetExists( vs: VariantSet): BOOLEAN;
  PROCEDURE GetVariantSetDescr( vs: VariantSet; VAR vsDescr: ARRAY OF CHAR);	
  PROCEDURE DiscardVariantSet( VAR vs: VariantSet);

  (* Variants *)
  PROCEDURE AddVariant( vs: VariantSet; VAR vord: VariantOrd; vIdent, variDescr: ARRAY OF CHAR);
  PROCEDURE VariantExists( vs: VariantSet; vIdent: ARRAY OF CHAR): BOOLEAN;	
  PROCEDURE DiscardVariant( vord: VariantOrd);
  PROCEDURE RemoveVariant( vs: VariantSet; vIdent: ARRAY OF CHAR);

  (* Accessing Variants *)
  PROCEDURE VOrd( vs: VariantSet; vIdent: ARRAY OF CHAR): VariantOrd;
  PROCEDURE OrdInVS (vs: VariantSet; vord: VariantOrd): INTEGER;
  PROCEDURE GetVVal( vord: VariantOrd; VAR vs: VariantSet; VAR vIdent: ARRAY OF CHAR);
  PROCEDURE GetNthSubString( VAR (*speed-up*) string: ARRAY OF CHAR; n: INTEGER; VAR subs: ARRAY OF CHAR);
  PROCEDURE VListToVCombination( vlist: ARRAY OF CHAR; VAR combination: ARRAY OF VariantOrd);
  PROCEDURE VCombinationToVList( combination: ARRAY OF VariantOrd; VAR vlist: ARRAY OF CHAR);

  (* Current Variant In a Variant Set *)
  PROCEDURE SetCurVariant (vs: VariantSet;     vIdent: ARRAY OF CHAR);
  PROCEDURE SetCurV       (vs: VariantSet; vord: VariantOrd);
  PROCEDURE GetCurVariant (vs: VariantSet; VAR vIdent: ARRAY OF CHAR);
  PROCEDURE CurVOrd       (vs: VariantSet): VariantOrd;
  PROCEDURE IsCurV ( vIdent: ARRAY OF CHAR; invs: VariantSet): BOOLEAN;
  PROCEDURE IsCurVOrd    (vord: VariantOrd; invs: VariantSet): BOOLEAN;
  PROCEDURE CurOrdInVS    (vs: VariantSet): INTEGER;
  PROCEDURE CurOr1stOrd (invs: VariantSet): CARDINAL;

  (* Looping through Variant Sets *)
  PROCEDURE VSDim( vs: VariantSet): INTEGER;	
  PROCEDURE VSMin( vs: VariantSet): VariantOrd;
  PROCEDURE VSMax( vs: VariantSet): VariantOrd;	
  PROCEDURE VSucc( vs: VariantSet; vord: VariantOrd): VariantOrd;
  PROCEDURE VPred( vs: VariantSet; vord: VariantOrd): VariantOrd;	

  (* Combinations *)
  PROCEDURE ForbidVCombination( combination: ARRAY OF VariantOrd);
  PROCEDURE AllowVCombination( combination: ARRAY OF VariantOrd);	
  PROCEDURE LegalVCombination( combination: ARRAY OF VariantOrd): BOOLEAN;

  (* Accessing Variant Sets *)
  PROCEDURE FirstVS(): VariantSet;
  PROCEDURE PrevVS( vs: VariantSet): VariantSet;	
  PROCEDURE NextVS( vs: VariantSet): VariantSet;
  PROCEDURE LastVS(): VariantSet;	

  (* Handlers & Attributes *)
  PROCEDURE AddVSRemoveHandler( vs: VariantSet; rmh: VSRemoveHandler);	
  PROCEDURE VoidVSRemoveHandler( vs: VariantSet; rmh: VSRemoveHandler);
  PROCEDURE GetVDescriptor( vord: VariantOrd; VAR vDescr: ARRAY OF CHAR);	
  PROCEDURE AttachVAttr( vord: VariantOrd; va: VariantAttribute);
  PROCEDURE VAttr( vord: VariantOrd): VariantAttribute;	
  PROCEDURE AddVRemoveHandler( vord: VariantOrd; rmh: VRemoveHandler);
  PROCEDURE VoidVRemoveHandler( vord: VariantOrd; rmh: VRemoveHandler);	

(*  ===============================     E N D     ==============================  *)

                   ISIS may be freely copied but not for profit!

  Contact RAMSES@env.ethz.ch Last updated: 25-Jul-2011 [Top of page]