You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For integration test purposes (in 2020), I created a Docker image with a NetCoreConsoleServer and a customized TestDataDesign.yml model that was compiled with the UA-ModelCompiler.
This custom model includes my own UD structure data type (that inherits from Structure datatype) with 4 fields.
I make use of the ComplexTypeSystem's emitted .Net types to handle encoding and decoding of UD structs when reading / writing to nodes of this type.
All worked well until I recently had to make small changes to my UD struct.
I don't have the same UA-Compiler that I used in 2020, so I had to pull the latest of the UA-ModelCompiler in order to compile the modified model again.
So after compiling the model with a more recent UA-ModelCompiler, reading and writing of nodes of this struct type do not work as expected.
On closer inspection, I found that the ComplexTypeSystem does not return the struct type definition if any of the fields are optional (IsOptional == true) as seen here
I then checked in UAExpert to see if there are differences between the model from 2020 and the more recently compiled model, and I discovered that the model from 2020 shows all fields as required (IsOptional == false), whereas for the recently compiled model, all the fields are optional. (See screenshots)
So something must have changed since the previous version of the ModelCompiler that I used in 2020.
I then tried to get the UA-ModelCompiler to compile the fields as required (IsOptional == false), but I haven't managed to get it working. It seems to always compile struct fields as being optional.
On further inspection, I also found that the IsOptional property in the Opc.Ua.DataTypes.StructureField class is true by default as seen in the StructureField.Initialize method.
This property only gets set based on a few conditions in ModelDesignValidator.GetStructureDefinitionFields that are not clear to me.
It isn't clear to me how a struct's fields can be specified as either optional or required at compile time.
Furthermore, it is unclear why the ComplexTypeSystem does not return a struct's definition if any of the fields are optional.
I am trying to understand the reason between support for structs with required fields in the ComplexTypeSystem vs no support for structs with at least one optional field.
Can anybody please
indicate what I am missing with regards to defining a struct's fields as optional vs required,
explain why the ComplexTypeSystem does not seem to support structs with optional fields
point me to any specification explaining the rules regarding structs with optional fields vs required fields.
To Reproduce
Steps to reproduce the behavior:
Issue description above gives a clear idea of the steps.
Expected behavior
I would expect to see the ComplexTypeSystem work for any kind of structs, regardless of optional vs required fields, unless there is some clear documentation that explains the rules and different scenarios.
I would expect my struct's fields to be required by default, once compiled with the UA-ModelCompiler, unless there is a reason why the default was changed from IsOptional == false to IsOptional == true.
I would expect to see a .Net type emitted for my type, regardless of optional or required fields.
Screenshots
This is what I see in UAExpert when I look at the struct field definition:
First one is original model from 2020
Second is the recently compiled model showing fields as optional (and causing the ComplexTypeSystem to not work as expected)
Log output
Code snippets
Environment (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered:
Hi @hermoter , this condition: here indicates a false combination of struct and optional fields is used. The type should be StructureType.StructureWithOptionalFields.
I suspect you are seeing an issue with: Modelcompiler updates, errata 1.04.9 nodeset (#1284)
The way how the datatypedefinitions and structures are built during load was changed. So you need to make sure, if you used the latest modelcompiler to use also a latest nuget package to import the model. Please check in UANodesetHelper / Import if your model is properly imported.
Hi @hermoter , I can repro the issue here. I will check with the owner of the ModelCompiler if the change was intentional.
Maybe the check in the complex type loader for IsOptional should be removed..
Thanks, Martin
fixes#1476
Improve IOP, some recent ModelCompiler versions (starting with errata 1.04.9) produce invalid output and all IsOptional fields have become true by default, causing the complex types client to bail out for Structures created with this ModelCompiler release. However, the IsOptional field can be ignored.
ModelCompiler is fixed in 1.04.10 and greater
Type of Issue
Describe the Issue
For integration test purposes (in 2020), I created a Docker image with a NetCoreConsoleServer and a customized TestDataDesign.yml model that was compiled with the UA-ModelCompiler.
This custom model includes my own UD structure data type (that inherits from Structure datatype) with 4 fields.
I make use of the ComplexTypeSystem's emitted .Net types to handle encoding and decoding of UD structs when reading / writing to nodes of this type.
All worked well until I recently had to make small changes to my UD struct.
I don't have the same UA-Compiler that I used in 2020, so I had to pull the latest of the UA-ModelCompiler in order to compile the modified model again.
So after compiling the model with a more recent UA-ModelCompiler, reading and writing of nodes of this struct type do not work as expected.
On closer inspection, I found that the ComplexTypeSystem does not return the struct type definition if any of the fields are optional (IsOptional == true) as seen here
I then checked in UAExpert to see if there are differences between the model from 2020 and the more recently compiled model, and I discovered that the model from 2020 shows all fields as required (IsOptional == false), whereas for the recently compiled model, all the fields are optional. (See screenshots)
So something must have changed since the previous version of the ModelCompiler that I used in 2020.
I then tried to get the UA-ModelCompiler to compile the fields as required (IsOptional == false), but I haven't managed to get it working. It seems to always compile struct fields as being optional.
On further inspection, I also found that the IsOptional property in the Opc.Ua.DataTypes.StructureField class is true by default as seen in the StructureField.Initialize method.
This property only gets set based on a few conditions in ModelDesignValidator.GetStructureDefinitionFields that are not clear to me.
It isn't clear to me how a struct's fields can be specified as either optional or required at compile time.
Furthermore, it is unclear why the ComplexTypeSystem does not return a struct's definition if any of the fields are optional.
I am trying to understand the reason between support for structs with required fields in the ComplexTypeSystem vs no support for structs with at least one optional field.
Can anybody please
To Reproduce
Steps to reproduce the behavior:
Issue description above gives a clear idea of the steps.
Expected behavior
I would expect to see the ComplexTypeSystem work for any kind of structs, regardless of optional vs required fields, unless there is some clear documentation that explains the rules and different scenarios.
I would expect my struct's fields to be required by default, once compiled with the UA-ModelCompiler, unless there is a reason why the default was changed from IsOptional == false to IsOptional == true.
I would expect to see a .Net type emitted for my type, regardless of optional or required fields.
Screenshots
This is what I see in UAExpert when I look at the struct field definition:
First one is original model from 2020
Second is the recently compiled model showing fields as optional (and causing the ComplexTypeSystem to not work as expected)
Log output
Code snippets
Environment (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: