Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [milo-dev] Problem in assigning numeric value to nodeID

Adding the code for subscribing,

ReadValueId readValueId = new ReadValueId(
flip,
AttributeId.Value.uid(), null, QualifiedName.NULL_VALUE);



On Tue, Dec 10, 2019 at 3:19 PM J Dhanasekar <jdhanasekar@xxxxxxxxxxxxxxxxxx> wrote:
Yes.. I am trying to mirror a node from other server. 
I have removed namespace "NAMESPACE_URI = "urn:eclipse:milo:hello-world" and used namespace "NAMESPACE_URI = "urn:eclipse:milo:examples:server". I thought, It may fix the "Bad_nodeIdUnknow" issue when running SubscriptionExample.java.

image.png

As per your guidance, I have implemented separate nodeId creation method  in SubscriptionExample.java and 
created node ID for my dummy node. Like this,

public  final NodeId flip = init(12345);

public NodeId init(int value) {

return new NodeId(Unsigned.ushort(2), Unsigned.uint(value));
}
Stil I am observing "status=StatusCode{name=Bad_NodeIdUnknown, value=0x80340000, quality=bad} " issue When run SubscriptionExample.java.


-Dhanasekar




On Mon, Dec 9, 2019 at 8:21 PM Kevin Herron <kevinherron@xxxxxxxxx> wrote:
You would have to remove the namespace that is loaded at index 1 and replace it with the example namespace.

There’s no reason you need to do this, though. Assuming you’re still trying to build something that “mirrors” a node in a remote server, you can’t rely on the indices in your server matching up with the remote server. (And what if there are two remote servers, what’s your plan then?). You just need to keep some kind of mapping so you know what local NodeId corresponds to what remote NodeId.


On Dec 9, 2019, at 5:12 AM, J Dhanasekar <jdhanasekar@xxxxxxxxxxxxxxxxxx> wrote:



I have changed my code, like below,

<image.png>
,

Still, "HelloWorld" folder node having namespace = 2, instead of 1. How to change namespace index is to 1 ?

On Mon, Dec 9, 2019 at 2:18 PM J Dhanasekar <jdhanasekar@xxxxxxxxxxxxxxxxxx> wrote:
Hi Kevin,

Is it possible to change the NameSpaceIndex of HelloWorld Folder Node to 1 from 2 ?.

<image.png>



-Dhanasekar

On Fri, Dec 6, 2019 at 7:17 PM Kevin Herron <kevinherron@xxxxxxxxx> wrote:
You shouldn't be defining your own NodeIds in there. It's for the built-in NodeIds and it assigns them to namespace 0, which is why you get Bad_NodeIdUnknown when you run your modified SubscriptionExample.

In your modified namespace the NodeId has namespaceIndex=2, so make sure on the client side you actually use the same NodeId.

On Fri, Dec 6, 2019 at 5:41 AM J Dhanasekar <jdhanasekar@xxxxxxxxxxxxxxxxxx> wrote:
I have defined like this,

public static final NodeId flip = init(12345);

On Fri, Dec 6, 2019 at 7:05 PM Kevin Herron <kevinherron@xxxxxxxxx> wrote:
How is Identifiers.flip defined?

On Fri, Dec 6, 2019 at 5:25 AM J Dhanasekar <jdhanasekar@xxxxxxxxxxxxxxxxxx> wrote:


Attaching Subscription code. I have modified code in "SubscriptionExample.java" like this,


ReadValueId readValueId = new ReadValueId(
Identifiers.flip,
AttributeId.Value.uid(), null, QualifiedName.NULL_VALUE);
logger.info("dhanasekar @Subscription.java readValueId ={}", readValueId);



Please correct me if I  have implemented in the wrong way.


On Fri, Dec 6, 2019 at 4:14 PM J Dhanasekar <jdhanasekar@xxxxxxxxxxxxxxxxxx> wrote:
Hi Kevin,

I have created two dummy variable node like this,

private void addFlip(UaFolderNode rootNode) {
// dhanasekar -- Starting
// Adding code for flip
logger.info("dhanasekar @ExampleNamespac.java Inside addFlip()");
UaVariableNode flip = UaVariableNode.builder(getNodeContext())
.setNodeId(newNodeId(12345))
.setAccessLevel(ubyte(AccessLevel.getMask(AccessLevel.READ_WRITE)))
.setBrowseName(newQualifiedName("Flip"))
.setDisplayName(LocalizedText.english("Flip"))
.setDataType(Identifiers.Boolean)
.setTypeDefinition(Identifiers.BaseDataVariableType)
.build();
logger.info("dhanasekar @ExampleNamespac.j flip.getNodeId()={}",flip.getNodeId());

getNodeManager().addNode(flip);
rootNode.addOrganizes(flip);



flip.setValue(new DataValue(new Variant(0)));


}

