summaryrefslogtreecommitdiffstats
path: root/plugins/ufo/uca-ufo-camera.c
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2014-02-20 16:38:44 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2014-02-20 16:38:44 +0100
commit5ef987159875178528dc9ee15966668f205cda13 (patch)
tree57a635cd4df2ca29dba25084cb4c87c191fa4064 /plugins/ufo/uca-ufo-camera.c
parent1f58dac536f4344908efce496b1606afcb6be608 (diff)
downloadlibuca-5ef987159875178528dc9ee15966668f205cda13.tar.gz
libuca-5ef987159875178528dc9ee15966668f205cda13.tar.bz2
libuca-5ef987159875178528dc9ee15966668f205cda13.tar.xz
libuca-5ef987159875178528dc9ee15966668f205cda13.zip
ufo: Allow setting framerate
Diffstat (limited to 'plugins/ufo/uca-ufo-camera.c')
-rw-r--r--plugins/ufo/uca-ufo-camera.c63
1 files changed, 41 insertions, 22 deletions
diff --git a/plugins/ufo/uca-ufo-camera.c b/plugins/ufo/uca-ufo-camera.c
index 273d3dd..4c278ef 100644
--- a/plugins/ufo/uca-ufo-camera.c
+++ b/plugins/ufo/uca-ufo-camera.c
@@ -400,6 +400,29 @@ uca_ufo_camera_trigger (UcaCamera *camera, GError **error)
pcilib_trigger (priv->handle, PCILIB_EVENT0, 0, NULL);
}
+static gdouble
+total_readout_time (UcaUfoCamera *camera)
+{
+ gdouble clock_period;
+ gdouble exposure_time;
+ gdouble foo;
+ guint output_mode;
+ guint roi_height;
+
+ g_object_get (G_OBJECT (camera),
+ "exposure-time", &exposure_time,
+ "ufo-cmosis-output-mode", &output_mode,
+ "roi-height", &roi_height,
+ NULL);
+
+ clock_period = camera->priv->frequency == FPGA_40MHZ ? 1 / 40000000.0 : 1 / 48000000.0;
+ foo = pow (2, output_mode);
+ image_readout_time = (129 * clock_period * foo) * roi_height;
+ overhead_time = (10 /* reg73 */ + 2 * foo) * 129 * clock_period;
+
+ return exposure_time + overhead_time + image_readout_time;
+}
+
static void
uca_ufo_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
@@ -414,6 +437,19 @@ uca_ufo_camera_set_property(GObject *object, guint property_id, const GValue *va
pcilib_write_register(priv->handle, NULL, "cmosis_exp_time", reg_value);
}
break;
+ case PROP_FRAME_RATE:
+ {
+ gdouble readout_time;
+ gdouble frame_rate;
+ guint trigger_period;
+
+ frame_rate = g_value_get_double (value);
+ readout_time = total_readout_time (UCA_UFO_CAMERA (object));
+ trigger_period = (guint) (1. / ((frame_rate - 1. / readout_time) * 8 * 1e-9));
+
+ g_object_set (object, "ufo-trigger-period", &trigger_period, NULL);
+ }
+ break;
case PROP_ROI_X:
case PROP_ROI_Y:
case PROP_ROI_WIDTH:
@@ -443,7 +479,6 @@ uca_ufo_camera_set_property(GObject *object, guint property_id, const GValue *va
}
}
-
static void
uca_ufo_camera_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
{
@@ -490,30 +525,14 @@ uca_ufo_camera_get_property(GObject *object, guint property_id, GValue *value, G
break;
case PROP_FRAMES_PER_SECOND:
{
- const gdouble clock_period = priv->frequency == FPGA_40MHZ ? 1 / 40.0 : 1 / 48.0;
- gdouble exposure_time;
- gdouble readout_time, image_readout_time;
- gdouble overhead_time, delay_time;
+ gdouble delay_time;
gdouble framerate;
- gdouble foo;
- guint output_mode;
guint trigger_period;
- guint roi_height;
-
- g_object_get (object,
- "exposure-time", &exposure_time,
- "ufo-cmosis-output-mode", &output_mode,
- "roi-height", &roi_height,
- "ufo-trigger-period", &trigger_period,
- NULL);
-
- foo = pow(2, output_mode);
- image_readout_time = (129 * clock_period * foo) * roi_height;
- overhead_time = (10 /* reg73 */ + 2 * foo) * 129 * clock_period;
- readout_time = exposure_time + overhead_time + image_readout_time;
+
+ g_object_get (object, "ufo-trigger-period", &trigger_period, NULL);
+
delay_time = trigger_period * 8.0 * 1e-9;
- framerate = 1.0 / (readout_time + delay_time);
- framerate *= 1000 * 1000; /* clock_period is in MHz */
+ framerate = 1.0 / (total_readout_time (UCA_UFO_CAMERA (object)) + delay_time);
g_value_set_double(value, framerate);
}
break;