# Natural Access environment

This topic describes:

- The Natural Access programming model

- The Natural Access components

- Managing parameters in Natural Access

For more detailed information about Natural Access and the ADI service, see the Natural Access Developer's Reference Manual and the ADI Service Developer's Reference Manual.

## Programming model

Natural Access employs an asynchronous programming model to take advantage of concurrent processing. Each function called returns immediately with either a return value of SUCCESS or an error code. Synchronous functions are complete when the return code is received.

For asynchronous operations, if the return value is SUCCESS, the function is successfully initiated, and the execution result arrives asynchronously. If the return code is not SUCCESS, the operation is not initiated and no events associated with the particular function are generated.

The execution result is indicated by an event or a series of events. An event is a data structure with an event ID that identifies an operation and operation-specific results. For more information about events in the Natural Access environment, refer to the Natural Access Developer's Reference Manual.

Natural Access provides common system error codes that all the services use. These error codes are defined in the header file ctaerr.h and have a CTAERR_ prefix. Refer to the Natural Access Developer's Reference Manual for detailed descriptions of Natural Access error codes, and to the ADI Service Developer's Reference Manual for detailed descriptions of ADI service error codes. Use ctaGetText to obtain the text description of an error code.

## Natural Access components

Natural Access organizes services and accompanying resources around a single processing unit called a context. To access service functionality, an application creates a context and attaches the services it requires. Only one instance of a service can be opened on a single context.

A context usually represents an application thread performing a related set of functions, such as controlling a single line. The context maintains defined parameters for each type of service, allowing each line to have its own characteristics.

Some contexts are not associated with a line. For example, an operation performing speech recognition on a buffer of data does not require a telephone line.

To use the DTM service in the Natural Access environment, an application must obtain a context and open the DTM service on it.

An event queue is the communication path from a service to an application. A service generates events indicating certain conditions or state changes. An application retrieves the events from the event queue.

When the event queue is created, you specify the service managers to be attached to it. Use the ADI service manager (ADIMGR) for the DTM service. When creating a context, you specify an associated event queue. All events from the services on the context are sent to the event queue attached to the context.

One queue can be created for the entire application process or multiple queues can be used. The number of queues you create depends on the programming model used. Some models use one queue to handle all contexts, and handle multiple telephone lines through the same queue. Other models use one queue for each telephone line.

## Managing parameters in Natural Access

Natural Access service characteristics can be altered by modifying associated parameters. Each parameter structure has default values that are sufficient for most applications.

Natural Access manages parameters for services on a context basis. The context maintains a copy of the parameters for all services opened on the context. This allows each operation to have its own characteristics.

The following Natural Access functions allow you to obtain or change parameter information:

- ctaGetParmByName retrieves a single field for a given parameter name.

- ctaSetParmByName modifies a single field for a given parameter name.

- ctaGetParmInfo retrieves a parameter field definition.

- ctaGetParms returns parameter values for a given parameter structure.

- ctaRefreshParms resets the values of all context parameters on a context to the global defaults.

Refer to the Natural Access Developer's Reference Manual for details about Natural Access parameter management and Natural Access functions.