diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2012-10-18 12:44:40 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-10-18 13:38:41 +0200 |
commit | 983005dfbc3b07093145c0b964063e334b928d48 (patch) | |
tree | bcda1ab9dec89a08099de31b5cc4b5756d522d4e | |
parent | e16087fbe25df8901e9221602570c074ae887450 (diff) | |
download | uca-983005dfbc3b07093145c0b964063e334b928d48.tar.gz uca-983005dfbc3b07093145c0b964063e334b928d48.tar.bz2 uca-983005dfbc3b07093145c0b964063e334b928d48.tar.xz uca-983005dfbc3b07093145c0b964063e334b928d48.zip |
Fix download of in-camera frames
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | plugins/pco/uca-pco-camera.c | 25 | ||||
-rw-r--r-- | src/uca-camera.c | 44 | ||||
-rw-r--r-- | src/uca-camera.h | 3 | ||||
-rw-r--r-- | tools/gui/control.c | 10 |
5 files changed, 78 insertions, 6 deletions
@@ -23,6 +23,8 @@ Minor changes - It is now possible to generate GObject introspection meta data to bind libuca to all languages that support GObject introspection. +- Added uca_camera_stop_readout() to cleanup after using + uca_camera_start_readout(). Changes in libuca 1.0 aka 0.6 diff --git a/plugins/pco/uca-pco-camera.c b/plugins/pco/uca-pco-camera.c index d5f5593..03a1a17 100644 --- a/plugins/pco/uca-pco-camera.c +++ b/plugins/pco/uca-pco-camera.c @@ -385,7 +385,7 @@ check_pco_property_error (guint err, guint property_id) { if (err != PCO_NOERROR) { g_warning ("Call to libpco failed with error code %x for property `%s'", - err, + err, pco_properties[property_id]->name); } } @@ -523,10 +523,28 @@ uca_pco_camera_start_readout(UcaCamera *camera, GError **error) err = pco_get_num_images(priv->pco, priv->active_segment, &priv->num_recorded_images); HANDLE_PCO_ERROR(err); + err = Fg_AcquireEx(priv->fg, priv->fg_port, GRAB_INFINITE, ACQ_STANDARD, priv->fg_mem); + FG_SET_ERROR(err, priv->fg, UCA_PCO_CAMERA_ERROR_FG_ACQUISITION); + + priv->last_frame = 0; priv->current_image = 1; } static void +uca_pco_camera_stop_readout(UcaCamera *camera, GError **error) +{ + g_return_if_fail(UCA_IS_PCO_CAMERA(camera)); + UcaPcoCameraPrivate *priv = UCA_PCO_CAMERA_GET_PRIVATE(camera); + + guint err = Fg_stopAcquireEx(priv->fg, priv->fg_port, priv->fg_mem, STOP_SYNC); + FG_SET_ERROR(err, priv->fg, UCA_PCO_CAMERA_ERROR_FG_ACQUISITION); + + err = Fg_setStatusEx(priv->fg, FG_UNBLOCK_ALL, 0, priv->fg_port, priv->fg_mem); + if (err == FG_INVALID_PARAMETER) + g_warning(" Unable to unblock all\n"); +} + +static void uca_pco_camera_trigger(UcaCamera *camera, GError **error) { g_return_if_fail(UCA_IS_PCO_CAMERA(camera)); @@ -568,7 +586,7 @@ uca_pco_camera_grab(UcaCamera *camera, gpointer *data, GError **error) } pco_request_image(priv->pco); - priv->last_frame = Fg_getLastPicNumberBlockingEx(priv->fg, priv->last_frame+1, priv->fg_port, MAX_TIMEOUT, priv->fg_mem); + priv->last_frame = Fg_getLastPicNumberBlockingEx(priv->fg, priv->last_frame + 1, priv->fg_port, MAX_TIMEOUT, priv->fg_mem); if (priv->last_frame <= 0) { guint err = FG_OK + 1; @@ -1189,6 +1207,7 @@ uca_pco_camera_class_init(UcaPcoCameraClass *klass) camera_class->start_recording = uca_pco_camera_start_recording; camera_class->stop_recording = uca_pco_camera_stop_recording; camera_class->start_readout = uca_pco_camera_start_readout; + camera_class->stop_readout = uca_pco_camera_stop_readout; camera_class->trigger = uca_pco_camera_trigger; camera_class->grab = uca_pco_camera_grab; @@ -1383,7 +1402,7 @@ uca_pco_camera_init(UcaPcoCamera *self) camera = UCA_CAMERA (self); uca_camera_register_unit (camera, "sensor-width-extended", UCA_UNIT_PIXEL); uca_camera_register_unit (camera, "sensor-height-extended", UCA_UNIT_PIXEL); - uca_camera_register_unit (camera, "temperature", UCA_UNIT_DEGREE_CELSIUS); + uca_camera_register_unit (camera, "sensor-temperature", UCA_UNIT_DEGREE_CELSIUS); uca_camera_register_unit (camera, "cooling-point", UCA_UNIT_DEGREE_CELSIUS); uca_camera_register_unit (camera, "cooling-point-min", UCA_UNIT_DEGREE_CELSIUS); uca_camera_register_unit (camera, "cooling-point-max", UCA_UNIT_DEGREE_CELSIUS); diff --git a/src/uca-camera.c b/src/uca-camera.c index 9210a05..053dcca 100644 --- a/src/uca-camera.c +++ b/src/uca-camera.c @@ -543,6 +543,50 @@ uca_camera_start_readout (UcaCamera *camera, GError **error) } /** + * uca_camera_stop_readout: + * @camera: A #UcaCamera object + * @error: Location to store a #UcaCameraError error or %NULL + * + * Stop reading out frames. + * + * Since: 1.1 + */ +void +uca_camera_stop_readout (UcaCamera *camera, GError **error) +{ + UcaCameraClass *klass; + static GStaticMutex mutex = G_STATIC_MUTEX_INIT; + + g_return_if_fail (UCA_IS_CAMERA(camera)); + + klass = UCA_CAMERA_GET_CLASS(camera); + + g_return_if_fail (klass != NULL); + g_return_if_fail (klass->start_readout != NULL); + + g_static_mutex_lock (&mutex); + + if (camera->priv->is_recording) { + g_set_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_RECORDING, + "Camera is still recording"); + } + else { + GError *tmp_error = NULL; + + (*klass->stop_readout) (camera, &tmp_error); + + if (tmp_error == NULL) { + camera->priv->is_readout = FALSE; + g_object_notify (G_OBJECT (camera), "is-readout"); + } + else + g_propagate_error (error, tmp_error); + } + + g_static_mutex_unlock (&mutex); +} + +/** * uca_camera_set_grab_func: * @camera: A #UcaCamera object * @func: A #UcaCameraGrabFunc callback function diff --git a/src/uca-camera.h b/src/uca-camera.h index ef3bf14..78edd95 100644 --- a/src/uca-camera.h +++ b/src/uca-camera.h @@ -126,6 +126,7 @@ struct _UcaCameraClass { void (*start_recording) (UcaCamera *camera, GError **error); void (*stop_recording) (UcaCamera *camera, GError **error); void (*start_readout) (UcaCamera *camera, GError **error); + void (*stop_readout) (UcaCamera *camera, GError **error); void (*trigger) (UcaCamera *camera, GError **error); void (*grab) (UcaCamera *camera, gpointer *data, GError **error); @@ -141,6 +142,8 @@ void uca_camera_stop_recording (UcaCamera *camera, GError **error); void uca_camera_start_readout (UcaCamera *camera, GError **error); +void uca_camera_stop_readout (UcaCamera *camera, + GError **error); void uca_camera_trigger (UcaCamera *camera, GError **error); void uca_camera_grab (UcaCamera *camera, diff --git a/tools/gui/control.c b/tools/gui/control.c index 930c4d0..aaeeb75 100644 --- a/tools/gui/control.c +++ b/tools/gui/control.c @@ -311,15 +311,19 @@ on_download_button_clicked (GtkWidget *widget, ThreadData *data) ring_buffer_proceed (data->buffer); } - if (error->code != UCA_CAMERA_ERROR_END_OF_STREAM) { + if (error->code == UCA_CAMERA_ERROR_END_OF_STREAM) { guint n_frames = ring_buffer_get_num_blocks (data->buffer); gtk_adjustment_set_upper (data->frame_slider, n_frames - 1); gtk_adjustment_set_value (data->frame_slider, n_frames - 1); } - else { + else g_printerr ("Error while reading out frames: %s\n", error->message); - } + + uca_camera_stop_readout (data->camera, &error); + + if (error != NULL) + g_printerr ("Failed to stop reading out of camera memory: %s\n", error->message); } static void |