References to childnodes yield crashes and bad generatedcode

Questions regarding the use of UaModeler

Moderator: uamodeler

Post Reply
LambertD
Hero Member
Hero Member
Posts: 22
Joined: 25 Jun 2014, 07:49

References to childnodes yield crashes and bad generatedcode

Post by LambertD »

Hi everyone,

Perhaps this bug report is a duplicate but I could not find it after a quickscan of the topics on this forum.

I have seen that the c++ code generator creates duplicate code when additional references to child nodes are added (when defining a type).
Also when trying to create these references in the uamodeler it often crashes.

I am running version 1.3.3 "285" which I downloaded for free so I assume it is the evaluation version. Running it on Fedora 19 (64bit)

Now to reproduce the bug the following steps need to be taken:

1. Create a new project, call it test
Choose cpp 1_4 -> c++ server 1.4.0
2. On the Base models screen leave everything default
3. The following screen, fill in:
Namespace Prefix : tst
Namespace Name : tst
Dll Export Prefix : tst
Leave "Create instalce component NodeIds in generated classes " off

4. When the project is created, create a new BaseObjectType
call it TestType
give it a Variable Called Test , TypeDefinition PropertyType DataType String
5. Click on ok to create the type
6. Now select the TestType in the Information model tree view
7. Add a reference of type HasNotifier to the Test child node ===> The first time I tried this resulted in a crash
8. When a crash occured, try again to add the reference
9. Generate code.


Now the code it generates contains multiples like this :

Code: Select all

UaBase::BaseNode *pChild = *it;
        if (pChild->browseName() == UaQualifiedName("Test", tst::NodeManagertst::getTypeNamespace()))
        {
            if (!m_pTest)
            {
                m_pTest = (OpcUa::PropertyType*) pFactory->createVariable((UaBase::Variable*)pChild, pNodeConfig, pSharedMutex);
                addStatus = pNodeConfig->addNodeAndReference(this, m_pTest, OpcUaId_HasProperty);
                UA_ASSERT(addStatus.isGood());
                if (!((UaBase::Variable*)pChild)->modellingRuleId().isNull())
                {
                    m_pTest->setModellingRuleId(((UaBase::Variable*)pChild)->modellingRuleId());
                }
            }
        }
        else if (pChild->browseName() == UaQualifiedName("Test", tst::NodeManagertst::getTypeNamespace()))
        {
            if (!m_pTest)
            {
                m_pTest = (OpcUa::PropertyType*) pFactory->createVariable((UaBase::Variable*)pChild, pNodeConfig, pSharedMutex);
                addStatus = pNodeConfig->addNodeAndReference(this, m_pTest, OpcUaId_HasNotifier);
                UA_ASSERT(addStatus.isGood());
                if (!((UaBase::Variable*)pChild)->modellingRuleId().isNull())
                {
                    m_pTest->setModellingRuleId(((UaBase::Variable*)pChild)->modellingRuleId());
                }
            }
        }
Which I think should be :

Code: Select all

UaBase::BaseNode *pChild = *it;
        if (pChild->browseName() == UaQualifiedName("Test", tst::NodeManagertst::getTypeNamespace()))
        {
            if (!m_pTest)
            {
                m_pTest = (OpcUa::PropertyType*) pFactory->createVariable((UaBase::Variable*)pChild, pNodeConfig, pSharedMutex);
                addStatus = pNodeConfig->addNodeAndReference(this, m_pTest, OpcUaId_HasProperty);
                UA_ASSERT(addStatus.isGood());
                addStatus = pNodeConfig->addUaReference(this, m_pTest, OpcUaId_HasNotifier);
                UA_ASSERT(addStatus.isGood());
                if (!((UaBase::Variable*)pChild)->modellingRuleId().isNull())
                {
                    m_pTest->setModellingRuleId(((UaBase::Variable*)pChild)->modellingRuleId());
                }
            }
        }
So as you can see it creates the variable twice, so for every reference created (including the default HasNotifier)

As attachment I send you a tar.gz of this small project that I created to replicate this bug so you can investigate.

I am sending this bug report because I want to help improve uamodeler. It looks like a promising tool but with some problems that need to be fixed.

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

Re: References to childnodes yield crashes and bad generated

Post by Support Team »

Hello,

Thank you for the detailed bug report. We will fix the described bugs in the code generation with the next version of the C++ 1.4 templates.
We could not reproduce the crash of the UaModeler.

The SourceNode of this ReferenceType shall be Objects or Views that are a source of event subscriptions.
The TargetNode of this ReferenceType shall be Objects that are a source of event subscriptions. A source of event subscriptions is an Object that has its “SubscribeToEvents” bit set within the EventNotifier Attribute.
If the TargetNode of a Reference of this type generates an Event, then this Event shall also be provided in the SourceNode of the Reference.

Best regards
Support Team

LambertD
Hero Member
Hero Member
Posts: 22
Joined: 25 Jun 2014, 07:49

Re: References to childnodes yield crashes and bad generated

Post by LambertD »

Hello Support Team,
Support Team wrote:Hello,

Thank you for the detailed bug report. We will fix the described bugs in the code generation with the next version of the C++ 1.4 templates.
Can you tell me when this next version is going to be released ?
Support Team wrote: We could not reproduce the crash of the UaModeler.
I haven't been able to reproduce this one either, I probably did something that is not in the test script I sent. If I manage to reproduce it, would you be interested in a core dump ? Unfortunately I did not catch the last one.

Post Reply