Establishes a list of services available to a Natural Access application.
DWORD ctaInitialize ( CTA_SERVICE_NAME svcname[], unsigned nsvcs, CTA_INIT_PARMS *initparms)
|
Argument |
Description |
|
svcname |
Pointer to an array of service names to make available for the application process. The CTA_SERVICE_NAME structure is: typedef struct
|
|
nsvcs |
Number of services in svcname. |
|
initparms |
Pointer to a structure containing initialization parameters. The CTA_INIT_PARMS structure is: typedef struct See the Details section for a description of these fields. |
|
Return value |
Description |
|
SUCCESS |
|
|
CTAERR_ALREADY_DEFINED |
There is a duplicate service or service manager in svcname. |
|
CTAERR_ALREADY_INITIALIZED |
|
|
CTAERR_BAD_ARGUMENT |
initparms is NULL. |
|
CTAERR_BAD_SIZE |
initparms size field is not valid. |
|
CTAERR_FILE_NOT_FOUND |
The filename specified in CTA_INIT_PARMS is not found or cta.cfg is not found. |
|
CTAERR_FUNCTION_ACTIVE |
Two separate threads have called ctaInitialize at the same time. The first thread executes the function correctly, the second thread receives this error. |
|
CTAERR_INCOMPATIBLE_PARMS |
The same services provided by two or more service managers have different standard parameters. |
|
CTAERR_INCOMPATIBLE_REVISION |
One of the specified services/svcnames is incompatible with the Natural Access dispatcher. |
|
CTAERR_INVALID_LIB |
The specified action (usually setting ctaflags bits) could not be performed because the application is not linked to the appropriate Natural Access library. |
|
CTAERR_LOAD_LIB |
There was an error loading the Natural Access core library. |
|
CTAERR_NOT_FOUND |
One or more services are not found or listed services are not found in filename. |
|
CTAERR_SHAREMEM_ACCESS |
Shared system parameters or tracing is enabled but ctdaemon is not running, or the CTA_PARM_MGMT_SHARED bit is set in parmflags but one or more of the specified services is not being managed within ctdaemon. Update cta.cfg to contain all required services and restart ctdaemon. |
|
CTAERR_WRONG_COMPAT_LEVEL |
Installed Natural Access compatibility level is different from the application-specified compatibility level. |
None.
This function finds all service managers and services that the application needs. It should be called only once at application initialization.
Note: If you want to use a remote server but pass NULL for svcname and pass the configuration file name cta.cfg, cta.cfg on the local server may not specify the same available services as the remote server.
After ctaInitialize is called, global default parameters can be modified and retrieved, and event queues and contexts can be created and destroyed.
The CTA_INIT_PARMS structure contains the following fields:
|
Field |
Description |
|---|---|
|
size |
Size of the passed structure. |
|
parmflags |
Specifies where the global default parameters are stored.
Refer to Global default parameters for more information on parameter storage. |
|
traceflags |
Allows you to receive a backlog of trace information on a context when an error condition occurs. Enable this feature if you want to see what happens on a per-context basis when you get an error. Do not enable this feature if you want to observe trace information for all contexts.
To write all recently logged trace messages on a particular context to ctdaemon, call ctaLogTrace, specifying the context you want to analyze, and set the traceseverity argument to CTA_TRACE_SEVERITY_ERROR. These flags are ignored if using a local or remote server. |
|
daemonflags |
Set to zero (0). |
|
ctaflags |
Note: When this bit is set under UNIX, a process cannot fork. Each process must create its own session to the server.
|
|
filename |
Determines what file name is used to obtain the service names.
|
|
ctacompatlevel |
Set to CTA_COMPATLEVEL to verify Natural Access compatibility. To omit compatibility checking, set this value to zero (0). The compatibility level is changed if the release includes changes that require applications to be re-compiled because these changes are not backward compatible. Refer to Verifying compatibility for more information. |
|
reserved |
Reserved for future use. Set this value to zero (0). |
Refer to Initializing Natural Access applications for more information.
Refer to Contents of the Natural Access configuration file for information on the cta.cfg file. Refer to Natural Access server: ctdaemon for more information on ctdaemon.
ctaLogTrace, ctaQueryWaitObjects, ctaSetTraceLevel
static CTA_SERVICE_NAME InitServices[] = { { "ADI", "ADIMGR" },
{ "SWI", "SWIMGR" },
{ "VCE", "VCEMGR" } };
void DemoInitialize()
{
DWORD ret;
CTA_INIT_PARMS initparms = { 0 };
/* Initialize size of init parms structure */
initparms.size = sizeof(CTA_INIT_PARMS);
/* Use process global default parameters */
initparms.parmflags |= CTA_PARM_MGMT_LOCAL;
/* If daemon running then initialize tracing */
initparms.traceflags = CTA_TRACE_ENABLE;
/* Notify when Natural Access changes its internal list of wait objects*/
initparms.ctaflags = CTA_NOTIFY_UPDATE_WAITOBJS;
/* Verify Natural Access compatibility */
initparms.ctacompatlevel = CTA_COMPATLEVEL;
/* Initialize Natural Access */
ctaInitialize(InitServices,
sizeof(InitServices)/sizeof(InitServices[0]),
&initparms);
}
Note: For QX boards, replace ADIMGR with QDIMGR.