Skip to content

Commit b4e95e3

Browse files
authored
Merge pull request #10 from OPCF-Members/9-remove-unconfigured-ua-attributes-from-the-aml-libraries
Removed attributes from SUCs and interfaces that contained default values
2 parents 7c479e4 + f95e945 commit b4e95e3

File tree

1 file changed

+46
-25
lines changed

1 file changed

+46
-25
lines changed

NodeSetToAML.cs

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -460,19 +460,22 @@ private void AddMetaModelLibraries(CAEXDocument doc)
460460

461461
private void AddBaseNodeClassAttributes(IClassWithBaseClassReference owner, bool isAbstract)
462462
{
463-
AttributeType a = owner.Attribute.Append("UaNodeNamespaceUri"); //bucket for the namespace URI of the node when present on an instance node
464-
a.AttributeDataType = "xs:anyURI";
463+
// #9 remove unused attributes from base
464+
465+
// AttributeType a = owner.Attribute.Append("UaNodeNamespaceUri"); //bucket for the namespace URI of the node when present on an instance node
466+
// a.AttributeDataType = "xs:anyURI";
465467

466-
AddModifyAttribute(owner.Attribute, "BrowseName", "QualifiedName", Variant.Null);
467-
AddModifyAttribute(owner.Attribute, "DisplayName", "LocalizedText", Variant.Null);
468+
// AddModifyAttribute(owner.Attribute, "BrowseName", "QualifiedName", Variant.Null);
469+
// AddModifyAttribute(owner.Attribute, "DisplayName", "LocalizedText", Variant.Null);
468470

469-
var abs = AddModifyAttribute(owner.Attribute, "IsAbstract", "Boolean", isAbstract);
471+
// var abs = AddModifyAttribute(owner.Attribute, "IsAbstract", "Boolean", isAbstract);
470472
// abs.Value = isAbstract ? "true" : "false";
471473

472-
AddModifyAttribute(owner.Attribute, "Description", "LocalizedText", Variant.Null);
473-
AddModifyAttribute(owner.Attribute, "WriteMask", "AttributeWriteMask", Variant.Null);
474-
AddModifyAttribute(owner.Attribute, "RolePermissions", "ListOfRolePermissionType", Variant.Null);
475-
AddModifyAttribute(owner.Attribute, "AccessRestrictions", "AccessRestrictionType", Variant.Null);
474+
// AddModifyAttribute(owner.Attribute, "Description", "LocalizedText", Variant.Null);
475+
// AddModifyAttribute(owner.Attribute, "WriteMask", "AttributeWriteMask", Variant.Null);
476+
// AddModifyAttribute(owner.Attribute, "RolePermissions", "ListOfRolePermissionType", Variant.Null);
477+
// AddModifyAttribute(owner.Attribute, "AccessRestrictions", "AccessRestrictionType", Variant.Null);
478+
476479
}
477480

