Using AVS/Express |
|
AVS/Express provides a status and interrupt facility that enables you to monitor and control the execution of your application. This chapter describes the status and interrupt facility, including its underlying Scheduler object. It contains the following sections:
The status and interrupt facility enables you to monitor and control how users execute your application. It provides you with the ability to provide selected status information to users, and manage when and how users interrupt the application.
You can provide users with the following status information:
You control how the module name and the percent-completion fields are displayed to the user by customizing the user interface of the control panel.
In order for the system to show status information for a module's method, you must:
While a method executes, you can also change the current module field to display a text message to the user about what operation is proceeding.
You use the interrupt capabilities to determine how and when users interrupt your application. The following capabilities are available:
You control interrupt information, whether a module is interruptible, and when and how a module reacts to an interrupt request by customizing the user interface of the control panel.
This section describes an AVS/Express object called the Scheduler. It, and subsequent sections, frequently refers to C API routines. For information on equivalent C++ API and FORTRAN API routines, see Chapter 9, Object Manager APIs.
Underpinning the status and interrupt facility is a special AVS/Express object called the Scheduler, which is located immediately under Root in the object hierarchy. An application must interact with the Scheduler to utilize the available status and interrupt capabilities. Interaction is through user-interface connections to the Scheduler's four external-user subobjects:
For example, if you want to display the current module to the user, you typically connect a UItext widget to the Scheduler.current_mod subobject.
See Connecting a User Interface to the Scheduler on page 12-5.
Detailed descriptions of the Schedule subobjects are as follows:
For more information on setting Scheduler.percent_done and Scheduler.current_mod, see Setting and Querying Information from an Update Function on page 12-8.
You can connect your application to the Scheduler either from the standard user interface or from a custom interface that you build.
AVS/Express supplies a standard user interface for displaying the information in the Scheduler as part of the SingleWindowApp and MultiWindowApp DataViewers. This interface, which appears below the Module panel, consists of simple User Interface widgets attached to Scheduler.percent_done, Scheduler.current_mod, Scheduler.interrupt, and Scheduler.disable subobjects.
Note that you can also access a control panel interface to the Scheduler from the control menu on a ModuleStack.
You can display Scheduler information in a user interface customized for your application. Simply build the user interface as you would build any user interface, inserting appropriate widgets for the Scheduler subobjects that you want to display.
To use your custom interface, connect each widget's value, label, or set subobject to the appropriate subobject in the Scheduler. Note that the Scheduler does not appear in the Network Object, hence you cannot draw a connection line to the appropriate subobject. Instead, you must enter a connection in the widget subobject's value box. For example, to refer to Scheduler.interrupt, enter the connection operator followed by Scheduler.interrupt:
Most widgets have no special execution priority. When the user interacts with a widget, the Object Manager executes the widget's update method after it handles any other methods already in the queue. However, when the user selects the interrupt toggle, it is desirable for the Scheduler.interrupt subobject to be updated immediately. An executing module's function can then query Scheduler.interrupt (by calling OMstatus_check) and take the appropriate action.
To enable an immediate update, connect a UIdynamic_toggle widget rather than a UItoggle widget to the Schedule.interrupt subobject. UIdynamic_toggle is similar to UItoggle, except that the Object Manager executes its update method immediately.
AVS/Express can use UIdynamic_toggle for immediate updates because it contains a subobject of type UImake_dyn_wind (dyn_wind stands for dynamic window), whose handle subobject is connected to UIdynamic_toggle's handle subobject. You can customize any widget in the same way to achieve the same affect.
A module's update method uses object properties to declare whether the Object Manager should display status information for the module and whether the module is interruptible.
By default, a method does not display status information. You enable and disable its display by setting the method object's status property in the Properties Editor. The following values are allowed:
By default, a method can be interrupted and disabled. You enable and disable interruptibility by setting the method object's interruptible property in the Properties Editor. The following values are allowed:
Disabling interruptibility allows a method to continue to execute even when the system is disabled. You might want to do this in order to allow user interface objects to continue to provide feedback in those circumstances.
The update function associated with a method can call Object Manager API routines to set and query Scheduler information. This section describes the C API routines; for information on equivalent C++ API and FORTRAN API routines, see Chapter 9, Object Manager APIs.
A function can do the following by calling the OMstatus_check routine:
For a description of OMstatus_check, see the AVS/Express online help system.
A function can also normalize Scheduler.percent_done; see the next section for details.
A function sets Scheduler.percent_done by calling the OMstatus_check routine. By indicating in advance a percent range, it can also normalize this subobject. For example, suppose that it does the following:
The Object Manager then normalizes Scheduler.percent_done to 5; that is, 25 percent of 20.
To specify a percent range, a function calls the OMpush_status_range routine and pushes the range onto a stack that the Object Manager maintains. Note that you are not restricted to pushing a single range onto the stack: you can push and pop multiple percent ranges onto and off the Object Manager's stack. (To pop a range off the stack, the function calls OMpop_status_range.) When the Object Manager normalizes, it uses the top range in the stack. This feature is useful when the work of an update function is split among several other functions that the update function calls: the update function uses the push and pop functionality to set percent ranges for the other functions.
For descriptions of OMpush_status_range and OMpop_status_range, see the AVS/Express online help system.
The following example module code illustrates pushing and popping ranges onto and off the Object Manager's stack.
The ~express/include/avs/util.h file was updated in AVS/Express 3.1 to include changes that will safeguard against memory allocation errors. The util.h file contains the following three macros for memory allocation:
These macros will execute if the pointer returned from malloc or alloc is NULL; when this happens, a dialog box titled "Memory Allocation FAILED" is displayed with a "Save State and Exit, or Retry Allocation?" message.
If you respond by selecting YES, the current system state is saved before exiting. If you respond by selecting NO, you can perform any memory cleanup on your own and then retry the allocation.
![]() |
![]() |
![]() |
![]() |