[aravis] fake: set register default values.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] fake: set register default values.
- Date: Thu, 6 May 2010 20:03:52 +0000 (UTC)
commit 2f05fadb5cf999dd8d98a93f607b33631792ebc8
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Thu May 6 22:03:15 2010 +0200
fake: set register default values.
src/Makefile.am | 5 +-
src/arv-fake-camera.xml | 190 ++++++++++++++++++++++++++++++++++++++---------
src/arvdevice.c | 44 +-----------
src/arvdevice.h | 7 +-
src/arvfakecamera.c | 11 +++
src/arvfakecamera.h | 11 +++
src/arvfakedevice.c | 20 ++++-
src/arvfakedevice.h | 2 +-
src/arvgc.c | 6 +-
src/arvgc.h | 2 +-
src/arvgvdevice.c | 23 +++++-
src/arvloadxml.c | 51 -------------
src/tests/fake.c | 42 ++++++++++
13 files changed, 264 insertions(+), 150 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 16afd82..b5773e9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -117,14 +117,11 @@ arvenumtypes.h: arvenumtypes.h.template $(ARAVIS_HDRS) $(GLIB_MKENUMS)
arvenumtypes.c: arvenumtypes.c.template $(ARAVIS_HDRS) $(GLIB_MKENUMS)
$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template arvenumtypes.c.template $(libaravis_la_HEADERS)) > $@
-noinst_PROGRAMS = arv-test arv-load-xml arv-genicam-test arv-evaluator-test arv-zip-test arv-camera-test
+noinst_PROGRAMS = arv-test arv-genicam-test arv-evaluator-test arv-zip-test arv-camera-test
arv_test_SOURCES = arvtest.c
arv_test_LDADD = $(ARAVIS_LIBS) libaravis.la
-arv_load_xml_SOURCES = arvloadxml.c
-arv_load_xml_LDADD = $(ARAVIS_LIBS) libaravis.la
-
arv_genicam_test_SOURCES = arvgenicamtest.c
arv_genicam_test_LDADD = $(ARAVIS_LIBS) libaravis.la
diff --git a/src/arv-fake-camera.xml b/src/arv-fake-camera.xml
index b7d5daf..04836b3 100644
--- a/src/arv-fake-camera.xml
+++ b/src/arv-fake-camera.xml
@@ -7,28 +7,36 @@
SchemaMajorVersion="1"
SchemaMinorVersion="0"
SchemaSubMinorVersion="0"
- MajorVersion="292"
+ MajorVersion="1"
MinorVersion="0"
SubMinorVersion="0"
- ToolTip="TestTooltip"
- ProductGuid="111-222"
- VersionGuid="222-333"
+ ToolTip="Fake camera"
+ ProductGuid="0"
+ VersionGuid="0"
xmlns="http://www.genicam.org/GenApi/Version_1_0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.genicam.org/GenApi/Version_1_0 GenApiSchema.xsd">
+
<Category Name="Root" NameSpace="Standard">
- <pFeature>AcquisitionControl</pFeature>
+ <pFeature>AcquisitionControl</pFeature>
+ <pFeature>FeatureControl</pFeature>
</Category>
<Category Name="AcquisitionControl" NameSpace="Custom">
- <pFeature>AcquisitionStart</pFeature>
- <pFeature>AcquisitionStop</pFeature>
+ <pFeature>AcquisitionStart</pFeature>
+ <pFeature>AcquisitionStop</pFeature>
+ </Category>
+
+ <Category Name="FeatureControl" NameSpace="Custom">
+ <pFeature>GainSelector</pFeature>
+ <pFeature>GainRaw</pFeature>
+ <pFeature>GainAuto</pFeature>
</Category>
<Command Name="AcquisitionStart" NameSpace="Standard">
- <Description>Start acquisition. Before image acquisition can occur, acquisition must be started, either by a hardware trigger or this software command.</Description>
- <pValue>RegAcquisitionCommand</pValue>
- <CommandValue>1</CommandValue>
+ <Description>Start acquisition. Before image acquisition can occur, acquisition must be started, either by a hardware trigger or this software command.</Description>
+ <pValue>RegAcquisitionCommand</pValue>
+ <CommandValue>1</CommandValue>
</Command>
<Command Name="AcquisitionStop" NameSpace="Standard">
@@ -38,43 +46,153 @@
</Command>
<IntReg Name="RegAcquisitionCommand" NameSpace="Custom">
- <Address>0x130F4</Address>
+ <Address>0x120</Address>
<Length>4</Length>
<AccessMode>WO</AccessMode>
<pPort>Device</pPort>
<Sign>Unsigned</Sign>
- <Endianess>BigEndian</Endianess>
+ <Endianess>LittleEndian</Endianess>
</IntReg>
- <IntReg Name="RegPixelFormat" NameSpace="Custom">
- <Address>0x12120</Address>
- <Length>4</Length>
- <AccessMode>RW</AccessMode>
- <pPort>Device</pPort>
- <pInvalidator>BinningHorizontal</pInvalidator>
- <pInvalidator>BinningVertical</pInvalidator>
- <Sign>Unsigned</Sign>
- <Endianess>BigEndian</Endianess>
+ <Integer Name="SensorHeight" NameSpace="Standard">
+ <Description>Full height of image sensor.</Description>
+ <pValue>RegSensorHeight</pValue>
+ </Integer>
+
+ <IntReg Name="RegSensorHeight" NameSpace="Custom">
+ <Address>0x118</Address>
+ <Length>4</Length>
+ <AccessMode>RO</AccessMode>
+ <pPort>Device</pPort>
+ <Sign>Unsigned</Sign>
+ <Endianess>LittleEndian</Endianess>
</IntReg>
- <IntReg Name="RegWhitebalValueMax" NameSpace="Custom">
- <Address>0x1418C</Address>
- <Length>4</Length>
- <AccessMode>RW</AccessMode>
- <pPort>Device</pPort>
- <Sign>Unsigned</Sign>
- <Endianess>BigEndian</Endianess>
+ <Integer Name="SensorWidth" NameSpace="Standard">
+ <Description>Full height of image sensor.</Description>
+ <pValue>RegSensorWidth</pValue>
+ </Integer>
+
+ <IntReg Name="RegSensorWidth" NameSpace="Custom">
+ <Address>0x11c</Address>
+ <Length>4</Length>
+ <AccessMode>RO</AccessMode>
+ <pPort>Device</pPort>
+ <Sign>Unsigned</Sign>
+ <Endianess>LittleEndian</Endianess>
+ </IntReg>
+
+ <Integer Name="Width" NameSpace="Standard">
+ <Description>Width of image, in pixels.</Description>
+ <pValue>RegWidth</pValue>
+ <Min>1</Min>
+ <pMax>SensorWidth</pMax>
+ <Inc>1</Inc>
+ </Integer>
+
+ <IntReg Name="RegWidth" NameSpace="Custom">
+ <Address>0x100</Address>
+ <Length>4</Length>
+ <AccessMode>RW</AccessMode>
+ <pPort>Device</pPort>
+ <Sign>Unsigned</Sign>
+ <Endianess>LittleEndian</Endianess>
</IntReg>
- <IntSwissKnife Name="IntWidthIncrement" NameSpace="Custom">
- <pVariable Name="FORMAT">RegPixelFormat</pVariable>
- <Formula>((FORMAT=35127328) || (FORMAT=34603039) || (FORMAT=34340894)) ? 4 : 1</Formula>
- </IntSwissKnife>
+ <Integer Name="Height" NameSpace="Standard">
+ <Description>Height of image, in pixels.</Description>
+ <pValue>RegHeight</pValue>
+ <Min>1</Min>
+ <pMax>SensorHeight</pMax>
+ <Inc>1</Inc>
+ </Integer>
- <SwissKnife Name="WhitebalValueMin" NameSpace="Custom">
- <pVariable Name="VALUE">RegWhitebalValueMin</pVariable>
- <Formula>(VALUE / 100)</Formula>
- </SwissKnife>
+ <IntReg Name="RegHeight" NameSpace="Custom">
+ <Address>0x104</Address>
+ <Length>4</Length>
+ <AccessMode>RW</AccessMode>
+ <pPort>Device</pPort>
+ <Sign>Unsigned</Sign>
+ <Endianess>LittleEndian</Endianess>
+ </IntReg>
+
+ <Integer Name="BinningHorizontal" NameSpace="Standard">
+ <Description>Binning in horizontal direction.</Description>
+ <pValue>RegBinningHorizontal</pValue>
+ <Min>1</Min>
+ <Max>16</Max>
+ </Integer>
+
+ <IntReg Name="RegBinningHorizontal" NameSpace="Custom">
+ <Address>0x108</Address>
+ <Length>4</Length>
+ <AccessMode>RW</AccessMode>
+ <pPort>Device</pPort>
+ <Sign>Unsigned</Sign>
+ <Endianess>LittleEndian</Endianess>
+ </IntReg>
+
+ <Integer Name="BinningVertical" NameSpace="Standard">
+ <Description>Binning in vertical direction.</Description>
+ <pValue>RegBinningVertical</pValue>
+ <Min>1</Min>
+ <Max>16</Max>
+ </Integer>
+
+ <IntReg Name="RegBinningVertical" NameSpace="Custom">
+ <Address>0x10c</Address>
+ <Length>4</Length>
+ <AccessMode>RW</AccessMode>
+ <pPort>Device</pPort>
+ <Sign>Unsigned</Sign>
+ <Endianess>LittleEndian</Endianess>
+ </IntReg>
+
+ <Enumeration Name="GainSelector" NameSpace="Standard">
+ <EnumEntry Name="All" NameSpace="Standard">
+ <Value>0</Value>
+ </EnumEntry>
+ <Value>0</Value>
+ </Enumeration>
+
+ <Integer Name="GainRaw" NameSpace="Standard">
+ <Description>Gain value of analog A/D stage. Units are usually in dB.</Description>
+ <pValue>RegGainValue</pValue>
+ <Min>0</Min>
+ <Max>10</Max>
+ </Integer>
+
+ <IntReg Name="RegGainValue" NameSpace="Custom">
+ <Address>0x110</Address>
+ <Length>4</Length>
+ <AccessMode>RW</AccessMode>
+ <pPort>Device</pPort>
+ <Sign>Unsigned</Sign>
+ <Endianess>LittleEndian</Endianess>
+ </IntReg>
+
+ <Enumeration Name="GainAuto" NameSpace="Standard">
+ <Description>Automatic gain mode.</Description>
+ <EnumEntry Name="Off" NameSpace="Standard">
+ <Value>1</Value>
+ </EnumEntry>
+ <EnumEntry Name="Once" NameSpace="Standard">
+ <Value>3</Value>
+ </EnumEntry>
+ <EnumEntry Name="Continuous" NameSpace="Standard">
+ <Value>2</Value>
+ </EnumEntry>
+ <pValue>RegGainMode</pValue>
+ </Enumeration>
+
+ <IntReg Name="RegGainMode" NameSpace="Custom">
+ <Address>0x114</Address>
+ <Length>4</Length>
+ <AccessMode>RW</AccessMode>
+ <pPort>Device</pPort>
+ <Sign>Unsigned</Sign>
+ <Endianess>LittleEndian</Endianess>
+ </IntReg>
<Port Name="Device" NameSpace="Standard">
</Port>
diff --git a/src/arvdevice.c b/src/arvdevice.c
index dd948a7..2aa3a5b 100644
--- a/src/arvdevice.c
+++ b/src/arvdevice.c
@@ -26,12 +26,6 @@
static GObjectClass *parent_class = NULL;
-struct _ArvDevicePrivate {
- ArvGc *genicam;
- char *genicam_data;
- size_t genicam_size;
-};
-
ArvStream *
arv_device_new_stream (ArvDevice *device, ArvStreamCallback callback, void *user_data)
{
@@ -77,56 +71,22 @@ arv_device_write_register (ArvDevice *device, guint32 address, guint32 value)
return ARV_DEVICE_GET_CLASS (device)->write_register (device, address, value);
}
-void
-arv_device_set_genicam_data (ArvDevice *device, char *genicam, size_t size)
-{
- g_return_if_fail (ARV_IS_DEVICE (device));
-
- g_free (device->priv->genicam_data);
- if (device->priv->genicam != NULL)
- g_object_unref (device->priv->genicam);
- device->priv->genicam_data = genicam;
- device->priv->genicam_size = size;
-
- device->priv->genicam = arv_gc_new (device,
- device->priv->genicam_data,
- device->priv->genicam_size);
-}
-
-const char *
-arv_device_get_genicam_data (ArvDevice *device, size_t *size)
-{
- g_return_val_if_fail (ARV_IS_DEVICE (device), NULL);
-
- if (size != NULL)
- *size = device->priv->genicam_size;
-
- return device->priv->genicam_data;
-}
-
ArvGc *
arv_device_get_genicam (ArvDevice *device)
{
g_return_val_if_fail (ARV_IS_DEVICE (device), NULL);
- return device->priv->genicam;
+ return ARV_DEVICE_GET_CLASS (device)->get_genicam (device);
}
static void
arv_device_init (ArvDevice *device)
{
- device->priv = G_TYPE_INSTANCE_GET_PRIVATE (device, ARV_TYPE_DEVICE, ArvDevicePrivate);
}
static void
arv_device_finalize (GObject *object)
{
- ArvDevice *device = ARV_DEVICE (object);
-
- g_free (device->priv->genicam_data);
- if (device->priv->genicam != NULL)
- g_object_unref (device->priv->genicam);
-
parent_class->finalize (object);
}
@@ -135,8 +95,6 @@ arv_device_class_init (ArvDeviceClass *device_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (device_class);
- g_type_class_add_private (device_class, sizeof (ArvDevicePrivate));
-
parent_class = g_type_class_peek_parent (device_class);
object_class->finalize = arv_device_finalize;
diff --git a/src/arvdevice.h b/src/arvdevice.h
index c1d81ee..d108ad1 100644
--- a/src/arvdevice.h
+++ b/src/arvdevice.h
@@ -36,12 +36,9 @@ G_BEGIN_DECLS
#define ARV_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), ARV_TYPE_DEVICE, ArvDeviceClass))
typedef struct _ArvDeviceClass ArvDeviceClass;
-typedef struct _ArvDevicePrivate ArvDevicePrivate;
struct _ArvDevice {
GObject object;
-
- ArvDevicePrivate *priv;
};
struct _ArvDeviceClass {
@@ -49,6 +46,8 @@ struct _ArvDeviceClass {
ArvStream * (*new_stream) (ArvDevice *device, ArvStreamCallback callback, void *user_data);
+ ArvGc * (*get_genicam) (ArvDevice *device);
+
gboolean (*read_memory) (ArvDevice *device, guint32 address, guint32 size, void *buffer);
gboolean (*write_memory) (ArvDevice *device, guint32 address, guint32 size, void *buffer);
gboolean (*read_register) (ArvDevice *device, guint32 address, guint32 *value);
@@ -65,8 +64,6 @@ 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);
-void arv_device_set_genicam_data (ArvDevice *device, char *genicam, size_t size);
-const char * arv_device_get_genicam_data (ArvDevice *device, size_t *size);
ArvGc * arv_device_get_genicam (ArvDevice *device);
G_END_DECLS
diff --git a/src/arvfakecamera.c b/src/arvfakecamera.c
index cd7bd5d..982eba9 100644
--- a/src/arvfakecamera.c
+++ b/src/arvfakecamera.c
@@ -21,6 +21,8 @@
*/
#include <arvfakecamera.h>
+#include <arvgc.h>
+#include <arvgcregister.h>
#include <arvgvcp.h>
#include <arvdebug.h>
#include <string.h>
@@ -154,6 +156,15 @@ arv_fake_camera_new (const char *serial_number)
strcpy (memory + ARV_GVBS_FIRST_XML_URL, xml_url);
g_free (xml_url);
+ arv_fake_camera_write_register (fake_camera, ARV_FAKE_CAMERA_REGISTER_SENSOR_WIDTH, 2048);
+ arv_fake_camera_write_register (fake_camera, ARV_FAKE_CAMERA_REGISTER_SENSOR_HEIGHT, 2048);
+ arv_fake_camera_write_register (fake_camera, ARV_FAKE_CAMERA_REGISTER_WIDTH, 512);
+ arv_fake_camera_write_register (fake_camera, ARV_FAKE_CAMERA_REGISTER_HEIGHT, 512);
+ arv_fake_camera_write_register (fake_camera, ARV_FAKE_CAMERA_REGISTER_BINNING_HORIZONTAL, 1);
+ arv_fake_camera_write_register (fake_camera, ARV_FAKE_CAMERA_REGISTER_BINNING_VERTICAL, 1);
+ arv_fake_camera_write_register (fake_camera, ARV_FAKE_CAMERA_REGISTER_GAIN_RAW, 0);
+ arv_fake_camera_write_register (fake_camera, ARV_FAKE_CAMERA_REGISTER_GAIN_MODE, 0);
+
return fake_camera;
}
diff --git a/src/arvfakecamera.h b/src/arvfakecamera.h
index 0b30ebe..e7ffe36 100644
--- a/src/arvfakecamera.h
+++ b/src/arvfakecamera.h
@@ -29,6 +29,17 @@ G_BEGIN_DECLS
#define ARV_FAKE_CAMERA_MEMORY_SIZE 0x1000
+/* To keep in sync with arv-fake-camera.xml */
+
+#define ARV_FAKE_CAMERA_REGISTER_SENSOR_WIDTH 0x11c
+#define ARV_FAKE_CAMERA_REGISTER_SENSOR_HEIGHT 0x118
+#define ARV_FAKE_CAMERA_REGISTER_WIDTH 0x100
+#define ARV_FAKE_CAMERA_REGISTER_HEIGHT 0x104
+#define ARV_FAKE_CAMERA_REGISTER_BINNING_HORIZONTAL 0x108
+#define ARV_FAKE_CAMERA_REGISTER_BINNING_VERTICAL 0x10c
+#define ARV_FAKE_CAMERA_REGISTER_GAIN_RAW 0x110
+#define ARV_FAKE_CAMERA_REGISTER_GAIN_MODE 0x114
+
#define ARV_TYPE_FAKE_CAMERA (arv_fake_camera_get_type ())
#define ARV_FAKE_CAMERA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ARV_TYPE_FAKE_CAMERA, ArvFakeCamera))
#define ARV_FAKE_CAMERA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ARV_TYPE_FAKE_CAMERA, ArvFakeCameraClass))
diff --git a/src/arvfakedevice.c b/src/arvfakedevice.c
index 551f383..9d02839 100644
--- a/src/arvfakedevice.c
+++ b/src/arvfakedevice.c
@@ -22,12 +22,14 @@
#include <arvfakedevice.h>
#include <arvfakestream.h>
+#include <arvgc.h>
#include <arvdebug.h>
static GObjectClass *parent_class = NULL;
struct _ArvFakeDevicePrivate {
ArvFakeCamera *camera;
+ ArvGc *genicam;
};
/* ArvFakeDevice implemenation */
@@ -45,6 +47,14 @@ arv_fake_device_new_stream (ArvDevice *device, ArvStreamCallback callback, void
return stream;
}
+static ArvGc *
+arv_fake_device_get_genicam (ArvDevice *device)
+{
+ ArvFakeDevice *fake_device = ARV_FAKE_DEVICE (device);
+
+ return fake_device->priv->genicam;
+}
+
static gboolean
arv_fake_device_read_memory (ArvDevice *device, guint32 address, guint32 size, void *buffer)
{
@@ -70,20 +80,20 @@ arv_fake_device_write_register (ArvDevice *device, guint32 address, guint32 valu
}
ArvDevice *
-arv_fake_device_new (const char *name)
+arv_fake_device_new (const char *serial_number)
{
ArvFakeDevice *fake_device;
const void *genicam_data;
size_t genicam_data_size;
- g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (serial_number != NULL, NULL);
fake_device = g_object_new (ARV_TYPE_FAKE_DEVICE, NULL);
- fake_device->priv->camera = arv_fake_camera_new (name);
+ fake_device->priv->camera = arv_fake_camera_new (serial_number);
genicam_data = arv_get_fake_camera_genicam_data (&genicam_data_size);
- arv_device_set_genicam_data (ARV_DEVICE (fake_device), (char *) genicam_data, genicam_data_size);
+ fake_device->priv->genicam = arv_gc_new (ARV_DEVICE (fake_device), genicam_data, genicam_data_size);
return ARV_DEVICE (fake_device);
}
@@ -99,6 +109,7 @@ arv_fake_device_finalize (GObject *object)
{
ArvFakeDevice *fake_device = ARV_FAKE_DEVICE (object);
+ g_object_unref (fake_device->priv->genicam);
g_object_unref (fake_device->priv->camera);
parent_class->finalize (object);
@@ -117,6 +128,7 @@ arv_fake_device_class_init (ArvFakeDeviceClass *fake_device_class)
object_class->finalize = arv_fake_device_finalize;
device_class->new_stream = arv_fake_device_new_stream;
+ device_class->get_genicam = arv_fake_device_get_genicam;
device_class->read_memory = arv_fake_device_read_memory;
device_class->write_memory = arv_fake_device_write_memory;
device_class->read_register = arv_fake_device_read_register;
diff --git a/src/arvfakedevice.h b/src/arvfakedevice.h
index 26e08e6..e9c344e 100644
--- a/src/arvfakedevice.h
+++ b/src/arvfakedevice.h
@@ -50,7 +50,7 @@ struct _ArvFakeDeviceClass {
GType arv_fake_device_get_type (void);
-ArvDevice * arv_fake_device_new (const char *name);
+ArvDevice * arv_fake_device_new (const char *serial_number);
G_END_DECLS
diff --git a/src/arvgc.c b/src/arvgc.c
index 2413a99..7c78099 100644
--- a/src/arvgc.c
+++ b/src/arvgc.c
@@ -377,19 +377,19 @@ arv_gc_set_double_to_value (ArvGc *genicam, GValue *value, double v_double)
}
ArvGc *
-arv_gc_new (ArvDevice *device, char *xml, size_t size)
+arv_gc_new (ArvDevice *device, const void *xml, size_t size)
{
ArvGc *genicam;
g_return_val_if_fail (xml != NULL, NULL);
if (size == 0)
- size = strlen (xml);
+ size = strlen ((char *) xml);
genicam = g_object_new (ARV_TYPE_GC, NULL);
g_return_val_if_fail (genicam != NULL, NULL);
genicam->device = device;
- arv_gc_parse_xml (genicam, xml, size);
+ arv_gc_parse_xml (genicam, (char *) xml, size);
return genicam;
}
diff --git a/src/arvgc.h b/src/arvgc.h
index b7f1688..8a2b19a 100644
--- a/src/arvgc.h
+++ b/src/arvgc.h
@@ -49,7 +49,7 @@ struct _ArvGcClass {
GType arv_gc_get_type (void);
-ArvGc * arv_gc_new (ArvDevice *device, char *xml, size_t size);
+ArvGc * arv_gc_new (ArvDevice *device, const void *xml, size_t size);
gint64 arv_gc_get_int64_from_value (ArvGc *genicam, GValue *value);
void arv_gc_set_int64_to_value (ArvGc *genicam, GValue *value, gint64 v_int64);
diff --git a/src/arvgvdevice.c b/src/arvgvdevice.c
index 04e8a98..8baac45 100644
--- a/src/arvgvdevice.c
+++ b/src/arvgvdevice.c
@@ -21,6 +21,7 @@
*/
#include <arvgvdevice.h>
+#include <arvgc.h>
#include <arvdebug.h>
#include <arvgvstream.h>
#include <arvgvcp.h>
@@ -38,6 +39,8 @@ struct _ArvGvDevicePrivate {
void *heartbeat_thread;
void *heartbeat_data;
+
+ ArvGc *genicam;
};
/* Shared data (main thread - heartbeat) */
@@ -393,8 +396,10 @@ arv_gv_device_load_genicam (ArvGvDevice *gv_device)
if (genicam == NULL)
genicam = _load_genicam (gv_device, ARV_GVBS_SECOND_XML_URL, &size);
- if (genicam != NULL)
- arv_device_set_genicam_data (ARV_DEVICE (gv_device), genicam, size);
+ if (genicam != NULL) {
+ gv_device->priv->genicam = arv_gc_new (ARV_DEVICE (gv_device), genicam, size);
+ g_free (genicam);
+ }
}
/* ArvDevice implemenation */
@@ -428,6 +433,14 @@ arv_gv_device_new_stream (ArvDevice *device, ArvStreamCallback callback, void *u
return stream;
}
+static ArvGc *
+arv_gv_device_get_genicam (ArvDevice *device)
+{
+ ArvGvDevice *gv_device = ARV_GV_DEVICE (device);
+
+ return gv_device->priv->genicam;
+}
+
gboolean
arv_gv_device_read_memory (ArvDevice *device, guint32 address, guint32 size, void *buffer)
{
@@ -536,6 +549,8 @@ static void
arv_gv_device_init (ArvGvDevice *gv_device)
{
gv_device->priv = G_TYPE_INSTANCE_GET_PRIVATE (gv_device, ARV_TYPE_GV_DEVICE, ArvGvDevicePrivate);
+
+ gv_device->priv->genicam = NULL;
}
static void
@@ -568,6 +583,9 @@ arv_gv_device_finalize (GObject *object)
g_free (gv_device->priv->io_data);
+ if (gv_device->priv->genicam != NULL)
+ g_object_unref (gv_device->priv->genicam);
+
parent_class->finalize (object);
}
@@ -584,6 +602,7 @@ arv_gv_device_class_init (ArvGvDeviceClass *gv_device_class)
object_class->finalize = arv_gv_device_finalize;
device_class->new_stream = arv_gv_device_new_stream;
+ device_class->get_genicam = arv_gv_device_get_genicam;
device_class->read_memory = arv_gv_device_read_memory;
device_class->write_memory = arv_gv_device_write_memory;
device_class->read_register = arv_gv_device_read_register;
diff --git a/src/tests/fake.c b/src/tests/fake.c
index a117d3b..3c1be84 100644
--- a/src/tests/fake.c
+++ b/src/tests/fake.c
@@ -15,6 +15,47 @@ load_fake_camera_genicam_test (void)
g_assert (genicam_data != NULL);
}
+static void
+fake_device_test (void)
+{
+ ArvDevice *device;
+ ArvGc *genicam;
+ int value;
+
+ device = arv_fake_device_new ("TEST0");
+ g_assert (ARV_IS_FAKE_DEVICE (device));
+
+ genicam = arv_device_get_genicam (device);
+ g_assert (ARV_IS_GC (genicam));
+
+ /* Check default */
+ value = arv_gc_integer_get_value (ARV_GC_INTEGER (arv_gc_get_node (genicam, "Width")));
+ g_assert_cmpint (value, ==, 512);
+
+ arv_gc_integer_set_value (ARV_GC_INTEGER (arv_gc_get_node (genicam, "Width")), 1024);
+ value = arv_gc_integer_get_value (ARV_GC_INTEGER (arv_gc_get_node (genicam, "Width")));
+ g_assert_cmpint (value, ==, 1024);
+
+ /* Check default */
+ value = arv_gc_integer_get_value (ARV_GC_INTEGER (arv_gc_get_node (genicam, "Height")));
+ g_assert_cmpint (value, ==, 512);
+
+ arv_gc_integer_set_value (ARV_GC_INTEGER (arv_gc_get_node (genicam, "Height")), 1024);
+ value = arv_gc_integer_get_value (ARV_GC_INTEGER (arv_gc_get_node (genicam, "Height")));
+ g_assert_cmpint (value, ==, 1024);
+
+ value = arv_gc_integer_get_value (ARV_GC_INTEGER (arv_gc_get_node (genicam, "BinningHorizontal")));
+ g_assert_cmpint (value, ==, 1);
+ value = arv_gc_integer_get_value (ARV_GC_INTEGER (arv_gc_get_node (genicam, "BinningVertical")));
+ g_assert_cmpint (value, ==, 1);
+ value = arv_gc_integer_get_value (ARV_GC_INTEGER (arv_gc_get_node (genicam, "GainRaw")));
+ g_assert_cmpint (value, ==, 0);
+ value = arv_gc_enumeration_get_int_value (ARV_GC_ENUMERATION (arv_gc_get_node (genicam, "GainAuto")));
+ g_assert_cmpint (value, ==, 0);
+
+ g_object_unref (device);
+}
+
int
main (int argc, char *argv[])
{
@@ -25,6 +66,7 @@ main (int argc, char *argv[])
g_type_init ();
g_test_add_func ("/fake/load-fake-camera-genicam", load_fake_camera_genicam_test);
+ g_test_add_func ("/fake/fake-device", fake_device_test);
return g_test_run();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]