Browse Source

forgot to set nodeClass

Leon Urbas 11 years ago
parent
commit
64fe6a6aa8
3 changed files with 25 additions and 16 deletions
  1. 7 4
      include/ua_basictypes.h
  2. 9 6
      src/ua_application.c
  3. 9 6
      src/ua_services_attribute.c

+ 7 - 4
include/ua_basictypes.h

@@ -10,12 +10,15 @@
 
 #include <stdint.h>
 
-#define DBG_VERBOSE(expression) //
-#define DBG_ERR(expression) //
-#if defined(DEBUG) || 1
+#define DBG_VERBOSE(expression) // omit debug code
+#define DBG_ERR(expression) // omit debug code
+#define DBG(expression) // omit debug code
+#if defined(DEBUG) 		// --enable-debug=(yes|verbose)
+# undef DBG
+# define DBG(expression) expression
 # undef DBG_ERR
 # define DBG_ERR(expression) expression
-# if defined(VERBOSE)
+# if defined(VERBOSE) 	// --enable-debug=verbose
 #  undef DBG_VERBOSE
 #  define DBG_VERBOSE(expression) expression
 # endif

+ 9 - 6
src/ua_application.c

@@ -16,8 +16,8 @@ Application appMockup = {
 		&nsMockup
 };
 
-UA_Node* create_node_ns0(UA_Int32 type, UA_Int32 const id, char const * qn, char const * dn, char const * desc) {
-	UA_Node* n; UA_[type].new((void **)&n);
+UA_Node* create_node_ns0(UA_Int32 class, UA_Int32 nodeClass, UA_Int32 const id, char const * qn, char const * dn, char const * desc) {
+	UA_Node* n; UA_[class].new((void **)&n);
 	n->nodeId.encodingByte = UA_NODEIDTYPE_FOURBYTE;
 	n->nodeId.namespace = 0;
 	n->nodeId.identifier.numeric = id;
@@ -26,6 +26,7 @@ UA_Node* create_node_ns0(UA_Int32 type, UA_Int32 const id, char const * qn, char
 	UA_String_copycstring(dn,&(n->displayName.text));
 	n->description.encodingMask = UA_LOCALIZEDTEXT_ENCODINGMASKTYPE_TEXT;
 	UA_String_copycstring(desc,&(n->description.text));
+	n->nodeClass = nodeClass;
 	return n;
 }
 
@@ -46,10 +47,12 @@ void appMockup_init() {
 	UA_indexedList_addValueToFront(appMockup.namespaces,1,local);
 
 	UA_Node* np;
-	np = create_node_ns0(UA_NODE, 2253, "Server", "open62541", "...");
+	np = create_node_ns0(UA_OBJECTNODE, UA_NODECLASS_OBJECT, 2253, "Server", "open62541", "...");
 	insert_node(ns0,np);
+	UA_ObjectNode* o = (UA_ObjectNode*)np;
+	o->eventNotifier = UA_FALSE;
 
-	np = create_node_ns0(UA_VARIABLENODE, 2255, "Server_NamespaceArray", "open62541", "..." );
+	np = create_node_ns0(UA_VARIABLENODE, UA_NODECLASS_VARIABLE, 2255, "Server_NamespaceArray", "open62541", "..." );
 	UA_VariableNode* v = (UA_VariableNode*)np;
 	UA_Array_new((void**)&(v->value.data),2,UA_STRING);
 	v->value.vt = &UA_[UA_STRING];
@@ -65,7 +68,7 @@ void appMockup_init() {
 
 	insert_node(ns0,np);
 
-//#if defined DEBUG && defined VERBOSE
+#if defined(DEBUG) && defined(VERBOSE)
 	uint32_t i, j;
 	for (i=0, j=0; i < ns0->size && j < ns0->count; i++) {
 		if (ns0->entries[i].node != UA_NULL) {
@@ -76,5 +79,5 @@ void appMockup_init() {
 			printf("}\n");
 		}
 	}
-//#endif
+#endif
 }

+ 9 - 6
src/ua_services_attribute.c

@@ -27,9 +27,9 @@ enum UA_AttributeId {
 };
 
 static UA_DataValue * service_read_node(Application *app, const UA_ReadValueId *id) {
-	UA_DataValue *v;
-	UA_alloc((void **) &v, sizeof(UA_DataValue));
+	UA_DataValue *v; UA_DataValue_new(&v);
 	
+	DBG(printf("service_read_node - entered with ns=%d,id=%d,attr=%i\n",id->nodeId.namespace, id->nodeId.identifier.numeric, id->attributeId));
 	namespace *ns = UA_indexedList_findValue(app->namespaces, id->nodeId.namespace);
 
 	if (ns == UA_NULL) {
@@ -38,7 +38,7 @@ static UA_DataValue * service_read_node(Application *app, const UA_ReadValueId *
 		v->status = UA_STATUSCODE_BADNODEIDUNKNOWN;
 		return v;
 	}
-	DBG_VERBOSE(UA_String_printf("service_read_node - namespaceUri=",&(ns->namespaceUri)));
+	DBG_VERBOSE(UA_String_printf(",namespaceUri=",&(ns->namespaceUri)));
 	
 	UA_Node const *node = UA_NULL;
 	ns_lock *lock = UA_NULL;
@@ -108,9 +108,12 @@ static UA_DataValue * service_read_node(Application *app, const UA_ReadValueId *
 		}
 		v->encodingMask = UA_DATAVALUE_ENCODINGMASK_STATUSCODE | UA_DATAVALUE_ENCODINGMASK_VARIANT;
 		v->status = UA_STATUSCODE_GOOD;
-		// FIXME: delete will be called on all the members of v, so essentially
-		// the item will be removed from the namespace.
-		v->value = ((UA_VariableNode *)node)->value; // be careful not to release the node before encoding the message
+		UA_VariableNode * vn = (UA_VariableNode*) node;
+		// FIXME: delete will be called later on on on all the members of v, so essentially
+		// the item's data will be removed from the namespace-object. We would need
+		// something like a deep copy function just as we have it for the strings
+		// UA_Variant_copy(UA_Variant* src, UA_Variant* dst);
+		v->value = vn->value; // be careful not to release the node before encoding the message
 		break;
 	case UA_ATTRIBUTEID_DATATYPE:
 		v->encodingMask = UA_DATAVALUE_ENCODINGMASK_STATUSCODE;