FileDirectoryType

Questions regarding the use of UaModeler

Moderator: uamodeler

Post Reply
drothe82
Sr. Member
Sr. Member
Posts: 12
Joined: 20 Oct 2015, 10:07

FileDirectoryType

Post by drothe82 »

Hi,
I would like to have a view of a file directory on the server, from an OPC UA client.
I found that the UaModeler offers the type FileDirectoryType (subtype of FolderType), which would probably be what I want.
However, compiling the output of UaModeler fails because the include file "opcua_filedirectorytype.h" is missing in the C++ SDK 1.4.3.291.
If I leave out the FileDirectoryType object in my information model, creating the model with UaModeler and compiling the C++ code works fine.
Is this a mistake, or do I need a newer SDK? I read something about C++ SDK 1.5 but It's not on the download page.

Thanks for any help

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

Re: FileDirectoryType

Post by Support Team »

Hello,

FileDirectoryType is not supported by C++ SDK 1.4.
The nodes and toolkit classes will be part of C++ SDK 1.5 which will be released soon.

Note: C++ SDK 1.5 will only add the OPC UA Type. If you want to reflect a file directory on disc, you need to implement functionality like discovering the file directory to get the already existing files and directories yourself.

Best regards
Support Team

drothe82
Sr. Member
Sr. Member
Posts: 12
Joined: 20 Oct 2015, 10:07

Re: FileDirectoryType

Post by drothe82 »

Hi,

I now switched to the C++ SDK 1.5.
I can see that now there are the include files include/uaserver/opcua_filedirectorytype.h and include/uaserver/opcua_filedirectorytypebase.h, which were not present before.
However, UaExpert does not yet show the derived type FileDirectoryType below FolderType, in the ObjectTypes tree. Is this a bug, or would I have to create the type definition in that place by myself?
Anyway, since FileDirectoryType was not available in SDK 1.4, I meanwhile created a subtype of FolderType with quite the same functionality as FileDirectoryType should provide.

Best regards,
D. Rothe

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

Re: FileDirectoryType

Post by Support Team »

Hello,

In C++ SDK some types nodes are added on demand, i.e. the type nodes are created when the first instance of the type is created.

Best regards
Support Team

drothe82
Sr. Member
Sr. Member
Posts: 12
Joined: 20 Oct 2015, 10:07

Re: FileDirectoryType

Post by drothe82 »

Hi,
seemingly there is a problem in the FileDirecotryType (or FileDirectoryTypeBase) implementation. If I use the type, the program stops with an exception:
Assertion failed: m_pCreateDirectoryMethod, file D:\work\uasdkcpp\src\uaserver\uaservercpp\coremodule\opcua_filedirectorytypebase.cpp, line 147

This can be triggered by
OpcUa::FileDirectoryTypeBase::createTypes(); // fails
but also by
OpcUa::FileDirectoryType* pdir2 = new OpcUa::FileDirectoryType(UaNodeId(sName, nsIndex), sName, nsIndex, this);


I am now using the UA C++ SDK version 1.5.1. Is this a known bug?
Best,
D. Rothe

impulze
Sr. Member
Sr. Member
Posts: 13
Joined: 28 Jun 2016, 02:06

Re: FileDirectoryType

Post by impulze »

drothe82 wrote:Hi,
seemingly there is a problem in the FileDirecotryType (or FileDirectoryTypeBase) implementation. If I use the type, the program stops with an exception:
Assertion failed: m_pCreateDirectoryMethod, file D:\work\uasdkcpp\src\uaserver\uaservercpp\coremodule\opcua_filedirectorytypebase.cpp, line 147

This can be triggered by
OpcUa::FileDirectoryTypeBase::createTypes(); // fails
but also by
OpcUa::FileDirectoryType* pdir2 = new OpcUa::FileDirectoryType(UaNodeId(sName, nsIndex), sName, nsIndex, this);


I am now using the UA C++ SDK version 1.5.1. Is this a known bug?
Best,
D. Rothe
The same thing is happening here.

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

Re: FileDirectoryType

Post by Support Team »

This is a bug in C++ SDK. We are working on a solution.
If you are using the source version of the C++ SDK, you can fix the file opcua_filedirectorytype.cpp. Please cut the block that adds the OPC UA Methods in method createType (at the end of the method) and paste the block after

Code: Select all

pTypeNodeConfig->addNodeAndReference(UaNodeId(OpcUaId_FolderType, nsSuperTypeIdx), pObjectType, OpcUaId_HasSubtype);
Best regards
Unified Automation Support Team

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

