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.

Obtaining type of the value

More
21 Jan 2016 12:53 #3805 by support
Replied by support on topic Obtaining type of the value
Well, this kind of depends on what you mean by type of the value.

In OPC UA, the node has some value type. The type is identified by yet another Node in OPC UA address space. This "value type" is not available in UAAttributeData, but has to be obtained separately by reading the UAAttributeId.DataType attribute of the node (attribute number is 14, I am mentioning that as the enum-s are somewhat difficult to access from COM). What you get needs to be interpreted according to UA specs, and is not much usable without it, because for all standard types, it is a pre-defined NodeId that determines the actual type.

If what you ask for is somehow interpreting the type of the value that has actually arrived to the client from the server, then it should first be said that the value and its type go through a series of conversions, therefore a "precise" type may not be obtainable in this way. The value needs to be converted from UA encoding to a .NET type first. Then, some types are converted to their nearest CLS-compliant equivalents (CLS is a spec that restricts .NET for language interoperability). Further, the value needs to be converted to a COM Variant, and that is what ultimately gets transferred to Delphi.

UAAttributeData.ValueType simply looks at the value (after conversions to .NET/CLS), and returns its .NET type. What you get is a Type object (msdn.microsoft.com/en-us/library/system.type(v=vs.110).aspx ). You can interrogate its properties, or you can convert it to string, as you suggested.

Similarly, there should be some way to figure out the value type from the .Value itself, but that depends on the language, and I am not a Delphi expert.

Best regards

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

More
21 Jan 2016 10:07 #3799 by Manfred
Can I ask you another question between?
I use : AttributeData := OPCUAServer.Read(UAServerEndpoint,ItemURL);
get:
ItemTimeStamp:= AttributeData.ServerTimestamp;
ItemQuality:= GetQuality(AttributeData);
ItemStatus:= AttributeData.StatusCode.ToString;

but how can I get the type of the value?

AttributeData.ValueType ...???? ToString ????

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

Moderators: support
Time to create page: 0.050 seconds