-
Notifications
You must be signed in to change notification settings - Fork 5
128 structure field selections #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
97aa0f0
Remove AllowSubtypes
Archie-Miller 3e35033
Remove MaxStringLength
Archie-Miller 23b463a
Address ValueRank and ArrayDimensions
Archie-Miller 5d972e8
Description is now array of Localized Text
Archie-Miller d250d67
Remove IsOptional if not required
Archie-Miller 24f4d0b
Finalize Structure Field Issue 128
Archie-Miller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3160,35 +3160,82 @@ private void AddStructureFieldDefinition( AttributeFamilyType attribute, UANode | |
|
|
||
|
|
||
| // Now fill the data | ||
| AddModifyAttribute( structureFieldAttribute.Attribute, | ||
| "Name", "String", new Variant( field.Name ) ); | ||
| AddModifyAttribute( structureFieldAttribute.Attribute, | ||
| "ValueRank", "Int32", new Variant( field.ValueRank ) ); | ||
| AddModifyAttribute( structureFieldAttribute.Attribute, | ||
| "IsOptional", "Boolean", new Variant( field.IsOptional) ); | ||
|
|
||
| SetArrayDimensions( structureFieldAttribute.Attribute, field.ArrayDimensions ); | ||
| RemoveUnwantedAttribute(structureFieldAttribute.Attribute["ArrayDimensions"], "StructureFieldDefinition"); | ||
| if ( string.IsNullOrEmpty(field.ArrayDimensions)) | ||
| RemoveUnwantedAttribute(structureFieldAttribute, "Name"); | ||
|
|
||
| if ( field.ValueRank == ValueRanks.Scalar || | ||
| field.ValueRank >= ValueRanks.OneDimension ) | ||
| { | ||
| AddModifyAttribute(structureFieldAttribute.Attribute, | ||
| "ValueRank", "Int32", new Variant(field.ValueRank)); | ||
| } | ||
| else | ||
| { | ||
| RemoveUnwantedAttribute(structureFieldAttribute.Attribute["ArrayDimensions"], "UInt32"); | ||
| RemoveUnwantedAttribute( structureFieldAttribute, "ValueRank" ); | ||
| } | ||
|
|
||
| AddModifyAttribute( structureFieldAttribute.Attribute, | ||
| "AllowSubtypes", "Boolean", new Variant( field.AllowSubTypes ) ); | ||
| AddModifyAttribute( structureFieldAttribute.Attribute, | ||
| "MaxStringLength", "UInt32", new Variant( field.MaxStringLength ) ); | ||
| if ( field.IsOptional ) | ||
| { | ||
| AddModifyAttribute(structureFieldAttribute.Attribute, | ||
| "IsOptional", "Boolean", new Variant(true)); | ||
| } | ||
| else | ||
| { | ||
| RemoveUnwantedAttribute(structureFieldAttribute, "IsOptional"); | ||
| } | ||
|
|
||
| if( field.Description != null && field.Description.Length > 0 ) | ||
| if ( field.ValueRank >= ValueRanks.OneDimension && | ||
| !string.IsNullOrEmpty( field.ArrayDimensions ) ) | ||
| { | ||
| SetArrayDimensions(structureFieldAttribute.Attribute, field.ArrayDimensions); | ||
| RemoveUnwantedAttribute(structureFieldAttribute.Attribute["ArrayDimensions"], | ||
| "StructureFieldDefinition"); | ||
| } | ||
| else | ||
| { | ||
| RemoveUnwantedAttribute(structureFieldAttribute, "ArrayDimensions"); | ||
| } | ||
|
|
||
|
|
||
| // Max String Length is only for strings and bytestrings | ||
| // This seems to be a point for discussion. | ||
| // Do we put max string length in if it zero? | ||
| if ( field.MaxStringLength > 0 && | ||
| m_modelManager.IsTypeOf( field.DecodedDataType, Opc.Ua.DataTypeIds.String ) || | ||
| m_modelManager.IsTypeOf( field.DecodedDataType, Opc.Ua.DataTypeIds.ByteString ) ) | ||
| { | ||
| LocalizedText localizedText = new LocalizedText( | ||
| field.Description[0].Locale, field.Description[ 0 ].Value ); | ||
| AddModifyAttribute( structureFieldAttribute.Attribute, | ||
| "Description", "LocalizedText", new Variant( localizedText ) ); | ||
| "MaxStringLength", "UInt32", new Variant( field.MaxStringLength ) ); | ||
| } | ||
| else if ( structureFieldAttribute.Attribute[ "MaxStringLength" ] != null ) | ||
| { | ||
| RemoveUnwantedAttribute( structureFieldAttribute, "MaxStringLength" ); | ||
| } | ||
|
|
||
| if (field.Description != null && field.Description.Length > 0) | ||
| { | ||
| List<Variant> localizedTextList = new List<Variant>(field.Description.Length); | ||
| foreach(NodeSet.LocalizedText description in field.Description) | ||
| { | ||
| localizedTextList.Add( | ||
| new Variant( | ||
| new LocalizedText(description.Locale, description.Value))); | ||
| } | ||
| Variant localizedTextArray = new Variant(localizedTextList); | ||
|
|
||
| LocalizedText localizedText = new LocalizedText( | ||
| field.Description[0].Locale, field.Description[0].Value); | ||
| AddModifyAttribute(structureFieldAttribute.Attribute, | ||
| "Description", "LocalizedText", localizedTextArray, | ||
| bListOf: true); | ||
| RemoveUnwantedAttribute(structureFieldAttribute.Attribute["Description"], | ||
| "StructureFieldDefinition"); | ||
| } | ||
| else if (structureFieldAttribute.Attribute["Description"] != null) | ||
| { | ||
| RemoveUnwantedAttribute(structureFieldAttribute, "Description"); | ||
| } | ||
|
|
||
| RemoveUnwantedAttribute(structureFieldAttribute.Attribute["Description"], | ||
| "StructureFieldDefinition"); | ||
|
|
||
|
|
||
| // Remove the NodeId from the structure Field | ||
| AttributeType nodeIdAttribute = structureFieldAttribute.Attribute[ "DataType" ]; | ||
|
|
@@ -3200,8 +3247,10 @@ private void AddStructureFieldDefinition( AttributeFamilyType attribute, UANode | |
| RemoveUnwantedNodeIdAttribute(structureFieldAttribute); | ||
| RemoveNodeIdsFromDefinition(structureFieldAttribute); | ||
|
|
||
|
|
||
| fieldDefinitionAttribute.Attribute.Insert( structureFieldAttribute ); | ||
| if (structureFieldAttribute.Attribute.Count > 0) | ||
| { | ||
| fieldDefinitionAttribute.Attribute.Insert(structureFieldAttribute); | ||
| } | ||
|
Comment on lines
+3250
to
+3253
|
||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing parentheses around the OR condition. The logical AND operator has higher precedence than OR, causing incorrect evaluation. The condition should be:
if ( field.MaxStringLength > 0 && (m_modelManager.IsTypeOf( field.DecodedDataType, Opc.Ua.DataTypeIds.String ) || m_modelManager.IsTypeOf( field.DecodedDataType, Opc.Ua.DataTypeIds.ByteString )) )