I am experiencing issues when trying to use mapping with object that are contained within an array in the server. In my testing, I found I was having similar issues simply trying to read those same variables. Through the simplified read testing, I believe it may have to do with the [] characters needed for the array index when used in the browse path. I have tried escaping those characters, but end up with the same result. As the read example seems easier to follow, I thought I would post those results and am hoping they would help with the mapping issues as well.
The server setup for these tests is illustrated in the attached ServerConfig.png3. This is the same server reference in the Calling Methods with complex types that you resolved so quickly, and should still have access to if needed. The following is the code I have been testing with:
UAEndpointDescriptor endpointDescriptor = "opc.tcp://192.168.1.20:4840";
// Instantiate the client object
var client = new EasyUAClient();
var browsePathParser = new UABrowsePathParser {DefaultNamespaceUriString = "urn:BeckhoffAutomation:Ua:PLC1" };
// Prepare arguments
// Note: Add error handling around the following statement if the browse paths are not guaranteed to be
// syntactically valid.
var readArgumentsArray = new[]
{
new UAReadArguments(endpointDescriptor,
// browsePathParser.Parse("[ObjectsFolder]/PLC1/OpcCommunication.OpcEffectLinear&[1&].stStatus")),
"nsu=urn:BeckhoffAutomation:Ua:PLC1;ns=4;s=OpcCommunication.OpcEffectLinear[1].stStatus"),
new UAReadArguments(endpointDescriptor,
browsePathParser.Parse("[ObjectsFolder]/PLC1/OpcCommunication.OpcEffect.stStatus")),
new UAReadArguments(endpointDescriptor,
browsePathParser.Parse("[ObjectsFolder]/PLC1/OpcCommunication.OpcTestData1")),
};
// Obtain attribute data.
UAAttributeDataResult[] resultArray = client.ReadMultiple(readArgumentsArray);
// Display results
for (int i = 0; i < resultArray.Length; i++)
{
UAAttributeDataResult attributeDataResult = resultArray[i];
if (attributeDataResult.Succeeded)
Console.WriteLine($"results[{i}].AttributeData: {attributeDataResult.AttributeData}");
else
Console.WriteLine($"results[{i}]: *** Failure: {attributeDataResult.ErrorMessageBrief}");
}
As written, all of the variables will return good results. Note the first ReadArgument is using a string NodeDesciptor as opposed to the BrowsePathParser. If I change the code to use the BrowsePathParser that is commented out ( and comment out the node desciptor string), I get the following exception thrown:
{"OPC-UA service result - An error specific to OPC-UA service occurred (status code: BadNoMatch). Details follow.\r\n---- SERVICE RESULT ----\r\nStatus Code: {BadNoMatch} = 0x806F0000 (2154758144)\r\n\r\n+ The client method called was 'ReadMultiple'."}
What is unclear to me is that the two different methods seem to result is what I understand to be equivalent results when I look in readArgumentsArray and inspect the Node Descriptor
Results when using the BrowsePathParser:
NodeDescriptor {BrowsePath="[ObjectsFolder]/PLC1/OpcCommunication.OpcEffectLinear[1].stStatus"}
Results when using the NodeDesciptor string:
NodeDescriptor {NodeId="nsu=urn:BeckhoffAutomation:Ua:PLC1 ;ns=4;s=OpcCommunication.OpcEffectLinear[1].stStatus"}
To try and help confirm this, I made an instance of an identical object not contained in an array. This is the second item in the readArgumentArray. This always works with the BrowsePathParser with good result and a Node Descriptor of:
NodeDescriptor {BrowsePath="[ObjectsFolder]/PLC1/OpcCommunication.OpcEffect.stStatus"}
As I will eventually be trying to look at these variables through LiveMapping, I believe that I need the BrowsePath approach to make that work? I have been successful in attaching and reading with a Mapper on the object not in the array - [ObjectsFolder]/PLC1/OpcCommunication.OpcEffect.stStatus - but have had similar problems in the mapper as in the read example above with the objects in the array.
Any help or suggestions are greatly appreciated. We are really hoping there is a way to use the array version of the variables.