[aravis] camera: allow software trigger.



commit c3059163f856a4f883504e10b0b458f34efb2146
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Thu Feb 17 14:59:56 2011 +0100

    camera: allow software trigger.

 docs/reference/aravis/aravis-sections.txt |    2 ++
 src/arvcamera.c                           |   23 +++++++++++++++++++++--
 src/arvcamera.h                           |    3 +++
 tests/arvcameratest.c                     |   25 ++++++++++++++++++++++++-
 4 files changed, 50 insertions(+), 3 deletions(-)
---
diff --git a/docs/reference/aravis/aravis-sections.txt b/docs/reference/aravis/aravis-sections.txt
index 2b2baf2..40047ba 100644
--- a/docs/reference/aravis/aravis-sections.txt
+++ b/docs/reference/aravis/aravis-sections.txt
@@ -28,6 +28,8 @@ arv_camera_get_acquisition_mode
 arv_camera_set_frame_rate
 arv_camera_get_frame_rate
 arv_camera_set_trigger
+arv_camera_set_software_trigger
+arv_camera_software_trigger
 arv_camera_set_exposure_time
 arv_camera_get_exposure_time
 arv_camera_get_exposure_time_bounds
diff --git a/src/arvcamera.c b/src/arvcamera.c
index fd87b0a..1271415 100644
--- a/src/arvcamera.c
+++ b/src/arvcamera.c
@@ -494,6 +494,9 @@ arv_camera_set_trigger (ArvCamera *camera, const char *source)
 			arv_device_set_integer_feature_value (camera->priv->device, "AcquisitionFrameRateEnable",
 							      0);
 			arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector",
+							     "FrameStart");
+			arv_device_set_string_feature_value (camera->priv->device, "TriggerMode", "Off");
+			arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector",
 							     "AcquisitionStart");
 			arv_device_set_string_feature_value (camera->priv->device, "TriggerMode", "On");
 			arv_device_set_string_feature_value (camera->priv->device, "TriggerActivation",
@@ -504,7 +507,8 @@ arv_camera_set_trigger (ArvCamera *camera, const char *source)
 			arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector",
 							     "AcquisitionStart");
 			arv_device_set_string_feature_value (camera->priv->device, "TriggerMode", "Off");
-			arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector", "FrameStart");
+			arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector",
+							     "FrameStart");
 			arv_device_set_string_feature_value (camera->priv->device, "TriggerMode", "On");
 			arv_device_set_string_feature_value (camera->priv->device, "TriggerActivation",
 							     "RisingEdge");
@@ -514,7 +518,8 @@ arv_camera_set_trigger (ArvCamera *camera, const char *source)
 			arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector",
 							     "AcquisitionStart");
 			arv_device_set_string_feature_value (camera->priv->device, "TriggerMode", "Off");
-			arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector", "FrameStart");
+			arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector",
+							     "FrameStart");
 			arv_device_set_string_feature_value (camera->priv->device, "TriggerMode", "On");
 			arv_device_set_string_feature_value (camera->priv->device, "TriggerActivation",
 							     "RisingEdge");
@@ -523,6 +528,20 @@ arv_camera_set_trigger (ArvCamera *camera, const char *source)
 	}
 }
 
