| Prev | Next | Start of Chapter | Next Chapter | Contents | Glossary | Index | Comments | (11 out of 11)

Planning Your Work

G2 offers many features that support building real-time applications. As you design your G2-based application, you must evaluate how to put these features to work. This section takes a broad view of G2's features and indicates why and how they are relevant to your work as an application developer.

Customizing the User Interface By Configuring the Default Developer's Environment

As you develop your KB, keep in mind that you can customize the interface to the KB's objects either by suppressing or by supplementing the default features of G2's developer's environment. G2 allows you to accomplish this by declaring configurations that are stored with your KB.

Whether you do this, and to what degree, depends upon the intended users of your KB. For instance, you might develop a set of KBs for use only by other G2 developers; whereas, another G2 developer might develop a set of KBs that are intended to work together as a complete application. The features that another G2 developer requires (such as editing procedures, changing the definitions of classes, and so on) are probably inappropriate to deliver to users of most applications.

Prototyping or Engineering

You can use G2 to very quickly develop a working prototype of an application. G2 easily supports a prototyping development approach to developing your application. G2's key features, such as its syntax-driven Text Editor, its structured-English programming language, its iconic and object-oriented class hierarchy, and its incremental development environment, all support rapid development and deployment of applications. You can complete your work in a small fraction of the time required using other software development technologies.

However, your application will also benefit from your taking a more disciplined, engineering-oriented approach to your application development project. For instance, developing a robust class hierarchy, with the associated data servers, methods, rules, and configurations that support the application's objects, can consume a significant portion of a project's time and effort.

Identifying Roles for Workspaces

You can create a set of workspaces where you capture and organize the definitions and objects that form the backbone of your application. Typically, these workspaces should not be available to the application's users.

Thus, while designing your application's user interface, you must determine how to use workspaces to display the KB's knowledge to the application's users. For instance, your KB might be designed to contain static workspaces: workspaces of fixed sizes and with more or less fixed relationships to each other. The application uses these workspaces as the areas within with to display the KB's knowledge and within which to allow user interaction.

Alternatively, you could design your KB to create and display workspaces and their contents dynamically. That is, the stored KB that you deliver as the application might not include any static, user-visible workspaces at all. Rather, at run-time the application creates the workspaces that the user must see based only on run-time conditions.

Identifying the User Interface Paradigm

Your application can utilize the user interface features of the G2 developer's environment, or you can develop a different interface paradigm. That is, your KB can display menus for its objects in the same manner as G2 does by default. Or, you can design new kinds of operations and objects that implement the same features in what is called a direct-manipulation paradigm.

One approach is to create objects that display their primary knowledge graphically and directly. For many kinds of applications, you can create objects with which the user interacts directly, without the need for selecting commands from menus.

For example, assume that you have developed a class of objects that can be the target of three operations: move this object, create a copy of this object, and delete this object. You can use G2 actions and configurations to accomplish this, without requiring the use of a menu-based interface. That is, you can configure the objects to respond to these user actions:

Under this interface paradigm, where the user drops the object, such as within a particular workspace, can also signify an operation on that object.

User Interface Utilities

G2 includes several utilities that provide specific user interface capabilities:

Identifying Data Servers for Variables

Typically, the variables in your KB represent a data point, or series of data points, collected over regular time intervals. Also, some variables represent data points that are collected outside of G2. One important part of the design of your G2-based application is to identify the sources of data, or data servers, for each class of variables in your KB.

Variables can have either internal or external data servers. External data service is a more complex task for your KB to perform than internal data service. For this reason, determining the minimum number of variables that must use an external data server is also a key design decision.

For more information about variables, see Chapter 15, Variables and Parameters.

Using Internal Data Servers

G2's internal data servers are the G2 inference engine and the G2 Simulator. If a variable's data server is the inference engine, G2 allows the variable to receive a new value via conclude actions (including those that result from chaining among rules) and from specific formula objects. If a variable receives data service from the simulator, G2 associates the variable with a simulation formula, which provides its value.

When a variable has been defined to receive internal data service, your KB can dynamically alternate its service between the G2 inference engine and the G2 Simulator. This allows your KB to respond more flexibly to situations in which a simulated value is just as useful to the application as a value obtained differently.

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

Using External Data Servers

G2's external data servers are other G2 processes, G2 Gateway bridge applications, and GFI files. If a variable receives external data service, your KB cannot dynamically change its data service. However, your KB can conclude the value of an internally data-served variable from another variable that is externally data-served.

External data service takes place asynchronously to the rest of your KB's processing; thus, the activity that your KB must perform to accommodate external data service is inherently more complex than internal data service. For instance, to support external data service, you must create and include interface objects in your KB.

For more information, see Chapter 51, G2 to G2 Interface, Chapter 52, G2 Gateway, and the G2 Gateway Bridge Developer's Guide. GFI is a superseded capability. For information about it, see Appendix F, Superseded Practices.

Using Timekeeping Features

