[aravis] device: add some convenience accessors for the genicam feature.



commit 2efe5106bb2c894099007784663aef177c386838
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Thu May 13 16:36:40 2010 +0200

    device: add some convenience accessors for the genicam feature.
    
    The [sg]et_string_feature_value should be made more generic and be
    allowed to get/set the value of any node using string.

 src/arvcamera.c |   75 +++++++++++++------------------------
 src/arvdevice.c |  110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/arvdevice.h |    9 ++++-
 3 files changed, 145 insertions(+), 49 deletions(-)
---
diff --git a/src/arvcamera.c b/src/arvcamera.c
index 61f5c07..b629497 100644
--- a/src/arvcamera.c
+++ b/src/arvcamera.c
@@ -51,7 +51,7 @@ arv_camera_get_vendor_name (ArvCamera *camera)
 {
 	g_return_val_if_fail (ARV_IS_CAMERA (camera), NULL);
 
-	return arv_gc_string_get_value (ARV_GC_STRING (arv_gc_get_node (camera->priv->genicam, "DeviceVendorName")));
+	return arv_device_get_string_feature_value (camera->priv->device, "DeviceVendorName");
 }
 
 const char *
@@ -59,7 +59,7 @@ arv_camera_get_model_name (ArvCamera *camera)
 {
 	g_return_val_if_fail (ARV_IS_CAMERA (camera), NULL);
 
-	return arv_gc_string_get_value (ARV_GC_STRING (arv_gc_get_node (camera->priv->genicam, "DeviceModelName")));
+	return arv_device_get_string_feature_value (camera->priv->device, "DeviceModelName");
 }
 
 const char *
@@ -67,7 +67,7 @@ arv_camera_get_device_id (ArvCamera *camera)
 {
 	g_return_val_if_fail (ARV_IS_CAMERA (camera), NULL);
 
-	return arv_gc_string_get_value (ARV_GC_STRING (arv_gc_get_node (camera->priv->genicam, "DeviceID")));
+	return arv_device_get_string_feature_value (camera->priv->device, "DeviceID");
 }
 
 void
@@ -75,9 +75,7 @@ arv_camera_set_acquisition_mode (ArvCamera *camera, const char *value)
 {
 	g_return_if_fail (ARV_IS_CAMERA (camera));
 
-	arv_gc_enumeration_set_string_value (ARV_GC_ENUMERATION (arv_gc_get_node (camera->priv->genicam,
-										  "AcquisitionMode")),
-					     value);
+	arv_device_set_string_feature_value (camera->priv->device, "AcquisitionMode", value);
 }
 
 const char *
@@ -85,8 +83,7 @@ arv_camera_get_acquisition_mode (ArvCamera *camera)
 {
 	g_return_val_if_fail (ARV_IS_CAMERA (camera), NULL);
 
-	return arv_gc_enumeration_get_string_value (ARV_GC_ENUMERATION (arv_gc_get_node (camera->priv->genicam,
-											 "AcquisitionMode")));
+	return arv_device_get_string_feature_value (camera->priv->device, "AcquisitionMode");
 }
 
 void
@@ -94,7 +91,7 @@ arv_camera_start_acquisition (ArvCamera *camera)
 {
 	g_return_if_fail (ARV_IS_CAMERA (camera));
 
-	arv_gc_command_execute (ARV_GC_COMMAND (arv_gc_get_node (camera->priv->genicam, "AcquisitionStart")));
+	arv_device_execute_command (camera->priv->device, "AcquisitionStart");
 }
 
 void
@@ -102,7 +99,7 @@ arv_camera_stop_acquisition (ArvCamera *camera)
 {
 	g_return_if_fail (ARV_IS_CAMERA (camera));
 
-	arv_gc_command_execute (ARV_GC_COMMAND (arv_gc_get_node (camera->priv->genicam, "AcquisitionStop")));
+	arv_device_execute_command (camera->priv->device, "AcquisitionStop");
 }
 
 void
@@ -110,9 +107,7 @@ arv_camera_set_trigger_selector	(ArvCamera *camera, const char *value)
 {
 	g_return_if_fail (ARV_IS_CAMERA (camera));
 
-	arv_gc_enumeration_set_string_value (ARV_GC_ENUMERATION (arv_gc_get_node (camera->priv->genicam,
-										  "TriggerSelector")),
-					     value);
+	arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector", value);
 }
 
 void
@@ -120,9 +115,7 @@ arv_camera_set_trigger_mode (ArvCamera *camera, const char *value)
 {
 	g_return_if_fail (ARV_IS_CAMERA (camera));
 
-	arv_gc_enumeration_set_string_value (ARV_GC_ENUMERATION (arv_gc_get_node (camera->priv->genicam,
-										  "TriggerMode")),
-					     value);
+	arv_device_set_string_feature_value (camera->priv->device, "TriggerMode", value);
 }
 
 const char *
