|
Camera API Technical Report:
Example Code |
#include <stdio.h>
#include <X11/Intrinsic.h>
#include <camera.h>
/* define the camera set value callback. The procedure is provided
with camera pointer, the data pointer installed with the callback
and the value type of the set attribute */
void camera_controls_callback( camera, client_data, val_type )
Camera camera;
XtPointer *client_data;
CameraValueType val_type;
{
Widget controls = (Widget) client_data;
switch( val_type ){ /* test for values in the dialog */
case CV_X_Binning:
case CV_Y_Binning:
/* reset the interface etc */
break;
.
.
.
}
return;
}
/* define a camera error handler. The procedure is provided with the
camera pointer, the data pointer installed with the handler and
a pointer to an error data structure. */
static int camera_error_handler( cam, data, error )
Camera cam;
caddr_t data;
CameraError *error;
{
Widget dialog = (Widget) data;
String str;
str = (String) malloc(sizeof(char) *
(strlen(CameraName(cam)) +
strlen(error->srcstr) +
strlen(error->errstr) + 40));
(void) sprintf(str, "%s camera error\nsource: %s\nerror: %s",
CameraName(cam), error->srcstr, error->errstr);
HGU_XmUserError( dialog, str, 0 );
free( str );
}
.
.
Camera camera;
/* open the camera initialise etc. etc. */
/* create the camera interface */
dialog = create_camera_interface( camera );
/* add an error handler */
CameraSetErrHandler( camera, camera_error_handler, dialog );
/* add a callback to the camera to reset interface values */
CameraAddSetCallback( camera, camera_controls_callback, dialog );
.
.
The CameraError structure contains an error-string, a source-string
and an error number. In this version of the library the error number is not
used.
Note the SetCallback is a callback list. Any number of functions can be added to the list and will be called in the order they were added to the list.