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.
[SOLVED] Source code example to write output values.
Moderator: uasdkcpp
-
- Hero Member
- Posts: 26
- Joined: 04 Oct 2012, 17:56
- Support Team
- Hero Member
- Posts: 3072
- Joined: 18 Mar 2011, 15:09
Re:Source code example to write output values.
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.
Best Regards, Unified Automation Support Team
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
Unified Automation Support Team
-
- Hero Member
- Posts: 26
- Joined: 04 Oct 2012, 17:56
Re:Source code example to write output values.
Thanks guys, it works perfectly!
Cheers,
Falko.
Cheers,
Falko.