Impact Acquire SDK C
Locating Properties

To bind an object handle (::HOBJ) to a certain feature offered by the device at runtime the C interface offers several functions that can be used to do that. Let's assume an application wants to access a 64 bit integer property that is called Width and is located somewhere in the devices feature tree. In this case, we want to bind the property of the base setting. The code to bind the device feature to a C interface object would look more or less like this:

//-----------------------------------------------------------------------------
// This function will try to obtain the handle to a certain driver feature list
HOBJ getDriverList( HDRV hDrv, const char* pName, const char* pAddListName, TDMR_ListType type )
//-----------------------------------------------------------------------------
{
TDMR_ERROR dmrResult;
HOBJ hObj = INVALID_ID;
HLIST baseList;
// try to locate the base list for these property
if( ( dmrResult = DMR_FindList( hDrv, pAddListName, type, 0, &baseList ) ) == DMR_NO_ERROR )
{
// try to locate the property
if( ( objResult = OBJ_GetHandleEx( baseList, pName, &hObj, smIgnoreProperties | smIgnoreMethods, 0 ) ) != PROPHANDLING_NO_ERROR )
{
printf( "OBJ_GetHandle for %s failed: %d Handle: %d. This list might not be supported by this device\n", pName, objResult, hObj );
}
}
else
{
printf( "DMR_FindList failed: %d. Lists of type %d are not available for this device\n", dmrResult, type );
}
return hObj;
}
//-----------------------------------------------------------------------------
HOBJ getSettingProp( HDRV hDrv, const char* pSettingName, const char* pPropName )
//-----------------------------------------------------------------------------
{
return getDriverProperty( hDrv, pPropName, pSettingName, dmltSetting );
}
//-----------------------------------------------------------------------------
void myFun()
//-----------------------------------------------------------------------------
{
HDRV hDrv = getTheDriverHandleFromSomewhere();
HOBJ hProp = getSettingProp( hDrv, "Base", "Width" );
int64_type maxVal = 0;
// now the property is ready to use when available:
if( hProp != INVALID_ID )
{
OBJ_GetI64( hProp, &maxVal, 0 );
OBJ_SetI64( hProp, maxVal / 2 ); // set the width to half of its maximum value
}
else
{
// oops... The feature is not offered by this device
}
}
TDMR_ERROR
Errors reported by the device manager.
Definition mvDriverBaseEnums.h:2601
TDMR_ListType
Defines valid interface list types, which can be located using the function DMR_FindList().
Definition mvDeviceManager.h:585
@ DMR_NO_ERROR
The function call was executed successfully.
Definition mvDriverBaseEnums.h:2603
@ dmltSetting
Specifies a certain setting.
Definition mvDeviceManager.h:592
MVDMR_API TDMR_ERROR DMR_CALL DMR_FindList(HDRV hDrv, const char *pName, TDMR_ListType type, unsigned int flags, HLIST *phDevList)
Locates a specified list within the device drivers interface.
Definition mvDeviceManager.cpp:2295
const int INVALID_ID
A constant to check for an invalid ID returned from the property handling module.
Definition mvPropHandlingDatatypes.h:62
MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetHandleEx(HLIST hList, const char *pObjName, HOBJ *phObj, unsigned int searchMode, int maxSearchDepth)
Retrieves an objects handle.
Definition ObjectHandling.cpp:343
MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_SetI64(HOBJ hProp, int64_type val, int index)
Sets a property's value as a 64 bit integer value.
Definition ObjectHandling.cpp:2733
MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetI64(HOBJ hProp, int64_type *pVal, int index)
Receives a property's value as an integer value.
Definition ObjectHandling.cpp:2808
TPROPHANDLING_ERROR
Error codes of the module handling everything related to properties.
Definition mvPropHandlingDatatypes.h:382
const unsigned int smIgnoreProperties
When set property objects are not taken into account during a search.
Definition mvPropHandlingDatatypes.h:105
const unsigned int smIgnoreMethods
When set method objects are not taken into account during a search.
Definition mvPropHandlingDatatypes.h:99
@ PROPHANDLING_NO_ERROR
The operation has been executed successfully.
Definition mvPropHandlingDatatypes.h:384