Esempio n. 1
0
static const char *
_get_unit (ArvGcConverter *gc_converter, GError **error)
{
	if (gc_converter->unit == NULL)
		return NULL;

	return arv_gc_property_node_get_string (ARV_GC_PROPERTY_NODE (gc_converter->unit), error);
}
Esempio n. 2
0
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);
		}
	}

}
Esempio n. 3
0
static const char *
arv_gc_float_node_get_unit (ArvGcFloat *gc_float, GError **error)
{
	ArvGcFloatNode *gc_float_node = ARV_GC_FLOAT_NODE (gc_float);
	GError *local_error = NULL;
	const char *string;

	if (gc_float_node->unit == NULL)
		return NULL;

	string = arv_gc_property_node_get_string (ARV_GC_PROPERTY_NODE (gc_float_node->unit), &local_error);

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

	return string;
}
Esempio n. 4
0
static const char *
arv_gc_float_node_get_value_as_string (ArvGcFeatureNode *node, GError **error)
{
	ArvGcFloatNode *float_node = ARV_GC_FLOAT_NODE (node);
	GError *local_error = NULL;
	const char *string;

	if (float_node->value == NULL)
		return NULL;

	string = arv_gc_property_node_get_string (ARV_GC_PROPERTY_NODE (float_node->value), &local_error);

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

	return string;
}
Esempio n. 5
0
static ArvGcCachable
_get_endianess (ArvGcRegisterNode *gc_register_node, GError **error)
{
	GError *local_error = NULL;
	const char *endianess;

	if (gc_register_node->endianess == NULL)
		return G_LITTLE_ENDIAN;

	endianess = arv_gc_property_node_get_string (gc_register_node->endianess, &local_error);

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

	if (g_strcmp0 (endianess, "BigEndian") == 0)
		return G_BIG_ENDIAN;

	return G_LITTLE_ENDIAN;
}
Esempio n. 6
0
const char *
arv_gc_feature_node_get_display_name (ArvGcFeatureNode *node, GError **error)
{
	const char *display_name;
	GError *local_error = NULL;

	g_return_val_if_fail (ARV_IS_GC_FEATURE_NODE (node), NULL);
	g_return_val_if_fail (error == NULL || *error == NULL, NULL);

	if (node->priv->display_name == NULL)
	       return NULL;

	display_name = arv_gc_property_node_get_string (node->priv->display_name, &local_error);

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

	return display_name;
}
Esempio n. 7
0
const char *
arv_gc_feature_node_get_tooltip (ArvGcFeatureNode *node, GError **error)
{
	const char *tooltip;
	GError *local_error = NULL;

	g_return_val_if_fail (ARV_IS_GC_FEATURE_NODE (node), NULL);
	g_return_val_if_fail (error == NULL || *error == NULL, NULL);

	if (node->priv->tooltip == NULL)
		return NULL;

	tooltip = arv_gc_property_node_get_string (node->priv->tooltip, &local_error);

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

	return tooltip;
}
Esempio n. 8
0
static ArvGcCachable
_get_cachable (ArvGcRegisterNode *gc_register_node, GError **error)
{
	GError *local_error = NULL;
	const char *cachable;

	if (gc_register_node->cachable == NULL)
		return ARV_GC_CACHABLE_NO_CACHE;

	cachable = arv_gc_property_node_get_string (gc_register_node->cachable, &local_error);

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

	if (g_strcmp0 (cachable, "WriteThrough") == 0)
		return ARV_GC_CACHABLE_WRITE_TRHOUGH;
	else if (strcmp (cachable, "WriteAround") == 0)
		return ARV_GC_CACHABLE_WRITE_AROUND;

	return ARV_GC_CACHABLE_NO_CACHE;
}
Esempio n. 9
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);
	}
}
Esempio n. 10
0
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;
}