当我将值写入变量(使用UaExpert)时,我从提供的ExampleServer
中收到此错误,该变量是另一个对象的子级。我在引发异常的位置打印了访问级别,并且如您在下面的堆栈跟踪中看到的那样,似乎已删除CurrentWrite访问。有人可以帮忙吗?
变量配置:
UaVariableNode foo = UaVariableNode.builder(server.getNodeMap())
.setNodeId(new NodeId(namespaceIndex, "ObjectTypes/MyObjectType.Foo"))
.setAccessLevel(ubyte(AccessLevel.getMask(AccessLevel.READ_WRITE)))
.setBrowseName(new QualifiedName(namespaceIndex, "Foo"))
.setDisplayName(LocalizedText.english("Foo"))
.setDataType(Identifiers.Int16)
.setTypeDefinition(Identifiers.BaseDataVariableType)
.build();
Stacktrace:
// System.out.println(""+node.getDisplayName()+" "+accessLevels); prints:
LocalizedText{text=Foo, locale=en} [CurrentRead]
// Rest of the stack trace
10:16:24.096 [ua-shared-pool-8] ERROR o.e.m.e.server.ExampleNamespace - Unable to write value=DataValue{value=Variant{value=1}, status=StatusCode{name=Good, value=0x00000000, quality=good}, sourceTime=DateTime{utcTime=0, javaDate=Mon Jan 01 08:00:00 SGT 1601}, serverTime=DateTime{utcTime=0, javaDate=Mon Jan 01 08:00:00 SGT 1601}}
org.eclipse.milo.opcua.stack.core.UaException: status=Bad_NotWritable, description=The access level does not allow writing to the Node.
at org.eclipse.milo.opcua.sdk.server.util.AttributeWriter.writeAttribute(AttributeWriter.java:72)
at org.eclipse.milo.opcua.sdk.server.nodes.ServerNode.writeAttribute(ServerNode.java:174)
at org.eclipse.milo.opcua.sdk.server.nodes.ServerNode.writeAttribute(ServerNode.java:153)
at org.eclipse.milo.examples.server.ExampleNamespace.write(ExampleNamespace.java:793)
at org.eclipse.milo.opcua.sdk.server.services.AttributeServices.lambda$8(AttributeServices.java:199)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)