Skip to content

Commit

Permalink
tests: test access mode
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelP committed Feb 15, 2022
1 parent d9a6be8 commit bee16e8
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/data/genicam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@
<Value>0x50</Value>
</Integer>

<IntReg Name="ROIntRegisterA">
<Address>0x1000</Address>
<pAddress>IntRegisterAddress</pAddress>
<Length>8</Length>
<AccessMode>RO</AccessMode>
<Cachable>NoCache</Cachable>
<PollingTime>5</PollingTime>
<Sign>Unsigned</Sign>
<Unit>Pa</Unit>
<Endianess>BigEndian</Endianess>
</IntReg>

<IntReg Name="IntRegisterA">
<Address>0x1000</Address>
<pAddress>IntRegisterAddress</pAddress>
Expand Down Expand Up @@ -244,6 +256,7 @@
<FloatReg Name="FloatReg4C">
<Address>0x1000</Address>
<Length>4</Length>
<AccessMode>RW</AccessMode>
<Cachable>NoCache</Cachable>
<Endianess>LittleEndian</Endianess>
<Unit>mA</Unit>
Expand All @@ -253,6 +266,7 @@
<FloatReg Name="FloatReg8C">
<Address>0x1000</Address>
<Length>8</Length>
<AccessMode>RW</AccessMode>
<Cachable>NoCache</Cachable>
<Endianess>LittleEndian</Endianess>
<Unit>mV</Unit>
Expand All @@ -270,6 +284,7 @@
<StringReg Name="StringReg">
<Address>0x1002</Address>
<Length>4</Length>
<AccessMode>RW</AccessMode>
<Cachable>NoCache</Cachable>
<pPort>Device</pPort>
</StringReg>
Expand Down Expand Up @@ -390,6 +405,12 @@
<ChunkID>12345680</ChunkID>
</Port>

<Converter Name="ROConverter">
<FormulaTo> 0.5 * FROM</FormulaTo>
<FormulaFrom> 2.0 * TO</FormulaFrom>
<pValue>ROIntRegisterA</pValue>
</Converter>

<Converter Name="Converter">
<FormulaTo> 0.5 * FROM</FormulaTo>
<FormulaFrom> 2.0 * TO</FormulaFrom>
Expand Down
95 changes: 95 additions & 0 deletions tests/genicam.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ integer_test (void)
GError *error = NULL;
gint64 v_int64;
const char *v_string;
ArvGcAccessMode access_mode;

device = arv_fake_device_new ("TEST0", &error);
g_assert (ARV_IS_FAKE_DEVICE (device));
Expand All @@ -88,6 +89,9 @@ integer_test (void)
node = arv_gc_get_node (genicam, "RWInteger");
g_assert (ARV_IS_GC_INTEGER_NODE (node));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

v_int64 = arv_gc_integer_get_value (ARV_GC_INTEGER (node), NULL);
g_assert_cmpint (v_int64, ==, 1);

Expand All @@ -110,6 +114,9 @@ integer_test (void)
node = arv_gc_get_node (genicam, "P_RWInteger");
g_assert (ARV_IS_GC_INTEGER_NODE (node));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

v_int64 = arv_gc_integer_get_value (ARV_GC_INTEGER (node), NULL);
g_assert_cmpint (v_int64, ==, 2);

Expand Down Expand Up @@ -273,6 +280,7 @@ boolean_test (void)
GError *error = NULL;
gboolean v_boolean;
const char *v_string;
ArvGcAccessMode access_mode;

device = arv_fake_device_new ("TEST0", &error);
g_assert (ARV_IS_FAKE_DEVICE (device));
Expand All @@ -284,6 +292,9 @@ boolean_test (void)
node = arv_gc_get_node (genicam, "RWBoolean");
g_assert (ARV_IS_GC_BOOLEAN (node));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

v_boolean = arv_gc_boolean_get_value (ARV_GC_BOOLEAN (node), NULL);
g_assert_cmpint (v_boolean, ==, TRUE);

Expand All @@ -300,6 +311,9 @@ boolean_test (void)
node = arv_gc_get_node (genicam, "P_RWBoolean");
g_assert (ARV_IS_GC_BOOLEAN (node));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

v_boolean = arv_gc_boolean_get_value (ARV_GC_BOOLEAN (node), NULL);
g_assert_cmpint (v_boolean, ==, TRUE);

Expand All @@ -323,6 +337,7 @@ float_test (void)
GError *error = NULL;
double v_double;
const char *v_string;
ArvGcAccessMode access_mode;

device = arv_fake_device_new ("TEST0", &error);
g_assert (ARV_IS_FAKE_DEVICE (device));
Expand All @@ -334,6 +349,9 @@ float_test (void)
node = arv_gc_get_node (genicam, "RWFloat");
g_assert (ARV_IS_GC_FLOAT_NODE (node));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

v_double = arv_gc_float_get_value (ARV_GC_FLOAT (node), NULL);
g_assert_cmpfloat (v_double, ==, 0.1);

Expand All @@ -356,6 +374,9 @@ float_test (void)
node = arv_gc_get_node (genicam, "P_RWFloat");
g_assert (ARV_IS_GC_FLOAT_NODE (node));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

