Giter Site home page Giter Site logo

Comments (7)

kevinherron avatar kevinherron commented on June 11, 2024

I'm not sure what you mean by "only the associated identifier" - are you talking about the client handle you assign a monitored item when creating it, or something else?

Side note: the mailing list may be a better place for general questions like this.

from milo.

tosuns avatar tosuns commented on June 11, 2024

If I want to read the value of a node I have to provide a NodeId first. One of the constructors is NodeId(int index, String identifier).
In my client code I don’t want to mess with namespace indices. I only want to provide the identifier and the opc ua client should somehow figure out to which namespace the identifier belongs to.

I want the opc ua client to be one of possible client implementations, that could be used. That is why I try to create a client facade/service to possible servers, like opcua or beckhoff ads, bachmann and so on. Not all of them have a concept of namespaces, but alot of them have the concept of identifiers/symbols.

from milo.

kevinherron avatar kevinherron commented on June 11, 2024

You always need the NodeId.

I think the only alternative would be using the TranslateBrowsePathsToNodeIds service, but you still need to be storing the whatever it is in a format that you could turn into a BrowsePath for the translate service call.

from milo.

ctron avatar ctron commented on June 11, 2024

I actually stumbled over the same issue. In order to access a variable you also need the NodeId, and therefore the index. However to me it seems (as far as I look into the server side code) that the index is not static as the URI is. So there is some sort of mapping on the server side from URI -> Index.

So assuming in the client that the index never changes seems to be wrong to me, and going with the URI is the better approach. What I did is that I do make a lookup on the server table:

CompletableFuture<DataValue> future = this.client.readValue(0, TimestampsToReturn.Neither,
   Identifiers.Server_NamespaceArray);

   return future.thenApply(value -> {
      final Object rawValue = value.getValue().getValue();

      if (rawValue instanceof String[]) {
         final String[] namespaces = (String[]) rawValue;
         for (int i = 0; i < namespaces.length; i++) {
         if (namespaces[i].equals(namespaceUri)) { return Unsigned.ushort(i); }
      }
   }
return null;
});

I am not sure if this is the proper way and I also could imagine that the lookup result could be cached on the client side.

from milo.

kevinherron avatar kevinherron commented on June 11, 2024

So what @ctron is suggesting is the most correct approach if you're going to be storing NodeIds. In practice I have never actually seen the need for this, as all the servers we deal with tend to have fixed namespaces 0, 1, and 2. (0 will never change. 1 is the namespace URI of the server; it shouldn't change. 2+ may change depending how the server uses namespaces).

from milo.

ctron avatar ctron commented on June 11, 2024

So what is the correct way to extend the #1 namespace?

from milo.

kevinherron avatar kevinherron commented on June 11, 2024

Right now the SDK registers a pretty sparse Namespace implementation called VendorNamespace as namespace 1. You could easily register your own Namespace at slot 1 instead if you wish to provide different/additional nodes.

In my experience with OPC-UA servers, such as Kepware etc..., all the nodes for configured devices and whatever else they expose are in namespace 2.

from milo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.