Read value in a node from server

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

Moderator: uasdkcpp

Post Reply
dopbs
Jr. Member
Jr. Member
Posts: 4
Joined: 20 Feb 2018, 20:17

Read value in a node from server

Post by dopbs »

Hello.

I have the following node: "Root->node->DataSet1->Int32" and I would like to read the value inside "int32". what should I add in the main function to read the value?

this how the node is created:

Code: Select all

void createDataSet1TargetVariables(NodeManagerConfig* pNM, OpcUa::FolderType* pParentFolder, UaMutexRefCounted* pSharedMutex)
{
    UaVariant defaultValue;
    OpcUa::BaseDataVariableType* pVariable = NULL;
    OpcUa_UInt16 nsIndx = pNM->getNameSpaceIndex();
    OpcUa_Byte accessLevel = OpcUa_AccessLevels_CurrentReadOrWrite;
    UaStatus addResult;
    UaString sParentNodeId = pParentFolder->nodeId().toString();
    UaString sName;
    UaString sNodeId;

    sName = "Int32";
    defaultValue.setInt32(0);
    sNodeId = UaString("%1.%2").arg(sParentNodeId).arg(sName);
    pVariable = new OpcUa::BaseDataVariableType(UaNodeId(sNodeId, nsIndx), sName, nsIndx, defaultValue, accessLevel, pNM, pSharedMutex);
    addResult = pNM->addNodeAndReference(pParentFolder, pVariable, OpcUaId_Organizes);
    if (addResult.isBad()) { pVariable->releaseReference(); return; }
}
I have this function but I don't know how to use UaVariableArray and UaDataValueArray:

Code: Select all

UaStatus NodeManagerDemo::readValues(const UaVariableArray& arrUaVariables, UaDataValueArray&   arrDataValues)

Best,

dopbs
Jr. Member
Jr. Member
Posts: 4
Joined: 20 Feb 2018, 20:17

Re: Read value in a node from server

Post by dopbs »

My real question is: how sould I call readValues in my main.cpp?

How should I set and initialize: UaVariableArray and UaDataValueArray?

Best,

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

Re: Read value in a node from server

Post by Support Team »

Hi,

We are confused.

Do you want to read a value from a server using a client?
Then start from here:
http://documentation.unified-automation ... son01.html
Best regards
Unified Automation Support Team

Post Reply