10/04/2021
Hello, I'm using a OPC UA Client in C# WPF Framework to read several values of variables in a PLC Project (Beckhoff) through OPC UA Server.
In the PLC Project, there are some variables like Array of Int, Array of Real, and Array of Structs.
I'm using the source code from GitHub provided by OPC Foundation. Here are the codes. Symbols = Variables in PLC
Knowing the NodeID of a Variable, I add it to the nodesToRead
ReadValueIdCollection nodesToRead = new ReadValueIdCollection()
{
new ReadValueId() { NodeId = symbol.NodeId, AttributeId = Attributes.Value },
};
// Read the node attributes
m_output.WriteLine("Reading node {0}", symbol.SymbolName);
// Call Read Service
m_session.Read(
null,
0,
TimestampsToReturn.Both,
nodesToRead,
out DataValueCollection resultsValues,
out DiagnosticInfoCollection diagnosticInfos);
m_validateResponse(resultsValues, nodesToRead);
//store the value of the Node to the Symbol / Variable Class
symbols.SymbolValue = resultsValues[0].Value;
So for example, if I read Integer Array[3 x 6] from the PLC, it returns in resultValues only the type of this array, which is Int [3, 6]
Can someone tell me how to access the value of single value in this Array ? like how to get the value of Array (2, 3) ?
10/04/2021
Randy Armstrong said
Multidimensional Arrays are accessed via the Matrix helper class.There should be a way to cast the Variant returned to a Matrix (look at the methods on the Variant class).
Thank you,
could you please tell me where I can find the matrix helper class or the variant class ?
05/30/2017
https://github.com/OPCFoundati.....Variant.cs
[DataContract(Namespace = Namespaces.OpcUaXsd)] public class Matrix : IFormattable
1 Guest(s)