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?
model attribute as array
Moderator: uasdknet
-
- Hero Member
- Posts: 22
- Joined: 07 Aug 2012, 14:11
Re: model attribute as array
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
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
- Support Team
- Hero Member
- Posts: 3072
- Joined: 18 Mar 2011, 15:09
Re: model attribute as array
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
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
-
- Hero Member
- Posts: 22
- Joined: 07 Aug 2012, 14:11
Re: model attribute as array
>> 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!
Looks like I missed that the DataModel class was also autogenerated, this is great, thank you!
-
- Hero Member
- Posts: 22
- Joined: 07 Aug 2012, 14:11
Re: model attribute as array
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
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
- Support Team
- Hero Member
- Posts: 3072
- Joined: 18 Mar 2011, 15:09
Re: model attribute as array
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
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