Can I use uamodeler generated code in client ?

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

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

Can I use uamodeler generated code in client ?

Post by LambertD »

Hello all,

First of all, I'm not sure if I should post this question here or in the uamodeler forum, but I think the answer to my question is specific to the c++ SDK so that's why I put it here.

I have managed to create an opcua server and a client that use the same datamodel. Now on the server side I use code that was generated by uamodeler. This code contains wrapper classes for the different object types etc, so knowledge of the tree structure of the model is embedded into that generated code. Now on the client side, when browsing nodes, I have to do a lot of manual coding like this (pseudocode):

Code: Select all

m_pClient->browse(UaNodeId("SomeContainerObject"), browseContext, [](const OpcUa_ReferenceDescription& ref){
    UaNodeId nodeId(ref.NodeId.NodeId);
    UaClientSdk::BrowseContext browseContext2;
    browseContext2.referenceId = OpcUaId_HasProperty;
    /* Browse into the node that was just browsed before */
    m_pClient->browse(nodeId, browseContext2, [] (const OpcUaReferenceDescription& ref2) {
        /* Read some data from the node here ..... */
    }
});
In other words, I have to manually write code again that has knowledge of the tree structure of the model. Is it somehow possible to reuse the code generated by uamodeler to do the browsing and reading ??

scalfee
Hero Member
Hero Member
Posts: 73
Joined: 08 Mar 2014, 01:13

Re: Can I use uamodeler generated code in client ?

Post by scalfee »

I have to manually write code again that has knowledge of the tree structure of the model. Is it somehow possible to reuse the code generated by uamodeler to do the browsing and reading ??
Not to butt in here, but the question does not make sense. The whole point of opc-ua is that the server describes its model for each namespace to the client. So the client can access the entire tree on the server. The example client_cpp_sdk shows how to access the server. It uses a .ini file to know which variables etc to access. You could do a tool to transfer variable names from the server xml (also creatable from uamodeler) to the ini file to share names. The xml does not describe what is being done, so you do need custom code on the client side if it is controlling something on the server.

Hope this helps, Steve

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

Re: Can I use uamodeler generated code in client ?

Post by Support Team »

Hi,

There is different code generated for a model. Some of the code can be used on server and client side like identifiers (xxx_identifiers.h), structure data type wrappers or enumeration definitions (xxx_datatypes.h/cpp). Other code like classes for ObjectTypes and EventTypes is server specific.

For this reason the templates for C++ SDK 1.4 have a version for client side and one for server side.

For the future it would be possible to create also proxy classes for ObjectTypes on the client side but this feature is not available yet. It will be useful only in a few specific use cases and would be very inefficient in others.

Best Regards,
Unified Automation Support Team

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

Re: Can I use uamodeler generated code in client ?

Post by LambertD »

Thanks for the replies so far,
For the future it would be possible to create also proxy classes for ObjectTypes on the client side but this feature is not available yet. It will be useful only in a few specific use cases and would be very inefficient in others.
You are right, this is only for a few use cases, but in my case at the moment they would have been handy.

Post Reply