Reading range from mutli dim array
Moderator: uasdkc
-
- Full Member
- Posts: 6
- Joined: 10 Dec 2015, 23:18
Reading range from mutli dim array
Good afternoon,
I am trying to read a certain index or range of indecees from a 2 or 3 dimensional array. For a 1D array I use the IndexRange attribute and set the range string (ex:"1:2" or "2" for single value). How do I do the same for 2d/3d matricees? "1,1,1" is returning the whole array. "1:2,1:2,1:2" results in error.
Pseudo-code for 1D array
OpcUa_ReadValueId readvalid;
OpcUa_String opc_range_string;
OpcUa_String_Initialize(&opc_range_string);
opc_string.uLength = range_length;
opc_string.strContent = "1:2";
readvalid.IndexRange = opc_range_string;
...
UaClient_Session_BeginRead(...)
Thank you,
Andres
I am trying to read a certain index or range of indecees from a 2 or 3 dimensional array. For a 1D array I use the IndexRange attribute and set the range string (ex:"1:2" or "2" for single value). How do I do the same for 2d/3d matricees? "1,1,1" is returning the whole array. "1:2,1:2,1:2" results in error.
Pseudo-code for 1D array
OpcUa_ReadValueId readvalid;
OpcUa_String opc_range_string;
OpcUa_String_Initialize(&opc_range_string);
opc_string.uLength = range_length;
opc_string.strContent = "1:2";
readvalid.IndexRange = opc_range_string;
...
UaClient_Session_BeginRead(...)
Thank you,
Andres
-
- Full Member
- Posts: 6
- Joined: 10 Dec 2015, 23:18
Re: Reading range from mutli dim array
I also have the same question for writing to index ranges of arrays and matricees.
Thank you!
Thank you!
- Support Team
- Hero Member
- Posts: 3072
- Joined: 18 Mar 2011, 15:09
Re: Reading range from mutli dim array
Hello,
Please check OPC UA specification Part 4, 7.22 NumericRange.
Best regards
Support Team
Please check OPC UA specification Part 4, 7.22 NumericRange.
Best regards
Support Team
-
- Full Member
- Posts: 6
- Joined: 10 Dec 2015, 23:18
Re: Reading range from mutli dim array
Thank you for your reply. I've looked at the documentation but still have the same issues. Even if I use the provided syntax for reading ranges or specific elements of matricees, I'm returned the entire matrix. I also haven't been able to write ranges or specific elements to arrays and matricees. Any further information is appreciated. Thank you.
- Support Team
- Hero Member
- Posts: 3072
- Joined: 18 Mar 2011, 15:09
Re: Reading range from mutli dim array
Hi,
If you use the described syntax, everything should be right on the client side.
If something is wrong in the syntax, the server should return an error instead of the whole matrix. At least the read should work or return an error.
The write support for index range is optional since not all servers can write partial data to the data source.
What kind of server do you use for testing?
Best Regards,
Unified Automation Support Team
If you use the described syntax, everything should be right on the client side.
If something is wrong in the syntax, the server should return an error instead of the whole matrix. At least the read should work or return an error.
The write support for index range is optional since not all servers can write partial data to the data source.
What kind of server do you use for testing?
Best Regards,
Unified Automation Support Team
-
- Hero Member
- Posts: 32
- Joined: 19 Feb 2016, 09:01
Re: Reading range from mutli dim array
Hi Support Team,
I have same question in writting uacppserver Matrix single element (e.g. Int32 {0,1,2}), error response with status: BadTypeMismatch
If I try to write a single element of a Matrix, how many dimension elements and DataType elements should I create and to set the IndexRange ?
Could you give me a Matrix writing example ?
I have same question in writting uacppserver Matrix single element (e.g. Int32 {0,1,2}), error response with status: BadTypeMismatch
If I try to write a single element of a Matrix, how many dimension elements and DataType elements should I create and to set the IndexRange ?
Could you give me a Matrix writing example ?
- Support Team
- Hero Member
- Posts: 3072
- Joined: 18 Mar 2011, 15:09
Re: Reading range from mutli dim array
Hi,
In a write with index range you must write a value with the same number of dimensions as the original value.
If you want to write a single element of a three dimensional array e.g. element [0,0,0], the IndexRange string parameter is "0,0,0" you must write a Variant where the value contains an array with a single value but the dimension settings must be set to {1,1,1}.
In a write with index range you must write a value with the same number of dimensions as the original value.
If you want to write a single element of a three dimensional array e.g. element [0,0,0], the IndexRange string parameter is "0,0,0" you must write a Variant where the value contains an array with a single value but the dimension settings must be set to {1,1,1}.
Best regards
Unified Automation Support Team
Unified Automation Support Team
- Support Team
- Hero Member
- Posts: 3072
- Joined: 18 Mar 2011, 15:09
Re: Reading range from mutli dim array
This is working sample code with the C++ client SDK:
Code: Select all
OpcUa_UInt32 i;
OpcUa_UInt32 count;
UaStatus status;
UaVariant tempValue;
UaWriteValues nodesToWrite;
UaStatusCodeArray results;
UaDiagnosticInfos diagnosticInfos;
ServiceSettings serviceSettings;
count = 1;
nodesToWrite.create(1);
UaNodeId writeNodeId("Demo.Static.Matrix.Int32", 2);
writeNodeId.copyTo(&nodesToWrite[0].NodeId);
nodesToWrite[0].AttributeId = OpcUa_Attributes_Value;
UaVariant tempValue;
UaInt32Array arrayInt32Value;
arrayInt32Value.create(1);
arrayInt32Value[0] = 99;
UaInt32Array arrayInt32Dim;
arrayInt32Dim.create(3);
arrayInt32Dim[0] = 1;
arrayInt32Dim[1] = 1;
arrayInt32Dim[2] = 1;
tempValue.setInt32Matrix(arrayInt32Value, arrayInt32Dim, OpcUa_True);
tempValue.copyTo(&nodesToWrite[0].Value.Value);
UaString sIndexRange("0,0,0");
sIndexRange.copyTo(&nodesToWrite[0].IndexRange);
/*********************************************************************
Call write service
**********************************************************************/
status = g_pUaSession->write(
serviceSettings, // Use default settings
nodesToWrite, // Array of nodes to write
results, // Returns an array of status codes
diagnosticInfos); // Returns an array of diagnostic info
/*********************************************************************/
Best regards
Unified Automation Support Team
Unified Automation Support Team
-
- Hero Member
- Posts: 32
- Joined: 19 Feb 2016, 09:01
Re: Reading range from mutli dim array
Dear Support Team,Support Team wrote:This is working sample code with the C++ client SDK:
Code: Select all
OpcUa_UInt32 i; OpcUa_UInt32 count; UaStatus status; UaVariant tempValue; UaWriteValues nodesToWrite; UaStatusCodeArray results; UaDiagnosticInfos diagnosticInfos; ServiceSettings serviceSettings; count = 1; nodesToWrite.create(1); UaNodeId writeNodeId("Demo.Static.Matrix.Int32", 2); writeNodeId.copyTo(&nodesToWrite[0].NodeId); nodesToWrite[0].AttributeId = OpcUa_Attributes_Value; UaVariant tempValue; UaInt32Array arrayInt32Value; arrayInt32Value.create(1); arrayInt32Value[0] = 99; UaInt32Array arrayInt32Dim; arrayInt32Dim.create(3); arrayInt32Dim[0] = 1; arrayInt32Dim[1] = 1; arrayInt32Dim[2] = 1; tempValue.setInt32Matrix(arrayInt32Value, arrayInt32Dim, OpcUa_True); tempValue.copyTo(&nodesToWrite[0].Value.Value); UaString sIndexRange("0,0,0"); sIndexRange.copyTo(&nodesToWrite[0].IndexRange); /********************************************************************* Call write service **********************************************************************/ status = g_pUaSession->write( serviceSettings, // Use default settings nodesToWrite, // Array of nodes to write results, // Returns an array of status codes diagnosticInfos); // Returns an array of diagnostic info /*********************************************************************/
It works, many thanks