16:42, EET
September 18, 2017
Hi there,
I am using Java-SDK 2.3.2 EVAL. I want to modify node attributes other than value.
My node set file looks like this:
<DisplayName>VariableAttributes</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
<Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=5004</Reference>
</References>
</UAVariable>
WriteMask/UserWriteMask are set to modify BrowseName, DisplayName, Description, DataType, ValueRank, ArrayDimensions, AccessLevel, UserAccessLevel, MinimumSamplingInterval and Historizing.
When I upload this node set then the nodes are there but WriteMask/UserWriteMask are set to ‘0’.
Then I implement IoManagerListener. First I implement onGetUserWriteMask():
public EnumSet<WriteAccess> onGetUserWriteMask(ServiceContext serviceContext, NodeId nodeId, UaNode node) {
String sNodeId = nodeId.toString();
switch(sNodeId) {
case "ns=2;i=6009": // VariableAttributes
return writableAttributes;
}
return EnumSet.noneOf(WriteAccess.class);
}
Where writableAttributes is defined as:
But the values of WriteMask/UserWriteMask are still ‘0’.
Then I implement onReadNonValue() as:
public boolean onReadNonValue(ServiceContext serviceContext, NodeId nodeId, UaNode node,
UnsignedInteger attributeId, DataValue dataValue) throws StatusException {
String sNodeId = nodeId.toString();
switch (sNodeId) {
case "ns=2;i=6009":
if (attributeId.intValue() == Attribute.WriteMask.toInt() ||
attributeId.intValue() == Attribute.UserWriteMask.toInt()) {
dataValue.setValue(new Variant(WriteAccess.getMask(writableAttributes)));
return true;
}
}
return false;
}
Now the values of WriteMask/UserWriteMask are ‘594551’.
With the debugger I can assure that my methods are executed.
When I use a client program (a user defined CTT script) to modify the attribute description of this node I get a BadNotWritable status code.
Then I implement the onWriteNonValue() method:
public boolean onWriteNonValue(ServiceContext serviceContext, NodeId nodeId, UaNode node,
UnsignedInteger attributeId, DataValue dataValue) throws StatusException {
String sNodeId = nodeId.toString();
switch(sNodeId) {
case "ns=2;i=6009":
// check if given attributeId is in list of allowed writable attributes
return writableAttributes.stream().filter(x -> (x.getAttributeId() == attributeId)).count() > 0L;
}
return false;
}
Using the debugger I recognize that this method is NOT called!!!
How can I implement to modify attributes?
The same script was formerly used to modify a node on the Softing Demo Server (“ns=2;s=/Trigger”) which also allows to modify node attributes. This script ran successfully all the time. Now I replaced server and node but all I get is a bad status.
Thomas
13:59, EET
April 3, 2012
Hi,
In the current release the WriteMask is not set correctly to the node, that is a bug, will be fixed for 3.0.
The UserWriteMask part is intentionally ignored when loading the model as that is per user setting and not a global, therefore it should not be defined in the model at all.
Normally you would set the WriteMask to the UaNode instance via UaNode.setWriteMask, then just override the UserWriteMask in the IoManagerListener as you have done (as the UserWriteMask must be subset of the WriteMask).
Note, the last code section contains an error, you compare the UnsignedIntegers via == operator which in java should be only used to compare primitives, you should use .equals instead.
The IoManagerListener allows you to modify the values that are sent to the client. Also you can override the UserAccessLevel/UserExecutable/UserWriteMask per user. However overriding the WriteMask Attribute does send that to the client, however the value for WriteMask comes from the UaNode when writing to Attributes. And due to the bug described above it is not read correctly from the model at the moment, which means it is WriteAccess.NONE. The IoManagerListener is not called if the WriteMask does not allow writing to that attribute.
Until the bug is fixed / 3.0 released, the following workarounds should work:
1. Call .setWriteMask for the UaNode in question
2. Create a subclass of IoManagerUaNode and override readNonValue and set that to the NodeManagerUaNode
– Bjarne
15:31, EET
September 18, 2017
Hi Bjarne,
thanks for information.
Now I set the WriteMask/UserWriteMask of these nodes after the call of loadModel().
this.getAddressSpace().loadModel(istream);
UaNode variableAttributes = this.myNodeManager.getNode("ns=2;i=6009");
variableAttributes.setWriteMask(MyIoManagerListener.writableAttributes);
variableAttributes.setUserWriteMask(MyIoManagerListener.writableAttributes);
Now the IoManagerListener.onWriteNonValue() is being called!!! 🙂
But now I face another problem: I cannot change the value of Description. When I call UaNode.setDescription() with a non-null value, e.g.
variableAttributes.setDescription(new LocalizedText("Test A"));
then Description contains an instance of LocalizedText where Locale is null and Text is null.
But setting other attributes does work:
variableAttributes.setBrowseName(new QualifiedName("AnotherBrowseName"));
Thomas
16:40, EET
April 3, 2012
Hi,
The Description Attribute (or well anything with LocalizedText) is a known problem, should work after 3.0.
The only workaround at the moment is that the Attribute in question must not be Null in the model. Otherwise the attribute value is LocalizedText.NULL (null text, null locale), which due to a bug cannot be replaced at the moment (the attribute value is stored in a LocalizedTextMap which allows to have text per locale). Since the LocalizedText.NULL is the first value given to that map, it is used as a default value for all locales that do not have a specific text set for the locale.
– Bjarne
Most Users Ever Online: 1919
Currently Online:
18 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 730
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
toneylapham544, rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25ZofModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1