-
Notifications
You must be signed in to change notification settings - Fork 8
basic
Josef edited this page Aug 12, 2021
·
21 revisions
These code examples show basic principles for AutomationML application development using the AMLEngine. The CAEX classes, used in the examples, are shown in the diagram. The CAEX Classes are all defined in the Aml_Engine_CAEX namespace.
using Aml.Engine.CAEX;
var document = CAEXDocument.LoadFromFile ("myFile.aml");
using Aml.Engine.CAEX;
CAEXDocument.SaveToFile ("myFile.aml", true);
using Aml.Engine.CAEX;
var document = CAEXDocument.New_Document ();
var myIH = document.CAEXFile.InstanceHierarchy.Append("myIH");
var myIE = myIH.InternalElement.Append("myIE");
using Aml.Engine.CAEX;
var document = CAEXDocument.New_Document ();
var myIH = document.CAEXFile.InstanceHierarchy.Append("myIH");
myIH.Version = "1.0";
// Get the first CAEXElement from the sequence of elements
myIH = document.CAEXFile.InstanceHierarchy[0];
// Get the first CAEXElement from the sequence of elements with the name "myIH"
myIH = document.CAEXFile.InstanceHierarchy["myIH"];
// Get the first CAEXElement with a specific attribute AND value from the sequence of elements
myIH = document.CAEXFile.InstanceHierarchy[(Name:"Version", Value:"1.0")];
using Aml.Engine.CAEX;
var document = CAEXDocument.LoadFromFile("myFile.aml");
// browse the Instance Hierarchies in the file
foreach (var instanceHierary in document.CaexFile.InstanceHierarchy)
{
// browse all InternalElements deep and import the internal Elements to your system
foreach (var internalElement in instanceHierarchy.Descendants<InternalElementType>())
{
// ToDo: import internal Element
}
}
using Aml.Engine.CAEX;
var document = CAEXDocument.New_Document ();
var myIH = document.CAEXFile.InstanceHierarchy.Append("myIH");
var mySlib = document.CAEXFile.SystemUnitClassLib.Append("mySlib");
var mySuc = mySlib.SystemUnitClass.Append("suClass");
// insert a new class instance (InternalElement) to the InstanceHierarchy
var myIE = myIH.Insert (mySuc.CreateClassInstance());
using Aml.Engine.CAEX;
var document = CAEXDocument.New_Document ();
var myIH = document.CAEXFile.InstanceHierarchy.Append("myIH");
var myIClib = document.CAEXFile.InterfaceClassLib.Append("myIClib");
var myIC = myIClib.InterfaceClass.Append("myIC");
// create an InternalElement which is a common parent to hold the InternalLink
var linkParent = myIH.InternalElement.Append ("linkParent");
// create the instances
var myIEA = linkParent.InternalElement.Append ("myIEA");
var myIEB = linkParent.InternalElement.Append ("myIEB");
// create the Interfaces for the InternalLink connection
myIEA.ExternalInterface.Append ("a");
myIEB.ExternalInterface.Append ("b");
// create the instance to instance relation
var relation = InternalLinkType.New_InternalLink (myIEA.ExternalInterface["a"], myIEB.ExternalInterface["b"], "rel1");
// an alternative way is, to use the InternalLink collection
// var relation = linkParent.InternalLink.Append ("rel1");
// relation.AInterface = myIEA.ExternalInterface["a"];
// relation.BInterface = myIEB.ExternalInterface["b"];
using Aml.Engine.CAEX;
using Aml.Engine.AmlObjects;
var document = CAEXDocument.New_Document ();
// the first solution shows an implementation, which uses existing libraries and classes
void methodWithClasses ()
{
// add the AutomationMLInterfaceClassLib
var amlBaseICLib = AutomationMLInterfaceClassLibType.InterfaceClassLib(document);
var myIClib = document.CAEXFile.InterfaceClassLib.Append("myIClib");
var myIC = myIClib.InterfaceClass.Append("myICClass");
var myIC.BaseClass = amlBaseICLib.AutomationMLClass(AutomationMLInterfaceClassLib.AutomationMLBaseInterface);
}
// the second solution shows an implementation, which uses the standardized class path
void methodWithClassPath ()
{
var myIClib = document.CAEXFile.InterfaceClassLib.Append("myIClib");
var myIC = myIClib.InterfaceClass.Append("myICClass");
// creates a class relation to the AutomationML Base Interface Class
myIC.MakeAutomationMLBaseInterface();
}
Home | Installation | API | Solutions
Getting Started
- Install
- First Steps with CAEX
- Working with CAEX Libraries
- Working with CAEX Relations
- Managing Inheritance
- Attribut Values
- Document Versions
Extended Examples
API Reference Guide