Generating DataChange to client with a minimalistic server

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

Moderator: uasdkcpp

Post Reply
seanka
Jr. Member
Jr. Member
Posts: 3
Joined: 23 Apr 2021, 12:01

Generating DataChange to client with a minimalistic server

Post by seanka »

Hi

I am trying to write a small server but I am a bit lost
when it comes to the general architecture so I am not sure
I am doing it in the right way.

So I have a class wrapper where inside I have a member variable
std::unique_ptr<UaApplication> m_application which I initialize
in the ctor.

I add variables to the application like this

Code: Select all

UaNodeId nodeId(itemPath.c_str(), GetNameSpaceIndex());
auto* pVariable = new OpcUa::BaseDataVariableType( 
	nodeId,
	variableBrowseName,  
	GetNameSpaceIndex(), // browse
	initialUaValue,
	accessLevel,
	nodeManagerConfig
);

pVariable->setValueHandling(UaVariable_Value_CacheIsSource); // needed?

if (auto const ret = nodeManagerConfig->addNodeAndReference(sourceNode, pVariable, OpcUaId_HasComponent); 
	ret.isGood())
{
  m_itemPaths.insert(itemPath);
  ++successful;
}
So an item path would be something like Applications.Application_1.Diagram1.MyVar which
in our case will be the nodeid together with a namespace index.

I seem to be able to read and write to the variables but when writing to a variable
I would like the client to get a datachange but it is not receiving that for some reason.

I write and read to the variables using serverManager->read/write from an update thread
that should simulate values changes so that the client gets datachange calls.

Am I on the right track or am I completely lost? :) I am using the default nodemanager and intenalsession.

How do I enable so that when values are changed by a write that client gets a data change?

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

Re: Generating DataChange to client with a minimalistic server

Post by Support Team »

Hello,

We do not completely understand your test setup (especially the serverManager->read/write) but we think you set the wrong value handling.

Simply remove the "pVariable->setValueHandling(UaVariable_Value_CacheIsSource);"
The default setting is handling everything if you update the value with write or pVariable->setValue.
Best regards
Unified Automation Support Team

Post Reply