I am working on the .Net 6 framework.
I have a custom C# application reading and writing to a OPC Server.
It works OK so far.
However, there is now a new NodeId added with 1-dimensional array and I need to write values to all the variable inside the array groups.
I've researched the topics regarding arrays in this forum but, I don't exactly see the same case as I have.
Here is my new NodeId;
I've tried this piece of code which is working OK with scalar and I've improvised it a bit in order to adapt to array case.
But, of course, if this is even the right way of doing this, I can still see two issues at a glance;
1. int[] array is not what I want. It could be maybe an object[] for allowing different typed values (how about then type casting?)
2. How can I choose array index so I can write to any array group selectively? e.g. ACS_PRODUCT_DATA[3].ACS_ORDER_NUMBER = 5
Code: Select all
int[] testArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
Variant valuesInArray = new Variant(testArray);
DataValue dataValue = new DataValue();
dataValue.Value = valuesInArray;
nodesToWrite.Add(new WriteValue()
{
NodeId = NodeId.Parse(nodeId),
Value = dataValue,
AttributeId = Attributes.Value
});
List<StatusCode> results = _iopcService.Session.Write(nodesToWrite);