@@ -130,8 +123,7 @@ arv_camera_get_trigger_mode (ArvCamera *camera)
 {
 	g_return_val_if_fail (ARV_IS_CAMERA (camera), NULL);
 
-	return arv_gc_enumeration_get_string_value (ARV_GC_ENUMERATION (arv_gc_get_node (camera->priv->genicam,
-											 "TriggerMode")));
+	return arv_device_get_string_feature_value (camera->priv->device, "TriggerMode");
 }
 
 void
@@ -139,9 +131,7 @@ arv_camera_set_trigger_source (ArvCamera *camera, const char *value)
 {
 	g_return_if_fail (ARV_IS_CAMERA (camera));
 
-	arv_gc_enumeration_set_string_value (ARV_GC_ENUMERATION (arv_gc_get_node (camera->priv->genicam,
-										  "TriggerSource")),
-					     value);
+	arv_device_set_string_feature_value (camera->priv->device, "TriggerSource", value);
 }
 
 const char *
@@ -149,8 +139,7 @@ arv_camera_get_trigger_source (ArvCamera *camera)
 {
 	g_return_val_if_fail (ARV_IS_CAMERA (camera), NULL);
 
-	return arv_gc_enumeration_get_string_value (ARV_GC_ENUMERATION (arv_gc_get_node (camera->priv->genicam,
-											 "TriggerSource")));
+	return arv_device_get_string_feature_value (camera->priv->device, "TriggerSource");
 }
 
 void
@@ -158,9 +147,7 @@ arv_camera_set_trigger_activation (ArvCamera *camera, const char *value)
 {
 	g_return_if_fail (ARV_IS_CAMERA (camera));
 
-	arv_gc_enumeration_set_string_value (ARV_GC_ENUMERATION (arv_gc_get_node (camera->priv->genicam,
-										  "TriggerActivation")),
-					     value);
+	arv_device_set_string_feature_value (camera->priv->device, "TriggerActivation", value);
 }
 
 const char *
@@ -168,8 +155,7 @@ arv_camera_get_trigger_activation (ArvCamera *camera)
 {
 	g_return_val_if_fail (ARV_IS_CAMERA (camera), NULL);
 
-	return arv_gc_enumeration_get_string_value (ARV_GC_ENUMERATION (arv_gc_get_node (camera->priv->genicam,
-											 "TriggerActivation")));
+	return arv_device_get_string_feature_value (camera->priv->device, "TriggerActivation");
 }
 
 guint
@@ -177,7 +163,7 @@ arv_camera_get_payload (ArvCamera *camera)
 {
 	g_return_val_if_fail (ARV_IS_CAMERA (camera), 0);
 
-	return arv_gc_integer_get_value (ARV_GC_INTEGER (arv_gc_get_node (camera->priv->genicam, "PayloadSize")));
+	return arv_device_get_integer_feature_value (camera->priv->device, "PayloadSize");
 }
 
 void
@@ -187,9 +173,9 @@ arv_camera_set_region (ArvCamera *camera, int x, int y, int width, int height)
 
 	/* FIXME check for limits */
 	if (width > 0)
-		arv_gc_integer_set_value (ARV_GC_INTEGER (arv_gc_get_node (camera->priv->genicam, "Width")), width);
+		arv_device_set_integer_feature_value (camera->priv->device, "Width", width);
 	if (height > 0)
-		arv_gc_integer_set_value (ARV_GC_INTEGER (arv_gc_get_node (camera->priv->genicam, "Height")), height);
+		arv_device_set_integer_feature_value (camera->priv->device, "Height", width);
 }
 
 void
@@ -203,11 +189,9 @@ arv_camera_get_region (ArvCamera *camera, gint *x, gint *y, gint *width, gint *h
 		*y = 0;
 
 	if (width != NULL)
-		*width = arv_gc_integer_get_value (ARV_GC_INTEGER (arv_gc_get_node (camera->priv->genicam,
-										    "Width")));
+		*width = arv_device_get_integer_feature_value (camera->priv->device, "Width");
 	if (height != NULL)
-		*height = arv_gc_integer_get_value (ARV_GC_INTEGER (arv_gc_get_node (camera->priv->genicam,
-										     "Height")));
+		*height = arv_device_get_integer_feature_value (camera->priv->device, "Height");
 }
 
 void
@@ -217,11 +201,9 @@ arv_camera_set_binning (ArvCamera *camera, gint dx, gint dy)
 
 	/* FIXME check for limits */
 	if (dx > 0)