+void
+arv_camera_set_software_trigger (ArvCamera *camera)
+{
+	arv_camera_set_trigger (camera, "Software");
+}
+
+void
+arv_camera_software_trigger (ArvCamera *camera)
+{
+	g_return_if_fail (ARV_IS_CAMERA (camera));
+
+	arv_device_execute_command (camera->priv->device, "TriggerSoftware");
+}
+
 /**
  * arv_camera_set_exposure_time:
  * @camera: a #ArvCamera
diff --git a/src/arvcamera.h b/src/arvcamera.h
index 368d037..2f23fcb 100644
--- a/src/arvcamera.h
+++ b/src/arvcamera.h
@@ -87,6 +87,9 @@ void		arv_camera_set_frame_rate		(ArvCamera *camera, double frame_rate);
 double 		arv_camera_get_frame_rate 		(ArvCamera *camera);
 void		arv_camera_set_trigger			(ArvCamera *camera, const char *source);
 
+void 		arv_camera_set_software_trigger 	(ArvCamera *camera);
+void 		arv_camera_software_trigger 		(ArvCamera *camera);
+
 void 		arv_camera_set_exposure_time 		(ArvCamera *camera, double exposure_time_us);
 double 		arv_camera_get_exposure_time 		(ArvCamera *camera);
 void		arv_camera_get_exposure_time_bounds	(ArvCamera *camera, double *min, double *max);
diff --git a/tests/arvcameratest.c b/tests/arvcameratest.c
index ec71f30..62b40e5 100644
--- a/tests/arvcameratest.c
+++ b/tests/arvcameratest.c
@@ -7,6 +7,7 @@ static char *arv_option_debug_domains = NULL;
 static gboolean arv_option_snaphot = FALSE;
 static int arv_option_auto_socket_buffer = -1;
 static char *arv_option_trigger = NULL;
+static gboolean arv_option_software_trigger = FALSE;
 static double arv_option_frequency = -1.0;
 static int arv_option_width = -1;
 static int arv_option_height = -1;
@@ -27,6 +28,8 @@ static const GOptionEntry arv_option_entries[] =
 		&arv_option_frequency,	"Acquisition frequency", NULL },
 	{ "trigger",		't', 0, G_OPTION_ARG_STRING,
 		&arv_option_trigger,	"External trigger", NULL},
+	{ "software-trigger",	'\0', 0, G_OPTION_ARG_NONE,
+		&arv_option_software_trigger,	"Emit software trigger", NULL},
 	{ "width", 		'\0', 0, G_OPTION_ARG_INT,
 		&arv_option_width,		"Width", NULL },
 	{ "height", 		'\0', 0, G_OPTION_ARG_INT,
@@ -87,6 +90,16 @@ periodic_task_cb (void *abstract_data)
 	return TRUE;
 }
 
+static gboolean
+emit_software_trigger (void *abstract_data)
+{
+	ArvCamera *camera = abstract_data;
+
+	arv_camera_software_trigger (camera);
+
+	return TRUE;
+}
+
 int
 main (int argc, char **argv)
 {
@@ -133,6 +146,7 @@ main (int argc, char **argv)
 		guint64 n_failures;
 		guint64 n_underruns;
 		int gain;
+		guint software_trigger_source = 0;
 
 		arv_camera_set_region (camera, 0, 0, arv_option_width, arv_option_height);
 		arv_camera_set_binning (camera, arv_option_horizontal_binning, arv_option_vertical_binning);
@@ -167,7 +181,7 @@ main (int argc, char **argv)
 
 		arv_camera_set_acquisition_mode (camera, ARV_ACQUISITION_MODE_CONTINUOUS);
 
-		if (arv_option_frequency > 0.0)
+		if (arv_option_frequency > 0.0 && !arv_option_software_trigger)
 			arv_camera_set_frame_rate (camera, arv_option_frequency);
 
 		if (arv_option_trigger != NULL)
@@ -180,12 +194,21 @@ main (int argc, char **argv)
 
 		g_timeout_add_seconds (1, periodic_task_cb, &data);
 
+		if (arv_option_software_trigger && arv_option_frequency > 0.0) {
+			arv_camera_set_software_trigger (camera);
+			software_trigger_source = g_timeout_add ((double) (0.5 + 1000.0 / arv_option_frequency),
+								 emit_software_trigger, camera);
+		}
+
 		data.main_loop = g_main_loop_new (NULL, FALSE);
 
 		old_sigint_handler = signal (SIGINT, set_cancel);
 
 		g_main_loop_run (data.main_loop);
 
+		if (software_trigger_source > 0)
+			g_source_remove (software_trigger_source);
+
 		signal (SIGINT, old_sigint_handler);
 
 		g_main_loop_unref (data.main_loop);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]