Example #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()
Example #2
0
double
arv_camera_get_frame_rate (ArvCamera *camera)
{
    ArvGcNode *feature;

    g_return_val_if_fail (ARV_IS_CAMERA (camera), -1.0);

    switch (camera->priv->vendor) {
    case ARV_CAMERA_VENDOR_BASLER:
    case ARV_CAMERA_VENDOR_PROSILICA:
        return arv_device_get_float_feature_value (camera->priv->device, "AcquisitionFrameRateAbs");
    case ARV_CAMERA_VENDOR_TIS:
        feature = arv_device_get_feature (camera->priv->device, "FPS");
        if (ARV_IS_GC_FEATURE_NODE (feature) &&
                g_strcmp0 (arv_dom_node_get_node_name (ARV_DOM_NODE (feature)), "Enumeration") == 0) {
            gint64 i;

            i = arv_gc_enumeration_get_int_value (ARV_GC_ENUMERATION (feature), NULL);
            if (i > 0)
                return (int)((10000000/(double) i) * 100 + 0.5) / 100.0;
            else
                return 0;
        } else
            return arv_device_get_float_feature_value (camera->priv->device, "FPS");
    case ARV_CAMERA_VENDOR_DALSA:
    case ARV_CAMERA_VENDOR_UNKNOWN:
        return arv_device_get_float_feature_value (camera->priv->device,
                camera->priv->use_acquisition_frame_rate_abs ?
                "AcquisitionFrameRateAbs":
                "AcquisitionFrameRate");
    }

    return -1.0;
}
Example #3
0
// 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()
Example #4
0
ArvDomNode *
arv_dom_node_append_child (ArvDomNode* self, ArvDomNode* new_child)
{
	ArvDomNodeClass *node_class;

	if (new_child == NULL)
		return NULL;

	g_return_val_if_fail (ARV_IS_DOM_NODE (new_child), NULL);

	if (!ARV_IS_DOM_NODE (self)) {
		g_critical ("%s: self is not a ArvDomNode", G_STRFUNC);
		g_object_unref (new_child);
		return NULL;
	}

	if (new_child->parent_node != NULL)
		arv_dom_node_remove_child (self, new_child);

	if (!ARV_DOM_NODE_GET_CLASS (self)->can_append_child (self, new_child)) {
		arv_log_dom ("[ArvDomNode::append_child] Can't append '%s' to '%s'",
			       arv_dom_node_get_node_name (new_child),
			       arv_dom_node_get_node_name (self));
		g_object_unref (new_child);
		return NULL;
	}

	if (self->first_child == NULL)
		self->first_child = new_child;
	if (self->last_child != NULL)
		self->last_child->next_sibling = new_child;

	new_child->parent_node = self;
	new_child->next_sibling = NULL;
	new_child->previous_sibling = self->last_child;
	self->last_child = new_child;

	node_class = ARV_DOM_NODE_GET_CLASS (self);

	if (node_class->post_new_child)
		node_class->post_new_child (self, new_child);

	arv_dom_node_changed (self);

	return new_child;
}
Example #5
0
void
arv_camera_get_frame_rate_bounds (ArvCamera *camera, double *min, double *max)
{
    ArvGcNode *feature;

    g_return_if_fail (ARV_IS_CAMERA (camera));

    switch (camera->priv->vendor) {
    case ARV_CAMERA_VENDOR_TIS:
        feature = arv_device_get_feature (camera->priv->device, "FPS");
        if (ARV_IS_GC_FEATURE_NODE (feature) &&
                g_strcmp0 (arv_dom_node_get_node_name (ARV_DOM_NODE (feature)), "Enumeration") == 0) {
            gint64 *values;
            guint n_values;
            guint i;

            if (min != NULL)
                *min = 0;
            if (max != NULL)
                *max = 0;

            values = arv_gc_enumeration_get_available_int_values (ARV_GC_ENUMERATION (feature), &n_values, NULL);
            for (i = 0; i < n_values; i++) {
                if (values[i] > 0) {
                    double s;

                    s = (int)((10000000/(double) values[i]) * 100 + 0.5) / 100.0;

                    if (s > *max && max != NULL)
                        *max = s;
                    if ((*min == 0 || *min > s) && min != NULL)
                        *min = s;
                }
            }
            g_free (values);
        } else
            arv_device_get_float_feature_bounds (camera->priv->device, "FPS", min, max);
        break;
    case ARV_CAMERA_VENDOR_BASLER:
    case ARV_CAMERA_VENDOR_PROSILICA:
        arv_device_get_float_feature_bounds (camera->priv->device, "AcquisitionFrameRateAbs", min, max);
        break;
    case ARV_CAMERA_VENDOR_DALSA:
    case ARV_CAMERA_VENDOR_UNKNOWN:
        arv_device_get_float_feature_bounds (camera->priv->device,
                                             camera->priv->use_exposure_time_abs ?
                                             "AcquisitionFrameRateAbs":
                                             "AcquisitionFrameRate",
                                             min, max);
        break;
    }
}
//! 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;
  }
}
Example #7
0
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)));
}
Example #8
0
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);
}
Example #9
0
void
arv_camera_set_frame_rate (ArvCamera *camera, double frame_rate)
{
    ArvGcNode *feature;
    double minimum;
    double maximum;

    g_return_if_fail (ARV_IS_CAMERA (camera));

    if (frame_rate <= 0.0)
        return;

    arv_camera_get_frame_rate_bounds(camera, &minimum, &maximum);

    if (frame_rate < minimum)
        frame_rate = minimum;
    if (frame_rate > maximum)
        frame_rate = maximum;

    switch (camera->priv->vendor) {
    case ARV_CAMERA_VENDOR_BASLER:
        arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector",
                                             "AcquisitionStart");
        arv_device_set_string_feature_value (camera->priv->device, "TriggerMode", "Off");
        arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector",
                                             "FrameStart");
        arv_device_set_string_feature_value (camera->priv->device, "TriggerMode", "Off");
        arv_device_set_integer_feature_value (camera->priv->device, "AcquisitionFrameRateEnable",
                                              1);
        arv_device_set_float_feature_value (camera->priv->device, "AcquisitionFrameRateAbs",
                                            frame_rate);
        break;
    case ARV_CAMERA_VENDOR_PROSILICA:
        arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector",
                                             "FrameStart");
        arv_device_set_string_feature_value (camera->priv->device, "TriggerMode", "Off");
        arv_device_set_float_feature_value (camera->priv->device, "AcquisitionFrameRateAbs",
                                            frame_rate);
        break;
    case ARV_CAMERA_VENDOR_TIS:
        arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector",
                                             "FrameStart");
        arv_device_set_string_feature_value (camera->priv->device, "TriggerMode", "Off");
        feature = arv_device_get_feature (camera->priv->device, "FPS");
        if (ARV_IS_GC_FEATURE_NODE (feature) &&
                g_strcmp0 (arv_dom_node_get_node_name (ARV_DOM_NODE (feature)), "Enumeration") == 0) {
            gint64 *values;
            guint n_values;
            guint i;

            values = arv_gc_enumeration_get_available_int_values (ARV_GC_ENUMERATION (feature), &n_values, NULL);
            for (i = 0; i < n_values; i++) {
                if (values[i] > 0) {
                    double e;

                    e = (int)((10000000/(double) values[i]) * 100 + 0.5) / 100.0;
                    if (e == frame_rate) {
                        arv_gc_enumeration_set_int_value (ARV_GC_ENUMERATION (feature), values[i], NULL);
                        break;
                    }
                }
            }
            g_free (values);
        } else
            arv_device_set_float_feature_value (camera->priv->device, "FPS", frame_rate);
        break;
    case ARV_CAMERA_VENDOR_DALSA:
    case ARV_CAMERA_VENDOR_UNKNOWN:
        arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector",
                                             "FrameStart");
        arv_device_set_string_feature_value (camera->priv->device, "TriggerMode", "Off");

        arv_device_set_float_feature_value (camera->priv->device,
                                            camera->priv->use_acquisition_frame_rate_abs ?
                                            "AcquisitionFrameRateAbs":
                                            "AcquisitionFrameRate", frame_rate);
        break;
    }
}
Example #10
0
ArvDomNode*
arv_dom_node_insert_before (ArvDomNode* self, ArvDomNode* new_child, ArvDomNode* ref_child)
{
	ArvDomNodeClass *node_class;

	if (ref_child == NULL)
		arv_dom_node_append_child (self, new_child);

	g_return_val_if_fail (ARV_IS_DOM_NODE (new_child), NULL);

	if (new_child->parent_node != NULL)
		arv_dom_node_remove_child (self, new_child);

	if (!ARV_IS_DOM_NODE (self)) {
		g_critical ("%s: self is not a ArvDomNode", G_STRFUNC);
		g_object_unref (new_child);
		return NULL;
	}

	if (!ARV_IS_DOM_NODE (ref_child)) {
		g_critical ("%s: ref_child is not a ArvDomNode", G_STRFUNC);
		g_object_unref (new_child);
		return NULL;
	}

	if (ref_child->parent_node != self) {
		arv_debug_dom ("[ArvDomNode::insert_before] Ref child '%s' doesn't belong to '%s'",
			   arv_dom_node_get_node_name (ref_child),
			   arv_dom_node_get_node_name (self));
		g_object_unref (new_child);
		return NULL;
	}

	if (!ARV_DOM_NODE_GET_CLASS (self)->can_append_child (self, new_child)) {
		arv_log_dom ("[ArvDomNode::insert_before] Can't append '%s' to '%s'",
			   arv_dom_node_get_node_name (new_child),
			   arv_dom_node_get_node_name (self));
		g_object_unref (new_child);
		return NULL;
	}

	new_child->parent_node = self;
	new_child->next_sibling = ref_child;
	new_child->previous_sibling = ref_child->previous_sibling;

	if (ref_child->previous_sibling == NULL)
		self->first_child = new_child;
	else
		ref_child->previous_sibling->next_sibling = new_child;

	ref_child->previous_sibling = new_child;

	node_class = ARV_DOM_NODE_GET_CLASS (self);

	if (node_class->post_new_child)
		node_class->post_new_child (self, new_child);

	arv_dom_node_changed (self);

	return new_child;
}