478481
private void SetBrowseNameUri( AttributeSequence seq, UANode uanode, UANode basenode = null)
@@ -517,7 +520,20 @@ private AttributeType AddModifyAttribute(AttributeSequence seq, string name, str
517520
var at = ob as AttributeFamilyType;
518521
AttributeType a = seq[name]; //find the existing attribute with the name
519522
if (a == null)
520-
a = seq.Append(name); // not found so create a new one
523+
{
524+
if (bListOf == false && val.TypeInfo != null) // look for reasons not to add the attribute because missing == default value
525+
{
526+
if (name == "ValueRank" && val == -2 )
527+
return null;
528+
if (name == "IsAbstract" && val == false)
529+
return null;
530+
if (name == "IsSource" && val == false)
531+
return null;
532+
if (name == "Symmetric" && val == false)
533+
return null;
534+
}
535+
a = seq.Append(name); // not found so create a new one
536+
}
521537

522538
a.RecreateAttributeInstance(at);
523539
if (bListOf == false && val.TypeInfo != null)
@@ -790,22 +806,20 @@ SystemUnitFamilyType FindOrAddSUC(ref SystemUnitClassLibType scl, ref RoleClassL
790806
{
791807
case NodeClass.ObjectType:
792808
AddBaseNodeClassAttributes(rtn, false);
793-
AddModifyAttribute(rtn.Attribute, "EventNotifier", "EventNotifierType", Variant.Null);
809+
// AddModifyAttribute(rtn.Attribute, "EventNotifier", "EventNotifierType", Variant.Null); // #9 remove unset attributes
794810
SetBrowseNameUri(rtn.Attribute, refnode);
795811
break;
796812
case NodeClass.VariableType:
797813
AddBaseNodeClassAttributes(rtn, true);
798-
AddModifyAttribute(rtn.Attribute, "ArrayDimensions", "ListOfUInt32", Variant.Null);
799-
AddModifyAttribute(rtn.Attribute, "ValueRank", "Int32", -2);
800-
AddModifyAttribute(rtn.Attribute, "Value", "BaseDataType", Variant.Null);
801-
AddModifyAttribute(rtn.Attribute, "AccessLevel", "AccessLevelType", Variant.Null);
802-
AddModifyAttribute(rtn.Attribute, "MinimumSamplingInterval", "Duration", Variant.Null);
814+
// AddModifyAttribute(rtn.Attribute, "ArrayDimensions", "ListOfUInt32", Variant.Null); // #9 remove unset attributes
815+
// AddModifyAttribute(rtn.Attribute, "ValueRank", "Int32", -2); // #9 remove unset attributes
816+
// AddModifyAttribute(rtn.Attribute, "Value", "BaseDataType", Variant.Null); // #9 remove unset attributes
817+
// AddModifyAttribute(rtn.Attribute, "AccessLevel", "AccessLevelType", Variant.Null); // #9 remove unset attributes
818+
// AddModifyAttribute(rtn.Attribute, "MinimumSamplingInterval", "Duration", Variant.Null); // #9 remove unset attributes
803819
SetBrowseNameUri(rtn.Attribute, refnode);
804820
break;
805821
case NodeClass.Method:
806822
AddBaseNodeClassAttributes(rtn, false);
807-
// AddModifyAttribute(rtn.Attribute, "Executable", "Boolean", true); // #7 removed Executable an UserExecutable
808-
// AddModifyAttribute(rtn.Attribute, "UserExecutable", "Boolean", true); // #7 removed Executable an UserExecutable
809823
SetBrowseNameUri(rtn.Attribute, refnode);
810824

811825
break;
@@ -867,7 +881,8 @@ SystemUnitFamilyType FindOrAddSUC(ref SystemUnitClassLibType scl, ref RoleClassL
867881
var modellingId = m_modelManager.FindFirstTarget(reference.TargetId, HasModellingRuleNodeId, true);
868882
var modellingRule = m_modelManager.FindNode<UANode>(modellingId);
869883
if (modellingRule != null)
870-
destInterface.SetAttributeValue("ModellingRule", modellingRule.DecodedBrowseName.Name);
884+
AddModifyAttribute(destInterface.Attribute, "ModellingRule", "ModellingRuleType", modellingRule.DecodedBrowseName.Name, false, MetaModelName);
885+
871886
}
872887
}
873888
else if (m_modelManager.IsTypeOf(reference.ReferenceTypeId, HasInterfaceNodeId) == true)
@@ -940,11 +955,11 @@ private void ProcessReferenceType(ref InterfaceClassLibType icl, NodeId nodeId)
940955
// AddBaseNodeClassAttributes(added.Attribute, true);
941956

942957

943-
AddModifyAttribute(added.Attribute, "InverseName", "LocalizedText", Variant.Null);
944-
AddModifyAttribute(added.Attribute, "ModellingRule", "ModellingRuleType", Variant.Null, false, MetaModelName);
945-
OverrideBooleanAttribute(added.Attribute, "Symmetric", true);
946-
OverrideBooleanAttribute(added.Attribute, "IsAbstract", true);
947-
OverrideAttribute(added, IsSource, "xs:boolean", true);
958+
// AddModifyAttribute(added.Attribute, "InverseName", "LocalizedText", Variant.Null);
959+
// AddModifyAttribute(added.Attribute, "ModellingRule", "ModellingRuleType", Variant.Null, false, MetaModelName);
960+
// OverrideBooleanAttribute(added.Attribute, "Symmetric", true);
961+
// OverrideBooleanAttribute(added.Attribute, "IsAbstract", true);
962+
// OverrideAttribute(added, IsSource, "xs:boolean", true);
948963
OverrideAttribute(added, RefClassConnectsToPath, "xs:string", added.CAEXPath());
949964

950965
}
@@ -1269,10 +1284,16 @@ InternalElementType RecursiveAddModifyInstance<T>(ref T parent, UANode toAdd) wh
12691284
}
12701285
Debug.Assert(suc != null);
12711286

1272-
ie = suc.CreateClassInstance(); // this crates GUI IDs for all the sub-elements
1287+
ie = suc.CreateClassInstance(); // this crates GUID IDs for all the sub-elements
12731288
ie.Name = toAdd.DecodedBrowseName.Name;
12741289
ie.ID = AmlIDFromNodeId(toAdd.DecodedNodeId); // decided not to replace the GUID IDs in the top level instances
12751290
SetBrowseNameUri(ie.Attribute, toAdd);
1291+
1292+
1293+
AttributeType a = ie.Attribute.Append("UaNodeNamespaceUri"); //bucket for the namespace URI of the node when present on an instance node
1294+
a.AttributeDataType = "xs:anyURI";
1295+
1296+
12761297
ie.Attribute["UaNodeNamespaceUri"].Value = m_modelManager.FindModelUri(toAdd.DecodedNodeId);
12771298

12781299
parent.Insert(ie);

0 commit comments

Comments
 (0)