I have a bare bones C# OPC UA Client communicating with a OPC UA Server. The Server uses a Modbus data model. I'm actually the using Opc.UA.Fx package from NuGet.
I can connect, and get attributes from the Node I'm trying to read. However, I'm cannot figure out how to read the elements of the Array. I simply would like to read the elements of the Boolean Array. When I access the node value, it returns "System.Boolean[ ]"
- I have searched the OPC 10000-8 Pat 8: Data Access Manual, but it's not very clear to me on how to access the elements of my node.
- I've studied numerous source examples, but they are very bloated and cryptic.
- I've tried samples from the OPC.Ua.Fx literature, but I cannot get past the type conversion.
- I can verify my server is working properly by monitoring using UAExpert.
Here is the simple client to read the Coil Node (Discrete IO):
static void Main(string[] args)
{
StringBuilder localEndpoint = new StringBuilder();
var rawIpAddress = "127.0.0.1";
localEndpoint.Append(epPrefix + rawIpAddress + epSuffix);
// HmiClient is a class that constructs the OpcClient and Connects.
var robot = new HmiClient(localEndpoint.ToString());
// Create a list and store Attribute info
List<string> coilNodeAttributes = new List<string>();
coilNodeAttributes = GetAttributeInfo(robot.hmiClient, NodeDef.Coils);
foreach (var el in coilNodeAttributes)
{
Console.WriteLine(el);
}
Console.WriteLine("==================================\n");
// Trying to determing the data type for reading the array elements.
OpcValue discreteInputs = robot.hmiClient.ReadNode(1,302,OpcAttribute.Value);
Type inputType = discreteInputs.GetType();
Console.WriteLine("ReadNode Value Relflection: {0}", inputType.ToString());
Console.Read();
}
Below is a screen shot of UAExpert connected to the server and my C# client connected.
Again, I do not understand why I simply cannot access the elements of the Boolean [ ]. I'm obviously struggling casting the value to the correct C# type.