Different value of ns to the same structure|OPC UA Standard|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Different value of ns to the same structure
Avatar
FEDERICA FEDERICA
Member
Members
Forum Posts: 3
Member Since:
02/11/2020
sp_UserOfflineSmall Offline
1
02/22/2022 - 05:17
sp_Permalink sp_Print sp_EditHistory

Hello, 

I'm working for the first time with OPCUA. I want to create a structure

{Variables  (NodeClass: Object; nodeId: ns=1;i=1000)

  Test1 (NodeClass: Variable; nodeId: ns=1;s=Test1)

  Test2 (NodeClass: Variable; nodeId: ns=1;s=Test2)

}

and to repeat it N times. Is it possible to associate the same variables but a different value of ns to another data structure? For example:

{Variables  (NodeClass: Object; nodeId: ns=100;i=1000)

  Test1 (NodeClass: Variable; nodeId: ns=100;s=Test1)

  Test2 (NodeClass: Variable; nodeId: ns=100;s=Test2)

}

 

{Variables  (NodeClass: Object; nodeId: ns=101;i=1000)

  Test1 (NodeClass: Variable; nodeId: ns=101;s=Test1)

  Test2 (NodeClass: Variable; nodeId: ns=101;s=Test2)

}

Avatar
Randy Armstrong
Admin
Forum Posts: 1457
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
02/22/2022 - 11:10
sp_Permalink sp_Print

Not sure what you mean by 'associate'.

The normal way to do this is create an ObjectType with the Test1/Test2 components. Each instance (no matter the namespace) would have a HasTypeDefinition reference to the ObjectType.

Avatar
FEDERICA FEDERICA
Member
Members
Forum Posts: 3
Member Since:
02/11/2020
sp_UserOfflineSmall Offline
3
02/23/2022 - 04:08
sp_Permalink sp_Print

Yes, I did this. But what should I do if I want to create another Object with the same instance but different namespace index?

I have added namespace URI in the XML file as shown below

<NamespaceUris>
<Uri>urn:myproject:Head1></Uri>
<Uri>urn:myproject:Head2></Uri>
<Uri>urn:myproject:NS1></Uri>
<Uri>urn:myproject:NS2></Uri>
</NamespaceUris>

 and then I have inserted a different namespace for each object. As specified in Namespace Array, ns=5 corresponds to urn:myproject:Head1, instead ns=6 is the index of urn:myproject:Head2

Variables  (NodeClass: Object; nodeId: ns=5;i=1000)

  Test1 (NodeClass: Variable; nodeId: ns=5;s=Test1)

  Test2 (NodeClass: Variable; nodeId: ns=5;s=Test2)

}

 

{Variables  (NodeClass: Object; nodeId: ns=6;i=1000)

  Test1 (NodeClass: Variable; nodeId: ns=6;s=Test1)

  Test2 (NodeClass: Variable; nodeId: ns=6;s=Test2)

}

Is it correct to proceed like this? Can I edit the file and add the Uri Namespace in URN format?
Avatar
Randy Armstrong
Admin
Forum Posts: 1457
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
4
02/23/2022 - 08:56
sp_Permalink sp_Print

Instances belong to any namespace. The contract defined by the ObjectType is based on the BrowseName so the namespace index in the BrowseNames Test1 and Test2 will be the same as the ObjectType but the namespace index in the NodeId can be anything.

Avatar
FEDERICA FEDERICA
Member
Members
Forum Posts: 3
Member Since:
02/11/2020
sp_UserOfflineSmall Offline
5
02/23/2022 - 09:48
sp_Permalink sp_Print

Ok, thank you. 

But is it possible to edit the XML file and add how many URI I want?
I want to create 10 objects as 'Variables' and I want the  namespace index in the NodeID is different for each object.
Avatar
Randy Armstrong
Admin
Forum Posts: 1457
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
6
02/23/2022 - 11:46
sp_Permalink sp_Print

The number of a namespaces you have should be small.

If you have a design that appears to require a large number of namespaces then you should revisit your design assumptions.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 13
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1353
Posts: 4589