DEFINITION MODULE SysMsgLingua;
(*******************************************************************
Module SysMsgLingua (ISIS_Version_1.2)
Copyright (c) 1998-2006 by Andreas Fischlin and ETH Zurich.
Purpose Message Language for exchanging messages between
a master system and its subsystems.
Remarks The System Message Language (SML) has the following EBNF:
message ::= [valueDef] { ";" valueDef }.
valueDef ::= identifier "=" value.
value ::= integer | real | boolean | identifier | string.
integer ::= digit {digit}.
digit ::= "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9".
real ::= digit {digit} ["." {digit}] [scalefactor].
scalefactor ::= ("E"|"e") ["+"|"-"] digit {digit}.
boolean ::= "TRUE"|"FALSE".
identifier ::= letter {letter|digit}.
string ::= '"' {character} '"' | "'" {character} "'".
Example:
Declare variables by
DeclareValDefName('anInt',integnum);
DeclareValDefName('anIdentifier',identstring);
DeclareValDefName('areal',realnum);
DeclareValDefName('str',charstring);
Then after receiving a message like
msg := "anInt = 2; anIdentifier = siteName; areal = 1.2E-2; str = 'just a string'"
extract from it 'areal' by
x := RealFrom(msg,'areal');
and a string by
GetStrFrom(msg,'str',theString);
This module belongs to ISIS
Integrative Systems Implementation Software.
Programming
o Design
Andreas Fischlin 07/05/1998
o Implementation
Andreas Fischlin 07/05/1998
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: 02/07/1998 AF
*******************************************************************)
(* Error constants: SysMsgLinguaOffSet = DMLanguage.userBase + 401 .. 420-1 *)
VAR
bulletinBoard: ARRAY [0..2048] OF CHAR;
(*
The following easy to use routines declare implicitely a
value definition with name 'name' (if not already declared
previously, calls IsValDefNameDeclared plus
DeclareValDefName if necessary) and add the value definition
to the message 'msg' (calls a SetXYZIn procedure). In case
the value definition is already present in 'msg', its old
associated value is first deleted and the new value
definition appended at the end of the message. Any other
value definitions possibly present in 'msg' are left
untouched.
*)
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);
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);
(*
The following routines allow to retrieve a specific value
definition and its associated actual value from the message
'msg'. They assume that the value definition with name
'name' has been previously declared, otherwise the routines
fail.
*)
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;
(*
The following routines replace a previously declared value
definition if it's already contained in msg or else append
it to the existing message. They assume that the value
definition with name 'name' has been previously declared,
otherwise the routines fail.
*)
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);
END SysMsgLingua.