private void addFlop(UaFolderNode rootNode) {

logger.info("dhanasekar @ExampleNamespac.java Inside addFlip()");
UaVariableNode flop = UaVariableNode.builder(getNodeContext())
.setNodeId(newNodeId(67890))
.setAccessLevel(ubyte(AccessLevel.getMask(AccessLevel.READ_WRITE)))
.setBrowseName(newQualifiedName("Flop"))
.setDisplayName(LocalizedText.english("Flop"))
.setDataType(Identifiers.Boolean)
.setTypeDefinition(Identifiers.BaseDataVariableType)
.build();
logger.info("dhanasekar @ExampleNamespac.j flop.getNodeId()={}",flop.getNodeId());

getNodeManager().addNode(flop);
rootNode.addOrganizes(flop);



flop.setValue(new DataValue(new Variant(0)));


}

I have had subscribed for "Flip and Flop" which is in other server. When I run ExampleNamespace.java, I am getting below error, 

12:09:44.093 [main] WARN  o.e.m.e.client.SubscriptionExample - failed to create item for nodeId=NodeId{ns=0, id=12345} (status=StatusCode{name=Bad_NodeIdUnknown, value=0x80340000, quality=bad})


Can you please help me to solve this error?.

ScreenShot of Dummy Variable node in Milo Server,

<image.png>


On Thu, Dec 5, 2019 at 8:11 PM J Dhanasekar <jdhanasekar@xxxxxxxxxxxxxxxxxx> wrote:
Ok.. I will implement new VariableNode by taking addVariableNodes() as a reference. 

On Thu, Dec 5, 2019 at 7:56 PM Kevin Herron <kevinherron@xxxxxxxxx> wrote:
To start with just create regular VariableNodes. Look at how any of the nodes in the addVariableNodes() function are added.

The custom datatype is another more advanced example that you don't need to worry about yet.

On Thu, Dec 5, 2019 at 6:09 AM J Dhanasekar <jdhanasekar@xxxxxxxxxxxxxxxxxx> wrote:
Ok.. I should not create VariableNode Under "Myobjec". I should follow the implementation  of "CustomDataTypeVariable" and create new VariableNode. 
Am I correct?.

On Thu, Dec 5, 2019 at 7:25 PM Kevin Herron <kevinherron@xxxxxxxxx> wrote:
What you've actually done here is add a new instance declaration variable to the "MyObject" type. If you found this instance declaration it would have the NodeId you configured, but what your'e looking at in the screenshot is an instantiated instance of MyObject created by NodeFactory, and all the NodeIds in new instances are derived.

If you're just trying to add some simple test nodes to the address space you're going about it the wrong way. 

On Thu, Dec 5, 2019 at 5:29 AM J Dhanasekar <jdhanasekar@xxxxxxxxxxxxxxxxxx> wrote:
I am sharing the same,


