Previous Next Table of Contents

8. Elements

Elements are the basic computing and organizational entities available to the user. Elements are organized in a hierarchical structure similar to a UNIX directory tree. Each element embodies a specific computation in the simulation. This computation may implement part of the model being simulated or may be part of the graphical interface or file I/O.

The state of an element is contained in the element's fields. Fields may be of any C defined type. A field protection facility provides for both the visibility and accessability of the element fields. Fields have default values which define the state of an element's fields when the element is created. The default values may be changed, changing the initial values of elements created subsequently.

Elements may need information from other elements to perform their calculations. This information is gathered from the other elements' fields via Messages.

A set of default element types (called ``objects'') is distributed with GENESIS. They are used as templates for the creation of the particular elements which are used in a GENESIS simulation. One example of an element type is the `` neutral'' object which is often used to create an empty element used for grouping, much like a directory in the operating system. Another example is an ``xform'' object used to create graphical form widgets which might appear on the screen. The GENESIS distribution currently contains over eighty predefined objects. These are summarized in Objects.

8.1 Related Commands

The following GENESIS routines are used for creating and working with specific elements:

Routine Description
create Creates new element of specified element type.
copy Copies an element (and its children, if any) from one
portion of the element tree to another.
createmap Copies an element multiple times to form a
two-dimensional array.
move Moves an element and its children from one portion of the
tree to another.
delete Deletes an element and all of its children.
deleteall Deletes all existing elements. [not recommended]
exists Tests for existence of specified element or field.
reclaim Reclaims memory from deleted elements.
addfield Adds a new (extended) field to an element.
deletefield Deletes an extended field of an element.
setfield Sets value of field in data structure of specified element.
getfield Returns value of field in data structure of specified element.
getfieldnames Returns names of all existing fields in specified element.
showfield Displays value of field in data structure of specified element.
save Saves current field values for specified element in a file.
restore Restores element state stored in file with save routine.
call Allows an element to execute the function associated with
the named action.
position Sets xyz coordinates of an element and all of its children.
rotcoord Rotates coordinates of elements in 3-d space.
egg Generates coordinates for points on the surface of an ovoid.
plane Generates 3-d coordinates for a plane with specified
dimensions and characteristics.

Other commands related to GENESIS elements are described in the sections on Hierarchical Structure, Objects, and Extended Objects.

8.2 Actions

Elements have defined actions which may be invoked explicity by the user via the call command. GENESIS calls many actions implicitly as a side effect of certain commands or as part of the process of running a simulation. The predefined actions of an element are inherited from the object which was used to create the element. Other actions may be added with the addaction command. The following predefined actions are common to many GENESIS objects.

PROCESS Called on each simulation step as described by the simulation
schedule to perform the element's update processing.
INIT Called on each simulation step as described by the simulation
schedule to initialize the element for this simulation step.
RESET Called when the simulation is reset (reset command) to allow
an element to reset itself to its default state.
CHECK Called from the check command to allow an element to verify
that it has all the information and the correct information
needed to proceed with the simulation.
SET Called when an element field is set (or once for a setfield
command if SPECIAL_SET exists as an element field). The SET
action must return 1 if it sets the field in question and 0
if it doesn't.
SHOW Called in order to perform special formating for field display
or retrieval (getfield or showfield commands).
CREATE Called when an element is created to initialize the element.
Must return non zero if the initialization is successful.
COPY Called when an element is copied.
DELETE Called when an element is destroyed.
SAVE2 Called to save the state of the element to a file.
RESTORE2 Called to restore the previous state of the element from a file.
DUMP Called by the simdump command.
UNDUMP Called by the simundump command.

Objects often have other predefined actions which are specific to the way the object is used. These are described in the documentation for the particular object. For a description of actions which are specific to XODUS elements (widgets), see XODUS Mouse Clicks.

If a particular action is not defined for an element, a default behavior is performed on the element (SET sets the field, SHOW returns the field, CREATE leaves fields initialized from defaults, etc.).


Previous Next Table of Contents