diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2013-07-17 11:02:57 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2013-09-09 15:56:40 +0200 |
commit | 4e18ec2beb15ea5ff5c611a0a89b0eeafc428bda (patch) | |
tree | aa710ea04c7d39a375cf7ac6ed1628eea3eb1bc8 | |
parent | 1a79387862e9c83be04732a846d5e2063e210aae (diff) | |
download | uca-4e18ec2beb15ea5ff5c611a0a89b0eeafc428bda.tar.gz uca-4e18ec2beb15ea5ff5c611a0a89b0eeafc428bda.tar.bz2 uca-4e18ec2beb15ea5ff5c611a0a89b0eeafc428bda.tar.xz uca-4e18ec2beb15ea5ff5c611a0a89b0eeafc428bda.zip |
Set acquisition parameters
-rw-r--r-- | plugins/xkit/uca-xkit-camera.cc | 88 |
1 files changed, 66 insertions, 22 deletions
diff --git a/plugins/xkit/uca-xkit-camera.cc b/plugins/xkit/uca-xkit-camera.cc index 6ecae84..7b580a3 100644 --- a/plugins/xkit/uca-xkit-camera.cc +++ b/plugins/xkit/uca-xkit-camera.cc @@ -43,31 +43,31 @@ G_DEFINE_TYPE_WITH_CODE (UcaXkitCamera, uca_xkit_camera, UCA_TYPE_CAMERA, GQuark uca_xkit_camera_error_quark() { - return g_quark_from_static_string("uca-ufo-camera-error-quark"); + return g_quark_from_static_string("uca-xkit-camera-error-quark"); } enum { - PROP_SENSOR_TEMPERATURE = N_BASE_PROPERTIES, - PROP_FPGA_TEMPERATURE, - PROP_UFO_START, - N_MAX_PROPERTIES = 512 + PROP_POSITIVE_POLARITY = N_BASE_PROPERTIES, + N_PROPERTIES }; static gint base_overrideables[] = { PROP_NAME, PROP_SENSOR_WIDTH, PROP_SENSOR_HEIGHT, + PROP_SENSOR_MAX_FRAME_RATE, PROP_SENSOR_BITDEPTH, + PROP_EXPOSURE_TIME, PROP_ROI_X, PROP_ROI_Y, PROP_ROI_WIDTH, PROP_ROI_HEIGHT, + PROP_HAS_STREAMING, + PROP_HAS_CAMRAM_RECORDING, 0, }; -static GParamSpec *ufo_properties[N_MAX_PROPERTIES] = { NULL, }; - -static guint N_PROPERTIES; +static GParamSpec *xkit_properties[N_PROPERTIES] = { NULL, }; struct _UcaXkitCameraPrivate { GError *construct_error; @@ -75,7 +75,9 @@ struct _UcaXkitCameraPrivate { gint devices[4]; gint n_devices; gint device; + DevInfo info; + AcqParams acq; }; @@ -92,6 +94,14 @@ setup_xkit (UcaXkitCameraPrivate *priv) priv->device = priv->devices[0]; priv->interface->getDevInfo (priv->device, &priv->info); + /* TODO: find some sensible defaults */ + priv->acq.useHwTimer = TRUE; + priv->acq.enableCst = FALSE; + priv->acq.polarityPositive = TRUE; + priv->acq.mode = ACQMODE_ACQSTART_TIMERSTOP; + priv->acq.acqCount = 1; + priv->acq.time = 1.0; + return TRUE; } @@ -99,7 +109,15 @@ static void uca_xkit_camera_start_recording (UcaCamera *camera, GError **error) { + UcaXkitCameraPrivate *priv; + g_return_if_fail (UCA_IS_XKIT_CAMERA (camera)); + priv = UCA_XKIT_CAMERA_GET_PRIVATE (camera); + + if (priv->interface->setAcqPars (priv->device, &priv->acq)) { + g_set_error_literal (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_RECORDING, + "Could not set acquisition parameters"); + } } static void @@ -172,9 +190,15 @@ uca_xkit_camera_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - /* UcaXkitCameraPrivate *priv = UCA_XKIT_CAMERA_GET_PRIVATE(object); */ + UcaXkitCameraPrivate *priv = UCA_XKIT_CAMERA_GET_PRIVATE(object); switch (property_id) { + case PROP_EXPOSURE_TIME: + priv->acq.time = g_value_get_double (value); + break; + case PROP_POSITIVE_POLARITY: + priv->acq.polarityPositive = g_value_get_boolean (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); return; @@ -193,6 +217,10 @@ uca_xkit_camera_get_property (GObject *object, case PROP_NAME: g_value_set_string (value, priv->info.ifaceName); break; + case PROP_SENSOR_MAX_FRAME_RATE: + /* TODO: pretty arbitrary, huh? */ + g_value_set_float (value, 150.0f); + break; case PROP_SENSOR_WIDTH: g_value_set_uint (value, priv->info.rowLen); break; @@ -202,6 +230,15 @@ uca_xkit_camera_get_property (GObject *object, case PROP_SENSOR_BITDEPTH: g_value_set_uint (value, 11); break; + case PROP_EXPOSURE_TIME: + g_value_set_double (value, priv->acq.time); + break; + case PROP_HAS_STREAMING: + g_value_set_boolean (value, TRUE); + break; + case PROP_HAS_CAMRAM_RECORDING: + g_value_set_boolean (value, FALSE); + break; case PROP_ROI_X: g_value_set_uint (value, 0); break; @@ -214,6 +251,9 @@ uca_xkit_camera_get_property (GObject *object, case PROP_ROI_HEIGHT: g_value_set_uint (value, priv->info.numberOfRows * MEDIPIX_SENSOR_HEIGHT); break; + case PROP_POSITIVE_POLARITY: + g_value_set_boolean (value, priv->acq.polarityPositive); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -269,12 +309,13 @@ uca_xkit_camera_initable_iface_init (GInitableIface *iface) static void uca_xkit_camera_class_init (UcaXkitCameraClass *klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->set_property = uca_xkit_camera_set_property; - gobject_class->get_property = uca_xkit_camera_get_property; - gobject_class->finalize = uca_xkit_camera_finalize; + GObjectClass *oclass = G_OBJECT_CLASS (klass); + UcaCameraClass *camera_class = UCA_CAMERA_CLASS (klass); + + oclass->set_property = uca_xkit_camera_set_property; + oclass->get_property = uca_xkit_camera_get_property; + oclass->finalize = uca_xkit_camera_finalize; - UcaCameraClass *camera_class = UCA_CAMERA_CLASS(klass); camera_class->start_recording = uca_xkit_camera_start_recording; camera_class->stop_recording = uca_xkit_camera_stop_recording; camera_class->start_readout = uca_xkit_camera_start_readout; @@ -283,27 +324,30 @@ uca_xkit_camera_class_init (UcaXkitCameraClass *klass) camera_class->trigger = uca_xkit_camera_trigger; for (guint i = 0; base_overrideables[i] != 0; i++) - g_object_class_override_property(gobject_class, base_overrideables[i], uca_camera_props[base_overrideables[i]]); + g_object_class_override_property (oclass, base_overrideables[i], uca_camera_props[base_overrideables[i]]); + + xkit_properties[PROP_POSITIVE_POLARITY] = + g_param_spec_boolean ("positive-polarity", + "Is polarity positive", + "Is polarity positive", + TRUE, (GParamFlags) G_PARAM_READWRITE); - g_type_class_add_private(klass, sizeof(UcaXkitCameraPrivate)); + for (guint id = N_BASE_PROPERTIES; id < N_PROPERTIES; id++) + g_object_class_install_property (oclass, id, xkit_properties[id]); + + g_type_class_add_private (klass, sizeof(UcaXkitCameraPrivate)); } static void uca_xkit_camera_init (UcaXkitCamera *self) { UcaXkitCameraPrivate *priv; - GObjectClass *oclass; self->priv = priv = UCA_XKIT_CAMERA_GET_PRIVATE (self); priv->construct_error = NULL; if (!setup_xkit (priv)) return; - - oclass = G_OBJECT_GET_CLASS (self); - - for (guint id = N_BASE_PROPERTIES; id < N_PROPERTIES; id++) - g_object_class_install_property (oclass, id, ufo_properties[id]); } G_MODULE_EXPORT GType |