Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Read an Array of structure

More
31 May 2024 13:16 #12826 by Twoaster
Hi!

The error I'm getting is:

OpcLabs.EasyOpc.UA.Navigation.Parsing.UABrowsePathFormatException: 'OPC-UA browse path format error: An incomplete character escape was encountered.
The string to be parsed: ".Application&.PersistentVars&.astFrontRailPositions[1]&". Symbolic code: IncompleteCharacterEscape.'

at this point my code breaks and I have to restart my application.

My code is the one below:
 mapper.Map(railData, new UAMappingContext
 {
   EndpointDescriptor = endpointDescriptor,
   NodeDescriptor = new UANodeDescriptor
   {
     BrowsePath = UABrowsePath.Parse("[ObjectsFolder]/Application/PersistentVars/Application&.PersistentVars&.astFrontRailPositions.Application&.PersistentVars&.astFrontRailPositions[1]", "urn:Schneider:M262:customprovider")
   }
 });;

and
class PersistentVars
{
  [UANode(BrowsePath = ".Application&.PersistentVars&.astFrontRailPositions[1]&")]
  public Rail _rail = new();
}
 
[UAType]
class Rail
{
 
  [UAData(Operations = UADataMappingOperations.Read)]
  public Boolean InUse { get; set; }
 
  [UAData(Operations = UADataMappingOperations.Read)]
  public Int16 InUseType { get; set; }
 
  [UAData(Operations = UADataMappingOperations.Read, Kind = UADataMappingKind.Exception)]
  public Exception? Master { get; set; }
 
  [UAData(Operations = UADataMappingOperations.Read)]
  public Int32 Slave { get; set; }
}
 

Please Log in or Create an account to join the conversation.

More
31 May 2024 13:00 #12824 by support
Replied by support on topic Read an Array of sctructure
Hello, thank you for additional information.

Variables under variables are fine in OPC UA, and are supported by Live Mapping. The complex data/ UAGenericObject you mentioned is not related to it and there is no indication you need complex data so far. Complex data/custom data types come into play when the actual *value* of the variable, i.e. the object that gets passed in Read/Write/Subscribe, is structured.

I need an explanation to this please:

[ObjectsFolder]/Application/PersistentVars/Application&.PersistentVars&.astRearRailPositions.Application&.PersistentVars&.astRearRailPositions[0].Application&.PersistentVars&.astRearRailPositions[0]&.InUse

REMARK: I was not able to get the last & on my BrowserPath on my C# project because I was facing an error saying invalid path.


Which last & are you referring to? Are you saying that the "ObjectsFolder]/Application/PersistentVars/Application&.PersistentVars&.astRearRailPositions.Application&.PersistentVars&.astRearRailPositions[0].Application&.PersistentVars&.astRearRailPositions[0]&.InUse" isn't what you are actually using now, and you are using "............[0].InUse" instead? If so, what precisely were the symptoms & error messages you were getting when '&' was there? In my opinion it *must* be there, otherwise the browse path syntax would denote a browse path different from what you want.

Best regards

Please Log in or Create an account to join the conversation.

More
30 May 2024 19:21 #12821 by Twoaster
Hi!

Just an answer to your previous questions I'm using QuickOPC ultimate license, so I should have access to Live Mapping.

Adding the Exception mapping kind to one of my variables was very useful to understand I have a path issue.:
OpcLabs.EasyOpc.UA.UAServiceException: OPC UA service result - {BadNoMatch}. The requested operation has no match to return.
+ The client method called (or event/callback invoked) was 'ReadMultiple[4]'.
......

