Initialization
[EDT Digital Imaging Library]


Detailed Description

Read configuration files and initialize the board and camera.

Typically the external utility program initcam handles these tasks (possibly invoked by an EDT application such as pdvshow or camconfig.) initcam calls these subroutines to do the work, and they are avaiable as well for programmers who wish to invoke them directly from a user application. See the initcam.c source code for an example of how how to use these subroutines to read configration files and initialize the board from within an application.


Functions

Dependentpdv_alloc_dependent ()
 Allocates a dependent structure, for use by pdv_readcfg and pdv_initcam, and checks for and reports error conditions as a result of the alloc.
int pdv_auto_set_timeout (PdvDev *pdv_p)
 Sets a reasonable image timeout value based on image size and exposure time (if set) and pixel clock speed (also if set).
int pdv_initcam (EdtDev *pdv_p, Dependent *dd_p, int unit, Edtinfo *ei_p, const char *cfgfname, char *bitdir, int pdv_debug)
 Initializes the framegrabber board and camera.
int pdv_readcfg (const char *cfgfile, Dependent *dd_p, Edtinfo *ei_p)
 Reads a configuration file and fills in the dependent and edtinfo structures based on the information in the file.


Function Documentation

Dependent* pdv_alloc_dependent (  ) 

Allocates a dependent structure, for use by pdv_readcfg and pdv_initcam, and checks for and reports error conditions as a result of the alloc.

The structure can be deallocated with free() later.

Returns:
pointer to a Dependent structure (defined in camera.h).
See also:
pdv_initcam, initcam.c and camera.h source files.

Definition at line 240 of file pdv_initcam.c.

int pdv_auto_set_timeout ( PdvDev pdv_p  ) 

Sets a reasonable image timeout value based on image size and exposure time (if set) and pixel clock speed (also if set).

Note:
This subroutine is called by pdv_initcam so it generally isn't necessary to call it from a user application. Nevertheless it can be useful to know how initcam sets the default timeout value (and how to override it); hence this description.

pdv_initcam calls this subroutine after reading in the various camera parameters from the config file. Since most configs don't (presently) have a pclock_speed directive specified, it assumes a conservative 5 Mhz pixel clock speed, which can make for a long timeout value. As a result, for faster cameras in general, and large format ones specifically, if data loss occurs for whatever reason, the pdv_wait acquisition routines may block for an excessively long time if data loss occurs. To get around this, either add a pclock_speed directive to the config file (preferred), or set your own fixed timeout override with the user_timeout directive or pdv_set_timeout.

See also:
pdv_initcam, pdv_set_timeout, pdv_set_exposure, pclock_speed & user_timeout directive in the Camera Configuration Guide
Returns:
0 on success, -1 on failure.

int pdv_initcam ( EdtDev pdv_p,
Dependent dd_p,
int  unit,
Edtinfo *  ei_p,
const char *  cfgfname,
char *  bitdir,
int  pdv_debug 
)

Initializes the framegrabber board and camera.

This is the "guts" of the inticam program that gets executed to initialize when you choose a camera. The library subroutine is provided for programmers who wish to incorporate the initialization procedure into their own applications.

Note:
unlike other pdv library calls, pdv_inticam requires an edt device pointer returned from edt_open or edt_open_channel. After initializing, close the device with edt_close before reopening with pdv_open_channel or pdv_open for futher use.

pdv_initcam is designed to initialize EDT framegrabber (input) boards only. For simulator boards, (e.g. the PCIe8 DVa CLS) see the clsiminit.c example/utility application.

Parameters:
pdv_p pointer to edt device structure returned by edt_open
dd_p pointer to a previously allocated (via pdv_alloc_dependent) and initialized (through pdv_readcfg) dependent structure. The library uses this until it is either freed by edt_close, or no longer used by later calls to this function (which means that if you call pdv_initcam again, you should free() pdv_p->dd_p first to avoid memory leaks).
unit unit number of the device. The first unit is 0.
edtinfo miscellaneous variable information structure, defined in initcam.h, initialized via pdv_readcfg.
cfgfname path name of configuration file.
bitdir directory path name for .bit (FPGA) files. If NULL, pdv_initcam will search for bitfiles under ".", then "./camera_config/bitfiles".
pdv_debug should be set to 0 (but is ignored currently).
Returns:
0 on success, -1 on failure
Example
Note:
The following is simplified example code. Normally, we would check the return values and handle error conditions. See initcam.c for a complete example of reading the configuration file and configuring the pdv device driver and camera.
 Dependent *dd_p;
 Edtinfo ei_p;
 EdtDev *edt_p;
 int unit, channel;
 char* unitstr = argv[1];

 dep = pdv_alloc_dependent();
 pdv_readcfg(cfgfname, dd_p, &edtinfo);
 unit = edt_parse_unit_channel(unitstr, edt_devname, "pdv", &channel);
 edt_p = edt_open_channel(edt_devname, unit, channel);
 pdv_initcam(edt_p, dd_p, unit, &ei_p, cfgfname, bitdir, 0);
 edt_close(edt_p);
 free(dd_p);

See also:
pdv_readcfg, initcam.c source code

Definition at line 135 of file pdv_initcam.c.

int pdv_readcfg ( const char *  cfgfile,
Dependent dd_p,
Edtinfo *  ei_p 
)

Reads a configuration file and fills in the dependent and edtinfo structures based on the information in the file.

These structures can then be passed in to pdv_initcam to initialize the board and camera.

Parameters:
cfgfile path name of configuration file to read
dd_p device and camera dependent information structure to fill in, defined in camera.h (user-allocated -- see pdv_alloc_dependent) -- persistent (stored in the driver)
ei_p structure holding non-persistent initialization strings and variables (information not in dd_p). Defined in initcam.h.
Returns:
0 on success, -1 on failure
See also:
pdv_initcam, initcam.c and initcam.h Utility application source code

Definition at line 320 of file readcfg.c.


Generated on 19 Jun 2015 by  doxygen 1.4.7