Returning the appropriate StatusCode when UserData are missing

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
User avatar
baldo
Hero Member
Hero Member
Posts: 25
Joined: 19 Nov 2019, 12:15

Returning the appropriate StatusCode when UserData are missing

Post by baldo »

Hi,

When I create variables but I don't set the user data, if I subscribe to them from a client I still get a 'Good' as a StatusCode result, where the variable's value I think it's the default one (e.g. 'false' in case of Boolean).
And these variables are not appearing as argument in the overridden Read/Write methods. So where can I set a different behaviour for them? i.e. I want to return a 'Bad..." status code when subscribing to those variables with no user data. And what would be an appropriate status for them to not confuse them with variables that have been successfully configured with some user data that legitimately return a 'Good' status? I see that UnifiedAutomation.UaBase.StatusCodes have for example BadNoDataAvailable or BadNoData or BadBoundNotFound or BadDataUnavailable or BadNoEntryExists or ... What is the right one? And in general where can I learn how to return the correct statuses?

Thanks,
Best regards.

Baldo

User avatar
baldo
Hero Member
Hero Member
Posts: 25
Joined: 19 Nov 2019, 12:15

Re: Returning the appropriate StatusCode when UserData are missing

Post by baldo »

Digging some more I found these topics that looks like they answer in part to my question:

https://forum.unified-automation.com/viewtopic.php?f=38&t=2042&p=4598&hilit=nodehandletype#p4598
https://forum.unified-automation.com/viewtopic.php?f=38&t=1120&p=1525&hilit=statuscodes#p1525

in this case I might be able to solve the problem initializing the value to be returned as {Value = null, StatusCode = StatusCodes.BadWaitingForInitialData} but I think the problem with this is that when I debug my overridden Read method I see only nodes having a non-null DataValue, and not those nodes that I would like them to return BadWaitingForInitialValue, so how can I set this?

Note that I'm using ExternalPolled handle type.

Post Reply