Updating displayname of the Server object...

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

Moderator: uasdkcpp

Post Reply
tommys
Sr. Member
Sr. Member
Posts: 15
Joined: 03 Oct 2023, 16:42

Updating displayname of the Server object...

Post by tommys »

Hi,

in the project I'm working on there is an internal requirement that specifies that the Server object of the UA NodeSet2 in namespace 0, with nodeId=2253 and browseName="Server", SHALL have its displayName set to: "<comp><prod><deviceid>" instead of the default "Server" display name.

I therefore tried to set it on the serverObject instance:

Code: Select all

auto newDisplayName = createDisplayname();
UaObjectserver* serverObject = getServerManager()->getNodeManagerRoot()->pServerObject();
serverObject->setDisplayName(newDisplayname);
Unfortunately, this won't compile since UaObjectServer only allows you to read its displayName.
Question 1: why does the UaObjectServer (or its base class UaObjectBase) not have a setDisplayName-method?

Ok, but what if I just get a reference to the UaNode of the Server object and update its DisplayName attribute? Like this:

Code: Select all

UaNode* node = getServerManager()->getNodeManagerRoot()->getNode(OpcUaId_Server);
if (node)
{
    UaDataValue dv(varDisplayName, OpcUa_Good, currentTime, currentTime);
    node->setAttributeValue(this, OpcUa_Attributes_DisplayName, dv, NULL, OpcUa_False);
    node->releaseReference();
}
Unfortunately, to my big surprise, this doesn't work either! The reason for this is obviously that the setAttributeValue is a no-op!!
Question 2: why is this UaNode::setAttribute method a no-op!? What are the reasons one cannot or maybe even must not update the attributes of UaNode?

Question 3: Since my two attempts above failed to update the displayName of the Server object, I wonder if there is a third way that actually works! If not, I'd be very interested to hear the reason why.

Thanks in advance! :-)
/Tommy

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

Re: Updating displayname of the Server object...

Post by Support Team »

Hi,

The original idea of localized text is "translation" to different languages, so I am not sure if UA specification allows any abritary name for the server object other than the pure translation of the word "Server". However, changing the DisplayName for namespace "0" objects is not possible in the C++SDK. We never had the requirement to do so yet. However, the DisplayName is a localized text and should change e.g. when different language translation are available, and when client request different locale during ActivateSession. But as C++ SDK has built-in NS0 you can not change. The setter is not available from application side. For all other namespaces (including your own instance NS), this is possible and you can change DisplayName.

In .NET SDK setting the DisplayName is possible (even though we never have made any use of that yet).
Best regards
Unified Automation Support Team

tommys
Sr. Member
Sr. Member
Posts: 15
Joined: 03 Oct 2023, 16:42

Re: Updating displayname of the Server object...

Post by tommys »

Thank you for your response!

Yes, colleagues of mine that use the .NetSDK are setting the displayName of the Server object. This made me think that this really should be possible with the C++SDK as well! Thanks to your reply, I now know it is not possible. However, if it does not violate the UA specification, it would be nice to be able to set displayName for NS0 objects in the future :-)

Regards,
/Tommy

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

Re: Updating displayname of the Server object...

Post by Support Team »

Hi,

we have created a change request for you. The dev team is validating if the change qualifies for hotfix.
In any case it is on the list.
Best regards
Unified Automation Support Team

Post Reply