From 97aa0f079c03b670c2d2b9573df24defa7cd6957 Mon Sep 17 00:00:00 2001 From: Archie Date: Mon, 1 Sep 2025 10:03:06 -0600 Subject: [PATCH 1/6] Remove AllowSubtypes --- NodeSetToAML.cs | 2 -- SystemTest/TestStructureFieldDefinition.cs | 3 --- 2 files changed, 5 deletions(-) diff --git a/NodeSetToAML.cs b/NodeSetToAML.cs index 80330cd..ca8709c 100644 --- a/NodeSetToAML.cs +++ b/NodeSetToAML.cs @@ -3174,8 +3174,6 @@ private void AddStructureFieldDefinition( AttributeFamilyType attribute, UANode RemoveUnwantedAttribute(structureFieldAttribute.Attribute["ArrayDimensions"], "UInt32"); } - AddModifyAttribute( structureFieldAttribute.Attribute, - "AllowSubtypes", "Boolean", new Variant( field.AllowSubTypes ) ); AddModifyAttribute( structureFieldAttribute.Attribute, "MaxStringLength", "UInt32", new Variant( field.MaxStringLength ) ); diff --git a/SystemTest/TestStructureFieldDefinition.cs b/SystemTest/TestStructureFieldDefinition.cs index 80761e9..0946b05 100644 --- a/SystemTest/TestStructureFieldDefinition.cs +++ b/SystemTest/TestStructureFieldDefinition.cs @@ -56,14 +56,12 @@ public void TestUnwantedAttributes(TestHelper.Uris uriId, uint nodeId) [DataRow("QosCategory", "ArrayDimensions", null)] [DataRow("QosCategory", "MaxStringLength", "123")] [DataRow("QosCategory", "IsOptional", "true")] - [DataRow("QosCategory", "AllowSubtypes", "false")] [DataRow("DatagramQos", "Name", "DatagramQos")] [DataRow("DatagramQos", "Description", "Transmit Quality of Service")] [DataRow("DatagramQos", "ValueRank", "2")] [DataRow("DatagramQos", "MaxStringLength", "0")] [DataRow("DatagramQos", "IsOptional", "false")] - [DataRow("DatagramQos", "AllowSubtypes", "true")] [DataRow("NoDescription", "Name", "NoDescription")] [DataRow("NoDescription", "Description", null)] @@ -71,7 +69,6 @@ public void TestUnwantedAttributes(TestHelper.Uris uriId, uint nodeId) [DataRow("NoDescription", "ArrayDimensions", null)] [DataRow("NoDescription", "MaxStringLength", "321")] [DataRow("NoDescription", "IsOptional", "false")] - [DataRow("NoDescription", "AllowSubtypes", "false")] public void TestAttributeValues(string variableName, string attributeName, From 3e3503301570d250b8078b85e60135ee29622985 Mon Sep 17 00:00:00 2001 From: Archie Date: Mon, 1 Sep 2025 11:10:14 -0600 Subject: [PATCH 2/6] Remove MaxStringLength Only there if non zero and string or bytestring or subtypes --- NodeSetToAML.cs | 20 ++++++++++++++++---- SystemTest/TestStructureFieldDefinition.cs | 1 - 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/NodeSetToAML.cs b/NodeSetToAML.cs index ca8709c..bcffa1a 100644 --- a/NodeSetToAML.cs +++ b/NodeSetToAML.cs @@ -3174,13 +3174,25 @@ private void AddStructureFieldDefinition( AttributeFamilyType attribute, UANode RemoveUnwantedAttribute(structureFieldAttribute.Attribute["ArrayDimensions"], "UInt32"); } - AddModifyAttribute( structureFieldAttribute.Attribute, - "MaxStringLength", "UInt32", new Variant( field.MaxStringLength ) ); + // 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 ) ) + { + AddModifyAttribute( structureFieldAttribute.Attribute, + "MaxStringLength", "UInt32", new Variant( field.MaxStringLength ) ); + } + else if ( structureFieldAttribute.Attribute[ "MaxStringLength" ] != null ) + { + RemoveUnwantedAttribute( structureFieldAttribute, "MaxStringLength" ); + } - if( field.Description != null && field.Description.Length > 0 ) + if ( field.Description != null && field.Description.Length > 0 ) { LocalizedText localizedText = new LocalizedText( - field.Description[0].Locale, field.Description[ 0 ].Value ); + field.Description[0].Locale, field.Description[0].Value ); AddModifyAttribute( structureFieldAttribute.Attribute, "Description", "LocalizedText", new Variant( localizedText ) ); } diff --git a/SystemTest/TestStructureFieldDefinition.cs b/SystemTest/TestStructureFieldDefinition.cs index 0946b05..f26ab57 100644 --- a/SystemTest/TestStructureFieldDefinition.cs +++ b/SystemTest/TestStructureFieldDefinition.cs @@ -60,7 +60,6 @@ public void TestUnwantedAttributes(TestHelper.Uris uriId, uint nodeId) [DataRow("DatagramQos", "Name", "DatagramQos")] [DataRow("DatagramQos", "Description", "Transmit Quality of Service")] [DataRow("DatagramQos", "ValueRank", "2")] - [DataRow("DatagramQos", "MaxStringLength", "0")] [DataRow("DatagramQos", "IsOptional", "false")] [DataRow("NoDescription", "Name", "NoDescription")] From 23b463a7daed6bae744b4632119697ebfff1f0cb Mon Sep 17 00:00:00 2001 From: Archie Date: Mon, 1 Sep 2025 11:40:02 -0600 Subject: [PATCH 3/6] Address ValueRank and ArrayDimensions --- NodeSetToAML.cs | 28 +++++++++++++++++----- SystemTest/TestStructureFieldDefinition.cs | 2 -- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/NodeSetToAML.cs b/NodeSetToAML.cs index bcffa1a..f7621c9 100644 --- a/NodeSetToAML.cs +++ b/NodeSetToAML.cs @@ -3162,18 +3162,34 @@ 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 ) ); + + if ( field.ValueRank == ValueRanks.Scalar || + field.ValueRank >= ValueRanks.OneDimension ) + { + AddModifyAttribute(structureFieldAttribute.Attribute, + "ValueRank", "Int32", new Variant(field.ValueRank)); + } + else + { + RemoveUnwantedAttribute( structureFieldAttribute, "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)) + if ( field.ValueRank >= ValueRanks.OneDimension && + !string.IsNullOrEmpty( field.ArrayDimensions ) ) + { + SetArrayDimensions(structureFieldAttribute.Attribute, field.ArrayDimensions); + RemoveUnwantedAttribute(structureFieldAttribute.Attribute["ArrayDimensions"], + "StructureFieldDefinition"); + } + else { - RemoveUnwantedAttribute(structureFieldAttribute.Attribute["ArrayDimensions"], "UInt32"); + 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? diff --git a/SystemTest/TestStructureFieldDefinition.cs b/SystemTest/TestStructureFieldDefinition.cs index f26ab57..f3c3e10 100644 --- a/SystemTest/TestStructureFieldDefinition.cs +++ b/SystemTest/TestStructureFieldDefinition.cs @@ -53,7 +53,6 @@ public void TestUnwantedAttributes(TestHelper.Uris uriId, uint nodeId) [DataRow("QosCategory","Name", "QosCategory")] [DataRow("QosCategory", "Description", "Quality of Service Category")] [DataRow("QosCategory", "ValueRank", "-1")] - [DataRow("QosCategory", "ArrayDimensions", null)] [DataRow("QosCategory", "MaxStringLength", "123")] [DataRow("QosCategory", "IsOptional", "true")] @@ -65,7 +64,6 @@ public void TestUnwantedAttributes(TestHelper.Uris uriId, uint nodeId) [DataRow("NoDescription", "Name", "NoDescription")] [DataRow("NoDescription", "Description", null)] [DataRow("NoDescription", "ValueRank", "-1")] - [DataRow("NoDescription", "ArrayDimensions", null)] [DataRow("NoDescription", "MaxStringLength", "321")] [DataRow("NoDescription", "IsOptional", "false")] From 5d972e8c9f88bf5161cbf499f555265608b4eef6 Mon Sep 17 00:00:00 2001 From: Archie Date: Tue, 2 Sep 2025 10:22:44 -0600 Subject: [PATCH 4/6] Description is now array of Localized Text --- NodeSetToAML.cs | 27 ++++-- .../NodeSetFiles/Modified.Opc.Ua.NodeSet2.xml | 33 +++---- SystemTest/NodeSetFiles/TestAml.xml | 24 ++++- SystemTest/TestStructureFieldDefinition.cs | 95 ++++++++++--------- 4 files changed, 107 insertions(+), 72 deletions(-) diff --git a/NodeSetToAML.cs b/NodeSetToAML.cs index f7621c9..4476240 100644 --- a/NodeSetToAML.cs +++ b/NodeSetToAML.cs @@ -3205,16 +3205,31 @@ private void AddStructureFieldDefinition( AttributeFamilyType attribute, UANode RemoveUnwantedAttribute( structureFieldAttribute, "MaxStringLength" ); } - if ( field.Description != null && field.Description.Length > 0 ) + if (field.Description != null && field.Description.Length > 0) { + List localizedTextList = new List(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", new Variant( 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" ]; diff --git a/SystemTest/NodeSetFiles/Modified.Opc.Ua.NodeSet2.xml b/SystemTest/NodeSetFiles/Modified.Opc.Ua.NodeSet2.xml index 1cf436a..a09946b 100644 --- a/SystemTest/NodeSetFiles/Modified.Opc.Ua.NodeSet2.xml +++ b/SystemTest/NodeSetFiles/Modified.Opc.Ua.NodeSet2.xml @@ -9723,26 +9723,19 @@ - 3DCartesianCoordinates - Base Info Spatial Data - https://reference.opcfoundation.org/v105/Core/docs/Part5/12.26 - - i=18809 - - - - No Locale - - - With Locale - - - Multiple Descriptions - Multiple Descriptions with Locale - - - - + 3DCartesianCoordinates + Base Info Spatial Data + https://reference.opcfoundation.org/v105/Core/docs/Part5/12.26 + + i=18809 + + + + + + + + Orientation Base Info Spatial Data https://reference.opcfoundation.org/v105/Core/docs/Part5/12.27 diff --git a/SystemTest/NodeSetFiles/TestAml.xml b/SystemTest/NodeSetFiles/TestAml.xml index 28566ce..244b556 100644 --- a/SystemTest/NodeSetFiles/TestAml.xml +++ b/SystemTest/NodeSetFiles/TestAml.xml @@ -335,6 +335,8 @@ Quality of Service Category + Catégorie de qualité de service + Kategorie „Dienstqualität“ Transmit Quality of Service @@ -343,6 +345,26 @@ + + 3DCartesianCoordinates + Base Info Spatial Data + https://reference.opcfoundation.org/v105/Core/docs/Part5/12.26 + + i=18809 + + + + No Locale + + + With Locale + + + Multiple Descriptions + Multiple Descriptions with Locale + + + http://opcfoundation.org/UA/FX/AML/TESTING @@ -3563,7 +3585,7 @@ diff --git a/SystemTest/TestStructureFieldDefinition.cs b/SystemTest/TestStructureFieldDefinition.cs index f3c3e10..00cb49a 100644 --- a/SystemTest/TestStructureFieldDefinition.cs +++ b/SystemTest/TestStructureFieldDefinition.cs @@ -50,51 +50,42 @@ public void TestUnwantedAttributes(TestHelper.Uris uriId, uint nodeId) } [TestMethod, Timeout(TestHelper.UnitTestTimeout)] - [DataRow("QosCategory","Name", "QosCategory")] - [DataRow("QosCategory", "Description", "Quality of Service Category")] - [DataRow("QosCategory", "ValueRank", "-1")] - [DataRow("QosCategory", "MaxStringLength", "123")] - [DataRow("QosCategory", "IsOptional", "true")] - - [DataRow("DatagramQos", "Name", "DatagramQos")] - [DataRow("DatagramQos", "Description", "Transmit Quality of Service")] - [DataRow("DatagramQos", "ValueRank", "2")] - [DataRow("DatagramQos", "IsOptional", "false")] - - [DataRow("NoDescription", "Name", "NoDescription")] - [DataRow("NoDescription", "Description", null)] - [DataRow("NoDescription", "ValueRank", "-1")] - [DataRow("NoDescription", "MaxStringLength", "321")] - [DataRow("NoDescription", "IsOptional", "false")] + [DataRow("QosCategory","Name", "QosCategory", "", "")] + [DataRow("QosCategory", "Description", "Quality of Service Category", "0", "en")] + [DataRow("QosCategory", "Description", "Catégorie de qualité de service", "1", "fr")] + [DataRow("QosCategory", "Description", "Kategorie „Dienstqualität“", "2", "")] + [DataRow("QosCategory", "ValueRank", "-1", "", "")] + [DataRow("QosCategory", "ArrayDimensions", null, "", "")] + [DataRow("QosCategory", "MaxStringLength", "123", "", "")] + [DataRow("QosCategory", "IsOptional", "true", "", "")] + + [DataRow("DatagramQos", "Name", "DatagramQos", "", "")] + [DataRow("DatagramQos", "Description", "Transmit Quality of Service", "0", "")] + [DataRow("DatagramQos", "ArrayDimensions", "2", "0", "")] + [DataRow("DatagramQos", "ArrayDimensions", "3", "1", "")] + [DataRow("DatagramQos", "ValueRank", "2", "", "")] + [DataRow("DatagramQos", "IsOptional", "false", "", "")] + + [DataRow("NoDescription", "Name", "NoDescription", "", "")] + [DataRow("NoDescription", "Description", null, "", "")] + [DataRow("NoDescription", "ValueRank", "-1", "", "")] + [DataRow("NoDescription", "ArrayDimensions", null, "", "")] + [DataRow("NoDescription", "MaxStringLength", "321", "", "")] + [DataRow("NoDescription", "IsOptional", "false", "", "")] public void TestAttributeValues(string variableName, string attributeName, - string expectedValue) - { - AttributeValues(variableName, attributeName, expectedValue); - } - - [TestMethod, Timeout(TestHelper.UnitTestTimeout)] - public void TestDescriptionLocale() - { - AttributeValues("QosCategory", "Description", "Quality of Service Category", "en"); - } - - [TestMethod, Timeout(TestHelper.UnitTestTimeout)] - public void TestArrayDimensions() + string expectedValue, + string arrayIndex, + string localeId) { - AttributeType structured = GetStructured(TestHelper.Uris.Test, - PublisherQosDataType, "DatagramQos"); - AttributeType attribute = GetAttribute(structured, "ArrayDimensions"); - AttributeType first = GetAttribute(attribute, "0"); - Assert.AreEqual("2", first.Value, "Unexpected value for ArrayDimensions[0]."); - AttributeType second = GetAttribute(attribute, "1"); - Assert.AreEqual("3", second.Value, "Unexpected value for ArrayDimensions[1]."); + AttributeValuesEx(variableName, attributeName, expectedValue, arrayIndex, localeId); } - public void AttributeValues(string variableName, + public void AttributeValuesEx(string variableName, string attributeName, string expectedValue, + string arrayIndex = "", string localeId = "") { AttributeFamilyType objectToTest = GetTestAttribute(TestHelper.Uris.Test, @@ -102,19 +93,33 @@ public void AttributeValues(string variableName, AttributeType variableAttribute = GetAttribute(objectToTest.Attribute, variableName); AttributeType structured = GetAttribute(variableAttribute, "StructureFieldDefinition"); - AttributeType attribute = GetAttribute(structured.Attribute, attributeName); - Assert.AreEqual(expectedValue, attribute.Value, - $"Unexpected value for {variableName}.{attributeName} in {structured.Name}."); - if (!string.IsNullOrEmpty(localeId)) + if (string.IsNullOrEmpty(expectedValue)) { - AttributeType locale = GetAttribute(attribute.Attribute, localeId); - Assert.AreEqual(expectedValue, locale.Value, - $"Unexpected locale value for {variableName}.{attributeName} in {structured.Name}."); + // attributeName should not exist + Assert.IsNull(structured.Attribute[attributeName], + $"Attribute {attributeName} exists in {variableName} when it should not."); } - } + else + { + AttributeType attribute = GetAttribute(structured.Attribute, attributeName); + + if (!string.IsNullOrEmpty(arrayIndex)) + { + attribute = GetAttribute(attribute, arrayIndex); + } + Assert.AreEqual(expectedValue, attribute.Value, + $"Unexpected value for {variableName}.{attributeName} in {structured.Name}."); + if (!string.IsNullOrEmpty(localeId)) + { + AttributeType locale = GetAttribute(attribute.Attribute, localeId); + Assert.AreEqual(expectedValue, locale.Value, + $"Unexpected locale value for {variableName}.{attributeName} in {structured.Name}."); + } + } + } #endregion From d250d67dd2952bdbe9d1c763e54497118cdf2ce9 Mon Sep 17 00:00:00 2001 From: Archie Date: Tue, 2 Sep 2025 10:34:15 -0600 Subject: [PATCH 5/6] Remove IsOptional if not required --- NodeSetToAML.cs | 13 ++++++++++--- SystemTest/NodeSetFiles/TestAml.xml | 2 +- SystemTest/TestStructureFieldDefinition.cs | 6 +++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/NodeSetToAML.cs b/NodeSetToAML.cs index 4476240..b2e4cc3 100644 --- a/NodeSetToAML.cs +++ b/NodeSetToAML.cs @@ -3174,9 +3174,16 @@ private void AddStructureFieldDefinition( AttributeFamilyType attribute, UANode RemoveUnwantedAttribute( structureFieldAttribute, "ValueRank" ); } - AddModifyAttribute( structureFieldAttribute.Attribute, - "IsOptional", "Boolean", new Variant( field.IsOptional) ); - + if ( field.IsOptional ) + { + AddModifyAttribute(structureFieldAttribute.Attribute, + "IsOptional", "Boolean", new Variant(true)); + } + else + { + RemoveUnwantedAttribute(structureFieldAttribute, "IsOptional"); + } + if ( field.ValueRank >= ValueRanks.OneDimension && !string.IsNullOrEmpty( field.ArrayDimensions ) ) { diff --git a/SystemTest/NodeSetFiles/TestAml.xml b/SystemTest/NodeSetFiles/TestAml.xml index 244b556..60ba56a 100644 --- a/SystemTest/NodeSetFiles/TestAml.xml +++ b/SystemTest/NodeSetFiles/TestAml.xml @@ -341,7 +341,7 @@ Transmit Quality of Service - + diff --git a/SystemTest/TestStructureFieldDefinition.cs b/SystemTest/TestStructureFieldDefinition.cs index 00cb49a..f3212cc 100644 --- a/SystemTest/TestStructureFieldDefinition.cs +++ b/SystemTest/TestStructureFieldDefinition.cs @@ -64,14 +64,14 @@ public void TestUnwantedAttributes(TestHelper.Uris uriId, uint nodeId) [DataRow("DatagramQos", "ArrayDimensions", "2", "0", "")] [DataRow("DatagramQos", "ArrayDimensions", "3", "1", "")] [DataRow("DatagramQos", "ValueRank", "2", "", "")] - [DataRow("DatagramQos", "IsOptional", "false", "", "")] + [DataRow("DatagramQos", "IsOptional", null, "", "")] [DataRow("NoDescription", "Name", "NoDescription", "", "")] [DataRow("NoDescription", "Description", null, "", "")] - [DataRow("NoDescription", "ValueRank", "-1", "", "")] + [DataRow("NoDescription", "ValueRank", null, "", "")] [DataRow("NoDescription", "ArrayDimensions", null, "", "")] [DataRow("NoDescription", "MaxStringLength", "321", "", "")] - [DataRow("NoDescription", "IsOptional", "false", "", "")] + [DataRow("NoDescription", "IsOptional", null, "", "")] public void TestAttributeValues(string variableName, string attributeName, From 24f4d0b0b4e0e568cdd107fae6cbf182ebb02a76 Mon Sep 17 00:00:00 2001 From: Archie Date: Fri, 5 Sep 2025 11:46:59 -0600 Subject: [PATCH 6/6] Finalize Structure Field Issue 128 --- NodeSetToAML.cs | 9 +++--- SystemTest/NodeSetFiles/TestAml.xml | 1 + SystemTest/TestStructureFieldDefinition.cs | 33 +++++++++++----------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/NodeSetToAML.cs b/NodeSetToAML.cs index b2e4cc3..41d48f1 100644 --- a/NodeSetToAML.cs +++ b/NodeSetToAML.cs @@ -3160,8 +3160,7 @@ private void AddStructureFieldDefinition( AttributeFamilyType attribute, UANode // Now fill the data - AddModifyAttribute( structureFieldAttribute.Attribute, - "Name", "String", new Variant( field.Name ) ); + RemoveUnwantedAttribute(structureFieldAttribute, "Name"); if ( field.ValueRank == ValueRanks.Scalar || field.ValueRank >= ValueRanks.OneDimension ) @@ -3248,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); + } } } } diff --git a/SystemTest/NodeSetFiles/TestAml.xml b/SystemTest/NodeSetFiles/TestAml.xml index 60ba56a..4d1e558 100644 --- a/SystemTest/NodeSetFiles/TestAml.xml +++ b/SystemTest/NodeSetFiles/TestAml.xml @@ -342,6 +342,7 @@ Transmit Quality of Service + diff --git a/SystemTest/TestStructureFieldDefinition.cs b/SystemTest/TestStructureFieldDefinition.cs index f3212cc..e7ac1bc 100644 --- a/SystemTest/TestStructureFieldDefinition.cs +++ b/SystemTest/TestStructureFieldDefinition.cs @@ -1,10 +1,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Collections.Generic; using Aml.Engine.CAEX; using Aml.Engine.CAEX.Extensions; -using System.Linq; using System; -using Opc.Ua; namespace SystemTest { @@ -26,7 +23,7 @@ public void TestUnwantedAttributes(TestHelper.Uris uriId, uint nodeId) foreach( AttributeType attribute in objectToTest.Attribute ) { - if ( attribute.Name != "NodeId") + if ( attribute.Name != "NodeId" && attribute.Name != "PracticallyEmpty" ) { AttributeType structureAttribute = GetAttribute(attribute, "StructureFieldDefinition"); foreach(AttributeType definitionAttribute in structureAttribute.Attribute) @@ -50,7 +47,7 @@ public void TestUnwantedAttributes(TestHelper.Uris uriId, uint nodeId) } [TestMethod, Timeout(TestHelper.UnitTestTimeout)] - [DataRow("QosCategory","Name", "QosCategory", "", "")] + [DataRow("QosCategory","Name", null, "", "")] [DataRow("QosCategory", "Description", "Quality of Service Category", "0", "en")] [DataRow("QosCategory", "Description", "Catégorie de qualité de service", "1", "fr")] [DataRow("QosCategory", "Description", "Kategorie „Dienstqualität“", "2", "")] @@ -59,14 +56,14 @@ public void TestUnwantedAttributes(TestHelper.Uris uriId, uint nodeId) [DataRow("QosCategory", "MaxStringLength", "123", "", "")] [DataRow("QosCategory", "IsOptional", "true", "", "")] - [DataRow("DatagramQos", "Name", "DatagramQos", "", "")] + [DataRow("DatagramQos", "Name", null, "", "")] [DataRow("DatagramQos", "Description", "Transmit Quality of Service", "0", "")] [DataRow("DatagramQos", "ArrayDimensions", "2", "0", "")] [DataRow("DatagramQos", "ArrayDimensions", "3", "1", "")] [DataRow("DatagramQos", "ValueRank", "2", "", "")] [DataRow("DatagramQos", "IsOptional", null, "", "")] - [DataRow("NoDescription", "Name", "NoDescription", "", "")] + [DataRow("NoDescription", "Name", null, "", "")] [DataRow("NoDescription", "Description", null, "", "")] [DataRow("NoDescription", "ValueRank", null, "", "")] [DataRow("NoDescription", "ArrayDimensions", null, "", "")] @@ -78,15 +75,6 @@ public void TestAttributeValues(string variableName, string expectedValue, string arrayIndex, string localeId) - { - AttributeValuesEx(variableName, attributeName, expectedValue, arrayIndex, localeId); - } - - public void AttributeValuesEx(string variableName, - string attributeName, - string expectedValue, - string arrayIndex = "", - string localeId = "") { AttributeFamilyType objectToTest = GetTestAttribute(TestHelper.Uris.Test, PublisherQosDataType); @@ -121,9 +109,20 @@ public void AttributeValuesEx(string variableName, } } + + [TestMethod, Timeout(TestHelper.UnitTestTimeout)] + public void TestUnwantedStructureAttribute() + { + AttributeFamilyType objectToTest = GetTestAttribute(TestHelper.Uris.Test, PublisherQosDataType); + AttributeType emptyAttribute = GetAttribute(objectToTest.Attribute, "PracticallyEmpty"); + Assert.IsNull(emptyAttribute.Attribute["StructureFieldDefinition"], + "Unexpected StructureFieldDefinition found in PracticallyEmpty"); + } + + #endregion - #region Helpers + #region Helpers private CAEXDocument GetDocument() {