-		arv_gc_integer_set_value (ARV_GC_INTEGER (arv_gc_get_node (camera->priv->genicam,
-									   "BinningHorizontal")), dx);
+		arv_device_set_integer_feature_value (camera->priv->device, "BinningHorizontal", dx);
 	if (dy > 0)
-		arv_gc_integer_set_value (ARV_GC_INTEGER (arv_gc_get_node (camera->priv->genicam,
-									   "BinningVertical")), dy);
+		arv_device_set_integer_feature_value (camera->priv->device, "BinningVertical", dx);
 }
 
 void
@@ -230,11 +212,9 @@ arv_camera_get_binning (ArvCamera *camera, gint *dx, gint *dy)
 	g_return_if_fail (ARV_IS_CAMERA (camera));
 
 	if (dx != NULL)
-		*dx = arv_gc_integer_get_value (ARV_GC_INTEGER (arv_gc_get_node (camera->priv->genicam,
-										 "BinningHorizontal")));
+		*dx = arv_device_get_integer_feature_value (camera->priv->device, "BinningHorizontal");
 	if (dy != NULL)
-		*dy = arv_gc_integer_get_value (ARV_GC_INTEGER (arv_gc_get_node (camera->priv->genicam,
-										 "BinningVertical")));
+		*dy = arv_device_get_integer_feature_value (camera->priv->device, "BinningVertical");
 }
 
 void
@@ -242,8 +222,7 @@ arv_camera_set_exposure_time (ArvCamera *camera, double exposure_time_us)
 {
 	g_return_if_fail (ARV_IS_CAMERA (camera));
 
-	arv_gc_float_set_value (ARV_GC_FLOAT (arv_gc_get_node (camera->priv->genicam, "ExposureTimeAbs")),
-				exposure_time_us);
+	arv_device_set_float_feature_value (camera->priv->device, "ExposureTimeAbs", exposure_time_us);
 }
 
 gboolean
@@ -251,7 +230,7 @@ arv_camera_get_exposure_time (ArvCamera *camera)
 {
 	g_return_val_if_fail (ARV_IS_CAMERA (camera), 0.0);
 
-	return arv_gc_float_get_value (ARV_GC_FLOAT (arv_gc_get_node (camera->priv->genicam, "ExposureTimeAbs")));
+	return arv_device_get_float_feature_value (camera->priv->device, "ExposureTimeAbs");
 }
 
 void
@@ -259,7 +238,7 @@ arv_camera_set_gain (ArvCamera *camera, gint64 gain)
 {
 	g_return_if_fail (ARV_IS_CAMERA (camera));
 
-	arv_gc_integer_set_value (ARV_GC_INTEGER (arv_gc_get_node (camera->priv->genicam, "GainRaw")), gain);
+	arv_device_set_integer_feature_value (camera->priv->device, "GainRaw", gain);
 }
 
 gint64
@@ -267,7 +246,7 @@ arv_camera_get_gain (ArvCamera *camera)
 {
 	g_return_val_if_fail (ARV_IS_CAMERA (camera), 0.0);
 
-	return arv_gc_integer_get_value (ARV_GC_INTEGER (arv_gc_get_node (camera->priv->genicam, "GainRaw")));
+	return arv_device_get_integer_feature_value (camera->priv->device, "GainRaw");
 }
 
 ArvCamera *
diff --git a/src/arvdevice.c b/src/arvdevice.c
index 2aa3a5b..645d253 100644
--- a/src/arvdevice.c
+++ b/src/arvdevice.c
@@ -22,6 +22,12 @@
 
 #include <arvdevice.h>
 #include <arvgc.h>
+#include <arvgccommand.h>
+#include <arvgcinteger.h>
+#include <arvgcfloat.h>
+#include <arvgcboolean.h>
+#include <arvgcenumeration.h>
+#include <arvgcstring.h>
 #include <arvstream.h>
 
 static GObjectClass *parent_class = NULL;
@@ -79,6 +85,110 @@ arv_device_get_genicam (ArvDevice *device)
 	return ARV_DEVICE_GET_CLASS (device)->get_genicam (device);
 }
 
