diff options
-rw-r--r-- | src/cameras/dummy.c | 6 | ||||
-rw-r--r-- | src/cameras/pco.c | 16 | ||||
-rw-r--r-- | src/cameras/pf.c | 6 | ||||
-rw-r--r-- | src/grabbers/me4.c | 16 | ||||
-rw-r--r-- | src/uca-cam.h | 15 | ||||
-rw-r--r-- | src/uca-grabber.h | 10 | ||||
-rw-r--r-- | src/uca.h | 13 |
7 files changed, 69 insertions, 13 deletions
diff --git a/src/cameras/dummy.c b/src/cameras/dummy.c index 58aa591..2bb0400 100644 --- a/src/cameras/dummy.c +++ b/src/cameras/dummy.c @@ -281,6 +281,11 @@ static uint32_t uca_dummy_destroy(struct uca_camera *cam) return UCA_NO_ERROR; } +static uint32_t uca_dummy_ignore(struct uca_camera *cam) +{ + return UCA_NO_ERROR; +} + uint32_t uca_dummy_init(struct uca_camera **cam, struct uca_grabber *grabber) { struct uca_camera *uca = uca_cam_new(); @@ -290,6 +295,7 @@ uint32_t uca_dummy_init(struct uca_camera **cam, struct uca_grabber *grabber) uca->get_property = &uca_dummy_get_property; uca->start_recording = &uca_dummy_start_recording; uca->stop_recording = &uca_dummy_stop_recording; + uca->trigger = &uca_dummy_ignore; uca->grab = &uca_dummy_grab; uca->register_callback = &uca_dummy_register_callback; diff --git a/src/cameras/pco.c b/src/cameras/pco.c index b3ff872..6c4f93f 100644 --- a/src/cameras/pco.c +++ b/src/cameras/pco.c @@ -69,6 +69,7 @@ static uint32_t uca_pco_set_property(struct uca_camera *cam, enum uca_property_i if (pco_set_roi(pco_d->pco, pco_d->roi) != PCO_NOERROR) return err | UCA_ERR_OUT_OF_RANGE; + /* Twice the width because of 16 bits per pixel */ uint32_t w = cam->frame_width * 2; grabber->set_property(grabber, UCA_PROP_WIDTH, &w); break; @@ -232,6 +233,7 @@ static uint32_t uca_pco_start_recording(struct uca_camera *cam) return err | UCA_ERR_UNCLASSIFIED; if (pco_set_rec_state(pco, 1) != PCO_NOERROR) return err | UCA_ERR_UNCLASSIFIED; + cam->state = UCA_CAM_RECORDING; return cam->grabber->acquire(cam->grabber, -1); } @@ -239,9 +241,18 @@ static uint32_t uca_pco_stop_recording(struct uca_camera *cam) { if (pco_set_rec_state(GET_PCO(cam), 0) != PCO_NOERROR) return UCA_ERR_CAMERA | UCA_ERR_INIT | UCA_ERR_UNCLASSIFIED; + cam->state = UCA_CAM_ARMED; return UCA_NO_ERROR; } +static uint32_t uca_pco_trigger(struct uca_camera *cam) +{ + if (cam->state != UCA_CAM_RECORDING) + return UCA_ERR_CAMERA | UCA_ERR_TRIGGER | UCA_ERR_NOT_RECORDING; + + return cam->grabber->trigger(cam->grabber); +} + static uint32_t uca_pco_grab(struct uca_camera *cam, char *buffer, void *meta_data) { uint16_t *frame; @@ -288,13 +299,14 @@ uint32_t uca_pco_init(struct uca_camera **cam, struct uca_grabber *grabber) uca->get_property = &uca_pco_get_property; uca->start_recording = &uca_pco_start_recording; uca->stop_recording = &uca_pco_stop_recording; + uca->trigger = &uca_pco_trigger; uca->grab = &uca_pco_grab; uca->register_callback = &uca_pco_register_callback; /* Prepare camera for recording */ pco_set_scan_mode(pco, PCO_SCANMODE_SLOW); pco_set_rec_state(pco, 0); - pco_set_timestamp_mode(pco, 2); + pco_set_timestamp_mode(pco, UCA_TIMESTAMP_ASCII); pco_set_timebase(pco, 1, 1); pco_arm_camera(pco); @@ -305,7 +317,7 @@ uint32_t uca_pco_init(struct uca_camera **cam, struct uca_grabber *grabber) val = UCA_FORMAT_GRAY8; grabber->set_property(grabber, UCA_GRABBER_FORMAT, &val); - val = UCA_TRIGGER_FREERUN; + val = UCA_TRIGGER_AUTO; grabber->set_property(grabber, UCA_GRABBER_TRIGGER_MODE, &val); uint32_t width, height; diff --git a/src/cameras/pf.c b/src/cameras/pf.c index b787f5c..aa05df6 100644 --- a/src/cameras/pf.c +++ b/src/cameras/pf.c @@ -171,6 +171,11 @@ static uint32_t uca_pf_stop_recording(struct uca_camera *cam) return cam->grabber->stop_acquire(cam->grabber); } +static uint32_t uca_pf_trigger(struct uca_camera *cam) +{ + return cam->grabber->trigger(cam->grabber); +} + static uint32_t uca_pf_grab(struct uca_camera *cam, char *buffer, void *metadata) { uint16_t *frame; @@ -217,6 +222,7 @@ uint32_t uca_pf_init(struct uca_camera **cam, struct uca_grabber *grabber) uca->get_property = &uca_pf_get_property; uca->start_recording = &uca_pf_start_recording; uca->stop_recording = &uca_pf_stop_recording; + uca->trigger = &uca_pf_trigger; uca->grab = &uca_pf_grab; uca->register_callback = &uca_pf_register_callback; diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c index 1c63f1a..f0120bb 100644 --- a/src/grabbers/me4.c +++ b/src/grabbers/me4.c @@ -34,8 +34,8 @@ static struct uca_sisofg_map_t uca_to_fg[] = { { UCA_PROP_EXPOSURE, FG_EXPOSURE, false }, { UCA_PROP_GRAB_TIMEOUT, FG_TIMEOUT, false }, - { UCA_GRABBER_TRIGGER_MODE, FG_TRIGGERMODE, true}, - { UCA_GRABBER_FORMAT, FG_FORMAT, true}, + { UCA_GRABBER_TRIGGER_MODE, FG_TRIGGERMODE, true }, + { UCA_GRABBER_FORMAT, FG_FORMAT, true }, { UCA_GRABBER_CAMERALINK_TYPE, FG_CAMERA_LINK_CAMTYP, true }, /* values */ @@ -43,7 +43,9 @@ static struct uca_sisofg_map_t uca_to_fg[] = { { UCA_FORMAT_GRAY16, FG_GRAY16, false }, { UCA_CL_8BIT_FULL_8, FG_CL_8BIT_FULL_8, false }, { UCA_CL_8BIT_FULL_10, FG_CL_8BIT_FULL_10, false }, - { UCA_TRIGGER_FREERUN, FREE_RUN, false }, + { UCA_TRIGGER_AUTO, FREE_RUN, false }, + { UCA_TRIGGER_SOFTWARE, ASYNC_SOFTWARE_TRIGGER, false }, + { UCA_TRIGGER_EXTERNAL, ASYNC_TRIGGER, false }, { UCA_GRABBER_INVALID, 0, false } }; @@ -195,6 +197,13 @@ static uint32_t uca_me4_stop_acquire(struct uca_grabber *grabber) return UCA_NO_ERROR; } +static uint32_t uca_me4_trigger(struct uca_grabber *grabber) +{ + if (Fg_sendSoftwareTrigger(GET_FG(grabber), PORT_A) != FG_OK) + return UCA_ERR_GRABBER | UCA_ERR_TRIGGER; + return UCA_NO_ERROR; +} + static uint32_t uca_me4_grab(struct uca_grabber *grabber, void **buffer, uint64_t *frame_number) { static frameindex_t last_frame = 0; @@ -270,6 +279,7 @@ uint32_t uca_me4_init(struct uca_grabber **grabber) uca->alloc = &uca_me4_alloc; uca->acquire = &uca_me4_acquire; uca->stop_acquire = &uca_me4_stop_acquire; + uca->trigger = &uca_me4_trigger; uca->grab = &uca_me4_grab; uca->register_callback = &uca_me4_register_callback; diff --git a/src/uca-cam.h b/src/uca-cam.h index f12bb12..e582066 100644 --- a/src/uca-cam.h +++ b/src/uca-cam.h @@ -140,6 +140,14 @@ typedef uint32_t (*uca_cam_start_recording) (struct uca_camera *cam); typedef uint32_t (*uca_cam_stop_recording) (struct uca_camera *cam); /** + * Send a software trigger signal to start a sensor read-out. + * + * This method is only useful when UCA_PROP_TRIGGER_MODE is set to + * UCA_TRIGGER_SOFTWARE. + */ +typedef uint32_t (*uca_cam_trigger) (struct uca_camera *cam); + +/** * Function pointer to a grab callback. * * Register such a callback function with uca_cam_register_callback() to @@ -187,6 +195,7 @@ typedef uint32_t (*uca_cam_register_callback) (struct uca_camera *cam, uca_cam_g typedef uint32_t (*uca_cam_grab) (struct uca_camera *cam, char *buffer, void *meta_data); + /** * Represents a camera abstraction, that concrete cameras must implement. */ @@ -224,6 +233,12 @@ typedef struct uca_camera { uca_cam_stop_recording stop_recording; /** + * Method to issue a software trigger signal. + * \see uca_cam_trigger + */ + uca_cam_trigger trigger; + + /** * Method to grab a frame. * \see uca_cam_grab */ diff --git a/src/uca-grabber.h b/src/uca-grabber.h index 885e0b6..e8b422a 100644 --- a/src/uca-grabber.h +++ b/src/uca-grabber.h @@ -23,9 +23,7 @@ enum uca_grabber_constants { UCA_FORMAT_GRAY16, UCA_CL_8BIT_FULL_8, - UCA_CL_8BIT_FULL_10, - - UCA_TRIGGER_FREERUN + UCA_CL_8BIT_FULL_10 }; @@ -86,6 +84,11 @@ typedef uint32_t (*uca_grabber_acquire) (struct uca_grabber *grabber, int32_t n_ typedef uint32_t (*uca_grabber_stop_acquire) (struct uca_grabber *grabber); /** + * Issue a software trigger signal. + */ +typedef uint32_t (*uca_grabber_trigger) (struct uca_grabber *grabber); + +/** * Grab a frame. * * This method is usually called through the camera interface and not directly. @@ -126,6 +129,7 @@ typedef struct uca_grabber { uca_grabber_alloc alloc; uca_grabber_acquire acquire; uca_grabber_stop_acquire stop_acquire; + uca_grabber_trigger trigger; uca_grabber_grab grab; uca_grabber_register_callback register_callback; @@ -123,13 +123,14 @@ enum uca_property_ids { }; /* Possible timestamp modes for UCA_PROP_TIMESTAMP_MODE */ +#define UCA_TIMESTAMP_NONE 0x00 #define UCA_TIMESTAMP_ASCII 0x01 #define UCA_TIMESTAMP_BINARY 0x02 /* Trigger mode for UCA_PROP_TRIGGER_MODE */ #define UCA_TRIGGER_AUTO 1 /**< free-run mode */ -#define UCA_TRIGGER_SOFTWARE 2 -#define UCA_TRIGGER_EXTERNAL 3 +#define UCA_TRIGGER_SOFTWARE 2 /**< software trigger via uca_cam_trigger() */ +#define UCA_TRIGGER_EXTERNAL 3 /**< external hardware trigger */ #define UCA_TRIGGER_EXP_CAMERA 1 /**< camera-controlled exposure time */ #define UCA_TRIGGER_EXP_LEVEL 2 /**< level-controlled (trigger signal) exposure time */ @@ -200,8 +201,8 @@ typedef struct uca_property { const char *name; enum uca_unit unit; - enum uca_access_rights access; enum uca_types type; + enum uca_access_rights access; } uca_property_t; @@ -247,6 +248,7 @@ extern const char *uca_unit_map[]; /**< maps unit numbers to corresponding #define UCA_ERR_INIT 0x00100000 /**< error during initialization */ #define UCA_ERR_PROP 0x00200000 /**< error while setting/getting property */ #define UCA_ERR_CALLBACK 0x00300000 /**< callback-related errors */ +#define UCA_ERR_TRIGGER 0x00400000 /**< errors concerning trigger */ #define UCA_ERR_FAILURE 0x10000000 #define UCA_ERR_WARNING 0x20000000 @@ -258,8 +260,9 @@ extern const char *uca_unit_map[]; /**< maps unit numbers to corresponding #define UCA_ERR_OUT_OF_RANGE 0x10000005 #define UCA_ERR_ACQUIRE 0x10000006 #define UCA_ERR_IS_RECORDING 0x10000007 /**< error because device is recording */ -#define UCA_ERR_FRAME_TRANSFER 0x10000008 -#define UCA_ERR_ALREADY_REGISTERED 0x10000009 +#define UCA_ERR_NOT_RECORDING 0x10000008 +#define UCA_ERR_FRAME_TRANSFER 0x10000009 +#define UCA_ERR_ALREADY_REGISTERED 0x1000000A /** * Keeps a list of cameras and grabbers. |