static void _update_variables (ArvGcSwissKnife *gc_swiss_knife, GError **error) { ArvGcNode *node; GError *local_error = NULL; GSList *iter; const char *expression; if (gc_swiss_knife->formula_node != NULL) expression = arv_gc_property_node_get_string (gc_swiss_knife->formula_node, &local_error); else expression = ""; if (local_error != NULL) { g_propagate_error (error, local_error); return; } arv_evaluator_set_expression (gc_swiss_knife->formula, expression); for (iter = gc_swiss_knife->variables; iter != NULL; iter = iter->next) { ArvGcVariableNode *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; } arv_evaluator_set_int64_variable (gc_swiss_knife->formula, arv_gc_variable_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; } arv_evaluator_set_double_variable (gc_swiss_knife->formula, arv_gc_variable_node_get_name (variable_node), value); } } }
static void arv_gc_feature_node_pre_remove_child (ArvDomNode *self, ArvDomNode *child) { ArvGcFeatureNode *node = ARV_GC_FEATURE_NODE (self); if (ARV_IS_GC_PROPERTY_NODE (child)) { ArvGcPropertyNode *property_node = ARV_GC_PROPERTY_NODE (child); switch (arv_gc_property_node_get_node_type (property_node)) { case ARV_GC_PROPERTY_NODE_TYPE_TOOLTIP: node->priv->tooltip = NULL; break; case ARV_GC_PROPERTY_NODE_TYPE_DESCRIPTION: node->priv->description = NULL; break; case ARV_GC_PROPERTY_NODE_TYPE_DISPLAY_NAME: node->priv->description = NULL; break; case ARV_GC_PROPERTY_NODE_TYPE_P_IS_AVAILABLE: node->priv->is_available = NULL; break; case ARV_GC_PROPERTY_NODE_TYPE_P_IS_IMPLEMENTED: node->priv->is_implemented = NULL; break; case ARV_GC_PROPERTY_NODE_TYPE_P_IS_LOCKED: node->priv->is_locked = NULL; break; default: break; } } }
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; }
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))); }
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_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))); }
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_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; }
static void arv_gc_feature_node_finalize (GObject *object) { ArvGcFeatureNode *node = ARV_GC_FEATURE_NODE(object); g_free (node->priv->name); parent_class->finalize (object); }
static void _write_cache (ArvGcRegisterNode *gc_register_node, GError **error) { GError *local_error = NULL; gint64 address; gboolean cachable; ArvGcNode *port; arv_gc_feature_node_inc_modification_count (ARV_GC_FEATURE_NODE (gc_register_node)); port = arv_gc_property_node_get_linked_node (gc_register_node->port); if (!ARV_IS_GC_PORT (port)) return; _update_cache_size (gc_register_node, &local_error); if (local_error != NULL) { g_propagate_error (error, local_error); return; } address = _get_address (gc_register_node, &local_error); if (local_error != NULL) { g_propagate_error (error, local_error); return; } arv_gc_port_write (ARV_GC_PORT (port), gc_register_node->cache, address, gc_register_node->cache_size, &local_error); if (local_error != NULL) { g_propagate_error (error, local_error); return; } cachable = _get_cachable (gc_register_node, &local_error); if (local_error != NULL) { g_propagate_error (error, local_error); return; } if (cachable == ARV_GC_CACHABLE_WRITE_TRHOUGH) gc_register_node->is_cache_valid = TRUE; else gc_register_node->is_cache_valid = FALSE; }
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))); }
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 const char * arv_gc_feature_node_get_attribute (ArvDomElement *self, const char *name) { ArvGcFeatureNode *node = ARV_GC_FEATURE_NODE (self); if (strcmp (name, "Name") == 0) return node->priv->name; else if (strcmp (name, "NameSpace") == 0) switch (node->priv->name_space) { case ARV_GC_NAME_SPACE_STANDARD: return "Standard"; default: return "Custom"; } arv_debug_dom ("[GcFeature::set_attribute] Unknown attribute '%s'", name); return NULL; }
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; }
gboolean _get_cache_validity (ArvGcRegisterNode *gc_register_node) { GSList *iter; gint modification_count; gint feature_modification_count; gboolean is_cache_valid = gc_register_node->is_cache_valid; for (iter = gc_register_node->invalidators; iter != NULL; iter = iter->next) { ArvGcInvalidatorNode *invalidator = iter->data; ArvGcNode *node; modification_count = arv_gc_invalidator_node_get_modification_count (invalidator); node = arv_gc_property_node_get_linked_node (ARV_GC_PROPERTY_NODE (invalidator)); feature_modification_count = arv_gc_feature_node_get_modification_count (ARV_GC_FEATURE_NODE (node)); arv_gc_invalidator_node_set_modification_count (invalidator, feature_modification_count); if (modification_count != feature_modification_count) is_cache_valid = FALSE; } return is_cache_valid; }
static void arv_gc_feature_node_set_attribute (ArvDomElement *self, const char *name, const char *value) { ArvGcFeatureNode *node = ARV_GC_FEATURE_NODE (self); if (strcmp (name, "Name") == 0) { ArvGc *genicam; g_free (node->priv->name); node->priv->name = g_strdup (value); genicam = arv_gc_node_get_genicam (ARV_GC_NODE (self)); /* Kludge around ugly Genicam specification (Really, pre-parsing for EnumEntry Name substitution ?) */ if (strcmp (arv_dom_node_get_node_name (ARV_DOM_NODE (node)), "EnumEntry") != 0) arv_gc_register_feature_node (genicam, node); } else if (strcmp (name, "NameSpace") == 0) { if (g_strcmp0 (value, "Standard") == 0) node->priv->name_space = ARV_GC_NAME_SPACE_STANDARD; else node->priv->name_space = ARV_GC_NAME_SPACE_CUSTOM; } else arv_debug_dom ("[GcFeature::set_attribute] Unknown attribute '%s'", name); }
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; }
int main(int argc, char *argv[]) { ArvDevice *device; ArvStream *stream; ArvCamera *camera; ArvGcFeatureNode *feature; guint64 n_completed_buffers; guint64 n_failures; guint64 n_underruns; GOptionContext *context; GError *error = NULL; void (*old_sigint_handler)(int); int i, payload; arv_g_thread_init (NULL); arv_g_type_init (); context = g_option_context_new (NULL); g_option_context_set_summary (context, "Test of heartbeat robustness while continuously changing a feature."); g_option_context_add_main_entries (context, arv_option_entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_option_context_free (context); g_print ("Option parsing failed: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } g_option_context_free (context); arv_debug_enable (arv_option_debug_domains); camera = arv_camera_new (arv_option_camera_name); if (!ARV_IS_CAMERA (camera)) { printf ("Device not found\n"); return EXIT_FAILURE; } device = arv_camera_get_device (camera); stream = arv_camera_create_stream (camera, NULL, NULL); if (!ARV_IS_STREAM (stream)) { printf ("Invalid device\n"); } else { payload = arv_camera_get_payload (camera); if (ARV_IS_GV_STREAM (stream)) { g_object_set (stream, //"socket-buffer", ARV_GV_STREAM_SOCKET_BUFFER_AUTO, "socket-buffer", ARV_GV_STREAM_SOCKET_BUFFER_FIXED, "socket-buffer-size", payload*6, "packet-timeout", 1000 * 1000, "frame-retention", 100 * 1000, "packet-resend", ARV_GV_STREAM_PACKET_RESEND_ALWAYS, NULL); } for (i = 0; i < 100; i++) arv_stream_push_buffer(stream, arv_buffer_new(payload, NULL)); arv_camera_set_acquisition_mode(camera, ARV_ACQUISITION_MODE_CONTINUOUS); feature = ARV_GC_FEATURE_NODE (arv_device_get_feature (device, arv_option_feature_name)); arv_camera_start_acquisition (camera); old_sigint_handler = signal (SIGINT, set_cancel); while (!cancel) { ArvBuffer *buffer = arv_stream_timeout_pop_buffer(stream, 2000000); if (buffer) { usleep(10); arv_stream_push_buffer (stream, buffer); } if (!(++i%5)) { char *value; if ((i/100) % 2 == 0) value = g_strdup_printf ("%d", arv_option_min); else value = g_strdup_printf ("%d", arv_option_max); fprintf (stderr, "Setting %s from %s to %s\n", arv_option_feature_name, arv_gc_feature_node_get_value_as_string (feature, NULL), value); arv_gc_feature_node_set_value_from_string (feature, value, NULL); g_free (value); } } signal (SIGINT, old_sigint_handler); arv_stream_get_statistics (stream, &n_completed_buffers, &n_failures, &n_underruns); printf ("\nCompleted buffers = %Lu\n", (unsigned long long) n_completed_buffers); printf ("Failures = %Lu\n", (unsigned long long) n_failures); printf ("Underruns = %Lu\n", (unsigned long long) n_underruns); arv_camera_stop_acquisition (camera); } g_object_unref (camera); return 0; }
// WriteCameraFeaturesFromRosparam() // Read ROS parameters from this node's namespace, and see if each parameter has a similarly named & typed feature in the camera. Then set the // camera feature to that value. For example, if the parameter camnode/Gain is set to 123.0, then we'll write 123.0 to the Gain feature // in the camera. // // Note that the datatype of the parameter *must* match the datatype of the camera feature, and this can be determined by // looking at the camera's XML file. Camera enum's are string parameters, camera bools are false/true parameters (not 0/1), // integers are integers, doubles are doubles, etc. // void WriteCameraFeaturesFromRosparam(void) { XmlRpc::XmlRpcValue xmlrpcParams; XmlRpc::XmlRpcValue::iterator iter; ArvGcNode *pGcNode; GError *error=NULL; global.phNode->getParam (ros::this_node::getName(), xmlrpcParams); if (xmlrpcParams.getType() == XmlRpc::XmlRpcValue::TypeStruct) { for (iter=xmlrpcParams.begin(); iter!=xmlrpcParams.end(); iter++) { std::string key = iter->first; pGcNode = arv_device_get_feature (global.pDevice, key.c_str()); if (pGcNode && arv_gc_feature_node_is_implemented (ARV_GC_FEATURE_NODE (pGcNode), &error)) { // unsigned long typeValue = arv_gc_feature_node_get_value_type((ArvGcFeatureNode *)pGcNode); // ROS_INFO("%s cameratype=%lu, rosparamtype=%d", key.c_str(), typeValue, static_cast<int>(iter->second.getType())); // We'd like to check the value types too, but typeValue is often given as G_TYPE_INVALID, so ignore it. switch (iter->second.getType()) { case XmlRpc::XmlRpcValue::TypeBoolean://if ((iter->second.getType()==XmlRpc::XmlRpcValue::TypeBoolean))// && (typeValue==G_TYPE_INT64)) { int value = (bool)iter->second; arv_device_set_integer_feature_value(global.pDevice, key.c_str(), value); ROS_INFO("Read parameter (bool) %s: %d", key.c_str(), value); } break; case XmlRpc::XmlRpcValue::TypeInt: //if ((iter->second.getType()==XmlRpc::XmlRpcValue::TypeInt))// && (typeValue==G_TYPE_INT64)) { int value = (int)iter->second; arv_device_set_integer_feature_value(global.pDevice, key.c_str(), value); ROS_INFO("Read parameter (int) %s: %d", key.c_str(), value); } break; case XmlRpc::XmlRpcValue::TypeDouble: //if ((iter->second.getType()==XmlRpc::XmlRpcValue::TypeDouble))// && (typeValue==G_TYPE_DOUBLE)) { double value = (double)iter->second; arv_device_set_float_feature_value(global.pDevice, key.c_str(), value); ROS_INFO("Read parameter (float) %s: %f", key.c_str(), value); } break; case XmlRpc::XmlRpcValue::TypeString: //if ((iter->second.getType()==XmlRpc::XmlRpcValue::TypeString))// && (typeValue==G_TYPE_STRING)) { std::string value = (std::string)iter->second; arv_device_set_string_feature_value(global.pDevice, key.c_str(), value.c_str()); ROS_INFO("Read parameter (string) %s: %s", key.c_str(), value.c_str()); } break; case XmlRpc::XmlRpcValue::TypeInvalid: case XmlRpc::XmlRpcValue::TypeDateTime: case XmlRpc::XmlRpcValue::TypeBase64: case XmlRpc::XmlRpcValue::TypeArray: case XmlRpc::XmlRpcValue::TypeStruct: default: ROS_WARN("Unhandled rosparam type in WriteCameraFeaturesFromRosparam()"); } } } } } // WriteCameraFeaturesFromRosparam()
int main(int argc, char** argv) { char *pszGuid = NULL; char szGuid[512]; int nInterfaces = 0; int nDevices = 0; int i = 0; const char *pkeyAcquisitionFrameRate[2] = {"AcquisitionFrameRate", "AcquisitionFrameRateAbs"}; ArvGcNode *pGcNode; GError *error=NULL; global.bCancel = FALSE; global.config = global.config.__getDefault__(); global.idSoftwareTriggerTimer = 0; ros::init(argc, argv, "camera"); global.phNode = new ros::NodeHandle(); // Service callback for firing nuc's. // Needed since we cannot open another connection to cameras while streaming. ros::NodeHandle nh; ros::ServiceServer NUCservice = nh.advertiseService("FireNUC", NUCService_callback); //g_type_init (); // Print out some useful info. ROS_INFO ("Attached cameras:"); arv_update_device_list(); nInterfaces = arv_get_n_interfaces(); ROS_INFO ("# Interfaces: %d", nInterfaces); nDevices = arv_get_n_devices(); ROS_INFO ("# Devices: %d", nDevices); for (i=0; i<nDevices; i++) ROS_INFO ("Device%d: %s", i, arv_get_device_id(i)); if (nDevices>0) { // Get the camera guid from either the command-line or as a parameter. if (argc==2) { strcpy(szGuid, argv[1]); pszGuid = szGuid; } else { if (global.phNode->hasParam(ros::this_node::getName()+"/guid")) { std::string stGuid; global.phNode->getParam(ros::this_node::getName()+"/guid", stGuid); strcpy (szGuid, stGuid.c_str()); pszGuid = szGuid; } else pszGuid = NULL; } // Open the camera, and set it up. ROS_INFO("Opening: %s", pszGuid ? pszGuid : "(any)"); while (TRUE) { global.pCamera = arv_camera_new(pszGuid); if (global.pCamera) break; else { ROS_WARN ("Could not open camera %s. Retrying...", pszGuid); ros::Duration(1.0).sleep(); ros::spinOnce(); } } global.pDevice = arv_camera_get_device(global.pCamera); ROS_INFO("Opened: %s-%s", arv_device_get_string_feature_value (global.pDevice, "DeviceVendorName"), arv_device_get_string_feature_value (global.pDevice, "DeviceID")); // See if some basic camera features exist. pGcNode = arv_device_get_feature (global.pDevice, "AcquisitionMode"); global.isImplementedAcquisitionMode = ARV_GC_FEATURE_NODE (pGcNode) ? arv_gc_feature_node_is_implemented (ARV_GC_FEATURE_NODE (pGcNode), &error) : FALSE; pGcNode = arv_device_get_feature (global.pDevice, "GainRaw"); global.isImplementedGain = ARV_GC_FEATURE_NODE (pGcNode) ? arv_gc_feature_node_is_implemented (ARV_GC_FEATURE_NODE (pGcNode), &error) : FALSE; pGcNode = arv_device_get_feature (global.pDevice, "Gain"); global.isImplementedGain |= ARV_GC_FEATURE_NODE (pGcNode) ? arv_gc_feature_node_is_implemented (ARV_GC_FEATURE_NODE (pGcNode), &error) : FALSE; pGcNode = arv_device_get_feature (global.pDevice, "ExposureTimeAbs"); global.isImplementedExposureTimeAbs = ARV_GC_FEATURE_NODE (pGcNode) ? arv_gc_feature_node_is_implemented (ARV_GC_FEATURE_NODE (pGcNode), &error) : FALSE; pGcNode = arv_device_get_feature (global.pDevice, "ExposureAuto"); global.isImplementedExposureAuto = ARV_GC_FEATURE_NODE (pGcNode) ? arv_gc_feature_node_is_implemented (ARV_GC_FEATURE_NODE (pGcNode), &error) : FALSE; pGcNode = arv_device_get_feature (global.pDevice, "GainAuto"); global.isImplementedGainAuto = ARV_GC_FEATURE_NODE (pGcNode) ? arv_gc_feature_node_is_implemented (ARV_GC_FEATURE_NODE (pGcNode), &error) : FALSE; pGcNode = arv_device_get_feature (global.pDevice, "TriggerSelector"); global.isImplementedTriggerSelector = ARV_GC_FEATURE_NODE (pGcNode) ? arv_gc_feature_node_is_implemented (ARV_GC_FEATURE_NODE (pGcNode), &error) : FALSE; pGcNode = arv_device_get_feature (global.pDevice, "TriggerSource"); global.isImplementedTriggerSource = ARV_GC_FEATURE_NODE (pGcNode) ? arv_gc_feature_node_is_implemented (ARV_GC_FEATURE_NODE (pGcNode), &error) : FALSE; pGcNode = arv_device_get_feature (global.pDevice, "TriggerMode"); global.isImplementedTriggerMode = ARV_GC_FEATURE_NODE (pGcNode) ? arv_gc_feature_node_is_implemented (ARV_GC_FEATURE_NODE (pGcNode), &error) : FALSE; pGcNode = arv_device_get_feature (global.pDevice, "FocusPos"); global.isImplementedFocusPos = ARV_GC_FEATURE_NODE (pGcNode) ? arv_gc_feature_node_is_implemented (ARV_GC_FEATURE_NODE (pGcNode), &error) : FALSE; pGcNode = arv_device_get_feature (global.pDevice, "GevSCPSPacketSize"); global.isImplementedMtu = ARV_GC_FEATURE_NODE (pGcNode) ? arv_gc_feature_node_is_implemented (ARV_GC_FEATURE_NODE (pGcNode), &error) : FALSE; pGcNode = arv_device_get_feature (global.pDevice, "AcquisitionFrameRateEnable"); global.isImplementedAcquisitionFrameRateEnable = ARV_GC_FEATURE_NODE (pGcNode) ? arv_gc_feature_node_is_implemented (ARV_GC_FEATURE_NODE (pGcNode), &error) : FALSE; // Find the key name for framerate. global.keyAcquisitionFrameRate = NULL; for (i=0; i<2; i++) { pGcNode = arv_device_get_feature (global.pDevice, pkeyAcquisitionFrameRate[i]); global.isImplementedAcquisitionFrameRate = pGcNode ? arv_gc_feature_node_is_implemented (ARV_GC_FEATURE_NODE (pGcNode), &error) : FALSE; if (global.isImplementedAcquisitionFrameRate) { global.keyAcquisitionFrameRate = pkeyAcquisitionFrameRate[i]; break; } } // Get parameter bounds. arv_camera_get_exposure_time_bounds (global.pCamera, &global.configMin.ExposureTimeAbs, &global.configMax.ExposureTimeAbs); arv_camera_get_gain_bounds (global.pCamera, &global.configMin.Gain, &global.configMax.Gain); arv_camera_get_sensor_size (global.pCamera, &global.widthSensor, &global.heightSensor); arv_camera_get_width_bounds (global.pCamera, &global.widthRoiMin, &global.widthRoiMax); arv_camera_get_height_bounds (global.pCamera, &global.heightRoiMin, &global.heightRoiMax); if (global.isImplementedFocusPos) { gint64 focusMin64, focusMax64; arv_device_get_integer_feature_bounds (global.pDevice, "FocusPos", &focusMin64, &focusMax64); global.configMin.FocusPos = focusMin64; global.configMax.FocusPos = focusMax64; } else { global.configMin.FocusPos = 0; global.configMax.FocusPos = 0; } global.configMin.AcquisitionFrameRate = 0.0; global.configMax.AcquisitionFrameRate = 1000.0; // Initial camera settings. if (global.isImplementedExposureTimeAbs) arv_device_set_float_feature_value(global.pDevice, "ExposureTimeAbs", global.config.ExposureTimeAbs); if (global.isImplementedGain) arv_camera_set_gain(global.pCamera, global.config.Gain); //arv_device_set_integer_feature_value(global.pDevice, "GainRaw", global.config.GainRaw); if (global.isImplementedAcquisitionFrameRateEnable) arv_device_set_integer_feature_value(global.pDevice, "AcquisitionFrameRateEnable", 1); if (global.isImplementedAcquisitionFrameRate) arv_device_set_float_feature_value(global.pDevice, global.keyAcquisitionFrameRate, global.config.AcquisitionFrameRate); // Set up the triggering. if (global.isImplementedTriggerMode) { if (global.isImplementedTriggerSelector && global.isImplementedTriggerMode) { arv_device_set_string_feature_value(global.pDevice, "TriggerSelector", "AcquisitionStart"); arv_device_set_string_feature_value(global.pDevice, "TriggerMode", "Off"); arv_device_set_string_feature_value(global.pDevice, "TriggerSelector", "FrameStart"); arv_device_set_string_feature_value(global.pDevice, "TriggerMode", "Off"); } } WriteCameraFeaturesFromRosparam (); #ifdef TUNING ros::Publisher pubInt64 = global.phNode->advertise<std_msgs::Int64>(ros::this_node::getName()+"/dt", 100); global.ppubInt64 = &pubInt64; #endif // Grab the calibration file url from the param server if exists std::string calibrationURL = ""; // Default looks in .ros/camera_info if (!(ros::param::get(std::string("calibrationURL").append(arv_device_get_string_feature_value (global.pDevice, "DeviceID")), calibrationURL))) { ROS_ERROR("ERROR: Could not read calibrationURL from parameter server"); } // Start the camerainfo manager. global.pCameraInfoManager = new camera_info_manager::CameraInfoManager(ros::NodeHandle(ros::this_node::getName()), arv_device_get_string_feature_value (global.pDevice, "DeviceID"), calibrationURL); // Start the dynamic_reconfigure server. dynamic_reconfigure::Server<Config> reconfigureServer; dynamic_reconfigure::Server<Config>::CallbackType reconfigureCallback; reconfigureCallback = boost::bind(&RosReconfigure_callback, _1, _2); reconfigureServer.setCallback(reconfigureCallback); ros::Duration(2.0).sleep(); // Get parameter current values. global.xRoi=0; global.yRoi=0; global.widthRoi=0; global.heightRoi=0; arv_camera_get_region (global.pCamera, &global.xRoi, &global.yRoi, &global.widthRoi, &global.heightRoi); global.config.ExposureTimeAbs = global.isImplementedExposureTimeAbs ? arv_device_get_float_feature_value (global.pDevice, "ExposureTimeAbs") : 0; global.config.Gain = global.isImplementedGain ? arv_camera_get_gain (global.pCamera) : 0.0; global.pszPixelformat = g_string_ascii_down(g_string_new(arv_device_get_string_feature_value(global.pDevice, "PixelFormat")))->str; global.nBytesPixel = ARV_PIXEL_FORMAT_BYTE_PER_PIXEL(arv_device_get_integer_feature_value(global.pDevice, "PixelFormat")); global.config.FocusPos = global.isImplementedFocusPos ? arv_device_get_integer_feature_value (global.pDevice, "FocusPos") : 0; // Print information. ROS_INFO (" Using Camera Configuration:"); ROS_INFO (" ---------------------------"); ROS_INFO (" Vendor name = %s", arv_device_get_string_feature_value (global.pDevice, "DeviceVendorName")); ROS_INFO (" Model name = %s", arv_device_get_string_feature_value (global.pDevice, "DeviceModelName")); ROS_INFO (" Device id = %s", arv_device_get_string_feature_value (global.pDevice, "DeviceID")); ROS_INFO (" Sensor width = %d", global.widthSensor); ROS_INFO (" Sensor height = %d", global.heightSensor); ROS_INFO (" ROI x,y,w,h = %d, %d, %d, %d", global.xRoi, global.yRoi, global.widthRoi, global.heightRoi); ROS_INFO (" Pixel format = %s", global.pszPixelformat); ROS_INFO (" BytesPerPixel = %d", global.nBytesPixel); ROS_INFO (" Acquisition Mode = %s", global.isImplementedAcquisitionMode ? arv_device_get_string_feature_value (global.pDevice, "AcquisitionMode") : "(not implemented in camera)"); ROS_INFO (" Trigger Mode = %s", global.isImplementedTriggerMode ? arv_device_get_string_feature_value (global.pDevice, "TriggerMode") : "(not implemented in camera)"); ROS_INFO (" Trigger Source = %s", global.isImplementedTriggerSource ? arv_device_get_string_feature_value(global.pDevice, "TriggerSource") : "(not implemented in camera)"); ROS_INFO (" Can set FrameRate: %s", global.isImplementedAcquisitionFrameRate ? "True" : "False"); if (global.isImplementedAcquisitionFrameRate) { global.config.AcquisitionFrameRate = arv_device_get_float_feature_value (global.pDevice, global.keyAcquisitionFrameRate); ROS_INFO (" AcquisitionFrameRate = %g hz", global.config.AcquisitionFrameRate); } ROS_INFO (" Can set Exposure: %s", global.isImplementedExposureTimeAbs ? "True" : "False"); if (global.isImplementedExposureTimeAbs) { ROS_INFO (" Can set ExposureAuto: %s", global.isImplementedExposureAuto ? "True" : "False"); ROS_INFO (" Exposure = %g us in range [%g,%g]", global.config.ExposureTimeAbs, global.configMin.ExposureTimeAbs, global.configMax.ExposureTimeAbs); } ROS_INFO (" Can set Gain: %s", global.isImplementedGain ? "True" : "False"); if (global.isImplementedGain) { ROS_INFO (" Can set GainAuto: %s", global.isImplementedGainAuto ? "True" : "False"); ROS_INFO (" Gain = %f %% in range [%f,%f]", global.config.Gain, global.configMin.Gain, global.configMax.Gain); } ROS_INFO (" Can set FocusPos: %s", global.isImplementedFocusPos ? "True" : "False"); if (global.isImplementedMtu) ROS_INFO (" Network mtu = %lu", arv_device_get_integer_feature_value(global.pDevice, "GevSCPSPacketSize")); ROS_INFO (" ---------------------------"); // // Print the tree of camera features, with their values. // ROS_INFO (" ----------------------------------------------------------------------------------"); // NODEEX nodeex; // ArvGc *pGenicam=0; // pGenicam = arv_device_get_genicam(global.pDevice); // // nodeex.szName = "Root"; // nodeex.pNode = (ArvDomNode *)arv_gc_get_node(pGenicam, nodeex.szName); // nodeex.pNodeSibling = NULL; // PrintDOMTree(pGenicam, nodeex, 0); // ROS_INFO (" ----------------------------------------------------------------------------------"); ArvGvStream *pStream = NULL; while (TRUE) { pStream = CreateStream(); if (pStream) break; else { ROS_WARN("Could not create image stream for %s. Retrying...", pszGuid); ros::Duration(1.0).sleep(); ros::spinOnce(); } } ApplicationData applicationdata; applicationdata.nBuffers=0; applicationdata.main_loop = 0; // Set up image_raw. image_transport::ImageTransport *pTransport = new image_transport::ImageTransport(*global.phNode); global.publisher = pTransport->advertiseCamera(ros::this_node::getName()+"/image_raw", 1); // Connect signals with callbacks. g_signal_connect (pStream, "new-buffer", G_CALLBACK (NewBuffer_callback), &applicationdata); g_signal_connect (global.pDevice, "control-lost", G_CALLBACK (ControlLost_callback), NULL); g_timeout_add_seconds (1, PeriodicTask_callback, &applicationdata); arv_stream_set_emit_signals ((ArvStream *)pStream, TRUE); void (*pSigintHandlerOld)(int); pSigintHandlerOld = signal (SIGINT, set_cancel); arv_device_execute_command (global.pDevice, "AcquisitionStart"); applicationdata.main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (applicationdata.main_loop); if (global.idSoftwareTriggerTimer) { g_source_remove(global.idSoftwareTriggerTimer); global.idSoftwareTriggerTimer = 0; } signal (SIGINT, pSigintHandlerOld); g_main_loop_unref (applicationdata.main_loop); guint64 n_completed_buffers; guint64 n_failures; guint64 n_underruns; guint64 n_resent; guint64 n_missing; arv_stream_get_statistics ((ArvStream *)pStream, &n_completed_buffers, &n_failures, &n_underruns); ROS_INFO ("Completed buffers = %Lu", (unsigned long long) n_completed_buffers); ROS_INFO ("Failures = %Lu", (unsigned long long) n_failures); ROS_INFO ("Underruns = %Lu", (unsigned long long) n_underruns); arv_gv_stream_get_statistics (pStream, &n_resent, &n_missing); ROS_INFO ("Resent buffers = %Lu", (unsigned long long) n_resent); ROS_INFO ("Missing = %Lu", (unsigned long long) n_missing); arv_device_execute_command (global.pDevice, "AcquisitionStop"); g_object_unref (pStream); } else ROS_ERROR ("No cameras detected."); delete global.phNode; return 0; } // main()
int main (int argc, char **argv) { ArvCamera * camera; ArvStream *stream; ArvBuffer *buffer; GOptionContext *context; GError *error = NULL; char memory_buffer[100000]; int i; arv_g_thread_init (NULL); arv_g_type_init (); context = g_option_context_new (NULL); g_option_context_add_main_entries (context, arv_option_entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_option_context_free (context); g_print ("Option parsing failed: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } g_option_context_free (context); if (arv_option_max_frames < 0) arv_option_max_errors_before_abort = -1; save_buffer_fn = GetSaveBufferFn(arv_option_save_type); arv_debug_enable (arv_option_debug_domains); if (arv_option_camera_name == NULL) g_print ("Looking for the first available camera\n"); else g_print ("Looking for camera '%s'\n", arv_option_camera_name); camera = arv_camera_new (arv_option_camera_name); int errors = 0; if (camera == NULL) { g_print("No device found"); return 1; } guint payload_size = arv_camera_get_payload(camera); g_print ("payload size = %d (0x%x)\n", payload_size, payload_size); stream = arv_camera_create_stream (camera, NULL, NULL); if (arv_option_auto_buffer) { g_object_set (stream,"socket-buffer", ARV_GV_STREAM_SOCKET_BUFFER_AUTO,"socket-buffer-size", 0,NULL); } for (i = 0; i < 30; i++) { arv_stream_push_buffer (stream, arv_buffer_new (payload_size, NULL)); } arv_camera_stop_acquisition(camera); // set the bit depth ArvDevice * device = arv_camera_get_device(camera); ArvGcNode * feature = arv_device_get_feature(device, "PixelFormat"); char * pix_format = "Mono8"; if (arv_option_pixel_format == 14) pix_format = "Mono14"; arv_gc_feature_node_set_value_from_string(ARV_GC_FEATURE_NODE(feature), pix_format, NULL); if (arv_option_pixel_format == 14) { feature = arv_device_get_feature(device, "CMOSBitDepth"); arv_gc_feature_node_set_value_from_string(ARV_GC_FEATURE_NODE(feature), "bit14bit", NULL); } signal (SIGINT, set_cancel); signal (SIGQUIT, set_cancel); int captured_frames = 0; guint64 timeout=1000000; #define _CAN_STOP (arv_option_max_frames > 0 && captured_frames >= arv_option_max_frames) arv_camera_start_acquisition(camera); do { g_usleep (100000); do { buffer = arv_stream_timeout_pop_buffer (stream, timeout); if (buffer == NULL) break; ArvBufferStatus status = arv_buffer_get_status(buffer); fprintf(stderr, "Status is %d\n", status); if (status == ARV_BUFFER_STATUS_SUCCESS) { if (timeout > 100000) timeout -= 1000; errors = 0; if (save_buffer_fn != NULL) { struct timespec timestamp; clock_gettime(CLOCK_REALTIME, ×tamp); char filename[BUFSIZ]; if (strcmp(arv_option_save_prefix,"") != 0) { sprintf(filename, "%s/%s%d.%s", arv_option_save_dir,arv_option_save_prefix, captured_frames, arv_option_save_type); } else { sprintf(filename, "%s/%d.%03ld.%s", arv_option_save_dir, (int)timestamp.tv_sec, (long)(timestamp.tv_nsec/1.0e6), arv_option_save_type); } if ((*save_buffer_fn)(buffer, filename) == false) { g_print("Couldn't save frame %d to %s\n", captured_frames, filename); set_cancel(SIGQUIT); } g_print("Saved frame %d to %s\n", captured_frames, filename); char latest[] = "latest.png"; sprintf(latest, "latest.%s", arv_option_save_type); unlink(latest); symlink(filename, latest); } captured_frames++; g_usleep(arv_option_sample_period); } else { if (timeout < 10000000) timeout+=1000; fprintf(stderr, "%d errors out of %d allowed\n", errors, arv_option_max_errors_before_abort); arv_camera_stop_acquisition(camera); if (++errors > arv_option_max_errors_before_abort && arv_option_max_errors_before_abort >= 0) { set_cancel(SIGQUIT); } else { arv_camera_start_acquisition(camera); } } arv_stream_push_buffer (stream, buffer); } while (!cancel && buffer != NULL && !_CAN_STOP); } while (!cancel && !_CAN_STOP); arv_camera_stop_acquisition(camera); guint64 n_processed_buffers; guint64 n_failures; guint64 n_underruns; arv_stream_get_statistics (stream, &n_processed_buffers, &n_failures, &n_underruns); g_print ("Processed buffers = %Lu\n", (unsigned long long) n_processed_buffers); g_print ("Failures = %Lu\n", (unsigned long long) n_failures); g_print ("Underruns = %Lu\n", (unsigned long long) n_underruns); g_object_unref (stream); g_object_unref (camera); return (errors > 0); }
static void _update_to_variables (ArvGcConverter *gc_converter, GError **error) { ArvGcNode *node; GError *local_error = NULL; GSList *iter; const char *expression; if (gc_converter->formula_to_node != NULL) expression = arv_gc_property_node_get_string (gc_converter->formula_to_node, &local_error); else expression = ""; if (local_error != NULL) { g_propagate_error (error, local_error); return; } arv_evaluator_set_expression (gc_converter->formula_to, 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; } name = arv_gc_property_node_get_name (iter->data); arv_evaluator_set_sub_expression (gc_converter->formula_to, 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; } name = arv_gc_property_node_get_name (iter->data); arv_evaluator_set_constant (gc_converter->formula_to, 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; } arv_evaluator_set_int64_variable (gc_converter->formula_to, 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; } arv_evaluator_set_double_variable (gc_converter->formula_to, 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) { arv_gc_integer_set_value (ARV_GC_INTEGER (node), arv_evaluator_evaluate_as_double (gc_converter->formula_to, NULL), &local_error); if (local_error != NULL) { g_propagate_error (error, local_error); return; } } else if (arv_gc_feature_node_get_value_type (ARV_GC_FEATURE_NODE (node)) == G_TYPE_DOUBLE) { arv_gc_float_set_value (ARV_GC_FLOAT (node), arv_evaluator_evaluate_as_double (gc_converter->formula_to, NULL), &local_error); if (local_error != NULL) { g_propagate_error (error, local_error); return; } } else arv_warning_genicam ("[GcConverter::set_value] Invalid pValue node '%s'", gc_converter->value); } }