The Natural Access software is accompanied by source code to the tik sample service. The goal of the tik service is to embed software timer functionality (a ticker) into Natural Access by:
Encapsulating the details of interacting with the software timer into a Natural Access service.
Presenting a simple API to Natural Access applications.
The implementation of the software timer is meant to model a physical device. The software timer sends a command to the device and receives asynchronous messages back. From an application's perspective, the software timer is simply another managed resource available under Natural Access, as shown in the following illustration:
Software timer service architecture
In subsequent topics of this manual, each phase of writing a Natural Access service is illustrated using code fragments from the tik service. All tik-specific information is displayed in a tik service section that looks similar to the following illustration:
tik service
tik example information
All source code for the tik service is provided as part of the Natural Access Developer's kit and can be found in the nms\ctaccess\demos\tiksvc directory. Refer to this source code as you read the information about creating a Natural Access service.
The tik service includes the following files:
|
File |
Description |
|---|---|
|
tikapi.c |
Implements the service API by calling the corresponding SPI function and handling API errors. |
|
tikspi.c |
Implements the service SPI functions. |
|
tikdef.h |
Contains API data structures, function prototypes, and definitions. |
|
tikspi.h |
Contains SPI function prototypes. |
|
tikbnd.c |
Implements the service manager binding functions. |
|
tikcmd.c |
Implements the service functions which interface to the managed resource. |
|
tikcomms.c |
Contains communication logic to tik server (the driver interface). |
|
tikutils.c |
Contains miscellaneous functions. |
|
tikparm.pf |
ASCII parameter definition file (used to generate tikparm.c and tikparm.h). |
|
tiksys.h |
Contains internal data structures, function prototypes, and definitions. |
|
tikapi.def |
Windows export definition file for tik API. |
|
tikmgr.def |
Windows export definition file for tik service manager. |
|
makefile |
Makefile to build the tik service. |
To facilitate writing a service, a set of template source files (based on the tik service) is provided in nms\ctaccess\template\ctatmplt.
Template files exist for each of the files listed in the previous table. Use these skeleton template files to start constructing a new service.