v_double = arv_gc_float_get_value (ARV_GC_FLOAT (node), NULL);
g_assert_cmpfloat (v_double, ==, 0.2);

Expand All @@ -382,6 +403,7 @@ enumeration_test (void)
gint64 *values;
guint n_values;
const char *v_string;
ArvGcAccessMode access_mode;

device = arv_fake_device_new ("TEST0", &error);
g_assert (ARV_IS_FAKE_DEVICE (device));
Expand All @@ -395,6 +417,9 @@ enumeration_test (void)
g_assert (ARV_IS_GC_INTEGER (node));
g_assert (ARV_IS_GC_STRING (node));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

v_int64 = arv_gc_enumeration_get_int_value (ARV_GC_ENUMERATION (node), NULL);
g_assert_cmpint (v_int64, ==, 0);

Expand Down Expand Up @@ -436,6 +461,7 @@ swiss_knife_test (void)
ArvGcNode *node;
GError *error = NULL;
gint64 value;
ArvGcAccessMode access_mode;

device = arv_fake_device_new ("TEST0", &error);
g_assert (ARV_IS_FAKE_DEVICE (device));
Expand All @@ -447,6 +473,9 @@ swiss_knife_test (void)
node = arv_gc_get_node (genicam, "IntSwissKnifeTest");
g_assert (ARV_IS_GC_SWISS_KNIFE (node));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RO);

value = arv_gc_integer_get_value (ARV_GC_INTEGER (node), NULL);
g_assert_cmpint (value, ==, 0x1234);

Expand Down Expand Up @@ -486,6 +515,7 @@ converter_test (void)
GError *error = NULL;
double v_double;
gint64 v_int64;
ArvGcAccessMode access_mode;

device = arv_fake_device_new ("TEST0", &error);
g_assert (ARV_IS_FAKE_DEVICE (device));
Expand All @@ -494,9 +524,18 @@ converter_test (void)
genicam = arv_device_get_genicam (device);
g_assert (ARV_IS_GC (genicam));

node = arv_gc_get_node (genicam, "ROConverter");
g_assert (ARV_IS_GC_CONVERTER (node));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RO);

node = arv_gc_get_node (genicam, "Converter");
g_assert (ARV_IS_GC_CONVERTER (node));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

v_double = arv_gc_float_get_value (ARV_GC_FLOAT (node), NULL);
g_assert_cmpfloat (v_double, ==, 200.0);

Expand All @@ -507,6 +546,9 @@ converter_test (void)
node = arv_gc_get_node (genicam, "IntConverter");
g_assert (ARV_IS_GC_CONVERTER (node));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

v_int64 = arv_gc_integer_get_value (ARV_GC_INTEGER (node), NULL);
g_assert_cmpint (v_int64, ==, 5);

Expand All @@ -523,9 +565,15 @@ converter_test (void)
v_double = arv_gc_float_get_value (ARV_GC_FLOAT (node), NULL);
g_assert_cmpint (v_double, ==, 5);

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

node = arv_gc_get_node (genicam, "IntConverterTestSubAndConstant");
g_assert (ARV_IS_GC_CONVERTER (node));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

v_int64 = arv_gc_integer_get_value (ARV_GC_INTEGER (node), NULL);
g_assert_cmpint (v_int64, ==, 10000);

Expand All @@ -549,6 +597,7 @@ register_test (void)
ArvGcNode *node_uc;
ArvGcNode *node_f;
ArvGcNode *node_str;
ArvGcAccessMode access_mode;
const char *string;
gint64 value;
double value_f;
Expand All @@ -562,6 +611,12 @@ register_test (void)

/* 64 bit IntReg */

node_a = arv_gc_get_node (genicam, "ROIntRegisterA");
g_assert (ARV_IS_GC_REGISTER (node_a));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node_a));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RO);

node_a = arv_gc_get_node (genicam, "IntRegisterA");
g_assert (ARV_IS_GC_REGISTER (node_a));
value = arv_gc_integer_get_min (ARV_GC_INTEGER (node_a), NULL);
Expand All @@ -571,12 +626,18 @@ register_test (void)
string = arv_gc_integer_get_unit (ARV_GC_INTEGER (node_a));
g_assert_cmpstr (string, ==, "Pa");

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node_a));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

value = arv_gc_register_get_address (ARV_GC_REGISTER (node_a), NULL);
g_assert_cmpint (value, ==, 0x1050);

node_b = arv_gc_get_node (genicam, "IntRegisterB");
g_assert (ARV_IS_GC_REGISTER (node_b));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node_b));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

value = arv_gc_register_get_address (ARV_GC_REGISTER (node_b), NULL);
g_assert_cmpint (value, ==, 0x20ff);

Expand All @@ -596,6 +657,9 @@ register_test (void)
value = arv_gc_integer_get_inc (ARV_GC_INTEGER (node_sc), NULL);
g_assert_cmpint (value, ==, 1);

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node_sc));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

