next up previous contents
Next: Issues Up: Extensions Previous: Extensions

defModule

 

 ;SPMlt;module;SPMgt; ::= (defTModule ;SPMlt;name;SPMgt; 
  		 [ 
:participants (;SPMlt;participant-spec) ]
  		 [ 
:conditions ({;SPMlt;simple-asentence;SPMgt; 
;SPMlt;coref-sentence;SPMgt;}) ] 
  		 :inputs
(;SPMlt;input-spec) 
  		 :outputs
(;SPMlt;output-spec) 
  		 [ :language {FORTRAN
 C  C++  LISP  ...} ]

[ :initialization-function ;SPMlt;function-name;SPMgt; ] [ :documentation ;SPMlt;string;SPMgt; ]   ) [3ex]

;SPMlt;input-spec;SPMgt; ::= (;SPMlt;quantity-name;SPMgt; T:type ;SPMlt;type-spec;SPMgt;

[ :optional {true false} ]

[ :documentation ;SPMlt;string;SPMgt; ] ) [2ex]

;SPMlt;output-spec;SPMgt; ::= (;SPMlt;quantity-name;SPMgt; T:type ;SPMlt;type-spec;SPMgt;

[ :documentation ;SPMlt;string;SPMgt; ] ) [2ex]

;SPMlt;quantity-name;SPMgt; ::= ;SPMlt;funconst;SPMgt; [2ex]

A module is a model whose behavior is defined by an executable function (e.g., an externally defined simulation code) instead of declaratively by a set of sentences. The name of the function which implements the module is specified by ;SPMlt;name;SPMgt;. Modules provide several key features. First, they allow the integration of preexisting codes with new, declarative models. This allows users with a large library of existing simulation codes to retain that functionality within a domain theory defined by CML. Second, they allow optimized, hand-crafted simulation codes to be defined when necessary. The functionality of defModule is modeled after that provided by AVS and KHOROS, visual programming systems for scientific computing which enable icons representing user-defined modules to be connected into data-flow diagrams and executed.

The module's function must be side-effect-free in that it must not destructively modify its input data structures. Some input quantities may be declared as optional (i.e., defined need not hold) using the :optional true keyword/value pair. If the :optional field is absent, its value defaults to false. Given the ordered list of input declarations (,...,), it cannot be the case that is optional or that is optional and is not optional, for j;SPMlt;k.

The ;SPMlt;type;SPMgt; specification of each quantity must include at least one subclass of the DataType class. The data type must be consistent with the formal parameter list declaration within the module's externally defined function. Subclasses of datatype include integer, char, fixnum, boolean.

If the :language field is absent, its value defaults to the native language of the implementation. Proper handling of the :language specification is implementation dependent at this time. Some implementations are free to not support foreign function calls. Likewise, the list of accepted languages is open and at the discretion of the local implementation.

An example of defModule is shown in Table gif.

 

 

   (defModule develop
       :inputs ((samples :type (integer))
                (pos :type (float position))
                (width :type (float distance))
                (vd0 :type (float voltage))
                (vsat :type (float voltage threshold))
                (maxDMA :type (float)))
      :outputs ((dma :type (float))
                (esv :type (float)))
      :language C
      :documentation "A simple model of the Xerographic develop process")


Table: A module describing a C code for the Xerographic development process.

   (defRelation real (?x)
     :=> (and (< -inf ?x)(< ?x +inf)))
   (defRelation char (?x) 
     :=> (and (integer ?x)(<= 0 ?x) (<= ?x 255)))
   (defRelation boolean (?x) 
     :=> (member ?x (setof 0 1)))
   (defQuantityFunction input-value (?port)
     :=> (and (input-port ?port) (char (input-value ?port)))
     :step-quantity t)

tex2html_wrap2732


next up previous contents
Next: Issues Up: Extensions Previous: Extensions

Tom Mostek
Wed Jan 21 13:00:43 CST 1998