06-01-2007 05:17 AM
Hi Labviewers,
I am using LV8.2 and I am trying to find if it is possible to read enumerations from an OPC server via Datasocket, not just the values.
I can successfully read a value for an OPC server via Datasocket and I get a value for example 3, is it possible to get the enumeration/string that corresponds to this value i.e. "Open".
Many thanks in advance
Dimitris
06-05-2007 04:14 AM
Hi Dimitris,
Do you already know the values of the enums? Are they user defined?
06-05-2007 04:36 AM
Hi Sarah,
The enums are not user defined but I don’t know the numeric values or enum strings beforehand. I was hoping to be able to read them directly from the server.
I think I know what you are thinking. Make a list of all the enumerations and their respective values. Place them in an array and then use the array to lookup the enums corresponding to the value returned from the server.
The only problem with this approach is the Lookup array must be kept up-to-date, as the server enumerations change.
Regards
Dimitris
06-05-2007 04:49 AM
Hi Dimitris,
With the Datasocket Read VI when you define the type(Variant) input as Enum it returns an the enum datatype. Does this not work for you?
06-05-2007 05:35 AM
Hi Sarah,
With the input type as variant I get the following response:
1 <-This is the current numeric value of the parameter
4 Attribute(s):
'Quality' -> 192
'TimeHigh' -> 29861723
'TimeLow' -> -665408304
'Timestamp' -> 39.238E+3
With the Input set to
Dimitris
06-05-2007 07:52 AM
Hi Dimitris,
This is actually expected behaviour. With enums, the string information is part of the datatype, so in order to extract the string information in the datasocket read, labview needs to know what the datatype is in order to interpret it (like with a cluster).
Unfortunately there isn't a way for LabVIEW to determine the corresponding string in the enum without prior knowledge of the datatype.
06-05-2007 08:44 AM
I will try to get more information regarding the datatype from the OPC developers.
Thanks for all your efforts
06-06-2007 03:35 AM
Hi Sarah
I have asked the OPC Developers and they would like to know the following. Can you help?
"The recognized OPC technique for obtaining the enumeration strings for a data item is to use the IEnumOPCItemAttributes interface on the OPC group object. The enum strings are returned as part of the Engineering Units information.
Is there a way of accessing this behaviour of the OPC server through datasockets or other standard LabView techniques?
Many thanks
Dimitris
06-07-2007 05:32 AM
06-07-2007 07:07 AM
Hi Sarah,
I don’t know how an OPC client would normally read the IEnumOPCItemAttributes property. It is a property and has no OPC address.
Below is an extract I found on the web:
“IEnumOPCItemAttributes
IEnumOPCItemAttributes allows a client to find out the contents (items) of a group and the attributes of those items.
NOTE: most of the returned information was either supplied by or returned to the client at the time it called AddItem.
The optional EU information (see the OPCITEMATTRIBUTES discussion) may be very useful to some clients. This interface is also useful for debugging or for enumerating the contents of a public group.
This interface is returned only by IOPCItemMgt::CreateEnumerator. It is not available through query interface.”......
I don’t know if this helps you,it didn’t help me, but then again I am not an OPC expert. If we both still struggle to make sense of this, would it be possible to seek advice from someone else within NI UK/USA with more knowledge of OPC to see if they can help.
Many Thanks
Dimitris