Exemple #1
0
// Get the sibling and the sibling's sibling, where <p___> indicates an indirection.
NODEEX GetGcNextSibling(ArvGc *pGenicam, NODEEX nodeex)
{
	const char *szName=0;

	// Go to the sibling.
	nodeex.pNode = nodeex.pNodeSibling;
	if (nodeex.pNode)
	{
		nodeex.szName = arv_dom_node_get_node_name(nodeex.pNode);
		nodeex.pNodeSibling = arv_dom_node_get_next_sibling(nodeex.pNode);

		// Do the indirection.
		if (nodeex.szName[0]=='p' && strcmp("pInvalidator", nodeex.szName))
		{
			szName = arv_dom_node_get_node_value(arv_dom_node_get_first_child(nodeex.pNode));
			nodeex.pNode = (ArvDomNode *)arv_gc_get_node(pGenicam, szName);
			nodeex.szTag = nodeex.pNode ? arv_dom_node_get_node_name(nodeex.pNode) : NULL;
		}
		else
		{
			nodeex.szTag = nodeex.szName;
		}
	}
	else 
	{
		nodeex.szName = NULL;
		nodeex.szTag = NULL;
		nodeex.pNodeSibling = NULL;
	}

	//ROS_INFO("GNS name=%s, node=%p, sib=%p", nodeex.szName, nodeex.pNode, nodeex.pNodeSibling);

	
	return nodeex;
} // GetGcNextSibling()
QArvCamera::QArvFeatureTree*
QArvCamera::QArvFeatureTree::createFeaturetree(ArvGc* cam)
{
  QArvCamera::QArvFeatureTree* tree =
    new QArvCamera::QArvFeatureTree(NULL, "Root");
  ArvGcNode* node = arv_gc_get_node(cam, tree->feature());
  recursiveMerge(cam, tree, node);
  return tree;
}
Exemple #3
0
ArvGcNode *
arv_gc_property_node_get_linked_node (ArvGcPropertyNode *node)
{
	ArvGc *genicam;

	g_return_val_if_fail (ARV_IS_GC_PROPERTY_NODE (node), NULL);
	g_return_val_if_fail (node->type > ARV_GC_PROPERTY_NODE_TYPE_P_UNKNONW, NULL);

	genicam = arv_gc_node_get_genicam (ARV_GC_NODE (node));
	return arv_gc_get_node (genicam, _get_value_data (node));
}
Exemple #4
0
void
arv_gc_set_default_node_data (ArvGc *genicam, const char *node_name, const char *node_data)
{
	g_return_if_fail (ARV_IS_GC (genicam));
	g_return_if_fail (node_name != NULL);
	g_return_if_fail (node_data != NULL);

	if (arv_gc_get_node (genicam, node_name) != NULL)
		return;

	arv_dom_document_append_from_memory (ARV_DOM_DOCUMENT (genicam), NULL, node_data, -1, NULL);
}
/**@{*/
void
QArvCamera::QArvFeatureTree::recursiveMerge(ArvGc* cam,
                                            QArvCamera::QArvFeatureTree* tree,
                                            ArvGcNode* node)
{
  const GSList* child = arv_gc_category_get_features(ARV_GC_CATEGORY(node));
  for (; child != NULL; child = child->next) {
    ArvGcNode* newnode = arv_gc_get_node(cam, (const char*)(child->data));
    auto newtree =
      new QArvCamera::QArvFeatureTree(tree, (const char*)(child->data));
    if (ARV_IS_GC_CATEGORY(newnode))
      recursiveMerge(cam, newtree, newnode);
  }
}
Exemple #6
0
static ArvDomNode *
_get_pvalue_node (ArvGcPropertyNode *property_node)
{
	ArvDomNode *pvalue_node;
	const char *node_name;
	ArvGc *genicam;

	if (property_node->type < ARV_GC_PROPERTY_NODE_TYPE_P_UNKNONW)
		return NULL;

	node_name = _get_value_data (property_node);
	genicam = arv_gc_node_get_genicam (ARV_GC_NODE (property_node));
	pvalue_node = ARV_DOM_NODE (arv_gc_get_node (genicam, node_name));

	return pvalue_node;
}
//! Serialize the tree, used by QArvCamera stream operators.
void
QArvCamera::QArvFeatureTree::recursiveSerialization(
  QTextStream& out, QArvCamera* camera, QArvCamera::QArvFeatureTree* tree)
{
  auto node = arv_gc_get_node(camera->genicam, tree->feature());

  if (tree->children().count() != 0) {
    if (QString("Root") != tree->feature())
      out << "Category: " << tree->feature() << endl;
    foreach (auto child, tree->children()) {
      recursiveSerialization(out, camera, child);
    }
    return;
  }

  if (ARV_IS_GC_COMMAND(node))
    return;

  out << "\t" << tree->feature() << "\t";
  if (ARV_IS_GC_REGISTER_NODE(node) &&
      QString(arv_dom_node_get_node_name(ARV_DOM_NODE(node))) == "IntReg") {
    QArvRegister r;
    r.length = arv_gc_register_get_length(ARV_GC_REGISTER(node), NULL);
    r.value = QByteArray(r.length, 0);
    arv_gc_register_get(ARV_GC_REGISTER(node), r.value.data(), r.length, NULL);
    out << "Register\t" << QString::number(r.length) << "\t"
        << QString("0x") + r.value.toHex() << endl;
  } else if (ARV_IS_GC_ENUMERATION(node)) {
    out << "Enumeration\t"
        << arv_gc_enumeration_get_string_value(ARV_GC_ENUMERATION(node), NULL)
        << endl;
  } else if (ARV_IS_GC_STRING(node)) {
    out << "String\t" << arv_gc_string_get_value(ARV_GC_STRING(node), NULL)
        << endl;
  } else if (ARV_IS_GC_FLOAT(node)) {
    out << "Float\t" << arv_gc_float_get_value(ARV_GC_FLOAT(node), NULL) << "\t"
        << arv_gc_float_get_unit(ARV_GC_FLOAT(node), NULL) << endl;
  } else if (ARV_IS_GC_BOOLEAN(node)) {
    out << "Boolean\t" << arv_gc_boolean_get_value(ARV_GC_BOOLEAN(node), NULL)
        << endl;
  } else if (ARV_IS_GC_INTEGER(node)) {
    out << "Integer\t" << arv_gc_integer_get_value(ARV_GC_INTEGER(node), NULL)
        << endl;
  }
}
Exemple #8
0
const char *
arv_chunk_parser_get_string_value (ArvChunkParser *parser, ArvBuffer *buffer, const char *chunk)
{
	ArvGcNode *node;
	const char *string = NULL;

	g_return_val_if_fail (ARV_IS_CHUNK_PARSER (parser), NULL);
	g_return_val_if_fail (ARV_IS_BUFFER (buffer), NULL);

	node = arv_gc_get_node (parser->priv->genicam, chunk);
	arv_gc_set_buffer (parser->priv->genicam, buffer);

	if (ARV_IS_GC_STRING (node))
		string = arv_gc_string_get_value (ARV_GC_STRING (node), NULL);
	else
		arv_warning_device ("[ArvChunkParser::get_string_value] Node '%s' is not a string", chunk);

	return string;
}
Exemple #9
0
double
arv_chunk_parser_get_float_value (ArvChunkParser *parser, ArvBuffer *buffer, const char *chunk)
{
	ArvGcNode *node;
	double value = 0.0;

	g_return_val_if_fail (ARV_IS_CHUNK_PARSER (parser), 0.0);
	g_return_val_if_fail (ARV_IS_BUFFER (buffer), 0.0);

	node = arv_gc_get_node (parser->priv->genicam, chunk);
	arv_gc_set_buffer (parser->priv->genicam, buffer);

	if (ARV_IS_GC_FLOAT (node))
		value = arv_gc_float_get_value (ARV_GC_FLOAT (node), NULL);
	else 
		arv_warning_chunk ("[ArvChunkParser::get_float_value] Node '%s' is not a float", chunk);

	return value;
}
Exemple #10
0
gint64
arv_chunk_parser_get_integer_value (ArvChunkParser *parser, ArvBuffer *buffer, const char *chunk)
{
	ArvGcNode *node;
	gint64 value = 0;

	g_return_val_if_fail (ARV_IS_CHUNK_PARSER (parser), 0.0);
	g_return_val_if_fail (ARV_IS_BUFFER (buffer), 0.0);

	node = arv_gc_get_node (parser->priv->genicam, chunk);
	arv_gc_set_buffer (parser->priv->genicam, buffer);

	if (ARV_IS_GC_INTEGER (node))
		value = arv_gc_integer_get_value (ARV_GC_INTEGER (node), NULL);
	else
		arv_warning_device ("[ArvChunkParser::get_integer_value] Node '%s' is not an integer", chunk);

	return value;
}
Exemple #11
0
gint64
arv_gc_index_node_get_index (ArvGcIndexNode *index_node, gint64 default_offset, GError **error)
{
	gint64 offset;
	gint64 node_value;
	GError *local_error = NULL;

	g_return_val_if_fail (ARV_IS_GC_INDEX_NODE (index_node), 0);
	g_return_val_if_fail (error == NULL || *error == NULL, 0);

	if (index_node->offset == NULL)
		offset = default_offset;
	else {
		if (index_node->is_p_offset) {
			ArvGcNode *node;
			ArvGc *genicam;

			genicam = arv_gc_node_get_genicam (ARV_GC_NODE (index_node));
			node = arv_gc_get_node (genicam, index_node->offset);
			offset = arv_gc_integer_get_value (ARV_GC_INTEGER (node), &local_error);

			if (local_error != NULL) {
				g_propagate_error (error, local_error);

				return 0;
			}
		} else
			offset = g_ascii_strtoll (index_node->offset, NULL, 0);
	}

	node_value = arv_gc_property_node_get_int64 (ARV_GC_PROPERTY_NODE (index_node), &local_error);

	if (local_error != NULL) {
		g_propagate_error (error, local_error);
		return 0;
	}

	return offset * node_value;
}
Exemple #12
0
int
main (int argc, char **argv)
{
	ArvGc *genicam;
	char *xml;
	size_t size;
	GOptionContext *context;
	GError *error = NULL;
	int i;

	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);

	arv_debug_enable (arv_option_debug_domains);

	if (arv_option_filenames == NULL) {
		g_print ("Missing input filename.\n");
		return EXIT_FAILURE;
	}

	for (i = 0; arv_option_filenames[i] != NULL; i++) {
		g_file_get_contents (arv_option_filenames[i], &xml, &size, NULL);

		if (xml != NULL) {
			ArvGcNode *node;

			g_print ("Loading '%s'.\n", arv_option_filenames[i]);

			genicam = arv_gc_new (NULL, xml, size);

			node = arv_gc_get_node (genicam, "RegAcquisitionCommand");
			if (node != NULL) {
				g_print ("RegAcquisitionCommand address = 0x%Lx - length = 0x%Lx\n",
					 (unsigned long long) arv_gc_register_get_address (ARV_GC_REGISTER (node), NULL),
					 (unsigned long long) arv_gc_register_get_length (ARV_GC_REGISTER (node), NULL));
			}

			node = arv_gc_get_node (genicam, "IntWidthIncrement");
			if (node != NULL) {
				g_print ("IntWidthIncrement value = %Ld\n",
					 (long long) arv_gc_integer_get_value (ARV_GC_INTEGER (node), NULL));
			}

			node = arv_gc_get_node (genicam, "WhitebalValueMin");
			if (node != NULL) {
				g_print ("WhitebalValueMin value = %g\n",
					 arv_gc_float_get_value (ARV_GC_FLOAT (node), NULL));
			}

			g_free (xml);

			g_object_unref (genicam);
		} else
			g_print ("File '%s' not found.\n", arv_option_filenames[i]);
	}

	return EXIT_SUCCESS;
}