diff --git a/QvtoTransformationRules/transforms/ClassDiagram/Instances.qvto b/QvtoTransformationRules/transforms/ClassDiagram/Instances.qvto index 9aff172..b8e5fe1 100644 --- a/QvtoTransformationRules/transforms/ClassDiagram/Instances.qvto +++ b/QvtoTransformationRules/transforms/ClassDiagram/Instances.qvto @@ -25,6 +25,11 @@ mapping UML::InstanceSpecification::instanceSpecification2OPCUAObject(inout node var classifier := self.classifier->any(true); // should only have one classifier + assert warning (self.classifier->size() <= 1) with log("Element specifies more than one classifier. Only the first value is used"); + _references := object OPCUA::ListOfReferences{}; + _references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := classifier.createNodeId()}; + _references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("Organizes"); value := getIdOrAlias("ObjectsFolder"); isForward := false}; + // transform property slots of the Instance nodeset.uAVariable += self.ownedElement->selectByType(UML::Slot)->select(slot | slot.definingFeature.oclIsTypeOf(UML::Property))->map transformPropertySlot2UAVariable(result); @@ -32,10 +37,6 @@ mapping UML::InstanceSpecification::instanceSpecification2OPCUAObject(inout node log("number of slots not defined in the instance: " + classifier.ownedElement->selectByType(UML::Property)->select(p | self.slot.definingFeature->excludes(p))->size().toString()); nodeset.uAVariable += classifier.ownedElement->selectByType(UML::Property)->select(p | self.slot.definingFeature->excludes(p))->map transformClassifierProperty2UAVariable(result); - assert warning (self.classifier->size() <= 1) with log("Element specifies more than one classifier. Only the first value is used"); - _references := object OPCUA::ListOfReferences{}; - _references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := classifier.createNodeId()}; - _references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("Organizes"); value := getIdOrAlias("ObjectsFolder"); isForward := false}; } mapping UML::Slot::transformPropertySlot2UAVariable(inout parent : OPCUA::UANode) : OPCUA::UAVariable { diff --git a/Uml2OpcuaTransformationTests/InstanceWithSlots.xml b/Uml2OpcuaTransformationTests/InstanceWithSlots.xml index 6cd2e2e..73cc6b5 100644 --- a/Uml2OpcuaTransformationTests/InstanceWithSlots.xml +++ b/Uml2OpcuaTransformationTests/InstanceWithSlots.xml @@ -4,38 +4,38 @@ InstanceWithSlots - i=85 - i=35 - i=12 - i=78 - i=47 - i=58 i=40 i=63 - i=37 i=45 + i=37 + i=12 + i=78 i=6 + i=35 + i=58 + i=85 + i=47 - - SN + + Manufacturer BaseDataVariableType ModellingRule_Mandatory ns=1;i=1000 - #000000 + ABB - - Manufacturer + + Axes BaseDataVariableType ModellingRule_Mandatory ns=1;i=1000 - ABB + 6 @@ -46,15 +46,15 @@ ns=1;i=1000 - - Axes + + SN BaseDataVariableType ModellingRule_Mandatory ns=1;i=1000 - 6 + #000000 @@ -67,34 +67,34 @@ ns=1;i=1004 - - Manufacturer + + Description BaseDataVariableType ModellingRule_Mandatory ns=1;i=1005 - - ABB - - - Description + + SN BaseDataVariableType ModellingRule_Mandatory ns=1;i=1005 + + #005001 + - - SN + + Manufacturer BaseDataVariableType ModellingRule_Mandatory ns=1;i=1005 - #005001 + ABB @@ -113,6 +113,10 @@ ns=1;i=1000 ObjectsFolder + ns=1;i=1006 + ns=1;i=1007 + ns=1;i=1008 + ns=1;i=1009 \ No newline at end of file