OPC UA Java - 如何从订阅publishResponse获取MonitoredItemID(OPC UA Java - How to get MonitoredItemID from a subscription publishResponse)
我目前正在使用OPC UA Foundation Java Stack,没有任何其他SDK。
我设法实现了多个受监控项目的订阅,并通过发布响应正确获取更改通知。
问题是当我在一个订阅中有多个项目时,我无法确定哪个受监视项目负责datachange响应。 MonitoredItemNotification似乎没有方法吗?! 那么如何才能获得itemId,displayname,nodeId或者只是为了识别响应中的项目?
这是我得到的响应(对于每个项目看起来几乎相同):
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]
I'm currently working with the OPC UA Foundation Java Stack, without any additional SDK's.
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?! So how can I get an itemId, displayname, nodeId or just anything to identify the item in the response?
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]
原文:https://stackoverflow.com/questions/38007986
更新时间:2019-12-15 16:19
最满意答案
每个MonitoredItem都有自己的ClientHandle。
当您向服务器发送CreateMonitoredItems请求时,您应该在每个MonitoredItemCreateRequest中传递所需的ClientHandle。 这将在每个发布响应的MonitoredItemNotification中返回。
我猜你通过了值“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)
Each MonitoredItem shall have its own ClientHandle.
When you send a CreateMonitoredItems Request to the server you should pass the ClientHandle you want in each MonitoredItemCreateRequest. This will be returned in each Publish Response's MonitoredItemNotification.
I guess you passed the value "0", that's why you have
[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)
2016-06-24
相关问答
MachineInfo将是一个Object节点(ObjectClass of Object),HasComponent引用13个属性中的每一个,它们本身就是Variable节点(NodeClass of Variable)。 就类型定义而言,您可以从使用BaseObjectType和BaseDataVariableTypes开始,但如果您将使用能够利用更复杂类型的客户端,则可以为该对象创建自定义ObjectType。 变量组件可以进一步公开为AnalogItemType或DiscreteItemT
...
埋在堆栈跟踪中是真正的问题: UaException: timed out waiting for acknowledge 。 也许你的防火墙或网络设置阻止了它,或者服务器没有发回它,但问题是客户端从未收到Acknowledge消息以响应其Hello 。 FWIW,我可以在没有问题的ReadExample针对该公共服务器运行ReadExample 。 在ReadExample我ReadExample getSecurityPolicy()并返回SecurityPolicy.None并在Client
...
编写示例时,它始终选择最安全的连接,另一方面,在启用连接之前,要求服务器接受客户端应用程序的应用程序实例证书。 Bad_SecurityChecksFailed是服务器的标准错误代码,当它不接受客户端连接时。 由于您无法控制这些公开可用的服务器以使它们信任您的客户端应用程序,因此您唯一的选择是在没有安全性的情况下尝试连接,如果服务器允许的话。 为此,您需要更改代码,以便选择不安全的端点。 更换 SessionChannel mySession = myClient.createSessionCha
...
你不应该自己创建一个会话,因为这是由客户端为你处理的,你绝对不应该试图删除以前的会话。 唯一需要做的是将一个SubscriptionListener添加到OpcUaSubscriptionManager并处理onSubscriptionTransferFailed回调。 接收此回调意味着客户端已重新连接并且必须创建新会话,但服务器无法将其旧订阅传输到此会话。 这通常发生在重新连接时间过长以及订阅超时或者导致服务器丢失其全部状态(例如重新启动)时发生。 我已经添加了一个有点复杂的集成测试,证明所有这
...
每个MonitoredItem都有自己的ClientHandle。 当您向服务器发送CreateMonitoredItems请求时,您应该在每个MonitoredItemCreateRequest中传递所需的ClientHandle。 这将在每个发布响应的MonitoredItemNotification中返回。 我猜你通过了值“0”,这就是你的原因 [0]=MonitoredItemNotification
ClientHandle=0
Value=DataValue(value=tru
...
NodeId在服务器上下文中必须是唯一的。 不要将自己的实例化节点与作为默认地址空间的一部分建模的Nodes和NodeIds混淆(在规范和架构文件中定义,位于https://opcfoundation.org/UA/schemas/ )。 The NodeId must be unique within the context of the server. Don't confuse your own instantiated nodes with the Nodes and NodeIds th
...
好的,所以你会添加一个新的VaribleNode和一个TypeDefinition属性( Identifiers.PropertyType )。 然后,您将写入它的Value属性,以便它包含EUInformation对象: EUInformation euInformation = ...
Variant v = new Variant(ExtensionObject.encode(euInformation));
...write the value to the node you crea
...
在实现UA客户端时,这是一个非常常见的问题。 服务器最终负责您获取的端点的内容,并且您连接的端点(错误)配置为在端点URL中返回127.0.0.1,显然。 您需要检查从服务器获得的端点,然后根据应用程序的性质,立即用新修复的EndpointDescription替换它们,其中包含您已修改的URL或让用户知道并首先请求他们获得许可。 无论哪种方式,您都需要创建一组新的EndpointDescription在此之前您已经更正了URL,然后再继续创建OpcUaClient 。 或者......您可以弄清
...
是否必须安装LDS? 不,LDS的安装纯粹是可选的。 特别是在小型/嵌入式设备上,您甚至无法安装OPC UA服务器以外的任何其他设备。 发现服务器,然后连接到服务器,直接连接到服务器端点而不发现之间有什么实际区别? 通过在标准化端口(4840)上运行LDS,可以在不知道其端点URL的情况下发现计算机上的所有服务器。 如果没有LDS,则无法在不知道URL的情况下连接到服务器。 正如已经评论过的那样,由于必须建立与LDS和服务器的连接,因此让LDS使发现(非常)稍慢。 如果计算机上只运行一台服务器,则
...
当前的Sinumerik OPC UA服务器是错误的,并没有提供正确编码的ExtensionObjects。 一旦可用,您将需要从西门子请求更新服务器。 请注意,您可以毫无问题地访问它,UaExpert可以解码编码不良的ExtesionObjects。 这只是让他们首先发布了这样一个错误的版本。 编辑:关于ExtensionObjects的注意事项:如果您尝试将其作为完整结构读取,则ServerStatus将作为ExtensionObject传输。 PublishResponse(用于提供订阅数据
...