Bladeren bron

Merge branch 'automation' of https://github.com/acplt/open62541 into automation

Conflicts:
	src/ua_application.c
FlorianPalm 10 jaren geleden
bovenliggende
commit
2c9d6946da
6 gewijzigde bestanden met toevoegingen van 58 en 38 verwijderingen
  1. 8 3
      README.md
  2. 1 0
      src/Makefile.am
  3. 41 33
      src/ua_application.c
  4. 2 0
      src/ua_services.h
  5. 3 2
      src/ua_services_attribute.c
  6. 3 0
      src/ua_transport_binary_secure.c

+ 8 - 3
README.md

@@ -62,14 +62,19 @@ $ make all
 ##### Get expat
 * start MinGW Installation Manager
 * choose all Packages, mark mingw32-expat and install
+* Open MinGW\msys\1.0\msys.bat
+```bash
+$ mingw-get install libexpat
+```
 
 ##### Get Python and lxml:
-* download Python at https://python.org/downloads
+* download Python at https://python.org/downloads (recommended version: 3.4.x)
 * install the executable
-* add the install directory (e. g. "c:\python27") to your windows path variable 
+* add the install directory (e. g. "c:\python34") to your windows path variable [Selectable in the setup-options]
 * restart mingw console
 * install lxml by either downloading and installing http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml (choose the version which fits    to your python installation) or by following the instructions
-  given here: http://lxml.de/installation.html
+  given here: http://lxml.de/installation.html 
+* [HINT for Windows x64 Users]: To use the first option to install lxml, it is necessary to edit the registry: The install path of python needs to be copyed in an other registry directroy: [FROM]: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\3.4\InstallPath [TO]: HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4\InstallPath
 
 ##### Get git (IMPORTANT: get 1.8.4, since 1.8.5.2 has a bug):
 * http://code.google.com/p/msysgit/downloads/detail?name=Git-1.8.4-preview20130916.exe&can=2&q=

+ 1 - 0
src/Makefile.am

@@ -24,6 +24,7 @@ libopen62541_la_SOURCES = ua_types.c \
 						  ua_services_securechannel.c \
 						  ua_services_nodemanagement.c \
 						  ua_services_view.c \
+						  ua_services_subscription.c\
 						  ua_application.c \
 						  ua_xml.c
 ua_types.c: ua_namespace_0.h

+ 41 - 33
src/ua_application.c

@@ -49,8 +49,8 @@ void appMockup_init() {
 	/* UA_NodeId RefTypeId_HasDescription = NS0NODEID(39); */
 	UA_NodeId RefTypeId_HasTypeDefinition = NS0NODEID(40);
 	/* UA_NodeId RefTypeId_HasSubtype = NS0NODEID(45); */
-//	UA_NodeId RefTypeId_HasProperty = NS0NODEID(46);
-//	UA_NodeId RefTypeId_HasComponent = NS0NODEID(47);
+	UA_NodeId RefTypeId_HasProperty = NS0NODEID(46);
+	UA_NodeId RefTypeId_HasComponent = NS0NODEID(47);
 	/* UA_NodeId RefTypeId_HasNotifier = NS0NODEID(48); */
 
     // ObjectTypes (Ids only)
@@ -61,6 +61,10 @@ void appMockup_init() {
 	UA_ExpandedNodeId ObjId_TypesFolder = NS0EXPANDEDNODEID(86);
 	UA_ExpandedNodeId ObjId_ViewsFolder = NS0EXPANDEDNODEID(87);
 	UA_ExpandedNodeId ObjId_Server = NS0EXPANDEDNODEID(2253);
+	UA_ExpandedNodeId ObjId_ServerArray = NS0EXPANDEDNODEID(2254);
+	UA_ExpandedNodeId ObjId_NamespaceArray = NS0EXPANDEDNODEID(2255);
+	UA_ExpandedNodeId ObjId_ServerStatus = NS0EXPANDEDNODEID(2256);
+	UA_ExpandedNodeId ObjId_ServerCapabilities = NS0EXPANDEDNODEID(2268);
 
 	// Root
 	UA_ObjectNode *root;
@@ -77,6 +81,8 @@ void appMockup_init() {
 		{RefTypeId_Organizes, UA_FALSE, ObjId_TypesFolder},
 		{RefTypeId_Organizes, UA_FALSE, ObjId_ViewsFolder}};
 
+	Namespace_insert(ns0,(UA_Node*)root);
+
 	// Objects
 	UA_ObjectNode *objects;
 	UA_ObjectNode_new(&objects);
@@ -90,6 +96,8 @@ void appMockup_init() {
 		{RefTypeId_HasTypeDefinition, UA_FALSE, ObjTypeId_FolderType},
 		{RefTypeId_Organizes, UA_FALSE, ObjId_Server}};
 
+	Namespace_insert(ns0,(UA_Node*)objects);
+
 	// Views
 	UA_ObjectNode *views;
 	UA_ObjectNode_new(&views);
@@ -102,7 +110,7 @@ void appMockup_init() {
 	views->references = (UA_ReferenceNode[1]){
 		{RefTypeId_HasTypeDefinition, UA_FALSE, ObjTypeId_FolderType}};
 
-
+	Namespace_insert(ns0,(UA_Node*)views);
 
 	// Server
 	UA_ObjectNode *server;
@@ -113,37 +121,37 @@ void appMockup_init() {
 	server->displayName = (UA_LocalizedText){{2,"EN"},{6, "Server"}};
 	server->description = (UA_LocalizedText){{2,"EN"},{6, "Server"}};
 	server->referencesSize = 0;
-	server->references = UA_NULL;
-	/*(UA_ReferenceNode[4]){
-		{RefTypeId_HasComponent, UA_FALSE, ObjId_Server},
-		{RefTypeId_HasComponent, UA_FALSE, ObjTypeId_FolderType},
-		{RefTypeId_HasProperty, UA_FALSE, ObjTypeId_FolderType},
-		{RefTypeId_HasProperty, UA_FALSE, ObjTypeId_FolderType}};
-
-	AddReference(ObjectID::Server, forward, ReferenceID::HasComponent, ObjectID::ServerCapabilities, Names::ServerCapabilities, NodeClass::Variable, ObjectID::PropertyType);
-	AddReference(ObjectID::Server, forward, ReferenceID::HasComponent, ObjectID::NamespaceArray, Names::NamespaceArray, NodeClass::Variable, ObjectID::PropertyType);
-	AddReference(ObjectID::Server, forward, ReferenceID::HasProperty, ObjectID::ServerStatus, Names::ServerStatus, NodeClass::Variable, ObjectID::ServerStatusType);
-	AddReference(ObjectID::Server, forward, ReferenceID::HasProperty, ObjectID::ServerArray, Names::ServerArray, NodeClass::Variable, ObjectID::PropertyType);
-*/
-
-	//Types
-	UA_ObjectNode *types;
-	UA_ObjectNode_new(&types);
-	types->nodeId = ObjId_TypesFolder.nodeId;
-
-	types->nodeClass = UA_NODECLASS_OBJECT;
-	types->browseName = (UA_QualifiedName){0, {6, "Types"}};
-	types->displayName = (UA_LocalizedText){{2,"EN"},{6, "Types"}};
-	types->description = (UA_LocalizedText){{2,"EN"},{6, "Types"}};
-	types->referencesSize = 0;
-	types->references = UA_NULL; // TODO. Fill up here.
-
-	
-	Namespace_insert(ns0,(UA_Node*)root);
-	Namespace_insert(ns0,(UA_Node*)objects);
-	Namespace_insert(ns0,(UA_Node*)views);
+	server->references = (UA_ReferenceNode[4]){
+		{RefTypeId_HasComponent, UA_FALSE, ObjId_ServerCapabilities},
+		{RefTypeId_HasComponent, UA_FALSE, ObjId_NamespaceArray},
+		{RefTypeId_HasProperty, UA_FALSE, ObjId_ServerStatus},
+		{RefTypeId_HasProperty, UA_FALSE, ObjId_ServerArray}};
+
 	Namespace_insert(ns0,(UA_Node*)server);
-	Namespace_insert(ns0,(UA_Node*)types);
+
+	// NamespaceArray
+	UA_VariableNode *namespaceArray;
+	UA_VariableNode_new(&namespaceArray);
+	namespaceArray->nodeId = ObjId_NamespaceArray.nodeId;
+	namespaceArray->nodeClass = UA_NODECLASS_VARIABLE; //FIXME: this should go into _new?
+	namespaceArray->browseName = (UA_QualifiedName){0, {6, "NamespaceArray"}};
+	namespaceArray->displayName = (UA_LocalizedText){{2,"EN"},{6, "NamespaceArray"}};
+	namespaceArray->description = (UA_LocalizedText){{2,"EN"},{6, "NamespaceArray"}};
+	//FIXME: can we avoid new here?
+	UA_Array_new((void**)&namespaceArray->value.data, 2, &UA_.types[UA_STRING]);
+	namespaceArray->value.vt = &UA_.types[UA_STRING];
+	namespaceArray->value.arrayLength = 2;
+	UA_String_copycstring("http://opcfoundation.org/UA/",&((UA_String *)((namespaceArray->value).data))[0]);
+	UA_String_copycstring("http://localhost:16664/open62541/",&((UA_String *)(((namespaceArray)->value).data))[1]);
+	namespaceArray->dataType.encodingByte = UA_NODEIDTYPE_FOURBYTE;
+	namespaceArray->dataType.identifier.numeric = UA_STRING_NS0;
+	namespaceArray->valueRank = 1;
+	namespaceArray->minimumSamplingInterval = 1.0;
+	namespaceArray->historizing = UA_FALSE;
+
+	Namespace_insert(ns0,(UA_Node*)namespaceArray);
+
+	//TODO: free(namespaceArray->value.data) later or forget it
 
 
 	/* UA_VariableNode* v = (UA_VariableNode*)np; */

+ 2 - 0
src/ua_services.h

@@ -225,6 +225,8 @@ UA_Int32 Service_CreateMonitoredItems(SL_Channel *channel, const UA_CreateMonito
  * @{
  */
 // Service_CreateSubscription
+UA_Int32 Service_CreateSubscription(SL_Channel *channel, const UA_CreateSubscriptionRequest *request,
+                                   UA_CreateSubscriptionResponse *response);
 // Service_ModifySubscription
 // Service_SetPublishingMode
 // Service_Publish

+ 3 - 2
src/ua_services_attribute.c

@@ -140,8 +140,9 @@ static UA_DataValue service_read_node(Application *app, const UA_ReadValueId *id
 		CHECK_NODECLASS(UA_NODECLASS_VARIABLE);
 		v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
 		// TODO: Ensure that the borrowed value is not freed prematurely (multithreading)
-		retval |= UA_Variant_borrowSetValue(&v.value, &UA_.types[UA_VARIANT],
-		                                    &((UA_VariableNode *)node)->value);
+		/* retval |= UA_Variant_borrowSetValue(&v.value, &UA_.types[UA_VARIANT], */
+		/*                                     &((UA_VariableNode *)node)->value); */
+		retval |= UA_Variant_copy(&((UA_VariableNode *)node)->value, &v.value);
 		break;
 
 	case UA_ATTRIBUTEID_DATATYPE:

+ 3 - 0
src/ua_transport_binary_secure.c

@@ -146,6 +146,9 @@ UA_Int32 SL_handleRequest(SL_Channel *channel, const UA_ByteString *msg, UA_UInt
 	}else if(serviceid == UA_BROWSEREQUEST_NS0) {
 		INVOKE_SERVICE(Browse);
 		responsetype = UA_BROWSERESPONSE_NS0;
+	}else if(serviceid == UA_CREATESUBSCRIPTIONREQUEST_NS0) {
+		INVOKE_SERVICE(CreateSubscription);
+		responsetype = UA_CREATESUBSCRIPTIONRESPONSE_NS0;
 	}else{
 		printf("SL_processMessage - unknown request, namespace=%d, request=%d\n",
 		       serviceRequestType.namespace,