One big difference I found while searching for solutions, was that the UAConsoleMapping demo uses an object and maps its variables using live mapping (I tested with the /CCX001 path.
The way my Array of structures show on any OPC-UA client is way different. It shows a variable that has other variables inside. I've seen on other posts that this won't work well with Live mapping, instead the ideal would be to just use a complex data reading with a UAGenericObject, is that correct?

On the demo code:
[ObjectsFolder]/Boilers.Boiler &#1.CCX001.ControlOut



My code:
[ObjectsFolder]/Application/PersistentVars/Application&.PersistentVars&.astRearRailPositions.Application&.PersistentVars&.astRearRailPositions[0].Application&.PersistentVars&.astRearRailPositions[0]&.InUse

REMARK: I was not able to get the last & on my BrowserPath on my C# project because I was facing an error saying invalid path.

Attachments:

Please Log in or Create an account to join the conversation.

More
25 May 2024 09:25 #12813 by support
Replied by support on topic Read an Array of sctructure
Hello.

I do not see anything obviously wrong with your code.

Can you please read "Error Model in Live Mapping" - opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Late...del%20in%20Live%20Mapping.html , and make sure you look/treat for all kinds of errors described there? Specifically,

a) hook to the UpdateFailure and see if it is not called (described under bullet "C"), and
b) map additional member alongside your diHMIDrawerHomeAcc (described under bullet "D"), with the Exception type and Exception mapping kind (opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Late...rame.html#Mapping%20Kinds.html ), and check whether it stays null or received some non-null exception, after the Read/Subscribe.

Best regards

Please Log in or Create an account to join the conversation.

More
23 May 2024 18:53 #12811 by Twoaster
Sorry I used the wrong formating for my code:
 UAEndpointDescriptor endpointDescriptor =
             "opc.tcp://10.151.251.100:4840/UADiscovery";
 
 var mapper = new UAClientMapper();
 var LiveMappingTest = new PersistentVarsTest();
 mapper.Map(LiveMappingTest, new UAMappingContext
 {
     EndpointDescriptor = endpointDescriptor,   
 
     NodeDescriptor = new UANodeDescriptor
         {
             BrowsePath = UABrowsePath.Parse("[nsu=urn:Schneider:M262:customprovider;i=85]/Application/PersistentVars/Application", "urn:Schneider:M262:customprovider")
     },
     MonitoringParameters = 1000,
 });
[UANamespace("urn:Schneider:M262:customprovider")]
 
 [UAType]
 
class PersistentVarsTest
 
 {
 
// Specifying BrowsePath-s here only because we have named the class members differently from OPC node names.
 
 [UANode(BrowsePath = ".PersistentVars")]
 
public CustomController CustomController = new CustomController();
 
 }
 
 
 
class CustomController
 
 {
 
 [UANode(BrowsePath = ".diHMIDrawerHomeAcc"), UAData(Operations = UADataMappingOperations.Read)]    // not readable
 
public int diHMIDrawerHomeAcc { get; set; }
 
}

Please Log in or Create an account to join the conversation.

More
23 May 2024 18:46 #12810 by Twoaster
Thank you for the response.

With further testing, I was able to access each individual element of the array using the ComplexData._EasyUAClient example!

About the live mapping (and if you want I can move this question to the proper section on the forum), I've tested the UAConsoleLiveMapping project sample and changed for my need, but all I'm getting back is "0" from all my variables. Could you please advise if I'm doing something wrong here?

My variable Browse path is: Application/PersistentVars/Application.PersistentVars.diHMIDrawerHomeAcc

I changed the program.cs to fit my need:
 
[UANamespace("urn:Schneider:M262:customprovider")]
[UAType]
class PersistentVarsTest
{
// Specifying BrowsePath-s here only because we have named the class members differently from OPC node names.
[UANode(BrowsePath = ".PersistentVars")]
public CustomController CustomController = new CustomController();
}
 
class CustomController
{
[UANode(BrowsePath = ".diHMIDrawerHomeAcc"), UAData(Operations = UADataMappingOperations.Read)] // not readable
public int diHMIDrawerHomeAcc { get; set; }
}
 


While debugging, I can watch the "mapper" variable and see that the Mapping Sources URLs are correct, but instead of showing 600, it's always 0

Please Log in or Create an account to join the conversation.

More
22 May 2024 17:45 #12809 by support
Replied by support on topic Read an Array of sctructure
Hello.
I am not sure if I understand the question in full. I will try to give the related information, and you can then tell me if the question was answered.

The custom data types (or their arrays) are supported as such in QuickOPC. That is, you should be able to Read the node that contains the array, or (with Live Mapping) map it e.g. to a property of your object. In both cases, the value that you will see will be an instance of UAGenericObject , and inside it there are sub-objects that can be used to retrieve the fields (such as yours ID, Descriptoin, Position, Side...) etc. This is described in the documentation part dealing with OPC UA Complex Data Extension. And it should work for you (provided that you have the right QuickOPC edition) - can you confirm that?

Then, you might want to map the actual contents of the custom data type (ID, Descriptoin, Position, Side...) to some individual properties of a mapped C#/VB.NET class. That, however, is *not* supported, at least not now. You can still use Live Binding, but the "unpacking" from UAGenericObject needs to be done in the code.

Best regards

Please Log in or Create an account to join the conversation.

More
22 May 2024 14:36 #12808 by Twoaster
Hi!

I have an array of 200 positions, with a structure inside each position containing integer, strings and booleans.
I'm using a schneider PLC with an OPC server on it.



I want to map this array on my C# application, and until now I haven't found an easy way to map the whole array. For other arrays of integers,strings, I used the function UAIndexRangeList.OneDimension, but here I'm not able to list my structure on the same process.

I'm looking into Live mapping at this point, is this the case?

Thanks in advance for the help!
Attachments:

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.105 seconds