From f5c8628d31265e154323197c2efecd450bfd9526 Mon Sep 17 00:00:00 2001 From: Archie Date: Wed, 30 Jul 2025 11:42:38 -0600 Subject: [PATCH] Allow ValueRank of -2 to be added to Aml file --- NodeSetToAML.cs | 13 ++++++++++--- SystemTest/TestAttributes.cs | 7 +++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/NodeSetToAML.cs b/NodeSetToAML.cs index a41a839..f5c0431 100644 --- a/NodeSetToAML.cs +++ b/NodeSetToAML.cs @@ -41,6 +41,7 @@ using UAObject = MarkdownProcessor.NodeSet.UAObject; using UAType = MarkdownProcessor.NodeSet.UAType; using UAVariable = MarkdownProcessor.NodeSet.UAVariable; +using UAVariableType = MarkdownProcessor.NodeSet.UAVariableType; using DataTypeField = MarkdownProcessor.NodeSet.DataTypeField; using Aml.Engine.Adapter; using System.Xml.Linq; @@ -53,7 +54,6 @@ using System.Reflection; using System.Xml; using Opc2Aml; -using Newtonsoft.Json.Linq; namespace MarkdownProcessor @@ -604,6 +604,15 @@ private void AddBaseNodeClassAttributes( AttributeSequence seq, UANode uanode) { AddModifyAttribute(seq, "IsAbstract", "Boolean", uaType.IsAbstract); } + + UAVariableType uaVariableType = uanode as UAVariableType; + if (uaVariableType != null) + { + if (uaVariableType.ValueRank != -1) + { + AddModifyAttribute(seq, "ValueRank", "Int32", uaVariableType.ValueRank); + } + } } private void BuildLocalizedTextAttribute( @@ -714,8 +723,6 @@ private AttributeType AddModifyAttribute(AttributeSequence seq, string name, str { if (bListOf == false && val.TypeInfo != null) // look for reasons not to add the attribute because missing == default value { - if (name == "ValueRank" && val == -2 ) - return null; if (name == "IsSource" && val == false) return null; if (name == "Symmetric" && val == false) diff --git a/SystemTest/TestAttributes.cs b/SystemTest/TestAttributes.cs index f28be0a..555e901 100644 --- a/SystemTest/TestAttributes.cs +++ b/SystemTest/TestAttributes.cs @@ -43,6 +43,13 @@ public class TestAttributes [DataRow("IsAbstract", "2881", "false", true, true, DisplayName = "AcknowledgeableConditionType should not be Abstract")] + [DataRow("ValueRank", "62", "-2", + true, true, DisplayName = "BaseVariableType ValueRank -2")] + [DataRow("ValueRank", "58", "", + false, true, DisplayName = "BaseObjectType No ValueRank")] + [DataRow("ValueRank", "18773", "-1", + true, true, DisplayName = "CartesianCoordinates LengthUnit ValueRank -1")] + public void TestAttribute(string attribute, string nodeId, string expected, bool expectedToBeFound, bool foundationRoot = false) {