CHAILink SDK
Version 1.3
|
Almost all CHAI functionalities are available when using the CHAILink Client SDK, but its architecture implies differences in programming models.
In the CHAILink Client, CHAI objects are manipulated through their handle and not via their interface pointer. There are two types of handle:
An exception exists for performance messages (Event, Modifier, Selector, ...). These are handled directly and their message data are transferred in data structures (see CPEVENTMSG, CPMODIFIERMSG, ...).
In the CHAILink, instead of calling a method from an interface pointer, a function is called with the object handle as its first parameter. Each CHAILink function return a standard code (CLC_ErrorCode), CopperLan return codes (CPNS::Enums::Errors in CHAI Errors in CHAILink) and Boolean return codes are included in this CHAILink return code:
Example:
In CHAI
In CHAILink
For object numeric properties, the CHAILink typically uses a function called xxx_GetInfo to retrieve all these parameters in one call to the CHAI.
Example:
In CHAI
In CHAILink
In the standard CHAI SDK, usually, to register a notification on an object, a method is called with an interface pointer as parameter. This interface pointer contains a set of handler called when the object wants to notify the application. In CHAILink Client, notifications are global. Each notification has a unique callback function associated to it, and all instances use it. To identify the source of the notification, the object handle is passed as the first parameter of the callback function. The second parameter of the notification is a 32 bit data associated by the application to the handle during the object creation. All the notifications (callback function pointer) are stored in a CLC_NH_CallbackList structure and are passed to the CHAILink Client during initialization (see CLC_Init and CLC_Callbacks for more information). Except for the CHAI which is unique, the notifications are enabled independently per object even if the same Callback function pointer is used for all instances.
Example: Registration of the Notification Handler for an ILocalDevice
In CHAI
In CHAILink
Asynchronous Returns for Asynchronous Calls also differ from standard CHAI development in some points:
dwClientContextData
.Example: The GetNamAsync call on a IRemoteDevice
In CHAI
In CHAILink
Contrarily to the CHAI, the CHAILink Client is designed to work in a cooperative single threaded environment, with or without OS.