简体   繁体   English

OPC UA Java-如何从订阅publishResponse获取MonitoredItemID

[英]OPC UA Java - How to get MonitoredItemID from a subscription publishResponse

I'm currently working with the OPC UA Foundation Java Stack, without any additional SDK's. 我目前正在使用OPC UA Foundation Java Stack,而没有任何其他SDK。

I managed to implement subscriptions with multiple monitored items and I'm getting the change notifications correctly via the publish response. 我设法实现了具有多个受监视项目的订阅,并且通过发布响应正确获取了更改通知。

The Problem is that I can not figure out which monitored item is responsible for the datachange response, when I have multiple items in one subscription. 问题是,当我在一个订阅中有多个项目时,我无法确定哪个受监视项目负责数据更改响应。 The MonitoredItemNotification doesn't seem to have a method for that?! MonitoredItemNotification似乎没有方法吗?! So how can I get an itemId, displayname, nodeId or just anything to identify the item in the response? 那么,如何获取itemId,displayname,nodeId或仅用于标识响应中项目的任何内容?

This is the response I get(looks almost identically for each item): 这是我得到的响应(每个项目看起来几乎相同):

ResponseHeader=ResponseHeader
Timestamp=06/23/16 10:36:41.9018551 GMT
RequestHandle=0
ServiceResult=GOOD (0x00000000) ""
ServiceDiagnostics=Diagnostic Info: 

StringTable=class java.lang.String[0]
AdditionalHeader=null
SubscriptionId=92
AvailableSequenceNumbers=class org.opcfoundation.ua.builtintypes.UnsignedInteger[2]
[0]=1
[1]=2
MoreNotifications=false
NotificationMessage=NotificationMessage
SequenceNumber=2
PublishTime=06/23/16 10:36:41.9018551 GMT
NotificationData=class org.opcfoundation.ua.builtintypes.ExtensionObject[1]
  [0]=DataChangeNotification: DataChangeNotification
    MonitoredItems=class org.opcfoundation.ua.core.MonitoredItemNotification[1]
      [0]=MonitoredItemNotification
      ClientHandle=0
      Value=DataValue(value=true, statusCode=GOOD (0x00000000) "", sourceTimestamp=06/23/16 10:36:41.7146527 GMT, sourcePicoseconds=0, serverTimestamp=null, serverPicoseconds=0)
    DiagnosticInfos=class org.opcfoundation.ua.builtintypes.DiagnosticInfo[0]

Results=class org.opcfoundation.ua.builtintypes.StatusCode[0]
DiagnosticInfos=class org.opcfoundation.ua.builtintypes.DiagnosticInfo[0]

Each MonitoredItem shall have its own ClientHandle. 每个MonitoredItem应具有其自己的ClientHandle。

When you send a CreateMonitoredItems Request to the server you should pass the ClientHandle you want in each MonitoredItemCreateRequest. 当您向服务器发送CreateMonitoredItems请求时,应在每个MonitoredItemCreateRequest中传递所需的ClientHandle。 This will be returned in each Publish Response's MonitoredItemNotification. 这将在每个发布响应的MonitoredItemNotification中返回。

I guess you passed the value "0", that's why you have 我猜您传递的值为“ 0”,这就是为什么

[0]=MonitoredItemNotification
  ClientHandle=0
  Value=DataValue(value=true, statusCode=GOOD (0x00000000) "", sourceTimestamp=06/23/16 10:36:41.7146527 GMT, sourcePicoseconds=0, serverTimestamp=null, serverPicoseconds=0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM