[SOLVED] Source code example to write output values.

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

Moderator: uasdkcpp

Post Reply
falko.wiese
Hero Member
Hero Member
Posts: 26
Joined: 04 Oct 2012, 17:56

[SOLVED] Source code example to write output values.

Post by falko.wiese »

Hi guys,
there exists an example to write output values of OPC UA Server methods, or could I get any information about how to deal with UaVariantArray instances? Because of, that's the type of the resulting array in the method callback.

Thanks for your help,
Falko.

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

Re:Source code example to write output values.

Post by Support Team »

Hi Falko,

We used the UaModeler to create a type with a method, that has an array of BaseDataType as input and output. In the following source code we added a sample implementation for the method.

Code: Select all

UaStatus TestType::Method(const ServiceContext& serviceContext,
                     /*IN*/ const UaVariantArray&input,
                     /*OUT*/ UaVariantArray& output)
{
    UaStatus ret;
    // create the UaVariantArray
    output.create(input.length());
    for (OpcUa_UInt32 u=0; u<input.length(); u++)
    {
        // access to array
        UaVariant vTemp = input[u];
        // set values of the array
        vTemp.copyTo(&output[u]);
    }
    return ret;
}
Best Regards, Unified Automation Support Team
Best regards
Unified Automation Support Team

falko.wiese
Hero Member
Hero Member
Posts: 26
Joined: 04 Oct 2012, 17:56

Re:Source code example to write output values.

Post by falko.wiese »

Thanks guys, it works perfectly!

Cheers,
Falko.

Post Reply