OPC UA - Update NamespaceIndex |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
OPC UA - Update NamespaceIndex
Avatar
Rabah Toulaït
Member
Members
Forum Posts: 3
Member Since:
06/10/2020
sp_UserOfflineSmall Offline
1
07/01/2020 - 08:12
sp_Permalink sp_Print sp_EditHistory

Hi,

I am currenttly developping simulator server to generate data using parquet file to be used in DEV/TEST environment.
I was able to generate the nodes and updating variabéles value coming from parquet file.

I would like to update NamespaceIndex to use NS=4 instead of the default one (NS=2)

I tried to force it to 4 when creating the base variable but i can’t browse the nodes using uaExpert.

I got this message: “Item [NS4|String|K4000] failed [ret = BadNodeIdUnknown]”

Any help please;

Kind regards,

Rabah Toulaït

Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
07/01/2020 - 09:07
sp_Permalink sp_Print

Namespace indexes must be sequential. You cannot have index 4 unless you have 0 through 3.

Namespace indexes are usually assigned automatically by the server sdk you are using.

If you wish a specific index you must make sure you request indexes in an order that results in the correct index being assigned.

Lastly, you should not be doing this because it sounds like you are hard coding indexes in your configuration files which is strongly discouraged.

The correct way to store configuration always serializes a table of NamespaceURIs and NodeIDs with indexes that reference the serialized table. When the configuration file is loaded the serialized NamespaceURIs are used to find the current index in the Server and any saved NodeIds are then updated to match current index.

Avatar
Rabah Toulaït
Member
Members
Forum Posts: 3
Member Since:
06/10/2020
sp_UserOfflineSmall Offline
3
07/02/2020 - 02:45
sp_Permalink sp_Print

I found only one index (index[0]) in NamespaceIndexes with value set to 2.
What i need is to try to use value 4 instead of 2 but the folder/nodes were not generated with the new value in uaExpert client (did the same change with value 2 and it works).
Is there a way to change the value (not the index itself) to get NodeId with custom value instead of the one configured?

Thanks

Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
4
07/02/2020 - 11:06
sp_Permalink sp_Print

As I said, namespace indexes are set by the server and they have to be sequential.

So if you only have 3 entries in the NamespaceArray then the largest index is 2. Nothing the client can do will change this to 4.

That said, there are various ways to hack the server if you have the code to build it. But you should not designing code that depends on a specific number for a namespace index. You need to come up with a better solution.

Avatar
Rabah Toulaït
Member
Members
Forum Posts: 3
Member Since:
06/10/2020
sp_UserOfflineSmall Offline
5
07/08/2020 - 07:41
sp_Permalink sp_Print

Hi Randy,

My application is an opcua simulator server.

I understand that for each folder/node created uses ns=2 because this is the value configured in the namespaceindexes.

I am trying to find a way to change the configuration to be able to use index 4 because when the simulator generates the variables from the node config file, all variables uses ns=4 (see example below);

so when opcua client will be installed in the iot edge device to use the simulator server, the variables generated should use ns=4 and not ns=2 as it was the case actually (default config.)

Example of configured variable in node config file:
{
“NodeId”: “ns=4;s=K4040.CDU345/DP.Programs.IOT_Data.Process111.Wire”,
“Name”: “Test”,
“DataType”: “String”,
“ValueRank”: 0,
“AccessLevel”: “CurrentReadOrWrite”,
“Description”: “Test”
}

I din’t find how to set and use a new index.
It’s a prerequisite to use the simulator server (input use ns=4 in the variable name and the output from simulator should return ns=4)

Thanks for your help

Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
6
07/08/2020 - 13:44
sp_Permalink sp_Print sp_EditHistory

We are talking past each other. You need to understand the relationship between NamespaceIndexes and NamespaceUris.

You have configuration files that need to be loaded. When you load these configuration files you should:

  1. Determine the “NamespaceUri” that corresponds to NamespaceIndex 4 in the configuration file;
  2. Find the index of the NamespaceUri in the Server’s NamespaceArray;
  3. Change the NamespaceIndex in NodeIds during load from 4 to whatever the correct NamespaceIndex is.

For example, you have a NamespaceArray and the NamespaceUri for your configuration file is “https://siimulationserver/instances”

[0] https://opcfoundation.org/UA/
[1] http://mycomputer/mycompany/myserver/
[2] http://simulationserver/types
[3] https://siimulationserver/instances

Then 4 must be converted to 3.

So when parse the node config file you change

“NodeId”: “ns=4;s=K4040.CDU345/DP.Programs.IOT_Data.Process111.Wire”

to

“NodeId”: “ns=3;s=K4040.CDU345/DP.Programs.IOT_Data.Process111.Wire”

If the NamespaceArray was

[0] https://opcfoundation.org/UA/
[1] http://mycomputer/mycompany/myserver/
[2] https://siimulationserver/instances
[3] http://simulationserver/types
[4] http://someunrelatedmodel/types

Then 4 must be converted to 2.

Basically, NamespaceIndexes have no meaning without a NamespaceUri – so figure out what the NamespaceUri is first.

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