node_uc = arv_gc_get_node (genicam, "IntUnsigned32BitRegisterC");
g_assert (ARV_IS_GC_REGISTER (node_uc));
value = arv_gc_integer_get_min (ARV_GC_INTEGER (node_uc), NULL);
Expand All @@ -605,6 +669,9 @@ register_test (void)
value = arv_gc_integer_get_inc (ARV_GC_INTEGER (node_uc), NULL);
g_assert_cmpint (value, ==, 1);

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node_uc));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

arv_gc_integer_set_value (ARV_GC_INTEGER (node_sc), -1, NULL);

value = arv_gc_integer_get_value (ARV_GC_INTEGER (node_sc), NULL);
Expand Down Expand Up @@ -632,6 +699,9 @@ register_test (void)
value = arv_gc_integer_get_inc (ARV_GC_INTEGER (node_sc), NULL);
g_assert_cmpint (value, ==, 1);

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node_sc));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

node_uc = arv_gc_get_node (genicam, "IntUnsigned16BitRegisterC");
g_assert (ARV_IS_GC_REGISTER (node_uc));
value = arv_gc_integer_get_min (ARV_GC_INTEGER (node_uc), NULL);
Expand All @@ -641,6 +711,9 @@ register_test (void)
value = arv_gc_integer_get_inc (ARV_GC_INTEGER (node_uc), NULL);
g_assert_cmpint (value, ==, 1);

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node_uc));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

arv_gc_integer_set_value (ARV_GC_INTEGER (node_sc), -1, NULL);

value = arv_gc_integer_get_value (ARV_GC_INTEGER (node_sc), NULL);
Expand All @@ -665,6 +738,9 @@ register_test (void)
string = arv_gc_integer_get_unit (ARV_GC_INTEGER (node_sc));
g_assert_cmpstr (string, ==, "V");

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node_sc));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

node_uc = arv_gc_get_node (genicam, "MaskedIntUnsignedRegisterC");
g_assert (ARV_IS_GC_REGISTER (node_uc));
value = arv_gc_integer_get_min (ARV_GC_INTEGER (node_uc), NULL);
Expand All @@ -676,6 +752,9 @@ register_test (void)
string = arv_gc_integer_get_unit (ARV_GC_INTEGER (node_uc));
g_assert_cmpstr (string, ==, "A");

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node_uc));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

/* 4 byte FLoatReg */

arv_gc_integer_set_value (ARV_GC_INTEGER (node_c), 0x1234567887654321, NULL);
Expand All @@ -689,6 +768,9 @@ register_test (void)
string = arv_gc_float_get_unit (ARV_GC_FLOAT (node_f));
g_assert_cmpstr (string, ==, "mA");

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node_f));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

arv_gc_float_set_value (ARV_GC_FLOAT (node_f), 2.0, NULL);
value_f = arv_gc_float_get_value (ARV_GC_FLOAT (node_f), NULL);
g_assert_cmpfloat (value_f, ==, 2.0);
Expand All @@ -710,6 +792,9 @@ register_test (void)
string = arv_gc_float_get_unit (ARV_GC_FLOAT (node_f));
g_assert_cmpstr (string, ==, "mV");

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node_f));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

arv_gc_float_set_value (ARV_GC_FLOAT (node_f), 1.2, NULL);
value_f = arv_gc_float_get_value (ARV_GC_FLOAT (node_f), NULL);
g_assert_cmpfloat (value_f, ==, 1.2);
Expand All @@ -729,6 +814,9 @@ register_test (void)
value = arv_gc_string_get_max_length (ARV_GC_STRING (node_str), NULL);
g_assert_cmpint (value, ==, 4);

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node_str));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

arv_gc_string_set_value (ARV_GC_STRING (node_str), "Toto", NULL);
string = arv_gc_string_get_value (ARV_GC_STRING (node_str), NULL);
g_assert_cmpstr (string, ==, "Toto");
Expand All @@ -752,6 +840,7 @@ string_test (void)
ArvGcNode *node_str;
gint64 value;
const char *str;
ArvGcAccessMode access_mode;

device = arv_fake_device_new ("TEST0", &error);
g_assert (ARV_IS_FAKE_DEVICE (device));
Expand All @@ -763,6 +852,9 @@ string_test (void)
node_str = arv_gc_get_node (genicam, "StringNodeA");
g_assert (ARV_IS_GC_STRING (node_str));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node_str));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

value = arv_gc_string_get_max_length (ARV_GC_STRING (node_str), &error);
g_assert_cmpint (value, ==, 4);
g_assert (error == NULL);
Expand All @@ -781,6 +873,9 @@ string_test (void)
node_str = arv_gc_get_node (genicam, "StringNodeB");
g_assert (ARV_IS_GC_STRING (node_str));

access_mode = arv_gc_feature_node_get_actual_access_mode (ARV_GC_FEATURE_NODE (node_str));
g_assert_cmpint (access_mode, ==, ARV_GC_ACCESS_MODE_RW);

value = arv_gc_string_get_max_length (ARV_GC_STRING (node_str), &error);
g_assert_cmpint (value, ==, G_MAXINT64);
g_assert (error == NULL);
Expand Down

0 comments on commit bee16e8

Please sign in to comment.