Generating C++ for complex object types

Questions regarding the use of UaModeler

Moderator: uamodeler

Post Reply
nerve
Full Member
Full Member
Posts: 8
Joined: 28 Jun 2013, 09:31

Generating C++ for complex object types

Post by nerve »

Hello

In the readme.txt it's stated that "Complex types may not generate correct code". As far as I can see, this seems to be true for even moderate complex object types. For example, if I define and instantiate the following not very complex object type:

Code: Select all

MyFancyObjectType::BaseObjectType
   |
   Folder1 (FolderType)
      |
      Var1 (VariableType), DataType: TwoStateDiscreteType
the Folder under MyFancyObjectType is added, but the Variable under the folder is missing...

Is it correct that UaModeler cannot create code that creates this Variable automatically? If yes, UaModeler seems rather useless to me.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3064
Joined: 18 Mar 2011, 15:09

Re: Generating C++ for complex object types

Post by Support Team »

Hello nerve,

The templates for C++ only create the direct children of a type node. The grandchildren are only created if they are defined by the TypeDefinition of the parent.

For your example:
FolderType does not have any children, so Var1 is not created.
To generate all nodes you can create a subtype of FolderType that has the Var1 child. If you use this type for Folder1 in MyFancyObjectType, Var1 will be generated.

Best regards,
Unified Automation Support Team

AGO
Full Member
Full Member
Posts: 8
Joined: 01 Jun 2016, 08:22

Re: Generating C++ for complex object types

Post by AGO »

If var1 would have several other childvariables and they would have also childs, would it be possible to create a subtype of the FolderType, which implements this structure or is it necessary to create a subtype of FolderType with the child var1 and then create a variable type var1Type, which implements the next level (var1 child variables) and so on?

Thank you in advance!!

User avatar
Support Team
Hero Member
Hero Member
Posts: 3064
Joined: 18 Mar 2011, 15:09

Re: Generating C++ for complex object types

Post by Support Team »

For C++ Templates ObjectTypes having new grandchildren are supported:

Code: Select all

MyObjectType : BaseObjectType
  |
  Folder1 (FolderType)
    |
    Var1 (BaseDataVariableType, not defined at FolderType)
If Var1 has more children, no code will be generated for these children. This feature is not supported. Not all features that are supported for modelling are supported for generated code.

If you want to model deeper structures, you should create types for the further layors.

Code: Select all

Layor2Type : BaseDataVariableType
  |
  Var2 (BaseDataVariableType)

Layor1Type : FolderType
  |
  Var1 (Layor2Type)

MyObjectType : BaseObjectType
  |
  Folder1 (Layor1Type)
This model for complex types will also work for VariableType and for generated code for .NET SDK.
Best regards
Unified Automation Support Team

AGO
Full Member
Full Member
Posts: 8
Joined: 01 Jun 2016, 08:22

Re: Generating C++ for complex object types

Post by AGO »

This is exactly what I modelled. The only difference is that I used individual Object Types derived from BaseObjectType (No Folders).
Analog to your example, it would be like that:

Code: Select all

Layer3 Type: derived from BaseObjectType
  |
  Var7
  Var8

Layor2Type : derived from BaseObjectType
  |
  Var5 (individual Enumeration)
  Var6
  Object 3 (Layer3Type)

Layor1Type : derived from BaseObjectType
  |
  Var3
  Var4
  Object2 (Layor2Type)

MyObjectType : Layer0 Type derived from BaseObjectType
  |
  Var1
  Var2
  Object1 (Layor1Type)
I got it implemented in my Server. The thing is that the information model is not fully accessible from UaExpert. It is only displayed until Layer1. In Layer 1 you can see the Variables but not Object2.. Does this have anything to do with ModellingRules (Optional, Optional Placeholders)? I should mention that I chose all optional components and optional placeholders.

//EDIT:
I found out, that even when I choose all Optionals and Optional Placeholders manuelly by selecting them in the Object Menu "Select Optional Components" & "Select Optional Placeholders" they will appear in the Information Model, but when you analyze their status of "ModellingRule", it is selected "NoModellingRule". It gets worse if you try to change it manually with the dropdown menu. For some Objects / Variables it is possible to change the ModellingRule and for some it is not...
//EDIT

Thank you for your answer in advance!

User avatar
Support Team
Hero Member
Hero Member
Posts: 3064
Joined: 18 Mar 2011, 15:09

Re: Generating C++ for complex object types

Post by Support Team »

The issue seems to have to do with ModellingRules and deeply nested types. We should stop discussing in the public forum at this point. Please send your project and model to support@unifiedautomation.com for analysing.
Best regards
Unified Automation Support Team

AGO
Full Member
Full Member
Posts: 8
Joined: 01 Jun 2016, 08:22

Re: Generating C++ for complex object types

Post by AGO »

Thank you, i sent you an e-mail.

AGO

Post Reply