Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
What is difference between monitoredItem errorcode and dataValue statusCode in onDataChange method ? Why we getting one as good and another as bad?
December 8, 2023
11:21, EET
Avatar
amj005
Member
Members
Forum Posts: 33
Member Since:
July 27, 2021
sp_UserOfflineSmall Offline

Hi,

We are reading values from OPCUA server with prosys using the below onDataChange method:
onDataChange(MonitoredDataItem monitoredDataItem, DataValue prevValue, DataValue dataValue)

But we are seeing different status for monitoredDataItem and dataValue.
i.e. Ex:
monitoredDataItem.getErrorCode() – GOOD (0x00000000) “The operation succeeded.”
Whereas dataValue.getStatusCode().getValue() – 2147483648
The above code refers to Bad status, as per OPCUA error codes.

Can you please explain the difference between them?
Why we have different status for these for same node?
And which one we should consider for specifying the status for the read. And persist in our system?

Thank you!

December 8, 2023
11:59, EET
Avatar
Matti Siponen
Moderator
Members

Moderators
Forum Posts: 321
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline

Hello,

The StatusCode returned by the getErrorCode method of MonitoredItem class refers to the StatusCode returned by the Server when the MonitoredItem was created. Typically this StatusCode is good, but if creating the MonitoredItem fails, e.g. because the NodeId the MonitoredItem is being created for is not recognized by the Server, the ErrorCode will be bad.

The StatusCode of the DataValue in onDataChange method of MonitoredDataItemListener interface is the StatusCode of the Value reported by the MonitoredItem. Even if creating the MonitoredItem succeeds and getErrorCode returns a good StatusCode, the DataValue in onDataChange could have a bad StatusCode, e.g. when the Value of the Node has not been initialized yet and the StatusCode of the DataValue is set to Bad_WaitingForInitialData.

The StatusCode in the DataValue is the StatusCode you’re interested in when processing Values of the Node. The StatusCode returned by the getErrorCode method is only needed for checking whether or not the MonitoredItem was created successfully and it has nothing to do with the Value of the Node.

December 8, 2023
16:33, EET
Avatar
amj005
Member
Members
Forum Posts: 33
Member Since:
July 27, 2021
sp_UserOfflineSmall Offline

Thanks for the clear explanation!

Further, I want to understand on below things.
1. If the dataValue status code is bad, do we always have the value as null object?
i.e. in above case I received null for ‘dataValue.getValue()’.
2. Is there a way, we can have more details, what happened with the subscription etc, than just status code?
Ex: In my scenario, when I check values with prosys browser, I see it. But I started receiving null values with status code -2147483648. This is for some nodes.
And I do not have more information on what happened or how to resolve this.
3. Do you know when the status code -2147483648, happens in Prosys ? I see it form multiple nodes intermittently..

Thank you!

December 11, 2023
8:26, EET
Avatar
Matti Siponen
Moderator
Members

Moderators
Forum Posts: 321
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline

Hello,

1. The OPC UA Specification states the following for value field of a DataValue: “If the StatusCode indicates an error then the value is to be ignored and the Server shall set it to null” (https://reference.opcfoundation.org/Core/Part4/v105/docs/7.11). Therefore, you should ignore the value when the StatusCode is Bad.

2. You can use SubscriptionAliveListener and SubscriptionNotificationListener to monitor the Subscription in more detail. But if you start receiving null Values from the Server, it would imply that the Subscription is still alive and something has happened to the Nodes corresponding to its MonitoredItems. If you can read the Values of those Nodes with Browser after receiving null Values via MonitoredItems, this does seem like an error in the Server and you should contact its manufacturer for advice. Has the Server been developed with Prosys OPC UA SDK for Java?

3. StatusCodes are defined as 32-bit unsigned integers (https://reference.opcfoundation.org/Core/Part4/v105/docs/7.39). Your number, -2147483648, is the minimum value of signed int32, so it would be 0x80000000 in hexadecimal form and that would corresponds to the generic Bad StatusCode (https://github.com/OPCFoundation/UA-Nodeset/blob/latest/Schema/StatusCode.csv).

Typically Servers would use some other StatusCode that is more specific to the error. Which Server are you connecting your Client to? Has it been developed with Prosys OPC UA SDK for Java?

In general, StatusCodes are referred to by their names, not by their exact numerical values. When you have a StatusCode object, you would typically use the getName method to get the name of the StatusCode. Using toString would also convert the StatusCode into understandable format.

December 12, 2023
16:07, EET
Avatar
amj005
Member
Members
Forum Posts: 33
Member Since:
July 27, 2021
sp_UserOfflineSmall Offline

Thanks for the inputs.

It is not Prosys server. We are connecting Java client (Using Prosys Java SDK) to Kepware, which has internally connected to different OPCUA servers.

Do you think there can be any issue w.r.t connecting Prosys client with Kepware for reading?

Thank You!

December 12, 2023
16:21, EET
Avatar
amj005
Member
Members
Forum Posts: 33
Member Since:
July 27, 2021
sp_UserOfflineSmall Offline

Also, do we have any listener for moniteredDataItem? So, we can have more information if something goes wrong at the monitered item level?

Thanks.

December 13, 2023
8:14, EET
Avatar
Matti Siponen
Moderator
Members

Moderators
Forum Posts: 321
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline

Hello,

If the MonitoredItems are reporting StatusCode Bad, then that is the code sent by the Kepware Server. You will need to investigate the Server to understand why it does that for no apparent reason if reading the Nodes directly is still working.

While troubleshooting the Kepware Server itself is outside the scope of support provided on this forum, we would recommend using Wireshark to capture traffic between the applications and sending the logs to uajava-support@prosysopc.com so that we can verify the problem. See https://www.prosysopc.com/blog/opc-ua-wireshark/ for instructions on how to capture OPC UA communication with Wireshark. If you’re running the applications on the same host, remember to select “Support loopback traffic” option when installing Wireshark.

MonitoredDataItems have MonitoredDataItemListener. Its onChange method can be used to check the StatusCode in the reported DataValue. The OPC UA Specification defines that StatusCode Bad_NodeIdUnknown should be reported if the Node is removed from the Server’s AddressSpace, but other StatusCodes do not have any “special” meaning when used in DataValues reported via MonitoredItems.

In general, we would recommend you to report this problem to the support of the Kepware Server. It is very unusual that a MonitoredItem would stop reporting Values normally while reading the Value directly from the Node is working.

December 13, 2023
16:12, EET
Avatar
amj005
Member
Members
Forum Posts: 33
Member Since:
July 27, 2021
sp_UserOfflineSmall Offline

Hi,

Thanks for your inputs and insights !
We will look into this and get back.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
9 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

TimK: 41

Member Stats:

Guest Posters: 0

Members: 682

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

digitechroshni, LouieWreve, Kickbiche, karrimacvitie5, graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma

Moderators: Jouni Aro: 1010, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1