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());
}
}
}
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());
}
}
}
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.