Opens one or more services on the specified context.
DWORD ctaOpenServices ( CTAHD ctahd, CTA_SERVICE_DESC svclist[], unsigned nsvcs)
|
Argument |
Description |
|
ctahd |
Context handle. |
|
svclist |
List of services to open on the context. The CTA_SERVICE_DESC structure is typedef struct The CTA_SERVICE_NAME structure is: typedef struct The CTA_SERVICE_ADDR structure is reserved and should be initialized to zero (0). The CTA_SERVICE_ARGS structure is: typedef struct The CTA_MVIP_ADDR structure is: typedef struct
|
|
nsvcs |
Number of services in svclist. |
|
Return value |
Description |
|
SUCCESS |
|
|
CTAERR_INVALID_CTAHD |
|
|
CTAERR_INVALID_SEQUENCE |
There is a pending open or close service on the context. |
|
CTAERR_NOT_FOUND |
One or more of the services in svclist was not registered with Natural Access, the application requested a service on a local or remote server that is not specified in the server configuration file (for example, cta.cfg), or the service manager was not attached to the event queue. |
|
CTAERR_NOT_INITIALIZED |
Natural Access is not initialized. Call ctaInitialize first. |
|
CTAERR_SERVICE_IN_USE |
One or more of the services is already open on the context. |
|
CTAERR_SVR_COMM |
Server communication error. |
CTAEVN_OPEN_SERVICES_DONE
The event value field contains the open services completion status. If the value is CTA_REASON_FINISHED, then all services were successfully opened.
|
Caution: |
If the event value field is not CTA_REASON_FINISHED, one of the services failed to open. The resources associated with all of the services listed in svclist are de-allocated and the context is returned to its state just before to the call to ctaOpenServices. |
ADI Service
The following errors can be returned in the event value field:
|
Error |
Description |
|
ADIERR_CANNOT_CREATE_CHANNEL |
Out of resources on board. |
|
ADIERR_OUTPUT_ACTIVE |
The DSP timeslot is in use. |
|
CTAERR_BAD_ARGUMENT |
Invalid MVIP stream, timeslot, or mode. |
|
CTAERR_INVALID_BOARD |
Invalid board number; board was not configured by the configuration utility. |
Voice Message Service and Switching Service
No errors will be returned when opening either of these services.
This function opens one or more services on the specified context (ctahd). If any service fails to open, then all services successfully opened in this call will be closed and a service-specific error is returned in the value field of the CTAEVN_OPEN_SERVICES_DONE event.
Note: Ensure that the services you open on a context are services that are specified in the server configuration file.
ctaOpenServices is asynchronous and returns immediately. When all services are successfully opened, a DONE event returns to the application via the application event queue.
void DemoOpenPort(
unsigned userid, /* for ctaCreateContext */
char *contextname, /* for ctaCreateContext */
CTA_SERVICE_DESC services[], /* for ctaOpenServices */
unsigned numservices, /* number of "services" */
CTAQUEUEHD *pctaqueuehd, /* returned Natural Access queue handle*/
CTAHD *pctahd) /* returned Natural Access context hd */
{
CTA_EVENT event = { 0 };
/* Open the Natural Access application queue, attaching all defined
* service managers.
*/
ctaCreateQueue( NULL, 0, pctaqueuehd );
/* Create a Natural Access context */
ctaCreateContext( *pctaqueuehd, userid, contextname, pctahd );
/* Open services */
ctaOpenServices( *pctahd, services, numservices );
/* Wait for the service manager and services to be opened asynchronously */
do
{
ctaWaitEvent( *pctaqueuehd, &event, CTA_WAIT_FOREVER );
} while (event.id != CTAEVN_OPEN_SERVICES_DONE);
if (event.value != CTA_REASON_FINISHED)
printf ("Opening services failed: val=0x%x\n", event.value );
}
void DemoStartLine(DEMOCONTEXT *cx)
{
char cxname[12];
CTA_SERVICE_DESC services[] = /* for ctaOpenServices */
{ { {"ADI", "ADIMGR"}, { 0 }, { 0 }, { 0 } },
{ {"SWI", "SWIMGR"}, { 0 }, { 0 }, { 0 } },
{ {"VCE", "VCEMGR"}, { 0 }, { 0 }, { 0 } }
};
/* Fill in ADI service (index 0) MVIP address information */
services[0].mvipaddr.board = cx->ag_board;
services[0].mvipaddr.stream = cx->mvip_stream;
services[0].mvipaddr.timeslot = cx->mvip_slot;
services[0].mvipaddr.mode = ADI_FULL_DUPLEX;
/* Context name will be printed in all trace records for this context */
sprintf( cxname, "DEMOCX%04d", cx->line );
DemoOpenPort( 0, "DEMOCONTEXT", services,
sizeof(services)/sizeof(services[0]),
&(cx->ctaqueuehd), &(cx->ctahd) );
}
Note: For QX boards, replace ADIMGR with QDIMGR.