Ua Methods, UaVariantArray can be double array?

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

Moderator: uasdkcpp

Post Reply
darsin
Jr. Member
Jr. Member
Posts: 1
Joined: 14 Mar 2013, 09:52

Ua Methods, UaVariantArray can be double array?

Post by darsin »

Hello all,

Let's say we are implementing Ua Methods and we have a call function such as:
virtual UaStatus call(
UaMethod* /*pMethod*/,
const UaVariantArray& /*inputArguments*/,
UaVariantArray& /*outputArguments*/,
UaStatusCodeArray& /*inputArgumentResults*/,
UaDiagnosticInfos& /*inputArgumentDiag*/) { return OpcUa_BadMethodInvalid; }
// ++

I have UaVariantArray of ms (A) and another UaVariantArray of addresses (B). I want another array having 0th element as A and 1st element as B.

What i want to do is giving UaVariantArrays as an item in UaVariantArray. Is this possible? Can you give me an example? Or should i modify somewhere?

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

Re: Ua Methods, UaVariantArray can be double array?

Post by Support Team »

Hi darsin,

I am not sure if I understand your question but attached you can find an example for preparing input arguments of different data types and for extracting the output arguments of different data types:

Code: Select all

    UaVariantArray inputArguments;
    UaVariantArray outputArguments;
    UaVariant tempValue;

    // Create input argument array with three arguments
    inputArguments.create(3);

    // Set first argument as Int16 value
    tempValue.setInt16(20);
    tempValue.copyTo(&inputArguments[0]);

    // Set second argument as String value
    tempValue.setString("MyString");
    tempValue.copyTo(&inputArguments[1]);

    // Set third argument as Double array with two entries
    UaDoubleArray doubleArray;
    doubleArray.create(2);
    doubleArray[0] = 2.2;
    doubleArray[0] = 33.5;
    tempValue.setDoubleArray(doubleArray, OpcUa_True);
    tempValue.copyTo(&inputArguments[2]);

    // Call method

    // Check expected number of 3 output arguments
    if ( outputArguments.length() == 3 )
    {
        OpcUa_Int32   out1;
        UaUInt32Array out2;
        UaString      out3;

        // Extract first out argument as Int32
        tempValue = outputArguments[0];
        if ( OpcUa_IsNotGood(tempValue.toInt32(out1)) )
        {
            // Error handling
        }

        // Extract second out argument as UInt32 array
        tempValue = outputArguments[1];
        if ( OpcUa_IsNotGood(tempValue.toUInt32Array(out2)) )
        {
            // Error handling
        }

        // Extract third out argument as String
        tempValue = outputArguments[2];
        out3 = tempValue.toString();
    }
    else
    {
        // Error handling
    }
Best Regards,
Unified Automation Support Team

Post Reply