private void addCustomObjectTypeAndInstance(UaFolderNode rootFolder) {

logger.info("dhanasekar @ExampleNamespac.j getNodeContext()={}",getNodeContext());
// Define a new ObjectType called "MyObjectType".
UaObjectTypeNode objectTypeNode = UaObjectTypeNode.builder(getNodeContext())
.setNodeId(newNodeId("ObjectTypes/MyObjectType"))
.setBrowseName(newQualifiedName("MyObjectType"))
.setDisplayName(LocalizedText.english("MyObjectType"))
.setIsAbstract(false)
.build();

logger.info("dhanasekar @ExampleNamespac.j newQualifiedName()={}",newQualifiedName("Foo"));
// "Foo" and "Bar" are members. These nodes are what are called "instance declarations" by the spec.
UaVariableNode foo = UaVariableNode.builder(getNodeContext())
.setNodeId(newNodeId("ObjectTypes/MyObjectType.Foo"))
.setAccessLevel(ubyte(AccessLevel.getMask(AccessLevel.READ_WRITE)))
.setBrowseName(newQualifiedName("Foo"))
.setDisplayName(LocalizedText.english("Foo"))
.setDataType(Identifiers.Int16)
.setTypeDefinition(Identifiers.BaseDataVariableType)
.build();

//dhanasekar object intentiated of Reference
foo.addReference(new Reference(
foo.getNodeId(),
Identifiers.HasModellingRule,
Identifiers.ModellingRule_Mandatory.expanded(),
true
));

//method
foo.setValue(new DataValue(new Variant(0)));
objectTypeNode.addComponent(foo);

UaVariableNode bar = UaVariableNode.builder(getNodeContext())
.setNodeId(newNodeId("ObjectTypes/MyObjectType.Bar"))
.setAccessLevel(ubyte(AccessLevel.getMask(AccessLevel.READ_WRITE)))
.setBrowseName(newQualifiedName("Bar"))
.setDisplayName(LocalizedText.english("Bar"))
.setDataType(Identifiers.String)
.setTypeDefinition(Identifiers.BaseDataVariableType)
.build();

bar.addReference(new Reference(
bar.getNodeId(),
Identifiers.HasModellingRule,
Identifiers.ModellingRule_Mandatory.expanded(),
true
));

bar.setValue(new DataValue(new Variant("bar")));
objectTypeNode.addComponent(bar);


// dhanasekar -- Starting
// Adding code for flip
UaVariableNode flip = UaVariableNode.builder(getNodeContext())
.setNodeId(newNodeId(12345))
.setAccessLevel(ubyte(AccessLevel.getMask(AccessLevel.READ_WRITE)))
.setBrowseName(newQualifiedName("Flip"))
.setDisplayName(LocalizedText.english("Flip"))
.setDataType(Identifiers.Int32)
.setTypeDefinition(Identifiers.BaseDataVariableType)
.build();
logger.info("dhanasekar @ExampleNamespac.j flip.getNodeId()={}",flip.getNodeId());

flip.addReference(new Reference(
flip.getNodeId(),
Identifiers.HasModellingRule,
Identifiers.ModellingRule_Mandatory.expanded(),
true
));

flip.setValue(new DataValue(new Variant(0)));
objectTypeNode.addComponent(flip);

// Adding code for flop

UaVariableNode flop = UaVariableNode.builder(getNodeContext())
.setNodeId(newNodeId("ObjectTypes/MyObjectType.Flop"))
.setAccessLevel(ubyte(AccessLevel.getMask(AccessLevel.READ_WRITE)))
.setBrowseName(newQualifiedName("Flop"))
.setDisplayName(LocalizedText.english("Flop"))
.setDataType(Identifiers.Boolean)
.setTypeDefinition(Identifiers.BaseDataVariableType)
.build();

flop.addReference(new Reference(
flop.getNodeId(),
Identifiers.HasModellingRule,
Identifiers.ModellingRule_Mandatory.expanded(),
true
));

flop.setValue(new DataValue(new Variant(0)));
objectTypeNode.addComponent(flop);

// dhanasekar -- Ending

// Tell the ObjectTypeManager about our new type.
// This let's us use NodeFactory to instantiate instances of the type.
getServer().getObjectTypeManager().registerObjectType(
objectTypeNode.getNodeId(),
UaObjectNode.class,
UaObjectNode::new
);

// Add the inverse SubtypeOf relationship.
objectTypeNode.addReference(new Reference(
objectTypeNode.getNodeId(),
Identifiers.HasSubtype,
Identifiers.BaseObjectType.expanded(),
false
));


// Add type definition and declarations to address space.
getNodeManager().addNode(objectTypeNode);
getNodeManager().addNode(foo);
getNodeManager().addNode(bar);
//dhanasekar
getNodeManager().addNode(flip);
getNodeManager().addNode(flop);
//dhanasekar

// Use NodeFactory to create instance of MyObjectType called "MyObject".
// NodeFactory takes care of recursively instantiating MyObject member nodes
// as well as adding all nodes to the address space.
try {
UaObjectNode myObject = (UaObjectNode) getNodeFactory().createNode(
newNodeId("HelloWorld/MyObject"),
objectTypeNode.getNodeId(),
false
);
myObject.setBrowseName(newQualifiedName("MyObject"));
myObject.setDisplayName(LocalizedText.english("MyObject"));

// Add forward and inverse references from the root folder.
rootFolder.addOrganizes(myObject);

myObject.addReference(new Reference(
myObject.getNodeId(),
Identifiers.Organizes,
rootFolder.getNodeId().expanded(),
false
));
} catch (UaException e) {
logger.error("Error creating MyObjectType instance: {}", e.getMessage(), e);
}
}

On Thu, Dec 5, 2019 at 6:56 PM Kevin Herron <kevinherron@xxxxxxxxx> wrote:
Yes, more code is necessary to help debug.

On Thu, Dec 5, 2019 at 5:20 AM J Dhanasekar <jdhanasekar@xxxxxxxxxxxxxxxxxx> wrote:
You want me to provide complete code for further debug??..

On Thu, Dec 5, 2019 at 6:46 PM Kevin Herron <kevinherron@xxxxxxxxx> wrote:
This looks okay on its own, we'll need to see more of the surrounding code for additional context.

On Thu, Dec 5, 2019 at 5:15 AM J Dhanasekar <jdhanasekar@xxxxxxxxxxxxxxxxxx> wrote:
Attaching the screenshot,

<image.png>


On Thu, Dec 5, 2019 at 6:34 PM J Dhanasekar <jdhanasekar@xxxxxxxxxxxxxxxxxx> wrote:
Hi Milo,

I have created variableNode and I have assigned numeric ID,

UaVariableNode flip = UaVariableNode.builder(getNodeContext())
.setNodeId(newNodeId(12345))
.setAccessLevel(ubyte(AccessLevel.getMask(AccessLevel.READ_WRITE)))
.setBrowseName(newQualifiedName("Flip"))
.setDisplayName(LocalizedText.english("Flip"))
.setDataType(Identifiers.Int32)
.setTypeDefinition(Identifiers.BaseDataVariableType)
.build();

But, I am not getting numeric ID  "12345" in browser window, Instead I am getting string value "ns=2;s=HelloWorld/MyObject/2:Flip".

Can you please help me to solve this issue ?.

Thanks,
Dhanasekar
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev

Back to the top