| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (4 out of 14)

Operating the Current KB

A running G2 process always contains a KB, called the current KB, in its memory. You operate the current KB by starting, pausing, resuming, resetting, or restarting it. You can operate the current KB by using the G2 menus or programmatically.

Creating an Empty KB

By default, a new G2 process contains an empty KB. You add knowledge interactively to an empty KB.

An empty KB contains a set of installed system tables and one or more G2-window items, as illustrated in this figure:


When a new G2 process starts, G2 initializes all attributes of all system-defined items to their default values.


Tip: You can customize the attributes of the system tables in an empty KB, then save the empty KB to a file. When you next load this KB file, you restore those customized settings, for use in developing new knowledge in the KB.

Clearing the Current KB

Sometimes, it might be necessary to clear the contents of the current KB. For example, if you have loaded an existing KB, add items to it, and later decide you want to revert to the saved version, you might want to clear the KB.

To clear the current KB:


Caution: Clearing the current KB cannot be undone. To save the knowledge in the current KB before clearing it, you must save the KB to either a KB file or a KB snapshot file.

Clearing the current KB causes it to become empty, with all item attributes initialized to their system-defined defaults.

Starting the Current KB

Starting the current KB initializes all executable items so they can run. You can start the current KB after launching a new G2 process or after resetting the KB. After you start the current KB, it continues to run until you pause, reset, or restart it.

To start the current KB:

Pausing and Resuming the Current KB

Pausing a KB means suspending temporarily the execution of all items. You can pause the current KB only if it is already running.

You can still create items and interact with them in most ways when a KB is paused. However, certain interactions are restricted when a KB is paused.

Once you have paused a KB, you can resume running it to continue execution. You can pause a KB interactively or programmatically. You can only resume a KB interactively.

To pause the current KB interactively:

To pause the current KB programmatically:

To resume a paused KB:

Resetting the Current KB

Resetting the current KB:

You can reset the current KB at any time.

To reset the current KB interactively:

To reset the current KB programmatically:

Restarting the Current KB

Restarting the current KB starts the KB again as if it had been reset. Restarting is the same as selecting Main Menu > Reset, then selecting Main Menu > Start, in succession.

To restart the current KB:

Determining the Run-State of the Current KB

Because G2 executes, or runs, the current KB, we refer to the current KB's run-state. Run-states affect the contents of a KB.

The next table summarizes how menu choices on the Main Menu affect the current KB run-state:

Main Menu Choice Purpose Resulting Run-States
Start
Start executing the current KB after it is loaded or reset.
Running
Pause
Stop executing the current KB, but allow execution to be resumed.
Paused
Resume
Continue executing a paused current KB.
Running
Reset
Initialize all information in the current KB.
Initial/Reset
Restart
Reset and start executing a current KB that is already running or paused.
Running

G2 displays only the Main Menu choices that are valid for the current run-state. For instance, if the current KB is paused, the Main Menu displays the Restart, Resume, and Reset choices, but not the Start and Pause choices.

The next diagram shows the Main Menu choices that transition between run-states.


The Initial/Reset Run-State

In the initial/reset run-state, a KB is ready for running. In this run-state, you can interactively change all knowledge in the KB.

In this run-state, a KB contains only permanent knowledge. For a description of permanent items and their initialized state, see Chapter 10, G2 Items.

From the initial/reset run-state, a KB can transition only to the running run-state.

The Running Run-State

In the running run-state, G2 is performing the tasks specified in the current KB. G2 detects events that occur in real time, performs actions specified in rules, executes procedures, seeks data for variables, and so on. G2 performs these tasks as a series of operations dispatched and controlled by the scheduler, as described in Chapter 46, Task Scheduling.

When the KB is running, it can contain both updated permanent knowledge and transient knowledge. Transient knowledge consists of a KB's transient items and the transient information associated with permanent items. For a description of transient items and the transient information associated with permanent items, see Chapter 10, G2 Items.

From the running run-state, a KB can transition to the initial/reset run-state or to the paused run-state.

The Paused Run-State

In the paused run-state, G2 suspends the execution of all tasks specified by the KB. G2 retains all information about updated permanent and transient knowledge. When in this state, you can resume running, at which time G2 continues performing suspended tasks.

From the paused run-state, a KB can transition to the initial/reset run-state or to the running run-state.

Summary of Run-States

For each part of a KB's knowledge, the following table summarizes its condition under each run-state:

Status of Knowledge During Each Run-State
Item Knowledge Initial/Reset Running Paused
Attributes of items
Initial: Contain default values. Reset: contain the most recently assigned values.
Contain most recently assigned values.
Contain most recently assigned values.
Variables
Values revert to initial values. Do not have collection times, expiration times, simulation values, histories, or simulation histories (as applicable).
Conclude initial values when activated. After activation, have current values, collection times, etc. (as applicable).
Have current values, collection times, etc. (as applicable).
Parameters
Values revert to initial values. Do not have histories.
After activation, have current values.
Have current values.
Arrays and lists
Can have contents if permanent.
Can have contents.
Can have contents.
Relation instances
Can exist if permanent.
Can exist.
Can exist.
Transient items
Do not exist.
Can exist.
Can exist.
Rules, procedures, formulas, and functions
Do not execute, and cannot resume previous execution.
Execute.
Do not execute, but can be resumed.
Definitions
Can be edited.
Definitions without instances can be edited.
Definitions without instances can be edited.
User-interface items, such as, buttons
Show a menu when clicked.
Operational.
Show a menu when clicked.
Internal and external data service and polling
Neither data service nor polling takes place; external data service connection closed; new external data service connection not allowed
All data service and polling takes place; new external data service connection allowed
Data service does not take place; polling paused; external data service paused; new external data service connection allowed
Item registration status for external data service
No new registrations; existing registrations removed
New registrations allowed; existing registrations retained
New registrations allowed; existing registrations retained
Internal and external message service
Neither takes place
Both take place
Message input; message output paused

The G2 Simulator, which can provide simulation values and simulation histories, is a superseded capability. For more information, see Appendix F, Superseded Practices.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (4 out of 14)

Copyright © 1997 Gensym Corporation, Inc.