| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (10 out of 19)

Creating Object Classes

Objects represent physical items, (such as a tank, a pump, or a car), abstract ideas and concepts, relations, variables, parameters, lists, and arrays. The G2 class hierarchy provides:

This section refers to OBJECT and any system-defined or user-defined subclass of OBJECT as an object class.

To create an object class:

  1. Create a CLASS-DEFINITION whose primary direct superior is OBJECT or any subclass of OBJECT, following the directions under:

  2. Provide additional information as described in this section.

System-Defined Object Attributes

Two system-defined attributes (in addition to Icon-description) exist in every object class:

When you create a CLASS-DEFINITION that inherits any object class, the attribute-displays and stubs attributes appear as initializable system attributes in the definition. The grammar for providing their default values is described under Specifying Default Values for Inherited Attributes. For details see:

Each system-defined subclass of OBJECT adds the initializable system attributes that it needs in order to carry out its purpose. Some of these are described in this section under:

One type of object, the CONNECTION-POST, is functionally more closely associated with connections than with objects, which are typically used to represent knowledge. Instructions for creating connection posts appear under Creating Connection Post Classes.

For information on other initializable system attributes of object classes, see the documentation in this manual for the particular class.

Specifying Attribute Displays

The Attribute-displays attribute lets you display the values and, optionally, the names of, one or more system- or user-defined attributes of class instances.

Most attribute tables in G2 have a show attribute display option in their table menu, as shown here on the History-keeping-spec attribute of a variable.


While you can display most attribute values by choosing that option, the Attribute-displays attribute in a definition provides additional functionality.

In addition to displaying the attribute value, the Attribute-displays attribute lets you optionally display the attribute name, and position the display at a location of your choice.

To define the Attribute-displays attribute, enter the name of any system- or user-defined attributes, and select one or more of the phrases that appear in the Text Editor.

Separate attribute displays with a semi-colon (;). Here is how to specify attribute displays:

To display the attribute... Enter the value like this...
value (with or without the attribute name) at the standard position
Displaying only the attribute value at the standard position is the default setting for attribute displays. The standard position aligns with the top edge of the object to the right-hand side. The with name statement displays the attribute name along with its value.
value (and name) at a non-standard position
where (10, 10) are x and y coordinates that define the location of the attribute display as an offset from the center of the icon.

When you specify attribute displays, instances of the object include those displays at creation time and remain in effect until you change them in the attribute table of the instance. Alternatively, you can use the Change attribute in the class definition to update the attribute displays of all instances. For information about changing attribute displays with the Change attribute, see the section Using the Change Attribute.

Specifying Connection Stubs

Connection stubs are short connections attached to and extending from an object. They are the starting point for connections between objects. This figure shows an object with stubs extending to the left and right.


All stubs have the qualities of elasticity and style. You can lengthen a stub by dragging the stub end that is not attached to the object or item. In style, a stub is either orthogonal or diagonal.

The Stubs attribute indicates the number of stubs and the location of where each attaches to class instances.

Use this syntax to specify stubs:

A stub can optionally have a direction. The next diagram shows a particular connection style, and its direction, indicated by arrows:


By default, stubs are non-directional and associated with the system-defined CONNECTION class. For a complete description of using connections, see Chapter 17, Connections.

You can assign a name to a stub, and reference it by that name in expressions. A named stub is called a port. Specify a port's name by including a portname in the Stubs attribute that specifies the stub.

You can indicate direction in a stub by specifying it to be an input or output stub in the Stubs attribute. Providing direction to a stub gives you more control over connections made to it, such as restricting the direction of flow. For example, G2 does not let you connect an input stub to another input stub, or an output stub to another output stub. When a connection is directional, G2 can reason about the objects it connects this way:

The following diagram shows the stub specification for the stubs in the previous diagrams. You can specify multiple stubs in the Stubs attribute:


You can optionally provide a portname in the stub specification, which you can also refer to in expressions this way:

By assigning a connection class to a stub, the stub has the same visual properties of that class. You can then provide expressions that could, for example, change a particular stripe color of the connection this way:

