User`s guide
6 Defining Device-Specific Properties
6-12
IPropInfo functions you can retrieve the property name, its storage type and its
default value. This information is useful if you have a generic listener class that
handles multiple properties.
• value is a pointer to the location in memory where your adaptor stores the requested
property value.—The engine passes this value as a void*. Your getValue()
function must cast the value to the appropriate C++ data type. The following table
tells which C++ data type to cast to for all property types supported by the adaptor
kit.
imaqkit::PropertyTypes C++ Data Type
STRING char**
DOUBLE double*
INT int*
DOUBLE_ARRAY imaqkit::PropertyTypes::NDoubles*
INT_ARRAY imaqkit::PropertyTypes::NInts*
For nonscalar data types, strings, double arrays, and integer arrays, your listener
class must allocate sufficient memory for the current property value using the new[]
operator. The engine deletes this memory, calling delete[]. An example using a
string property is:
char** returnStr = reinterpret_cast<char**>(value);
*returnStr = imaqkit::imaqmalloc(sizeof(char) * (stringLength));
strcpy(*returnStr, currentPropertyValueString);
Suggested Algorithm for a getValue() Function
The design of the getValue() function varies with the needs of your device and the
facilities offered by its SDK. For example, you could create one get listener class that
handles value queries for all properties in a particular property container (general or
device-specific). In this case, the getValue() function includes a switch statement with
cases that handle each individual property.
Alternatively, define a separate get listener class for each property or each property
storage type. Then, the engine calls the specific listener for the property specified.
You also can define get listener classes that fit the way the device SDK organizes
property configuration. For example, if an SDK provides one function to configure all
device properties, you can define a get listener class for these properties.