Filling LUT with Content With the Basler Framegrabber API

In this section you find an example how you can easily fill a LUT with content during runtime. The method is based on the struct FieldParameterAccess. Documentation for the struct FieldParameterAccess and the function Fg_setParameterWithType() is available in the Basler Framegrabber API documentation.

Example Implementation:

This struct FieldParameterAccess allows access to array parameters of any type in a flexible way. Range accesses as well as single value accesses are both possible.

Example:

                
# include <fgrab_struct.h>
					
struct FieldParameterAccess singleaccess;
					
struct FieldParameterAccess rangeaccess; 
 	
				

To fill the LUT with content with the Basler Framegrabber API:

  1. Define the values of the LUT content

    Example:

    					 
    uint64_t primes[7] = { 1, 2, 3, 5, 7, 11, 13 }; 
     					
    uint32_t answer = 42; 
     				
    					
  2. Set up single value access or range access:

    1. FieldParameterAccess:: vtype: set the type of the included data

    2. FieldParameterAccess:: index: set the first index in the range

    3. FieldParameterAccess:: count: set the value count of the range

    4. A range of values according to the type of the included data: FieldParameterAccess:: p_double, p_int32_t, p_int64_t, p_uint32_t, or puint64_t

    Example:

    				
    // set up single value access 
    
    singleaccess.vtype = FG_PARAM_TYPE_UINT32_T; 
    
    singleaccess.index = 17; 
    
    singleaccess.count = 1; 
    
    singleaccess.p_uint32_t = &answer; 
    
     
    
    // set up range access 
    
    rangeaccess.vtype = FG_PARAM_TYPE_UINT64_T// every data value is an uint64_t 
    
    rangeaccess.index = 0; 
    
    rangeaccess.count = 7; 
    
    rangeaccess.p_uint64_t = primes; 
     				 
    				
  3. Write the content into the applet operator LUT

    Write the content into the applet Operator LUT using the function Fg_setParameterWithType().

    Example:

  4. Write the LUT Content to the Corresponding LUT Operators in the Compiled Hardware Applet

    For a VisualApplets design structure with two LUT operators as shown in screenshot above, you can write the LUT content to the corresponding LUT operators in the compiled hardware applet as:

    				
    retCode += Fg_setParameterWithType(fg, Fg_getParameterIdByName(fg, "Device1_Process0_LUT0 _LUTcontent"), 
    &singleaccess, 0, FG_PARAM_TYPE_STRUCT_FIELDPARAMACCESS); 
    
    retCode += Fg_setParameterWithType(fg, Fg_getParameterIdByName(fg, "Device1_Process0_LUT1 _LUTcontent"), 
    &rangeaccess, 0, FG_PARAM_TYPE_STRUCT_FIELDPARAMACCESS);