model attribute as array

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
oroulet
Hero Member
Hero Member
Posts: 22
Joined: 07 Aug 2012, 14:11

model attribute as array

Post by oroulet »

Hi,


In a server I use model to exchange data between underlying system and ua server.
It works fine for simple variables but I cannot get the array or list to work

Here is declaration. I tried to map both to array and list
[UaInstanceDeclaration(NamespaceUri = Production.PCS.Namespaces.PCS)]
public String ResourceState { get; set; }
[UaInstanceDeclaration(NamespaceUri = Production.PCS.Namespaces.PCS)]
//public List<String> CurrentOrderIds { get; set; }
public String[] CurrentOrderIds { get; set; }

Then initialization at startip:
//DataModel.CurrentOrderIds = new List<String>(new string[]{"titi", "toto"});
DataModel.CurrentOrderIds = new string[] { "titi", "toto" };

When a client, for example uaexpert tries to read value from this specific node. It can read but when writing an array of string I get an error BadtypeMismatch..... . If I try to write a simple string(no array), the server replies no error but the variable is set to Null.

What is wrong here?
What c# type should array og string be mapped to?

oroulet
Hero Member
Hero Member
Posts: 22
Joined: 07 Aug 2012, 14:11

Re: model attribute as array

Post by oroulet »

OK I found out that the issue was that that particular variable was declarered as scalar in uamodeller. and mapped tio an array in .net.
The strange stuff is that it was still it was possible to read variable as an array (written from .net) but writting an array returned an error to clients

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: model attribute as array

Post by Support Team »

Hello,

If a client writes a value, there are some checks executed by the SDK, especially checking the DataType and the ValueRank. If there are msimatches in DataType and ValueRank, the Write request is rejected. On server side there are less checks because of performance reasons.

Please use the classes that are auto-generated by UaModeler for using LinkModelToNode. This will save time and less error-prone.

Best regards
Support Team

oroulet
Hero Member
Hero Member
Posts: 22
Joined: 07 Aug 2012, 14:11

Re: model attribute as array

Post by oroulet »

>> Please use the classes that are auto-generated by UaModeler for using LinkModelToNode.

Looks like I missed that the DataModel class was also autogenerated, this is great, thank you!

oroulet
Hero Member
Hero Member
Posts: 22
Joined: 07 Aug 2012, 14:11

Re: model attribute as array

Post by oroulet »

Looks like classes are generated for the first level of the DataModel, but if there is a second level it is missing code.
I have a node inheriting from BaseObjectClass having node attributes and a BaseObjectClass as childs. But the BaseObjectChild has also custom node attributes.
The generate code just says:
public WeldingCell(WeldingCell template) : base(template)
{
RawData = new BaseObjectModel();
}
completely ignoring the childs of the object while the generated opc-ua model correctly include all childs

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: model attribute as array

Post by Support Team »

Hi,

You are right, only the first level of nodes is created in the generated code. You can create a subtype in code that adds the "grandchildren". Alternatively you can create an ObjectType for the child and the grandchildren and use this ObjectType.

Best regards
Support Team

Post Reply