Keeping time is central to how G2 performs its tasks. As shown in the figure Computational Features of G2, G2 has awareness of three streams of time: real-time, scheduled time, and simulated time.

Querying the Real Time

After G2 starts and as long as it runs, G2 has awareness of the real time. G2 has this awareness by querying your computer's own clock. G2 uses the capabilities of your computer's operating system to perform these queries. G2 has as precise a grasp of the real time as your computer and its operating system provide.

Scheduling G2's Work

G2 schedules its own work, and the work it performs when running the current KB, using a second time stream. You can adjust the granularity of this time stream in the Minimum-scheduling-interval attribute of your KB's Timing Parameters system table. Its granularity determines how often G2 checks whether there is more work for it to do.

G2 manages its own work by dividing it into tasks, by assigning a priority to each task, and by scheduling a given set of prioritized tasks to be performed at a particular point in future time. G2 calculates that future point in time as the current time plus a multiple of the minimum scheduling interval.

G2 performs only the work that has been scheduled for the current scheduling interval. After G2 performs that work, G2 waits, by default, for the remainder of the minimum scheduling interval (if any) to pass, then it begins performing the tasks scheduled for the next interval.

G2 keeps this time using the G2 clock. G2 increments the G2 clock each time it moves from one minimum scheduling interval to the next.

G2 manages its work in this way, because it must manage several threads (independently running G2 tasks) of data processing that take place more or less simultaneously. The tasks that G2 must constantly schedule and perform include, but are not limited to:

Thus, you can set your KB's knowledge so that G2 checks more often or less often whether there is new work waiting to be done.

Determining the Minimum Scheduling Interval

You determine the right minimum scheduling interval for your KB by determining the minimum interval of real time that is significant to your application. For instance, perhaps one class of variables in your KB must be updated as often as once per 0.5 seconds, but none of its rules must be invoked more often than once per 0.5 seconds. Thus, for this KB there is no need to set the minimum scheduling interval to a value less than 0.5 seconds. For this KB, doing so would increase G2's own overhead while adding no more capability to the KB's time-based processing.

You can also adjust the rate at which this second time stream elapses. The Scheduler-mode attribute of the Timing Parameters system table contains this setting. Specifically, this determines whether G2 waits for the entire minimum scheduling interval to elapse, before moving on to its set of tasks that are scheduled for the next interval.

Use this feature to cause G2 to run your KB unconstrained by the granularity of the minimum scheduling interval. For a KB whose processing does not depend, or depends only minimally, upon the occurrence of events upon which G2 must wait an entire minimum scheduling interval, setting the KB to run in the as fast as possible scheduler mode allows G2 to move from minimum scheduling interval to interval (and thereby increment the G2 clock) as fast as G2 can perform its scheduled work without waiting for real-time based events.

For more information about the G2 scheduler and the G2 clock, see Chapter 46, Task Scheduling.

Establishing Simulated Time

G2 can also maintain a distinct time stream for each simulation model object defined in the KB. Your KB can establish a distinct current time for each simulation model, to allow the G2 Simulator to represent the occurrence of events independently of the real time. You use G2 system procedures to set and manipulate the time streams of simulation models.

The granularity at which G2 increments this time stream is determined by the Default-simulation-time-increment attribute of the Simulation Parameters system table. The rate at which G2 allows this time stream to elapse is determined by the Scheduler-mode attribute of the Timing Parameters system table.

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

Establishing Naming Conventions

As for applications coded in other programming languages, you must assign names and identifiers to many entities in your KB, and you should establish conventions for how you derive and assign those names.

G2 allows more than one object to have the same name. However, G2 requires that each user-defined class and relation definition have a unique name.

If you are developing a modularized KB, you might prefer to establish module-based naming conventions for classes, attribute names, user interface objects, procedures, and methods.

Considering Natural Language Support

As you use G2 to implement an application, you can configure G2's developer's environment to display G2's default menu choices and to display the default text of buttons in the Text Editor and other G2 facilities, using a particular natural language.

You can also use the features of G2's Text Editor to enter a text value that contains any character in any natural language that G2 supports. Using this feature, you can also define language-specific versions of each of your application's custom menu choices.

You can make this Text Editor feature available to your application's users, so that they can enter text into the application in a particular language (English or not), or in any language that G2 supports.

These features are described in Chapter 39, Natural Language Facilities.

You can also use ASCII characters to signify any character in any natural language that G2 supports. This scheme for signifying non-English characters is defined as the Gensym character set, which is described in Chapter 40, G2 Character Support. Use the Gensym character set to specify text outside of G2 that must be input to G2, and to translate text containing non-English characters that G2 outputs for use by other applications.

Also, Telewindows users can connect to G2 and can operate its current KB such that each displayed Telewindow displays its menu text and G2's system-defined text in a distinct G2-supported natural language. This feature is described in Chapter 8, G2-Windows, and in Chapter 50, Telewindows Support.

| Prev | Next | Start of Chapter | Next Chapter | Contents | Glossary | Index | Comments | (11 out of 11)

Copyright © 1997 Gensym Corporation, Inc.