Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Reading an array of floating point numbers?

More
27 Nov 2013 05:43 #1563 by support
Actually, we are just passing this (the RequestedDataType) to the target OPC server, and it is up to the server to provide the values in whatever type is has been requested to.

I would expect the server to react the way I described, i.e. provide the array with the same number of element as it has bytes, except that each element will be a float instead. I think this is also the way that is compliant with the OPC specification. A specific server, however, may behave differently, that is outside of our control.

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

More
26 Nov 2013 21:01 #1562 by tlaford
Oh, so if I did use VarType.Array | VarType.R4 the system wouldn't combine each set of 4 bytes into a Single, it would instead give me 2048 Single values?

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

More
26 Nov 2013 20:10 #1561 by support
Correct.

You could specify VarType.Array | VarType.R4 as the requested data type, but that would mean to return *each* member of the array as R4 - clearly, not what you want.

Best regards

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

More
26 Nov 2013 20:06 #1560 by tlaford
Thank you for your quick reply.

Yes, in fact I am using the BitConverter.ToSingle() method to perform the conversion.

I posted this question to inquire if there was a way to call the SubscribeItem() method with a VarType argument that combines ARRAY and R4 so that my code wouldn't need to do the conversion.

But, since you so kindly informed me that there isn't, I will leave my code as is.

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

More
26 Nov 2013 19:59 #1559 by support
There is no such pre-made method; also, there are various float representations on the devices, and one needs to be careful and know well how the number is represented.

Provided that you have four bytes that represent a Single in the same way as .NET does (IEEE 754 format I believe), you can use BitConverter.ToSingle (msdn.microsoft.com/en-us/library/system.bitconverter.tosingle(v=vs.110).aspx ) to achieve what you want, quite easily.

Best regards
The following user(s) said Thank You: tlaford

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

More
26 Nov 2013 18:42 #1558 by tlaford
I am using QuickOPC.NET to read array data from two different OPC data sources. The first data source returns its array values in an array of 512 bytes, and each byte is one data point. The second data source returns its values in an array of 2048 bytes, and I have to convert each set of four bytes into a floating point number.

Is there a way to configure the system so it knows to return an array of a specific data type other than BYTE? For example, instead of needing to convert the 4 bytes into a Single, is there a way to tell the system to give me an array of 512 singles?

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

Moderators: support
Time to create page: 0.050 seconds