Professional OPC
Development Tools

logos

How to read logical value as 0/1 instead of "True"/"False"? (OPC-UA)

More
24 Mar 2015 20:25 - 24 Mar 2015 20:26 #3006 by support
Oh, I see, then this is just a basic .NET question of converting the bool to whatever you need, not related to OPC or our component that much.

You did not say that you converted the bool to the string yourself...

You could use simply Convert.ToInt32 for it: msdn.microsoft.com/en-us/library/2cew9dz7(v=vs.110).aspx .

Best regards
Last edit: 24 Mar 2015 20:26 by support.

Please Log in or Create an account to join the conversation.

More
24 Mar 2015 16:14 #3005 by sun21
Thank you for your help. Kepserver indeed returned the Value that have right type.

The problem was in conversion of an object of type "bool" using ToString() that produced "True"/"False". My workaround is to replace bool with int:
if (value is bool) {
if ((bool)value == true)
value = 1;
else if ((bool)value == false)
value = 0;
}

Regards, Serge

Please Log in or Create an account to join the conversation.

More
24 Mar 2015 13:42 #3002 by support
If the type of the value returned in UAAtributeData.Value is truly a System.String, then it means that the server has returned to us a String, and not a Boolean. And you will have to convert it to whatever you need, or ask the server whether and how the server can provide truly Boolean values.

Please Log in or Create an account to join the conversation.

More
24 Mar 2015 13:30 #3001 by sun21
Hello All,

When I get a logical (boolean) value from QuickOPC-UA EasyUAMonitoredItemChangedEventArgs I see a string "True" or "False".
I there a way to get integers 1/0 instead?

Regards, Serge

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.165 seconds

      

 Recommend this on Google