const char * arv_gc_enumeration_get_string_value (ArvGcEnumeration *enumeration) { const GSList *iter; gint64 value; g_return_val_if_fail (ARV_IS_GC_ENUMERATION (enumeration), NULL); value = arv_gc_enumeration_get_int_value (enumeration); for (iter = enumeration->entries; iter != NULL; iter = iter->next) { if (arv_gc_enum_entry_get_value (iter->data) == value) { const char *string; string = arv_gc_feature_node_get_name (iter->data); arv_log_genicam ("[GcEnumeration::get_string_value] value = %Ld - string = %s", value, string); return string; } } arv_warning_genicam ("[GcEnumeration::get_string_value] value = %Ld not found for node %s", value, arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (enumeration))); return NULL; }
double arv_gc_property_node_get_double (ArvGcPropertyNode *node, GError **error) { ArvDomNode *pvalue_node; g_return_val_if_fail (ARV_IS_GC_PROPERTY_NODE (node), 0.0); g_return_val_if_fail (error == NULL || *error == NULL, 0.0); pvalue_node = _get_pvalue_node (node); if (pvalue_node == NULL) return g_ascii_strtod (_get_value_data (node), NULL); if (ARV_IS_GC_FLOAT (pvalue_node)) { GError *local_error = NULL; double value; value = arv_gc_float_get_value (ARV_GC_FLOAT (pvalue_node), &local_error); if (local_error != NULL) g_propagate_error (error, local_error); return value; } arv_warning_genicam ("[GcPropertyNode::get_double] Invalid node '%s'", arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (pvalue_node))); return 0.0; }
void arv_gc_enumeration_set_string_value (ArvGcEnumeration *enumeration, const char *value, GError **error) { const GSList *iter; g_return_if_fail (ARV_IS_GC_ENUMERATION (enumeration)); g_return_if_fail (error == NULL || *error == NULL); for (iter = enumeration->entries; iter != NULL; iter = iter->next) if (g_strcmp0 (arv_gc_feature_node_get_name (iter->data), value) == 0) { GError *local_error = NULL; gint64 enum_value; arv_log_genicam ("[GcEnumeration::set_string_value] value = %d - string = %s", &enumeration->value, value); enum_value = arv_gc_enum_entry_get_value (iter->data, &local_error); if (local_error != NULL) { g_propagate_error (error, local_error); return; } arv_gc_enumeration_set_int_value (enumeration, enum_value, &local_error); if (local_error != NULL) g_propagate_error (error, local_error); return; } arv_warning_genicam ("[GcEnumeration::set_string_value] entry %s not found", value); }
void arv_gc_property_node_set_double (ArvGcPropertyNode *node, double v_double, GError **error) { ArvDomNode *pvalue_node; g_return_if_fail (ARV_IS_GC_PROPERTY_NODE (node)); g_return_if_fail (error == NULL || *error == NULL); pvalue_node = _get_pvalue_node (node); if (pvalue_node == NULL) { char buffer[G_ASCII_DTOSTR_BUF_SIZE]; g_ascii_dtostr (buffer, G_ASCII_DTOSTR_BUF_SIZE, v_double); _set_value_data (node, buffer); return ; } if (ARV_IS_GC_FLOAT (pvalue_node)) { GError *local_error = NULL; arv_gc_float_set_value (ARV_GC_FLOAT (pvalue_node), v_double, &local_error); if (local_error != NULL) g_propagate_error (error, local_error); return; } arv_warning_genicam ("[GcPropertyNode::set_double] Invalid linked node '%s'", arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (pvalue_node))); }
gint64 arv_gc_property_node_get_int64 (ArvGcPropertyNode *node, GError **error) { ArvDomNode *pvalue_node; g_return_val_if_fail (ARV_IS_GC_PROPERTY_NODE (node), 0); g_return_val_if_fail (error == NULL || *error == NULL, 0); pvalue_node = _get_pvalue_node (node); if (pvalue_node == NULL) return g_ascii_strtoll (_get_value_data (node), NULL, 0); if (ARV_IS_GC_INTEGER (pvalue_node)) { GError *local_error = NULL; gint64 value; value = arv_gc_integer_get_value (ARV_GC_INTEGER (pvalue_node), &local_error); if (local_error != NULL) g_propagate_error (error, local_error); return value; } arv_warning_genicam ("[GcPropertyNode::get_int64] Invalid node '%s'", arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (pvalue_node))); return 0; }
void arv_gc_property_node_set_int64 (ArvGcPropertyNode *node, gint64 v_int64, GError **error) { ArvDomNode *pvalue_node; g_return_if_fail (ARV_IS_GC_PROPERTY_NODE (node)); g_return_if_fail (error == NULL || *error == NULL); pvalue_node = _get_pvalue_node (node); if (pvalue_node == NULL) { char *buffer; buffer = g_strdup_printf ("%" G_GINT64_FORMAT, v_int64); _set_value_data (node, buffer); g_free (buffer); return ; } if (ARV_IS_GC_INTEGER (pvalue_node)) { GError *local_error = NULL; arv_gc_integer_set_value (ARV_GC_INTEGER (pvalue_node), v_int64, &local_error); if (local_error != NULL) g_propagate_error (error, local_error); return; } arv_warning_genicam ("[GcPropertyNode::set_int64] Invalid linked node '%s'", arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (pvalue_node))); }
void arv_gc_property_node_set_string (ArvGcPropertyNode *node, const char *string, GError **error) { ArvDomNode *pvalue_node; g_return_if_fail (ARV_IS_GC_PROPERTY_NODE (node)); g_return_if_fail (error == NULL || *error == NULL); pvalue_node = _get_pvalue_node (node); if (pvalue_node == NULL) { _set_value_data (node, string); return; } if (ARV_IS_GC_STRING (pvalue_node)) { GError *local_error = NULL; arv_gc_string_set_value (ARV_GC_STRING (pvalue_node), string, &local_error); if (local_error != NULL) g_propagate_error (error, local_error); return; } arv_warning_genicam ("[GcPropertyNode::set_string] Invalid linked node '%s'", arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (pvalue_node))); }
const char * arv_gc_property_node_get_string (ArvGcPropertyNode *node, GError **error) { ArvDomNode *pvalue_node; g_return_val_if_fail (ARV_IS_GC_PROPERTY_NODE (node), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); pvalue_node = _get_pvalue_node (node); if (pvalue_node == NULL) return _get_value_data (node); if (ARV_IS_GC_STRING (pvalue_node)) { GError *local_error = NULL; const char *value; value = arv_gc_string_get_value (ARV_GC_STRING (pvalue_node), &local_error); if (local_error != NULL) g_propagate_error (error, local_error); return value; } arv_warning_genicam ("[GcPropertyNode::get_string] Invalid node '%s'", arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (pvalue_node))); return NULL; }
// Walk the DOM tree, i.e. the tree represented by the XML file in the camera, and that contains all the various features, parameters, etc. void PrintDOMTree(ArvGc *pGenicam, NODEEX nodeex, int nIndent) { char *szIndent=0; const char *szFeature=0; const char *szDomName=0; const char *szFeatureValue=0; szIndent = new char[nIndent+1]; memset(szIndent,' ',nIndent); szIndent[nIndent]=0; nodeex = GetGcFirstChild(pGenicam, nodeex); if (nodeex.pNode) { do { if (ARV_IS_GC_FEATURE_NODE((ArvGcFeatureNode *)nodeex.pNode)) { szDomName = arv_dom_node_get_node_name(nodeex.pNode); szFeature = arv_gc_feature_node_get_name((ArvGcFeatureNode *)nodeex.pNode); szFeatureValue = arv_gc_feature_node_get_value_as_string((ArvGcFeatureNode *)nodeex.pNode, NULL); if (szFeature && szFeatureValue && szFeatureValue[0]) ROS_INFO("FeatureName: %s%s, %s=%s", szIndent, szDomName, szFeature, szFeatureValue); } PrintDOMTree(pGenicam, nodeex, nIndent+4); // Go to the next sibling. nodeex = GetGcNextSibling(pGenicam, nodeex); } while (nodeex.pNode && nodeex.pNodeSibling); } } //PrintDOMTree()
const char * arv_gc_enumeration_get_string_value (ArvGcEnumeration *enumeration, GError **error) { const GSList *iter; GError *local_error = NULL; gint64 value; g_return_val_if_fail (ARV_IS_GC_ENUMERATION (enumeration), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); value = arv_gc_enumeration_get_int_value (enumeration, &local_error); if (local_error != NULL) { g_propagate_error (error, local_error); return NULL; } for (iter = enumeration->entries; iter != NULL; iter = iter->next) { gint64 enum_value; enum_value = arv_gc_enum_entry_get_value (iter->data, &local_error); if (local_error != NULL) { g_propagate_error (error, local_error); return NULL; } if (enum_value == value) { const char *string; string = arv_gc_feature_node_get_name (iter->data); arv_log_genicam ("[GcEnumeration::get_string_value] value = %Ld - string = %s", value, string); return string; } } arv_warning_genicam ("[GcEnumeration::get_string_value] value = %Ld not found for node %s", value, arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (enumeration))); return NULL; }
void arv_gc_float_impose_max (ArvGcFloat *gc_float, double maximum, GError **error) { ArvGcFloatInterface *float_interface; g_return_if_fail (ARV_IS_GC_FLOAT (gc_float)); g_return_if_fail (error == NULL || *error == NULL); float_interface = ARV_GC_FLOAT_GET_INTERFACE (gc_float); if (float_interface->impose_max != NULL) float_interface->impose_max (gc_float, maximum, error); else g_set_error (error, ARV_GC_ERROR, ARV_GC_ERROR_PROPERTY_NOT_DEFINED, "<Max> node not found for '%s'", arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (gc_float))); }
void arv_gc_enumeration_set_string_value (ArvGcEnumeration *enumeration, const char *value) { const GSList *iter; g_return_if_fail (ARV_IS_GC_ENUMERATION (enumeration)); for (iter = enumeration->entries; iter != NULL; iter = iter->next) if (g_strcmp0 (arv_gc_feature_node_get_name (iter->data), value) == 0) { arv_log_genicam ("[GcEnumeration::set_string_value] value = %d - string = %s", &enumeration->value, value); arv_gc_enumeration_set_int_value (enumeration, arv_gc_enum_entry_get_value (iter->data)); return; } arv_warning_genicam ("[GcEnumeration::set_string_value] entry %s not found", value); }
double arv_gc_float_get_inc (ArvGcFloat *gc_float, GError **error) { ArvGcFloatInterface *float_interface; g_return_val_if_fail (ARV_IS_GC_FLOAT (gc_float), 0.0); g_return_val_if_fail (error == NULL || *error == NULL, 0.0); float_interface = ARV_GC_FLOAT_GET_INTERFACE (gc_float); if (float_interface->get_inc != NULL) return float_interface->get_inc (gc_float, error); g_set_error (error, ARV_GC_ERROR, ARV_GC_ERROR_PROPERTY_NOT_DEFINED, "<Inc> node not found for '%s'", arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (gc_float))); return 1; }
static gint64 arv_gc_enumeration_get_max_string_length (ArvGcString *gc_string, GError **error) { ArvGcEnumeration *gc_enumeration = ARV_GC_ENUMERATION (gc_string); const GSList *entries, *iter; gint64 length, max_length = 0; entries = arv_gc_enumeration_get_entries (gc_enumeration); for (iter = entries; iter != NULL; iter = iter->next) { const char *name; name = arv_gc_feature_node_get_name (iter->data); length = name != NULL ? strlen (name) : 0; if (length > max_length) max_length = length; } return max_length; }
void arv_gc_register_feature_node (ArvGc *genicam, ArvGcFeatureNode *node) { const char *name; g_return_if_fail (ARV_IS_GC (genicam)); g_return_if_fail (ARV_IS_GC_FEATURE_NODE (node)); name = arv_gc_feature_node_get_name (node); if (name == NULL) return; g_object_ref (node); g_hash_table_remove (genicam->nodes, (char *) name); g_hash_table_insert (genicam->nodes, (char *) name, node); arv_log_genicam ("[Gc::register_feature_node] Register node '%s' [%s]", name, arv_dom_node_get_node_name (ARV_DOM_NODE (node))); }
static gboolean _update_from_variables (ArvGcConverter *gc_converter, ArvGcConverterNodeType node_type, GError **error) { ArvGcNode *node = NULL; GError *local_error = NULL; GSList *iter; const char *expression; if (gc_converter->formula_from_node != NULL) expression = arv_gc_property_node_get_string (gc_converter->formula_from_node, &local_error); else expression = ""; if (local_error != NULL) { g_propagate_error (error, local_error); return FALSE; } arv_evaluator_set_expression (gc_converter->formula_from, expression); for (iter = gc_converter->expressions; iter != NULL; iter = iter->next) { const char *expression; const char *name; expression = arv_gc_property_node_get_string (ARV_GC_PROPERTY_NODE (iter->data), &local_error); if (local_error != NULL) { g_propagate_error (error, local_error); return FALSE; } name = arv_gc_property_node_get_name (iter->data); arv_evaluator_set_sub_expression (gc_converter->formula_from, name, expression); } for (iter = gc_converter->constants; iter != NULL; iter = iter->next) { const char *constant; const char *name; constant = arv_gc_property_node_get_string (ARV_GC_PROPERTY_NODE (iter->data), &local_error); if (local_error != NULL) { g_propagate_error (error, local_error); return FALSE; } name = arv_gc_property_node_get_name (iter->data); arv_evaluator_set_constant (gc_converter->formula_from, name, constant); } for (iter = gc_converter->variables; iter != NULL; iter = iter->next) { ArvGcPropertyNode *variable_node = iter->data; node = arv_gc_property_node_get_linked_node (ARV_GC_PROPERTY_NODE (variable_node)); if (arv_gc_feature_node_get_value_type (ARV_GC_FEATURE_NODE (node)) == G_TYPE_INT64) { gint64 value; value = arv_gc_integer_get_value (ARV_GC_INTEGER (node), &local_error); if (local_error != NULL) { g_propagate_error (error, local_error); return FALSE; } arv_evaluator_set_int64_variable (gc_converter->formula_from, arv_gc_property_node_get_name (variable_node), value); } else if (arv_gc_feature_node_get_value_type (ARV_GC_FEATURE_NODE (node)) == G_TYPE_DOUBLE) { double value; value = arv_gc_float_get_value (ARV_GC_FLOAT (node), &local_error); if (local_error != NULL) { g_propagate_error (error, local_error); return FALSE; } arv_evaluator_set_double_variable (gc_converter->formula_from, arv_gc_property_node_get_name (variable_node), value); } } if (gc_converter->value != NULL) { node = arv_gc_property_node_get_linked_node (gc_converter->value); if (arv_gc_feature_node_get_value_type (ARV_GC_FEATURE_NODE (node)) == G_TYPE_INT64) { gint64 value; switch (node_type) { case ARV_GC_CONVERTER_NODE_TYPE_MIN: value = arv_gc_integer_get_min (ARV_GC_INTEGER (node), &local_error); break; case ARV_GC_CONVERTER_NODE_TYPE_MAX: value = arv_gc_integer_get_max (ARV_GC_INTEGER (node), &local_error); break; default: value = arv_gc_integer_get_value (ARV_GC_INTEGER (node), &local_error); break; } if (local_error != NULL) { g_propagate_error (error, local_error); return FALSE; } arv_evaluator_set_int64_variable (gc_converter->formula_from, "TO", value); } else if (arv_gc_feature_node_get_value_type (ARV_GC_FEATURE_NODE (node)) == G_TYPE_DOUBLE) { double value; switch (node_type) { case ARV_GC_CONVERTER_NODE_TYPE_MIN: value = arv_gc_float_get_min (ARV_GC_FLOAT (node), &local_error); break; case ARV_GC_CONVERTER_NODE_TYPE_MAX: value = arv_gc_float_get_max (ARV_GC_FLOAT (node), &local_error); break; default: value = arv_gc_float_get_value (ARV_GC_FLOAT (node), &local_error); break; } if (local_error != NULL) { g_propagate_error (error, local_error); return FALSE; } arv_evaluator_set_double_variable (gc_converter->formula_from, "TO", value); } else { arv_warning_genicam ("[GcConverter::set_value] Invalid pValue node '%s'", gc_converter->value); g_set_error (error, ARV_GC_ERROR, ARV_GC_ERROR_INVALID_PVALUE, "pValue node '%s' of '%s' is invalid", arv_gc_property_node_get_string (gc_converter->value, NULL), arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (gc_converter))); return FALSE; } } else { g_set_error (error, ARV_GC_ERROR, ARV_GC_ERROR_PVALUE_NOT_DEFINED, "pValue node of '%s' converter is not defined", arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (gc_converter))); return FALSE; } return TRUE; }