### C# example using Item with ATTRIBUTE_UNIT_STRING and ALIAS_ATTRIBUTE Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/P_Aml_Engine_CAEX_CAEXSequence_1_Item_1.htm Example showing how to use the indexer to get the first attribute with a unit in 'mm' and the external reference with alias 'baseClasses'. ```C# // get the first attribute with a unit in 'mm' var attributeWithUnit=internalElement.Attribute[(CAEX_CLASSModel_TagNames.ATTRIBUTE_UNIT_STRING, "mm")]; // get the external reference with the alias 'baseClasses' var referenceWithAlias = caexFile.ExternalReference[(CAEX_CLASSModel_TagNames.ALIAS_ATTRIBUTE, "baseClasses")]; ``` -------------------------------- ### RegisterServer example call in C# Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_Services_Interfaces_IAMLLibraryService_RegisterServer.htm Example call to RegisterServer with the server address 'https://automationml.ovgu.de/'. The method returns true if connecting to the server was successful. ```C# RegisterServer ("https://automationml.ovgu.de/"); ``` -------------------------------- ### AddInterfaceClassReference Usage Example Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_CAEX_Extensions_ObjectWithExternalInterface_AddInterfaceClassReference_1.htm Example demonstrating how to call the AddInterfaceClassReference method using a standard InterfaceClass path. ```C# var myIH = myDocument.CAEXFile.InstanceHierarchy.Append ("myIH"); var myIE = myIH.InternalElement.Append("myIH"); myIE.AddInterfaceClassReference (AutomationMLInterfaceClassLib.AutomationMLBaseInterface); ``` -------------------------------- ### C# Example: Calling AddRoleClassReference with AutomationMLBaseRole Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_CAEX_InternalElementType_AddRoleClassReference_1.htm Example showing how to append an InstanceHierarchy and InternalElement, then call AddRoleClassReference with the AutomationMLBaseRole path from AutomationMLBaseRoleClassLib. ```C# var myIH = myDocument.CAEXFile.InstanceHierarchy.Append ("myIH"); var myIE = myIH.InternalElement.Append("myIH"); myIE.AddRoleClassReference (AutomationMLBaseRoleClassLib.AutomationMLBaseRole); ``` -------------------------------- ### C# Example: Calling AddRoleClassReference Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_CAEX_InternalElementType_AddRoleClassReference.htm Shows how to call the method using a standard base RoleClass from the RoleClassLib. The example appends an InstanceHierarchy and an InternalElement, then adds the RoleClass reference. ```C# var amlBaseRoleClassLib = AutomationMLBaseRoleClassLibType.RoleClassLib (myDocument); var myIH = myDocument.CAEXFile.InstanceHierarchy.Append ("myIH"); var myIE = myIH.InternalElement.Append("myIH"); myIE.AddRoleClassReference (amlBaseRoleClassLib.AutomationMLBaseRole); ``` -------------------------------- ### Create and save a new CAEX document Source: https://github.com/automationml/amlengine2.1/blob/master/readme.md Demonstrates how to initialize a new empty CAEX document, add an InstanceHierarchy, and save the file to disk. ```c# using Aml.Engine.CAEX; using Aml.Engine.CAEX.Extensions; // create a new empty document var caexDocument = CAEXDocument.New_CAEXDocument(); // add content to the ROOT CAEXFile element var myIH = caexDocument.CAEXFile.New_InstanceHierarchy("myIH"); caexDocument.SaveToFile ("myfile.aml", true); ``` -------------------------------- ### ServiceLocator Methods Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/T_Aml_Engine_Services_ServiceLocator.htm Static methods to manage service registration and retrieval. These methods allow starting, ending, getting, registering, and unregistering services. ```APIDOC ## ServiceLocator Methods ### BeginService(Func) Starts the usage of a service of the provided type T. If an already registered service of this type exists, the registered service is used. If the service is not registered it is registered using the provided method. ### EndService(T) Ends the usage of the provided service. If the service was newly registered when it was started in BeginService(Func) it will be unregistered calling the provided unregistration method. ### GetService() Gets a service for the provided service interface. ### Register(T) Registers a service which will be locatable. ### UnRegister() Removes a service of this type from the registration which will afterwards no more locatable. ``` -------------------------------- ### Load a CAEX Document Source: https://github.com/automationml/amlengine2.1/blob/master/Samples/basic.md Demonstrates how to load an existing AutomationML file from the file system. ```C# using Aml.Engine.CAEX; var document = CAEXDocument.LoadFromFile ("myFile.aml"); ``` -------------------------------- ### CAEXSequence Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/Methods_T_Aml_Engine_CAEX_CAEXBasicObject.htm Gets the CAEXSequence owned by this instance, which contains the specified CAEX object. For example, if the specified object is a revision object, the sequence of the revision objects is returned. ```APIDOC ## CAEXSequence ### Description Gets the CAEXSequence owned by this instance, which contains the specified CAEX object. ### Method CAEXSequence ### Parameters - **caexObject** (CAEXWrapper) - The CAEX object whose containing sequence is to be retrieved. ### Returns The CAEXSequence that contains the specified CAEX object. ``` -------------------------------- ### BeginService Method Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/Methods_T_Aml_Engine_Services_ServiceLocator.htm Starts the usage of a service of the provided type T. If an already registered service of this type exists, the registered service is used. If the service is not registered, it is registered using the provided method. ```APIDOC ## BeginService Method ### Description Starts the usage of a service of the provided type T. If an already registered service of this type exists, the registered service is used. If the service is not registered, it is registered using the provided method. ### Method BeginService ### Signature public static T BeginService(Func registrationMethod) ### Parameters - **registrationMethod** (Func) - Required - The method used to register the service if it is not already registered. ### Returns - **T** - The service instance of type T. ### Remarks This method is a public static member of the ServiceLocator class. ``` -------------------------------- ### CAEXSequence(ICAEXWrapper) Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_CAEX_CAEXBasicObject_CAEXSequence.htm Gets the CAEXSequence owned by this instance, which contains the specified CAEX object. For example, if the specified object is a revision object, the sequence of the revision objects is returned. ```APIDOC ## CAEXSequence(ICAEXWrapper) ### Description Gets the CAEXSequence owned by this instance, which contains the specified CAEX object. For example, if the specified object is a revision object, the sequence of the revision objects is returned. ### Method CAEXSequence ### Signature public virtual ICAEXSequence CAEXSequence(ICAEXWrapper caexObject) ### Parameters - **caexObject** (ICAEXWrapper) - The CAEX object, contained in a sequence, owned by this CAEX object. ### Return Value - **ICAEXSequence** - The CAEX sequence or null, if no sequence exists, containing the specified CAEX object. ### Implements ICAEXBasicObject.CAEXSequence(ICAEXWrapper) ### Syntax Examples #### C# ```csharp public virtual ICAEXSequence CAEXSequence( ICAEXWrapper caexObject ) ``` #### VB ```vb Public Overridable Function CAEXSequence ( caexObject As ICAEXWrapper ) As ICAEXSequence ``` #### C++ ```cpp public: virtual ICAEXSequence^ CAEXSequence( ICAEXWrapper^ caexObject ) ``` ``` -------------------------------- ### Get InternalLinks connected to an ExternalInterface in C# Source: https://github.com/automationml/amlengine2.1/blob/master/Samples/queries.md Retrieves all InternalLinks attached to a specific ExternalInterface using the QueryService. The example demonstrates iterating through links to return the opposite interface. ```C# using Aml.Engine.Services; using Aml.Engine.AmlObjects; using Aml.Engine.CAEX; // Get all InternalLinks, which are attached to an ExternalInterface. // This method is appropriate, to get a collection of related ExternalInterfaces. IEnumerable GetAllRelatedExternalInterfaces(ExternalInterfaceType externalInterface) { var internalLinks = ServiceLocator.QueryService.InternalLinksToInterface(externalInterface); // or use the equivalent extension method externalInterface.InternalLinksToInterface(); foreach (var internalLink in internalLinks) { if (internalLink.AInterface.Equals(externalInterface) yield return internalLink.BInterface; else yield return internalLink.AInterface; } } ``` -------------------------------- ### CAEXDocument.Commanding Constructor Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_CAEX_CAEXDocument_Commanding__ctor.htm Initializes a new instance of the CAEXDocument.Commanding class. ```APIDOC ## CAEXDocument.Commanding Constructor ### Description Initializes a new instance of the CAEXDocument.Commanding class. ### Syntax #### C# ```csharp public Commanding() ``` #### VB ```vbnet Public Sub New ``` #### C++ ```cpp public: Commanding(); ``` ### Namespace Aml.Engine.CAEX ### Assembly Aml.Engine (in Aml.Engine.dll) Version: 3.2 ### See Also - CAEXDocument.Commanding Class - Aml.Engine.CAEX Namespace ``` -------------------------------- ### GetReferenceHierarchy Method Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_CAEX_IClassWithBaseClassReference_1_GetReferenceHierarchy.htm Gets the reference hierarchy for all class to class relations, starting with this class. Returns a collection containing this class and the reference hierarchy of the base class, if existing. ```APIDOC ## GetReferenceHierarchy Method ### Description Gets the reference hierarchy for all class to class relations, starting with this class. ### Namespace Aml.Engine.CAEX ### Assembly Aml.Engine (in Aml.Engine.dll) Version: 3.2 ### Syntax #### C# ```csharp IEnumerable GetReferenceHierarchy() ``` #### VB ```vb Function GetReferenceHierarchy As IEnumerable(Of T) ``` #### C++ ```cpp IEnumerable^ GetReferenceHierarchy() ``` ### Return Value IEnumerable - A collection, containing this class and the reference hierarchy of the base class, if existing. ### Remarks This method is part of the IClassWithBaseClassReference interface. ``` -------------------------------- ### CAEXLibrary Constructor Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/T_Aml_Engine_CAEX_CAEXLibrary_1.htm Initializes a new instance of the CAEXLibrary class. ```APIDOC ## CAEXLibrary Constructor ### Description Initializes a new instance of the CAEXLibrary class. ### Syntax ```csharp public CAEXLibrary(); ``` ### Parameters None. ### Return Value None. ``` -------------------------------- ### InternalLinkType.CAEXSequence Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/T_Aml_Engine_CAEX_InternalLinkType.htm Gets the CAEXSequence owned by this instance, which contains the specified CAEX object. For example, if the specified object is a revision object, the sequence of the revision objects is returned. Inherited from CAEXBasicObject. ```APIDOC ## Method: CAEXSequence ### Description Gets the CAEXSequence owned by this instance, which contains the specified CAEX object. For example, if the specified object is a revision object, the sequence of the revision objects is returned. Inherited from CAEXBasicObject. ### Method Signature `public CAEXSequence CAEXSequence(CAEXWrapper caexObject)` ### Parameters - **caexObject** (CAEXWrapper) - The CAEX object for which to find the owning sequence. ### Returns - The CAEXSequence that contains the specified object. ### Remarks - Inherited from CAEXBasicObject. ``` -------------------------------- ### Create Method Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/Methods_T_Aml_Engine_AmlObjects_AMLFacet.htm Creates a new AMLFacet instance. ```APIDOC ## Create Method ### Description Creates a new AMLFacet instance. ### Method Create ### Parameters None documented. ### Returns A new AMLFacet instance. ``` -------------------------------- ### CAEXSequence Method Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/Methods_T_Aml_Engine_CAEX_InterfaceIDMappingType.htm Gets the CAEXSequence owned by this instance, which contains the specified CAEX object. For example, if the specified object is a revision object, the sequence of the revision objects Revision is returned. ```APIDOC ## CAEXSequence Method ### Description Gets the CAEXSequence owned by this instance, which contains the specified CAEX object. For example, if the specified object is a revision object, the sequence of the revision objects Revision is returned. ### Inherited From CAEXBasicObject ### Remarks This method is inherited from the CAEXBasicObject class. ``` -------------------------------- ### ICAEXObject.CAEXPath() Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_CAEX_ICAEXObject_CAEXPath.htm Gets the CAEX path for this object. The path can be used to uniquely reference an object, for example in inheritances and instances. The path syntax is defined differently in CAEX 2.15 and CAEX 3.0. ```APIDOC ## ICAEXObject.CAEXPath() ### Description Gets the CAEX path for this object. A path can be used to uniquely reference an object, for example in inheritances and instances. The path syntax for an object is defined differently in CAEX 2.15 and CAEX 3.0. The engine uses the CAEXPathBuilder to generate the CAEX path of an object according to the document's CAEX version. ### Method CAEXPath() ### Return Value String - The CAEX path. ### Remarks Paths require the definition of separators between different path elements. CAEX 2.15 distinguishes between 4 separator types: Alias separator, object separator, interface separator and attribute separator. In CAEX 3.0 only the separator types Alias separator and object separator are used. Note that this method returns a different result than the GetFullNodePath(ICAEXObject) method, which always returns the path including the object names of all ancestor hierarchy levels. ### Syntax Examples #### C# ```csharp string CAEXPath() ``` #### VB ```vb Function CAEXPath As String ``` #### C++ ```cpp String^ CAEXPath() ``` ``` -------------------------------- ### Use AutomationML standard classes Source: https://github.com/automationml/amlengine2.1/blob/master/readme.md Illustrates how to add base libraries to a document and assign an AutomationML base role to an InternalElement. ```c# using Aml.Engine.AmlObjects; using Aml.Engine.CAEX; var caexDocument = CAEXDocument.New_CAEXDocument(); // adds the base libraries to the document AutomationMLInterfaceClassLibType.InterfaceClassLib(caexDocument); AutomationMLBaseRoleClassLibType.RoleClassLib(caexDocument); // add an InstanceHierarchy to the ROOT CAEXFile element var myIH = caexDocument.CAEXFile.New_InstanceHierarchy("myIH"); // add an InternalElement var ie = myIH.InternalElement.Append ("ie"); // assign the AutomationMLBaseRole ie.AddRoleClassReference(AutomationMLBaseRoleClassLib.AutomationMLBaseRole); ``` -------------------------------- ### CAEXObject.CAEXPath() Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_CAEX_CAEXObject_CAEXPath.htm Gets the CAEX path for this object. The path can be used to uniquely reference an object, for example in inheritances and instances. The path syntax is defined differently in CAEX 2.15 and CAEX 3.0, and the engine uses the CAEXPathBuilder to generate the path according to the document's CAEX version. ```APIDOC ## CAEXObject.CAEXPath() ### Description Gets the CAEX path for this object. A path can be used to uniquely reference an object, for example in inheritances and instances. The path syntax for an object is defined differently in CAEX 2.15 and CAEX 3.0. The engine uses the CAEXPathBuilder to generate the CAEX path of an object according to the documents CAEX version. ### Namespace Aml.Engine.CAEX ### Assembly Aml.Engine (in Aml.Engine.dll) Version: 3.2 ### Syntax #### C# ```csharp public string CAEXPath() ``` #### VB ```vbnet Public Function CAEXPath As String ``` #### C++ ```cpp public: virtual String^ CAEXPath() sealed ``` ### Return Value String The CAEX path. ### Implements ICAEXObject.CAEXPath ### Remarks Paths require the definition of separators between different path elements. CAEX 2.15 distinguishes between 4 separator types: Alias separator, object separator, interface separator and attribute separator. In CAEX 3.0 only the separator types Alias separator and object separator are used. Please note that this method returns a different result than the GetFullNodePath(ICAEXObject) method, which always returns the path including the object names of all ancestor hierarchy levels. ``` -------------------------------- ### Create a New CAEX Document with Internal Elements Source: https://github.com/automationml/amlengine2.1/blob/master/Samples/basic.md Shows how to initialize a new document and append an InstanceHierarchy and an InternalElement. ```C# using Aml.Engine.CAEX; var document = CAEXDocument.New_Document (); var myIH = document.CAEXFile.InstanceHierarchy.Append("myIH"); var myIE = myIH.InternalElement.Append("myIE"); ``` -------------------------------- ### getReferencedGUID Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/Methods_T_Aml_Engine_AmlObjects_AMLFacet.htm Parses a string of form GUID:Interface and returns the GUID. ```APIDOC ## getReferencedGUID ### Description Parses a string of form GUID:Interface and returns the GUID. ### Method Extension Method ### Defined By AMLEngineAdapter ``` -------------------------------- ### ServiceLocator.BeginService(Func register, out T service) Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_Services_ServiceLocator_BeginService__1.htm Starts the usage of a service of the provided type T. If an already registered service of this type exists, the registered service is used. If the service is not registered, it is registered using the provided method. ```APIDOC ## ServiceLocator.BeginService(Func register, out T service) ### Description Starts the usage of a service of the provided type T. If an already registered service of this type exists, the registered service is used. If the service is not registered, it is registered using the provided method. ### Method BeginService ### Signature public static void BeginService(Func register, out T service) where T : IAMLService ### Parameters - **register** (Func) - The registration method. - **service** (T) - The registered service (output parameter). ### Type Parameters - **T** - The type of the service, must implement IAMLService. ### Remarks This method is part of the ServiceLocator class in the Aml.Engine.Services namespace. It is used to start using a service, ensuring it is registered if not already. ``` -------------------------------- ### PublicLibraryCatalog.Library Constructor Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/T_Aml_Engine_Resources_PublicLibraryCatalog_Library.htm Initializes a new instance of the PublicLibraryCatalog.Library class. ```APIDOC ## PublicLibraryCatalog.Library Constructor ### Description Initializes a new instance of the PublicLibraryCatalog.Library class. ### Syntax ```csharp public Library() ``` ### Parameters None. ### Return Value None. ``` -------------------------------- ### getReferencedGUID Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/Methods_T_Aml_Engine_Adapter_AMLEngineAdapter.htm Obsolete. Parses a string of form GUID:Interface and returns the GUID. ```APIDOC ## getReferencedGUID ### Description Obsolete. Parses a string of form GUID:Interface and returns the GUID. ### Method Extension Method ### Remarks This method is marked as obsolete. ``` -------------------------------- ### CAEXFileType.InstanceHierarchy Property (get) Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/P_Aml_Engine_CAEX_CAEXFileType_InstanceHierarchy.htm Gets the collection of InstanceHierarchy objects contained in the CAEXFile. This is a read-only property. ```APIDOC ## CAEXFileType.InstanceHierarchy Property ### Description Gets the collection of InstanceHierarchy objects contained in the CAEXFile. ### Property Signature - **C#**: `public CAEXSequenceOfCAEXObjects InstanceHierarchy { get; }` - **VB**: `Public ReadOnly Property InstanceHierarchy As CAEXSequenceOfCAEXObjects(Of InstanceHierarchyType)` - **C++**: `public: property CAEXSequenceOfCAEXObjects^ InstanceHierarchy { CAEXSequenceOfCAEXObjects^ get(); }` ### Property Value - **Type**: CAEXSequenceOfCAEXObjects - **Description**: The collection of InstanceHierarchy objects contained in the CAEX file. ### Remarks - This property is read-only. - It belongs to the CAEXFileType class in the Aml.Engine.CAEX namespace. - Assembly: Aml.Engine (in Aml.Engine.dll) Version: 3.2 ``` -------------------------------- ### AMLEngineAdapter Methods Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_Adapter_AMLEngineAdapter_Ancestors.htm A list of methods available on the AMLEngineAdapter class, each with a link to its detailed documentation. ```APIDOC ## AMLEngineAdapter Methods ### Description This section lists the methods available on the AMLEngineAdapter class. Each method is documented in its own page. ### Methods - **Insert_SystemUnitFamilyType** - Inserts a SystemUnitFamilyType element. - **Insert_TypeBaseElement** - Inserts a TypeBaseElement. - **InstanceHierarchies** - Retrieves the instance hierarchies. - **InterfaceClassLibraries** - Retrieves the interface class libraries. - **InternalElementChildren** - Retrieves the children of an internal element. - **IsFacet** - Checks if an element is a facet. - **IsGroup** - Checks if an element is a group. - **IsPort** - Checks if an element is a port. - **Name** - Gets the name of an element. - **New_Comment** - Creates a new comment. - **New_NewVersion** - Creates a new version. - **New_OldVersion** - Creates an old version. - **New_RequiredMaxValue** - Creates a required maximum value. - **New_RequiredMinValue** - Creates a required minimum value. - **New_RequiredValue** - Creates a required value. - **New_RoleRequirements** - Creates role requirements. - **RoleClassLibraries** - Retrieves the role class libraries. - **SystemUnitClassChildren** - Retrieves the children of a system unit class. - **SystemUnitClassLibraries** - Retrieves the system unit class libraries. ### Notes - Each method has its own detailed documentation page accessible via the links in the source. - The methods are part of the Aml.Engine.Adapter namespace. ``` -------------------------------- ### Outsource a document library with SplitService Source: https://github.com/automationml/amlengine2.1/wiki/Externals This example demonstrates outsourcing the AutomationMLBaseRoleClassLib into an external file using the SplitService. It includes registering the service, setting a split point, and updating references to the outsourced library. ```C# using Aml.Engine.AmlObjects; using Aml.Engine.CAEX; using Aml.Engine.CAEX.Extensions; using Aml.Engine.Services; using Aml.Engine.Services.Interfaces; public CAEXDocument OutsourceLibrary() { // creates an empty CAEX document var document = CAEXDocument.New_CAEXDocument(); // registration of the split service var splitService = SplitService.Register(); // Add the AutomationMLBaseRoleClassLib to the document and mark the library as a split point splitService.SetSplitPoint(document.AddAutomationMLBaseRoleClassLib()); // Append a SystemUnitClass referencing the standard Resource-RoleClass var s1 = document.SystemUnitClassLib.Append("slib").SystemUnitClass.Append("s1"); s1.AddRoleClassReference(AutomationMLBaseRoleClassLib.Resource); // Outsource the AutomationMLBaseRoleClassLib to an external file splitService.Split(document, alias:"Base", filePath:"./base.aml"); // Remove the SplitService from the Service Registration SplitService.UnRegister(); // When the split is executed, the document contains a new external reference with // the provided 'alias' and 'path'. The RoleClassLibrary is removed from the document. // The reference to the roleClass is changed to a reference with the defined alias. // This is checked with the following assertions. // ----------------------------------------------------------------------------------- // Assert.NotNull(document.ExternalReferenceFromAlias("Base")); // Assert.IsNull (document.RoleClassLib[0]); // Assert.AreEqual ("Base@AutomationMLBaseRoleClassLib/AutomationMLBaseRole/Resource", // s1.SupportedRoleClass[0].RefRoleClassPath); // ----------------------------------------------------------------------------------- return document; } ``` -------------------------------- ### GUID_FORMAT Field Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/T_Aml_Engine_CAEX_CAEXObject.htm Specifies the format used for GUIDs. Format "D" is NOT adding {} around the GUID. ```APIDOC ## GUID_FORMAT Field ### Description Specifies the format used for GUIDs. Format "D" is NOT adding {} around the GUID. ### Field GUID_FORMAT ### Type string ### Remarks Public static field. ``` -------------------------------- ### Inheritance of SystemUnitClasses Source: https://github.com/automationml/amlengine2.1/wiki/Inheritance Demonstrates how to establish a class hierarchy by setting the BaseClass property and retrieving the inheritance chain or deep class references. ```C# using Aml.Engine.CAEX; using Aml.Engine.CAEX.Extensions; using Aml.Engine.Services; void CreateSystemUnitClassInheritance (CAEXDocument document) { // adding a Class library and some classes var systemUnitClassLib = document.CAEXFile.SystemUnitClassLib.Append("Slib"); var suc1 = systemUnitClassLib.SystemUnitClass.Append("s1"); var suc2 = systemUnitClassLib.SystemUnitClass.Append("s2"); var suc3 = systemUnitClassLib.SystemUnitClass.Append("s3"); // suc2 becomes a sub class from suc1 suc2.BaseClass = suc1; // suc3 becomes a sub class from suc2 suc3.BaseClass = suc2; // get the inheritance hierarchy from suc3 (the base classes) var inheritanceHierarchy = suc3.GetReferenceHierarchy().ToArray(); Debug.Assert(inheritanceHierarchy[0] == suc3); Debug.Assert(inheritanceHierarchy[1] == suc2); Debug.Assert(inheritanceHierarchy[2] == suc1); // gets the sub classes from suc1 (this also includes the sub-sub classes and further) var s = ServiceLocator.QueryService.AllClassReferencesDeep (suc1); Debug.Assert(s.Count() == 2); } ``` -------------------------------- ### CAEXObject.GUID_FORMAT Field Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/Fields_T_Aml_Engine_CAEX_CAEXObject.htm Specifies the format used for GUIDs. Format "D" is NOT adding {} around the GUID. ```APIDOC ## CAEXObject.GUID_FORMAT Field ### Description Specifies the format used for GUIDs. Format "D" is NOT adding {} around the GUID. ### Field GUID_FORMAT ### Type string (format specifier) ### Access Public, Static ### Remarks - The format "D" does not include curly braces around the GUID. - Other standard GUID format specifiers may be used as needed. ``` -------------------------------- ### Using Attribute Mirrors in C# Source: https://github.com/automationml/amlengine2.1/wiki/Mirrors Demonstrates creating an attribute mirror from an existing attribute, verifying the master-mirror relationship, and accessing values through the master attribute. ```C# using Aml.Engine.CAEX; using Aml.Engine.CAEX.Extensions; void UsingAttributeMirrors(CAEXDocument document) { var instanceHierarchy = document.CAEXFile.InstanceHierarchy.Append("ih1"); var element1 = instanceHierarchy.InternalElement.Append("element1"); var attribute1 = element1.SetAttributeValue("attribute1", 1.0); // creates an attribute mirror from 'attribute1' and inserts the mirror to element1 // as the first element element1.Insert(attribute1.CreateMirror()); // the attribute1 is a master attribute, because it has a mirror attribute Debug.Assert(attribute1.IsMaster()); // the first attribute is a mirror attribute var mirrorAttribute = element1.Attribute[0]; // the name of the mirror has to be different, because it is inserted // in the same attribute collection as the master mirrorAttribute.Name = "mirror"; Debug.Assert(mirrorAttribute.IsMirror); // the master of the mirror is attribute1 Debug.Assert(mirrorAttribute.Master==attribute1); // the reference to the master is stored in the RefAttributeType property; // the reference is set to the CAEXPath of the master Debug.Assert(mirrorAttribute.RefAttributeType==attribute1.CAEXPath()); // gets the attribute value of the master as a string representation var aValue = mirrorAttribute.Master.Value; Debug.Assert(double.Parse(aValue)==1.0); // gets the decoded value, according to its attribute data type var dValue = mirrorAttribute.Master.AttributeValue; Debug.Assert(dValue is double); // sets a new value using the encoding property mirrorAttribute.Master.AttributeValue = 4.0; } ``` -------------------------------- ### MappingSystemUnitClass Property (get) Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/P_Aml_Engine_CAEX_MappingElementType_1_MappingSystemUnitClass.htm Gets the SystemUnitClass, which provides the SystemUnitClassMappingElements. This property is read-only and returns a SystemUnitClassType object. ```APIDOC ## MappingSystemUnitClass Property ### Description Gets the SystemUnitClass, which provides the SystemUnitClassMappingElements. ### Property Signature - **Type**: SystemUnitClassType - **Access**: Read-only (get) - **Implements**: IMappingElementType.MappingSystemUnitClass ### Syntax #### C# ```csharp public SystemUnitClassType MappingSystemUnitClass { get; } ``` #### VB ```vb Public ReadOnly Property MappingSystemUnitClass As SystemUnitClassType Get End Property ``` #### C++ ```cpp public: virtual property SystemUnitClassType^ MappingSystemUnitClass { SystemUnitClassType^ get () sealed; } ``` ### Property Value - **Type**: SystemUnitClassType - **Description**: The SystemUnitClass that provides the SystemUnitClassMappingElements. ### Implements - **Interface**: IMappingElementType - **Member**: MappingSystemUnitClass ### Namespace Aml.Engine.CAEX ### Assembly Aml.Engine (in Aml.Engine.dll) Version: 3.2 ``` -------------------------------- ### AddInterfaceClassReference Usage Example Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_CAEX_Extensions_ObjectWithExternalInterface_AddInterfaceClassReference.htm Example demonstrating how to call the AddInterfaceClassReference method using a standard base InterfaceClass. ```csharp var amlInterfaceClassLib = AutomationMLInterfaceClassLibType.InterfaceClassLib (myDocument); var myIH = myDocument.CAEXFile.InstanceHierarchy.Append ("myIH"); var myIE = myIH.InternalElement.Append("myIH"); myIE.AddInterfaceClassReference (amlInterfaceClassLib.AutomationMLBaseInterface); ``` -------------------------------- ### Create ExternalInterface via C# Class Instantiation Source: https://github.com/automationml/amlengine2.1/wiki/Relations Demonstrates creating an InternalElement and adding three ExternalInterface instances with specific 'Direction' attributes using the AMLEngine API. ```C# using Aml.Engine.AmlObjects; using Aml.Engine.CAEX; void CreateInterfaceClassInstance(CAEXDocument document) { // add a new logistic project as an Instance Hierarchy var logisticsProject = document.CAEXFile.InstanceHierarchy.Append("LogisticsProject"); // import the standard AutomationML Interfaceclass library into the document var interfaceClassLib = AutomationMLInterfaceClassLibType.InterfaceClassLib(document); // add a distributing switch to your project var dswitch = logisticsProject.New_InternalElement("distributing switch"); // the switch should contain one input and two outputs // the standard interface class 'order' is used to model the distribution var order = document.FindByPath(AutomationMLInterfaceClassLib.Order) as InterfaceFamilyType; if (order == null) { throw new Exception("The standard interface class 'Order' doesnot exist"); } // create three new class instances (ExternalInterface), // the instances contain the interface class attribute 'Direction' var input = order.CreateClassInstance(); var out1 = order.CreateClassInstance(); var out2 = order.CreateClassInstance(); // the direction value is needed, because CAEX doesnot // provide directed instance to instance relations input.Attribute["Direction"].Value = "In"; out1.Attribute["Direction"].Value = "Out"; out2.Attribute["Direction"].Value = "Out"; // the direction attribute is defined in the standard attribute type library // the possible values are defined in a nominal value constraint // you can ensure, that the assigned values are in the nominal value collection // see the attrubte examples in the wiki for details. dswitch.Insert(input); dswitch.Insert(out1, asFirst:false); dswitch.Insert(out2, asFirst: false); } ``` -------------------------------- ### Importing External Classes with ExternalReferenceResolver Source: https://github.com/automationml/amlengine2.1/wiki/Externals This example demonstrates creating external documents, setting up split points, and importing classes while maintaining valid base class references. It uses the ExternalReferenceResolver to load referenced documents and the Insert method to import classes into the target document. ```C# using Aml.Engine.AmlObjects; using Aml.Engine.CAEX; using Aml.Engine.CAEX.Extensions; using Aml.Engine.Services; using Aml.Engine.Services.Interfaces; public void ImportExternalsTest() { // create the external documents as defined for this example using (var document = CAEXDocument.New_CAEXDocument()) { var aLib = document.SystemUnitClassLib.Append("ALib"); bLib = document.SystemUnitClassLib.Append("BLib"); var cb1 = bLib.SystemUnitClass.Append("CB1"); var ca1 = aLib.SystemUnitClass.AppendWithReference("CA1", cb1, out var isReferenced); var ca2 = aLib.SystemUnitClass.AppendWithReference("CA2", ca1, out isReferenced); var splitService = SplitService.Register(); splitService.SetSplitPoint(bLib); splitService.Split(document, alias: "RefB", filePath: "./document_b.aml"); document.SaveToFile ("./document_a.aml", true); SplitService.UnRegister(); } using (var document = CAEXDocument.New_CAEXDocument() ) { // prepare the document to access classes from document_a var refa = document.CAEXFile.ExternalReference.Append(); refa.Path = "./document_a.aml"; refa.Alias = "RefA"; // To work with external classes, the ExternalReferenceResolver is needed var externalsResolver = ExternalReferenceResolver.Register(); // Get the external document var (Document, Message) = externalsResolver.LoadOrGetReferencedDocument(refa); // locate the classes to be imported var ca2 = Document.FindByPath("ALib/CA2"); var ca1 = Document.FindByPath("ALib/CA1"); // simply call the standard insert method to import the external class ca2 // the reference to the BaseClass is updated document.SystemUnitClassLib.Append("Lib").Insert (ca2); // These assertions are true // --------------------------------------------------------------------------------------------- // Assert.AreEqual(document.SystemUnitClassLib["Lib"]["CA2"].RefBaseClassPath, "RefA@ALib/CA1"); // Assert.AreEqual(document.SystemUnitClassLib["Lib"]["CA2"].BaseClass, ca1); // --------------------------------------------------------------------------------------------- // simply call the standard insert method to import the external class ca1 // an additional ExternalReference is created to reference the BaseClass document.SystemUnitClassLib["Lib"].Insert(ca1); // These assertions are true // -------------------------------------------------------------------------------------------------- // Assert.IsNotNull(document.ExternalReferenceFromAlias("RefB")); // Assert.IsNotNull(document.FindByPath(document.SystemUnitClassLib["Lib"]["CA1"].RefBaseClassPath)); // Assert.AreEqual(document.SystemUnitClassLib["Lib"]["CA1"].BaseClass.Name, "CB1"); // -------------------------------------------------------------------------------------------------- } } ``` -------------------------------- ### Finding objects via a query service in C# Source: https://github.com/automationml/amlengine2.1/wiki/services Demonstrates locating an interface class using the default query service and the faster LookupService. The LookupService requires registration and additional memory for lookup tables. ```C# using Aml.Engine.CAEX; using Aml.Engine.Services; using Aml.Engine.AmlObjects; // Create a new document. var document = CAEXDocument.New_CAEXDocument (); // Add the standard AutomationML InterfaceClass library to this document. AutomationMLInterfaceClassLibType.InterfaceClassLib(document); // Locate a specific interface class from that library using the default query service. var interfaceClass = document.FindByPath (AutomationMLInterfaceClassLib.InterlockingVariableInterface); // Use the Lookup service, which is an alternative query service, for the same query LookupService.Register(); // After registration of the Lookup service, all queries are automatically // transferred to the Lookup service. // There is no need to change any method calls. The Lookup service performs faster but needs additional // memory space to maintain the lookup tables. The tables are updated automatically, whenever the content // of the document changes. var interfaceClass = document.FindByPath (AutomationMLInterfaceClassLib.InterlockingVariableInterface); ``` -------------------------------- ### AddAttributeTypeReference Usage Example Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_CAEX_Extensions_ObjectWithAttributes_AddAttributeTypeReference_1.htm Example showing how to call the AddAttributeTypeReference method using a standard AttributeType path. ```csharp var myIH = myDocument.CAEXFile.InstanceHierarchy.Append ("myIH"); var myIE = myIH.InternalElement.Append("myIH"); myIE.AddAttributeTypeReference (AutomationMLBaseAttributeTypeLib.Direction); ``` -------------------------------- ### PublicLibraryCatalog() Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_Resources_PublicLibraryCatalog__ctor.htm Initializes a new instance of the PublicLibraryCatalog class. This is the default constructor with no parameters. ```APIDOC ## PublicLibraryCatalog() ### Description Initializes a new instance of the PublicLibraryCatalog class. ### Namespace Aml.Engine.Resources ### Assembly Aml.Engine.Resources (in Aml.Engine.Resources.dll) Version: 3.0 ### Syntax #### C# ```csharp public PublicLibraryCatalog() ``` #### VB ```vb Public Sub New ``` #### C++ ```cpp public: PublicLibraryCatalog(); ``` ### Parameters None. ### Return Value None. ``` -------------------------------- ### StringExtensions.NormalizedGUID Method Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_CAEX_Extensions_StringExtensions_NormalizedGUID.htm String extension method to normalize a GUID. If the string cannot be identified as a GUID, the original string is returned. ```APIDOC ## NormalizedGUID Method ### Description String extension method to normalize a GUID. If the string cannot be identified as a GUID, the original string is returned. ### Namespace Aml.Engine.CAEX.Extensions ### Assembly Aml.Engine (in Aml.Engine.dll) Version: 3.2 ### Syntax #### C# ```csharp public static string NormalizedGUID( this string stringGuid ) ``` #### VB ```vbnet Public Shared Function NormalizedGUID ( stringGuid As String ) As String ``` #### C++ ```cpp public: [ExtensionAttribute] static String^ NormalizedGUID( String^ stringGuid ) ``` ### Parameters - **stringGuid** (String) - The stringGuid. ### Return Value String - The normalized GUID if the provided string is a GUID; otherwise the original string is returned. ### Usage Note In Visual Basic and C#, you can call this method as an instance method on any object of type String. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide). ``` -------------------------------- ### Loading a Document Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/basic.htm Demonstrates how to load a CAEX document from a file. Optionally, indices can be created for faster object search, which is recommended for read-only documents. ```C# using Aml.Engine.CAEX; // Load the document from a file var document = CAEXDocument.LoadFromFile ("myFile.aml"); // Load the document from a file with indices for fast object search, // use this for read-only documents only document = CAEXDocument.LoadFromFile ("myFile.aml", createIndices:true); ``` -------------------------------- ### DownloadLink Property (get, set) Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/P_Aml_Engine_Resources_PublicLibraryCatalog_LibraryVersion_DownloadLink.htm Gets and sets the download link where to load the library. The link should be publicly available. ```APIDOC ## DownloadLink Property ### Description Gets and sets the download link where to load the library. The link should be publicly available. ### Property Type string ### Syntax #### C# ```csharp public string DownloadLink { get; set; } ``` #### VB ```vbnet Public Property DownloadLink As String Get Set ``` #### C++ ```cpp public: property String^ DownloadLink { String^ get (); void set (String^ value); } ``` ### Property Value String - The download link for the library. ``` -------------------------------- ### Create SystemUnitClass Instance in C# Source: https://github.com/automationml/amlengine2.1/wiki/Relations Demonstrates creating an engineering project, defining a SystemUnitClass, and inserting a class instance as an InternalElement. It also shows how to manually assign a class reference to an InternalElement. ```C# using Aml.Engine.CAEX; void CreateSystemUnitClassInstance(CAEXDocument document) { // add a new engineering project as an Instance Hierarchy and a SystemUnitClass Library // which provides devices to be used in the project var engineeringProject = document.CAEXFile.InstanceHierarchy.Append("EngineeringProject"); var devices = document.CAEXFile.SystemUnitClassLib.Append("Devices"); // Adding a Product as a new SystemUnitClass to the SystemUnitClassLib var motionController = devices.SystemUnitClass.Append("ControllerS400"); // the technical data of the product is provided by an ECLASS identifier motionController.Attribute.Append("ECLASS").Value = "19234103"; // Insertion of a new class instance (InternalElement) in the InstanceHierarchy // The instance also contains the ECLASS attribute of the class engineeringProject.Insert(motionController.CreateClassInstance()); var ctrl1 = engineeringProject.InternalElement[0]; // The class-instance relation is saved in the InternalElement Debug.Assert(ctrl1.SystemUnitClass.Equals(motionController)); Debug.Assert(ctrl1.RefBaseSystemUnitPath == motionController.CAEXPath()); // In this example, it might be better to read the attributes from an ECLASS catalog and // not assign the ECLASS identifier to the instance var ctrl2 = engineeringProject.InternalElement.Append("motionController"); static void AddECLASSAttributes(InternalElementType element, SystemUnitFamilyType eclass) { // add the class reference without any attributes element.SystemUnitClass = eclass; if (eclass.Attribute["ECLASS"].Value == "19234103") { // you need a ECLASS license to get the data, this is only an example element.SetAttributeValue("MC_Power", 220.0); } } AddECLASSAttributes(ctrl2, motionController); } ``` -------------------------------- ### BSystemUnitClass Property (get) Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/P_Aml_Engine_CAEX_InternalLinkType_LinkedObjects_BSystemUnitClass.htm Gets the B-SystemUnitClass using the preserved value BInterface. If this value has not been calculated, a recalculation is performed. ```APIDOC ## BSystemUnitClass Property (get) ### Description Gets the B-SystemUnitClass using the preserved value BInterface. If this value has not been calculated, a recalculation is performed. ### Property Signature public SystemUnitClassType BSystemUnitClass { get; } ### Property Value SystemUnitClassType ### Syntax Examples #### C# ```csharp public SystemUnitClassType BSystemUnitClass { get; } ``` #### VB ```vb Public ReadOnly Property BSystemUnitClass As SystemUnitClassType Get ``` #### C++ ```cpp public: property SystemUnitClassType^ BSystemUnitClass { SystemUnitClassType^ get (); } ``` ### Remarks This property is read-only. It returns the B-SystemUnitClass associated with the internal link's BInterface. ``` -------------------------------- ### AddAttributeTypeReference Usage Example (C#) Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_CAEX_Extensions_ObjectWithAttributes_AddAttributeTypeReference.htm Example demonstrating how to call AddAttributeTypeReference using a base AttributeType from an AutomationML document. ```csharp var amlAttributeTypeLib = AutomationMLBaseAttributeTypeLibType.AttributeTypeLib (myDocument); var myIH = myDocument.CAEXFile.InstanceHierarchy.Append ("myIH"); var myIE = myIH.InternalElement.Append("myIH"); myIE.AddAttributeTypeReference (amlAttributeTypeLib.Direction); ``` -------------------------------- ### DescriptionType Constructor Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/T_Aml_Engine_CAEX_DescriptionType.htm Initializes a new instance of the DescriptionType class. ```APIDOC ## DescriptionType Constructor ### Description Initializes a new instance of the DescriptionType class. ### Syntax ```csharp public DescriptionType() ``` ### Parameters None. ### Return Value A new instance of the DescriptionType class. ``` -------------------------------- ### PublicLibraryCatalogLibraryVersion Constructor Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/T_Aml_Engine_Resources_PublicLibraryCatalog_LibraryVersion.htm Initializes a new instance of the PublicLibraryCatalogLibraryVersion class. ```APIDOC ## PublicLibraryCatalogLibraryVersion() ### Description Initializes a new instance of the PublicLibraryCatalogLibraryVersion class. ### Syntax ```csharp public PublicLibraryCatalogLibraryVersion() ``` ### Parameters None. ### Return Value A new instance of the PublicLibraryCatalogLibraryVersion class. ``` -------------------------------- ### ASystemUnitClass Property (get) Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/P_Aml_Engine_CAEX_InternalLinkType_LinkedObjects_ASystemUnitClass.htm Gets the A-SystemUnitClass using the preserved value of the AInterface property. If the value has not been calculated, a recalculation is performed. ```APIDOC ## ASystemUnitClass Property ### Description Gets the A-SystemUnitClass using the preserved value of the AInterface property. If the value has not been calculated, a recalculation is performed. ### Property Signature - **C#**: `public SystemUnitClassType ASystemUnitClass { get; }` - **VB**: `Public ReadOnly Property ASystemUnitClass As SystemUnitClassType` - **C++**: `public: property SystemUnitClassType^ ASystemUnitClass { SystemUnitClassType^ get(); }` ### Property Value - **Type**: SystemUnitClassType ### Remarks This property is read-only. It returns the A-SystemUnitClass associated with the internal link's linked objects. ``` -------------------------------- ### Install Aml.Engine NuGet package Source: https://github.com/automationml/amlengine2.1/wiki/Install Use this command in the NuGet package manager to install the Aml.Engine library version 3.3.1. ```powershell Install-Package Aml.Engine -Version 3.3.1 ``` -------------------------------- ### CAEXLibrary Constructor Source: https://github.com/automationml/amlengine2.1/blob/master/docs/html/M_Aml_Engine_CAEX_CAEXLibrary_1__ctor.htm Initializes a new instance of the CAEXLibrary class using a CAEX library XML node. ```APIDOC ## CAEXLibrary Constructor ### Description Initializes a new instance of the CAEXLibrary class. ### Syntax #### C# ```csharp public CAEXLibrary( XElement libraryNode ) ``` #### VB ```vb Public Sub New ( libraryNode As XElement ) ``` #### C++ ```cpp public: CAEXLibrary( XElement^ libraryNode ) ``` ### Parameters - **libraryNode** (XElement) - Any CAEX library XML node. ### Remarks This constructor is part of the Aml.Engine.CAEX namespace and is available in the Aml.Engine assembly (version 3.2). ```