+void
+arv_device_execute_command (ArvDevice *device, const char *feature)
+{
+	ArvGc *genicam;
+	ArvGcNode *node;
+
+	genicam = arv_device_get_genicam (device);
+	g_return_if_fail (ARV_IS_GC (genicam));
+
+	node = arv_gc_get_node (genicam, feature);
+	if (ARV_IS_GC_COMMAND (node))
+		arv_gc_command_execute (ARV_GC_COMMAND (node));
+}
+
+void
+arv_device_set_string_feature_value (ArvDevice *device, const char *feature, const char *value)
+{
+	ArvGc *genicam;
+	ArvGcNode *node;
+
+	genicam = arv_device_get_genicam (device);
+	g_return_if_fail (ARV_IS_GC (genicam));
+
+	node = arv_gc_get_node (genicam, feature);
+	if (ARV_IS_GC_ENUMERATION (node))
+		arv_gc_enumeration_set_string_value (ARV_GC_ENUMERATION (node), value);
+	else if (ARV_IS_GC_STRING (node))
+		arv_gc_string_set_value (ARV_GC_STRING (node), value);
+}
+
+const char *
+arv_device_get_string_feature_value (ArvDevice *device, const char *feature)
+{
+	ArvGc *genicam;
+	ArvGcNode *node;
+
+	genicam = arv_device_get_genicam (device);
+	g_return_val_if_fail (ARV_IS_GC (genicam), NULL);
+
+	node = arv_gc_get_node (genicam, feature);
+	if (ARV_IS_GC_ENUMERATION (node))
+		return arv_gc_enumeration_get_string_value (ARV_GC_ENUMERATION (node));
+	else if (ARV_IS_GC_STRING (node))
+		return arv_gc_string_get_value (ARV_GC_STRING (node));
+
+	return NULL;
+}
+
+void
+arv_device_set_integer_feature_value (ArvDevice *device, const char *feature, guint64 value)
+{
+	ArvGc *genicam;
+	ArvGcNode *node;
+
+	genicam = arv_device_get_genicam (device);
+	g_return_if_fail (ARV_IS_GC (genicam));
+
+	node = arv_gc_get_node (genicam, feature);
+	if (ARV_IS_GC_INTEGER (node))
+		arv_gc_integer_set_value (ARV_GC_INTEGER (node), value);
+	else if (ARV_IS_GC_ENUMERATION (node))
+		arv_gc_enumeration_set_int_value (ARV_GC_ENUMERATION (node), value);
+	else if (ARV_IS_GC_BOOLEAN (node))
+		arv_gc_boolean_set_value (ARV_GC_BOOLEAN (node), value);
+}
+
+guint64
+arv_device_get_integer_feature_value (ArvDevice *device, const char *feature)
+{
+	ArvGc *genicam;
+	ArvGcNode *node;
+
+	genicam = arv_device_get_genicam (device);
+	g_return_val_if_fail (ARV_IS_GC (genicam), 0);
+
+	node = arv_gc_get_node (genicam, feature);
+	if (ARV_IS_GC_INTEGER (node))
+		return arv_gc_integer_get_value (ARV_GC_INTEGER (node));
+	else if (ARV_IS_GC_ENUMERATION (node))
+		return arv_gc_enumeration_get_int_value (ARV_GC_ENUMERATION (node));
+	else if (ARV_IS_GC_BOOLEAN (node))
+		return arv_gc_boolean_get_value (ARV_GC_BOOLEAN (node));
+
+	return 0;
+}
+
+void
+arv_device_set_float_feature_value (ArvDevice *device, const char *feature, double value)
+{
+	ArvGc *genicam;
+
+	genicam = arv_device_get_genicam (device);
+	arv_gc_float_set_value (ARV_GC_FLOAT (arv_gc_get_node (genicam, feature)), value);
+}
+
+double
+arv_device_get_float_feature_value (ArvDevice *device, const char *feature)
+{
+	ArvGc *genicam;
+
+	genicam = arv_device_get_genicam (device);
+	return arv_gc_float_get_value (ARV_GC_FLOAT (arv_gc_get_node (genicam, feature)));
+}
+
 static void
 arv_device_init (ArvDevice *device)
 {
diff --git a/src/arvdevice.h b/src/arvdevice.h
index d108ad1..44b56e8 100644
--- a/src/arvdevice.h
+++ b/src/arvdevice.h
@@ -64,7 +64,14 @@ gboolean	arv_device_write_memory	 	(ArvDevice *device, guint32 address, guint32
 gboolean 	arv_device_read_register	(ArvDevice *device, guint32 address, guint32 *value);
 gboolean	arv_device_write_register 	(ArvDevice *device, guint32 address, guint32 value);
 
-ArvGc *		arv_device_get_genicam		(ArvDevice *device);
+ArvGc *		arv_device_get_genicam			(ArvDevice *device);
+void 		arv_device_execute_command 		(ArvDevice *device, const char *feature);
+void		arv_device_set_string_feature_value	(ArvDevice *device, const char *feature, const char *value);
+const char *	arv_device_get_string_feature_value	(ArvDevice *device, const char *feature);
+void		arv_device_set_integer_feature_value	(ArvDevice *device, const char *feature, guint64 value);
+guint64		arv_device_get_integer_feature_value	(ArvDevice *device, const char *feature);
+void		arv_device_set_float_feature_value	(ArvDevice *device, const char *feature, double value);
+double		arv_device_get_float_feature_value	(ArvDevice *device, const char *feature);
 
 G_END_DECLS
 



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