By default, a stub appears as a single black line extending from the object or item. The following table shows techniques for specifying stubs:

To specify stubs with... Enter a statement such as this...
direction, either input or output, at a specific location
The location can be top, bottom, right, or left, followed by a positive integer specifying the position on the object icon in workspace units
a style
Specifies whether the connection is orthogonal or diagonal. The default is orthogonal, indicating that the connection can be drawn using only straight and right angles. Diagonal specifies that the connection can be drawn using straight or diagonal lines with an angle. Stubs with a diagonal style are drawn with the default single black line.
a connection-class and a portname
Specifies the name of the connection class. You can specify a connection class that does not yet exist, but instances will not have stubs unless the connection class exists. The portname that you enter is the name of the port where a connection attaches to an object.


Note: G2 does not restrict connections to the stubs you define. Unless you specify no-manual-connections as a Configuration in the class definition (which limits connections to the stub locations), you can make any number of additional connections to an object.

Inheriting Default Values for Stubs

Icons and stubs are closely related, but they are specified by two different attributes of a definition. Where multiple inheritance exists, this independence could result in mismatched icons and stubs, so the G2 class inheritance rules contain a special provision that prevents it.

To prevent such a mismatch, a class can inherit a stubs definition only from the class from which it inherits its icon definition, or from a descendent of that class. If none of these provides a stubs definition, either inherited or locally defined, the class's stubs default value is none.

Specifying Other Object Class Attributes

Each system-defined subclass of object adds the initializable system attributes that it needs in order to carry out its purpose. This section describes the attributes of variables, parameters, lists, and arrays. For information on other initializable system attributes of object classes, see the documentation in this manual for the particular class.

Attribute Initializations for Variables and Parameters

The Attribute-initializations applicable to variables and parameters are as follows:

Attribute-initialization Variable Parameter
data server
any data-server-alias
inference engine
g2 simulator
g2 meter
,
g2 data server
gfi
gsi
GFI and the G2 Simulator are superseded capabilities. For further information see Appendix F, Superseded Practices.
N/A
data type (for quantitative-variable, or quantitative-parameter)
quantity
time-stamp
pure-number

quantity
time-stamp
pure-number

default update interval
any non-negative time interval, including subsecond values
N/A
history-keeping spec
[do not] keep history with maximum number of data points = any integer and maximum age of data point = time-interval, with minimum interval between data points = any non-negative-number time-interval
[do not] keep history with maximum number of data points = any integer and maximum age of data point = time-interval, with minimum interval between data points = any non-negative-number time-interval
initial value for
initial values for

any legal value for type of variable
any legal value for type of parameter
options for
do [not] forward chain;
do [not] seek data;
do [not] backward chain;
depth first backward chain;
breadth first backward chain;

do [not] forward chain
validity interval
any integer (not a float)
indefinite
supplied

N/A

You can also select supply simulation subtable as a default setting for a variable definition. Instances will then include a simulation subtable available from the variable's simulation-details attribute.

The G2 Simulator is a superseded capability. For more information, see Appendix F, Superseded Practices.


Note: For more information about specifying history keeping for variables and parameters, see Chapter 15, Variables and Parameters.

Attribute Initializations for Lists and Arrays

The attribute-initializations applicable for lists and arrays are as follows:

Attribute-initialization Lists Arrays
allow duplicate elements for g2-list
{yes | no}
Not applicable
array-length for g2-array
Not applicable
Any non-negative integer
element type for
item-list (any class)
item-array (any class)
initial values for
Not applicable
Any legal item or value for the type of array. If the number of default values disagrees with the array length, G2 assigns the default array value to all elements.


Note: You cannot change the allow duplicate elements for a g2-list or the element type for a g2-array while G2 is running when instances exist.

For array classes of a specific type, such as an integer-array, the Text Editor does not prevent you from entering elements of the incorrect type. Specifying such elements causes G2 to replace any element of an incorrect type with the default value for the array class.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (10 out of 19)

Copyright © 1997 Gensym Corporation, Inc.