/// <summary> /// Helper to create an ObjectType-Node. Note: __NO__ NodeId is created by the default! /// Must be done by outer functionality!! /// </summary> /// <param name="browseDisplayName">Name displayed in the node tree</param> /// <param name="superTypeId">Base class or similar</param> /// <param name="presetNodeId">Preset the NodeId</param> /// <param name="descriptionKey">Lookup a Description on AAS literal/ refSemantics</param> /// <param name="modellingRule">Modeling Rule, if not None</param> /// <returns>THe node</returns> public static BaseObjectTypeState CreateObjectType( string browseDisplayName, NodeId superTypeId, NodeId presetNodeId = null, string descriptionKey = null, ModellingRule modellingRule = ModellingRule.None) { var x = new BaseObjectTypeState(); x.BrowseName = "" + browseDisplayName; x.DisplayName = "" + browseDisplayName; x.Description = new LocalizedText("en", browseDisplayName); x.Description = SetLocalizedTextWithDescription(x.Description, descriptionKey); x.SuperTypeId = superTypeId; if (presetNodeId != null) { x.NodeId = presetNodeId; } CheckSetModellingRule(modellingRule, x); return(x); }
/// <summary> /// Appply modelling rule to an arbitrary node /// </summary> public static NodeState CheckSetModellingRule(ModellingRule modellingRule, NodeState o) { if (o == null || modellingRule == ModellingRule.None) { return(o); } if (modellingRule == ModellingRule.Optional) { o.AddReference(ReferenceTypeIds.HasModellingRule, false, ObjectIds.ModellingRule_Optional); } if (modellingRule == ModellingRule.OptionalPlaceholder) { o.AddReference(ReferenceTypeIds.HasModellingRule, false, ObjectIds.ModellingRule_OptionalPlaceholder); } if (modellingRule == ModellingRule.Mandatory) { o.AddReference(ReferenceTypeIds.HasModellingRule, false, ObjectIds.ModellingRule_Mandatory); } if (modellingRule == ModellingRule.MandatoryPlaceholder) { o.AddReference(ReferenceTypeIds.HasModellingRule, false, ObjectIds.ModellingRule_MandatoryPlaceholder); } return(o); }
/// <summary> /// Maps the modelling rule enumeration onto a string. /// </summary> public static NodeId ToNodeId(this ModellingRule modellingRule) { switch (modellingRule) { case ModellingRule.Mandatory: return(Objects.ModellingRule_Mandatory); case ModellingRule.MandatoryShared: return(79); // TODO case ModellingRule.Optional: return(Objects.ModellingRule_Optional); case ModellingRule.MandatoryPlaceholder: return(Objects.ModellingRule_MandatoryPlaceholder); case ModellingRule.OptionalPlaceholder: return(Objects.ModellingRule_OptionalPlaceholder); case ModellingRule.ExposesItsArray: return(Objects.ModellingRule_ExposesItsArray); } return(null); }