Re: FileDirectoryType

Post by AGO »

Hello,

I have the same problem with SDK 1.4.3:

Assertion failed: addStatus.isGood(), file ...\opcua_server\k_attributetypebase.cpp, line 144

The code looks like this:

Code: Select all

else if (pChild->browseName() == UaQualifiedName("DeliveryMode", k::NodeManagerkopplung::getTypeNamespace()))
        {
            if (!m_pDeliveryMode)
            {
                m_pDeliveryMode = (OpcUa::BaseDataVariableType*) pFactory->createVariable((UaBase::Variable*)pChild, pNodeConfig, pSharedMutex);
                addStatus = pNodeConfig->addNodeAndReference(this, m_pDeliveryMode, OpcUaId_HasComponent);
                UA_ASSERT(addStatus.isGood());
                if (!((UaBase::Variable*)pChild)->modellingRuleId().isNull())
                {
                    m_pDeliveryMode->setModellingRuleId(((UaBase::Variable*)pChild)->modellingRuleId());
                }
            }
        }
Where do I have to modify the code, I could not reproduce your solution. The createTypes method looks like this:

Code: Select all

void AttributeTypeBase::createTypes()
{
    if ( s_typeNodesCreated == false )
    {
        s_typeNodesCreated = true;

        UaStatus      addStatus;
        UaVariant     defaultValue;
        NodeManagerRoot* pNodeManagerRoot = NodeManagerRoot::CreateRootNodeManager();
        OpcUa_Int16 nsTypeIdx = NodeManagerkopplung::getTypeNamespace();
        OpcUa_Int16 nsSuperTypeIdx = NodeManagerRoot::getTypeNamespace();
        NodeManagerConfig* pTypeNodeConfig = pNodeManagerRoot->getNodeManagerByNamespace(nsTypeIdx)->getNodeManagerConfig();

        OpcUa::GenericObjectType* pObjectType;
        pObjectType = new OpcUa::GenericObjectType(
            UaNodeId(kId_AttributeType, nsTypeIdx),
            UaQualifiedName("AttributeType", nsTypeIdx),
            UaLocalizedText("", "AttributeType"),
            UaLocalizedText("", ""),
            OpcUa_False,
            &AttributeType::clearStaticMembers);
        pTypeNodeConfig->addNodeAndReference(UaNodeId(OpcUaId_BaseObjectType, nsSuperTypeIdx), pObjectType, OpcUaId_HasSubtype);

        // Mandatory variable ContentEncoding
        defaultValue.setString("");
        s_pContentEncoding = new OpcUa::BaseDataVariableType(UaNodeId(kId_AttributeType_ContentEncoding, nsTypeIdx), "ContentEncoding", k::NodeManagerkopplung::getTypeNamespace(), defaultValue, 3, pTypeNodeConfig);
        s_pContentEncoding->setModellingRuleId(OpcUaId_ModellingRule_Mandatory);
        addStatus = pTypeNodeConfig->addNodeAndReference(pObjectType, s_pContentEncoding, OpcUaId_HasComponent);
        UA_ASSERT(addStatus.isGood());

        // Mandatory variable ContentType
        defaultValue.setString("");
        s_pContentType = new OpcUa::BaseDataVariableType(UaNodeId(kId_AttributeType_ContentType, nsTypeIdx), "ContentType", k::NodeManagerkopplung::getTypeNamespace(), defaultValue, 3, pTypeNodeConfig);
        s_pContentType->setModellingRuleId(OpcUaId_ModellingRule_Mandatory);
        addStatus = pTypeNodeConfig->addNodeAndReference(pObjectType, s_pContentType, OpcUaId_HasComponent);
        UA_ASSERT(addStatus.isGood());

        // Optional variable DeliveryMode
        defaultValue.setString("");
        s_pDeliveryMode = new OpcUa::BaseDataVariableType(UaNodeId(kId_AttributeType_DeliveryMode, nsTypeIdx), "DeliveryMode", k::NodeManagerkopplung::getTypeNamespace(), defaultValue, 3, pTypeNodeConfig);
        s_pDeliveryMode->setModellingRuleId(OpcUaId_ModellingRule_Optional);
        addStatus = pTypeNodeConfig->addNodeAndReference(pObjectType, s_pDeliveryMode, OpcUaId_HasComponent);
        UA_ASSERT(addStatus.isGood());

        // Mandatory variable Exchange
        defaultValue.setInt32((OpcUa_Int32) k::ExchangeType_Direct);
        s_pExchange = new OpcUa::BaseDataVariableType(UaNodeId(kId_AttributeType_Exchange, nsTypeIdx), "Exchange", k::NodeManagerkopplung::getTypeNamespace(), defaultValue, 3, pTypeNodeConfig);
        s_pExchange->setDataType(UaNodeId(kId_ExchangeType, k::NodeManagerkopplung::getTypeNamespace()));
        s_pExchange->setModellingRuleId(OpcUaId_ModellingRule_Mandatory);
        addStatus = pTypeNodeConfig->addNodeAndReference(pObjectType, s_pExchange, OpcUaId_HasComponent);
        UA_ASSERT(addStatus.isGood());

        // Optional variable ExpirationPeriod
        defaultValue.setString("");
        s_pExpirationPeriod = new OpcUa::BaseDataVariableType(UaNodeId(kId_AttributeType_ExpirationPeriod, nsTypeIdx), "ExpirationPeriod", k::NodeManagerkopplung::getTypeNamespace(), defaultValue, 3, pTypeNodeConfig);
        s_pExpirationPeriod->setModellingRuleId(OpcUaId_ModellingRule_Optional);
        addStatus = pTypeNodeConfig->addNodeAndReference(pObjectType, s_pExpirationPeriod, OpcUaId_HasComponent);
        UA_ASSERT(addStatus.isGood());

        // Optional variable MessagePriority
        defaultValue.setString("");
        s_pMessagePriority = new OpcUa::BaseDataVariableType(UaNodeId(kId_AttributeType_MessagePriority, nsTypeIdx), "MessagePriority", k::NodeManagerkopplung::getTypeNamespace(), defaultValue, 3, pTypeNodeConfig);
        s_pMessagePriority->setModellingRuleId(OpcUaId_ModellingRule_Optional);
        addStatus = pTypeNodeConfig->addNodeAndReference(pObjectType, s_pMessagePriority, OpcUaId_HasComponent);
        UA_ASSERT(addStatus.isGood());

        // Optional variable MessagePublishTimestamp
        defaultValue.setString("");
        s_pMessagePublishTimestamp = new OpcUa::BaseDataVariableType(UaNodeId(kId_AttributeType_MessagePublishTimestamp, nsTypeIdx), "MessagePublishTimestamp", k::NodeManagerkopplung::getTypeNamespace(), defaultValue, 3, pTypeNodeConfig);
        s_pMessagePublishTimestamp->setModellingRuleId(OpcUaId_ModellingRule_Optional);
        addStatus = pTypeNodeConfig->addNodeAndReference(pObjectType, s_pMessagePublishTimestamp, OpcUaId_HasComponent);
        UA_ASSERT(addStatus.isGood());

        // Mandatory variable PublisherApplicationID
        defaultValue.setString("");
        s_pPublisherApplicationID = new OpcUa::BaseDataVariableType(UaNodeId(kId_AttributeType_PublisherApplicationID, nsTypeIdx), "PublisherApplicationID", k::NodeManagerkopplung::getTypeNamespace(), defaultValue, 3, pTypeNodeConfig);
        s_pPublisherApplicationID->setModellingRuleId(OpcUaId_ModellingRule_Mandatory);
        addStatus = pTypeNodeConfig->addNodeAndReference(pObjectType, s_pPublisherApplicationID, OpcUaId_HasComponent);
        UA_ASSERT(addStatus.isGood());

        // Optional variable RoutingKey
        defaultValue.setString("");
        s_pRoutingKey = new OpcUa::BaseDataVariableType(UaNodeId(kId_AttributeType_RoutingKey, nsTypeIdx), "RoutingKey", k::NodeManagerkopplung::getTypeNamespace(), defaultValue, 3, pTypeNodeConfig);
        s_pRoutingKey->setModellingRuleId(OpcUaId_ModellingRule_Optional);
        addStatus = pTypeNodeConfig->addNodeAndReference(pObjectType, s_pRoutingKey, OpcUaId_HasComponent);
        UA_ASSERT(addStatus.isGood());

    }
}
Thank you very much!!

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

Re: FileDirectoryType

Post by Support Team »

You get the same error, but the reason is not the same.
There have been additional unexpected references to other instance declaration nodes in the model you sent to us last week. Did you remove these references? The generated NodeManager that we created with your model can be loaded without an error.
Best regards
Unified Automation Support Team

Post Reply