-
Notifications
You must be signed in to change notification settings - Fork 8
Mirrors
Josef edited this page Apr 24, 2023
·
3 revisions
These examples explain the use of mirror objects in AutomationML using the AMLEngine. Mirrors can be defined for InternalElement
-, ExternalInterface
- and AttributeType
- objects. An element, referenced by a mirror object is called master.
Attribute mirrors are AttributeType
objects, referencing other AttributeType
objects.
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;
}
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