目前我正在使用 Eclipse Milo 开发 OPCUA 客户端。我能够从 OPC UA cpp 服务器读取数据并将设定点数据写入服务器。
我无法确认 OPCUA 警报和事件。
我尝试使用 node-red opcua 服务器并收到警报,现在我想确认相同,所以我尝试了调用 opcua 确认方法的代码。这里是:
byte[] b=new byte[] {-66, -115, -121, -6, -39, 40, 89, 114, 60, -66, -126, -79, -72, -128, -21, 23, 0, 0, 4, -4};
LocalizedText lt = new LocalizedText("bagiya");
ByteString bs=new ByteString(b);
Variant evntid1 = new Variant(bs);
System.out.println("jangli id :=>"+vs[1]);
Variant lt1 = new Variant(lt);
Variant[] v = new Variant[] { evntid1,lt1 = new Variant(lt)};
System.out.println(vs[1].getDataType());
CallMethodRequest rec = new CallMethodRequest(NodeId.parse("ns=1;i=1003"), NodeId.parse("ns=1;i=1022"), v);
System.out.println( rec.getTypeId()+"::=>"+client.call(rec).get());
此字节数组字符串由节点红色 opcua 服务器使用事件订阅示例的 eclipse milo 代码给出。
EventFilter eventFilter = new EventFilter(new SimpleAttributeOperand[] {
new SimpleAttributeOperand(Identifiers.BaseEventType,
new QualifiedName[] { new QualifiedName(0, "EventId") }, AttributeId.Value.uid(), null),
new SimpleAttributeOperand(Identifiers.BaseEventType,
new QualifiedName[] { new QualifiedName(0, "EventType") }, AttributeId.Value.uid(), null),
new SimpleAttributeOperand(Identifiers.BaseEventType,
new QualifiedName[] { new QualifiedName(0, "Severity") }, AttributeId.Value.uid(), null),
new SimpleAttributeOperand(Identifiers.BaseEventType,
new QualifiedName[] { new QualifiedName(0, "Time") }, AttributeId.Value.uid(), null),
new SimpleAttributeOperand(Identifiers.BaseEventType,
new QualifiedName[] { new QualifiedName(0, "Time") }, AttributeId.Value.uid(), null),
new SimpleAttributeOperand(Identifiers.BaseEventType,
new QualifiedName[] { new QualifiedName(0, "Message") }, AttributeId.Value.uid(), null) },
new ContentFilter(null));
所以我们得到以下给定状态: CallMethodResult{StatusCode=StatusCode{name= Bad_EventIdUnknown , value=0x809A0000, quality=bad}, InputArgumentResults=[StatusCode{name=Good, value=0x00000000, quality=good}, StatusCode{name=好,值=0x00000000,质量=好}],InputArgumentDiagnosticInfos=[],OutputArguments=[]}
请给我一些解决此问题的建议。