Assign a string to a one element UaVariantArray

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

Moderator: uasdkcpp

Post Reply
Jr. Member
Jr. Member
Posts: 2
Joined: 16 May 2024, 23:45

Assign a string to a one element UaVariantArray

Post by Smudge82 »

I am trying to pass an input argument in the form of a string to a call function of a UaSession.
as in: UaSession::call(ServiceSettings &serviceSettings, const CallIn &callRequest, CallOut &callResponse )

Inside callRequest, I would like to place my string into inputArguments which is a UaVariantArray. I get the following compiler error C2679 when I try to assign the OpcUa_Variant.Value to the string. Perhaps I'm going about this all wrong, I simply want to pass a string as an input argument to the call function. Can someone help me? Thank you very much.

UaStatus result;
ServiceSettings serviceSettings;
CallIn callRequest;
CallOut callResponse;
UaVariantArray inputargs;
UaNodeId nodeToUse;
UaNodeId methodToUse;
OpcUa_UInt32 arrayLength;
const char* mystring = "65fc51a583bf49";

UaString myUastring(mystring);
UaVariant myUaVariantstring(myUastring);
OpcUa_Variant ProgPosition;

ProgPosition.Datatype = OpcUaType_String;
ProgPosition.Value = myUastring; // compiler error: C2679 binary '=': no operator found which takes a right - hand operand of type 'OpcUa_Variant' (or there is no acceptable conversion)

nodeToUse = UaNodeId(1000, 1);
methodToUse = UaNodeId(1035, 1);
callRequest.methodId = methodToUse;
callRequest.objectId = nodeToUse;
arrayLength = sizeof(ProgPosition) / sizeof(const char*);
inputargs.attach(arrayLength, &ProgPosition);
callRequest.inputArguments = inputargs;
result = pTheApp->m_pMyClient->m_pSession->call(serviceSettings, callRequest, callResult);

Post Reply