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.

How to get the source data type?

More
21 Dec 2018 15:12 #6939 by support
Thanks for explanation - yes, that is a case in which the super-type search is needed (not sure, however, why Siemens chooses to sub-type Byte and other common types).

Let me know if you need something more.

Best regards

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

More
21 Dec 2018 14:45 - 21 Dec 2018 14:48 #6938 by Boris
Thanks for the detailed answer. This information helped me a lot. Before that, I understood some things wrong. I performed the steps in steps, as you described and now I can get the type "known" to my program.

> I would also welcome if you describe your case in broader terms. That is, why do you actually want to obtain this kind of information?

When processing data in the program, I need to know the exact data type of the variable and ignore the types with which the program cannot work. With Duration, everything turned out to be quite simple, I found it in the specification. But when importing tags from an Siemens OPС-UA server, I got a variable with this type (and many others):
UADataType 
 - NodeId="ns=3;i=3001" 
 - BrowseName="3:BYTE"
By name, I realized that this is a variable of type Byte. But I wanted to be sure of that. The data type identifier is 3001 and I did not know what to do with it. Now I followed HasSubType reference and saw that it was really Byte.
Reference 
 - ReferenceType="HasSubtype" 
 - IsForward="false" 
 - i=3 [Byte]
Last edit: 21 Dec 2018 14:48 by Boris.

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

More
20 Dec 2018 20:16 - 21 Dec 2018 15:04 #6937 by support
Hello.

You might be mixing two things here. The article you linked to has to do with custom data types, which are data types not defined in the OPC UA specs. They are usually structures, but can also be enumerations, arrays, and more. The custom data types do not support inheritance.

The Duration, however, is an OPC UA type datatype defined in the spec. If you do not "know" it, you can use the fact that such types are part of inheritance hierarchy, and yes, Duration is based on Double (here we assume that your code"knows" what Double is, so that it can somehow make sense of that information; some information simply has to be hard-wired somewhere).

The inheritance is expressed in terms of HasSubType references between the nodes that represent datatypes. What you can do is as follows:
  1. Determine the datatype of the variable you are working it. This can be done by reading the DataType attribute of the variable node.
  2. Check if the datatype is one of those that you implicitly know. If so, you are done.
  3. If not, browse the current node for the HasSubType reference, specifying that you want to follow the reference in an inverse direction. This will give you the super-type of the current type (or it will give nothing - that is a failure in trying to find the usable datatype).
  4. Repeat from Step 2.

We have a UADataTypeIds static class that gives you Node IDs of all the standard OPC UA data types. So, UADataTypeIds.Duration, UADataTypeIds.Double etc. are all there.

I hope this helped somehow.
I would also welcome if you describe your case in broader terms. That is, why do you actually want to obtain this kind of information?


Best regards
Last edit: 21 Dec 2018 15:04 by support.
The following user(s) said Thank You: Boris

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

More
20 Dec 2018 17:36 - 20 Dec 2018 17:38 #6936 by Boris
Hello.

I will try to describe the problem with a simple example. Suppose on the OPC-UA server there is a variable with the data type Duration (DataType.Identifier = 290). I know that this data type is actually based on the Double data type. Can I use QuickOPC to find out that Duration is actually a Double data type? This question applies to other "non-standard" data types. Duration taken for example.
If I understand correctly, the answer to my question in this article . And, perhaps, Duration is a primitive data type (DataTypeKind = Primitive). And the code given in the article will allow me to determine that Duration is actually a Double? If so, could you help translate the example from an article in Delphi?
...
  try
    // Error in this line. How can i correctly  cast to UAGenericObject in Delphi?
    genericObject := client.ReadValue(endpointDescriptor, nodeDescriptor);
  except
 
  end;
...
Thank.
Last edit: 20 Dec 2018 17:38 by Boris.

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

Moderators: support
Time to create page: 0.050 seconds