diff --git a/QvtoTransformationRules/transforms/ClassDiagram/Classes.qvto b/QvtoTransformationRules/transforms/ClassDiagram/Classes.qvto
index bd47239..5abf1f9 100644
--- a/QvtoTransformationRules/transforms/ClassDiagram/Classes.qvto
+++ b/QvtoTransformationRules/transforms/ClassDiagram/Classes.qvto
@@ -5,6 +5,7 @@ import ClassDiagram.Operations;
modeltype UML uses 'http://www.eclipse.org/uml2/5.0.0/UML';
modeltype OPCUA uses set('http://opcfoundation.org/UA/2011/03/UANodeSet.xsd');
+modeltype TYPES uses types('http://opcfoundation.org/UA/2008/02/Types.xsd');
modeltype ECORE uses ecore('http://www.eclipse.org/emf/2002/Ecore');
mapping UML::Class::class2OPCUAObjectType(inout nodeset : OPCUA::UANodeSetType) : OPCUA::UAObjectType {
@@ -44,26 +45,51 @@ mapping UML::Property::property2UAVariable(inout parent : OPCUA::UANode) : OPCUA
browseName := self.createBrowseName();
displayName := object OPCUA::LocalizedText{value := browseName};
- // set the datatype of the UA::Variable
- switch {
- case (self.type.toString().find("Integer") > 0) {
- dataType := getIdOrAlias("Int32"); // do not use getIdentifier here
- }
- case (self.type.toString().find("String") > 0) {
- dataType := getIdOrAlias("String"); // do not use getIdentifier here
- }
- case (self.type.toString().find("Real") > 0) {
- dataType := getIdOrAlias("Double"); // do not use getIdentifier here
- }
- case (self.type.toString().find("Float") > 0) {
- dataType := getIdOrAlias("Double"); // do not use getIdentifier here
- }
- case (self.type.toString().find("Boolean") > 0) {
- dataType := getIdOrAlias("Boolean"); // do not use getIdentifier here
- }
- else {
- raise Exception("Unkown datatype for parameter " + self.name + ": " + self.type.toString());
- }
+ // set the datatype and maybe the value of the UA::Variable
+ if(self.type.toString().find("Int") > 0) {
+ dataType := getIdOrAlias("Int32");
+ if(self.defaultValue <> null) {
+ var feature := TYPES::DocumentRoot.oclAsType(EClass).getEStructuralFeature("int32");
+ value := object OPCUA::ValueType1{};
+ value.oclAsType(EObject).eSet(feature, self.defaultValue.oclAsType(UML::LiteralInteger).value);
+ };
+ } else if (self.type.toString().find("String") > 0) {
+ dataType := getIdOrAlias("String");
+ if(self.defaultValue <> null) {
+ var feature := TYPES::DocumentRoot.oclAsType(EClass).getEStructuralFeature("string");
+ value := object OPCUA::ValueType1{};
+ value.oclAsType(EObject).eSet(feature, self.defaultValue.oclAsType(UML::LiteralString).value);
+ };
+ } else if (self.type.toString().find("Real") > 0) {
+ dataType := getIdOrAlias("Double");
+ if(self.defaultValue <> null) {
+ var feature := TYPES::DocumentRoot.oclAsType(EClass).getEStructuralFeature("double");
+ value := object OPCUA::ValueType1{};
+ value.oclAsType(EObject).eSet(feature, self.defaultValue.oclAsType(UML::LiteralReal).value);
+ };
+ } else if (self.type.toString().find("Double") > 0) {
+ dataType := getIdOrAlias("Double");
+ if(self.defaultValue <> null) {
+ var feature := TYPES::DocumentRoot.oclAsType(EClass).getEStructuralFeature("double");
+ value := object OPCUA::ValueType1{};
+ value.oclAsType(EObject).eSet(feature, self.defaultValue.oclAsType(UML::LiteralReal).value);
+ };
+ } else if (self.type.toString().find("Float") > 0) {
+ dataType := getIdOrAlias("Double");
+ if(self.defaultValue <> null) {
+ var feature := TYPES::DocumentRoot.oclAsType(EClass).getEStructuralFeature("double");
+ value := object OPCUA::ValueType1{};
+ value.oclAsType(EObject).eSet(feature, self.defaultValue.oclAsType(UML::LiteralReal).value);
+ };
+ } else if (self.type.toString().find("Boolean") > 0) {
+ dataType := getIdOrAlias("Boolean");
+ if(self.defaultValue <> null) {
+ var feature := TYPES::DocumentRoot.oclAsType(EClass).getEStructuralFeature("boolean");
+ value := object OPCUA::ValueType1{};
+ value.oclAsType(EObject).eSet(feature, self.defaultValue.oclAsType(UML::LiteralBoolean).value);
+ };
+ } else {
+ raise Exception("Unkown datatype for parameter " + self.name + ": " + self.type.toString());
};
// link the OPCUA::UAVariable to the parent via a HasComponent reference
diff --git a/Uml2OpcuaTransformationTests/PropertyDefaultValue.di b/Uml2OpcuaTransformationTests/PropertyDefaultValue.di
new file mode 100644
index 0000000..8c549ee
--- /dev/null
+++ b/Uml2OpcuaTransformationTests/PropertyDefaultValue.di
@@ -0,0 +1,2 @@
+
+
diff --git a/Uml2OpcuaTransformationTests/PropertyDefaultValue.notation b/Uml2OpcuaTransformationTests/PropertyDefaultValue.notation
new file mode 100644
index 0000000..13732d0
--- /dev/null
+++ b/Uml2OpcuaTransformationTests/PropertyDefaultValue.notation
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Uml2OpcuaTransformationTests/PropertyDefaultValue.uml b/Uml2OpcuaTransformationTests/PropertyDefaultValue.uml
new file mode 100644
index 0000000..ef3d733
--- /dev/null
+++ b/Uml2OpcuaTransformationTests/PropertyDefaultValue.uml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Uml2OpcuaTransformationTests/PropertyDefaultValue.xml b/Uml2OpcuaTransformationTests/PropertyDefaultValue.xml
new file mode 100644
index 0000000..951a144
--- /dev/null
+++ b/Uml2OpcuaTransformationTests/PropertyDefaultValue.xml
@@ -0,0 +1,34 @@
+
+
+
+ PropertyString
+
+
+ i=12
+ i=37
+ i=63
+ i=40
+ i=47
+ i=45
+ i=58
+ i=78
+
+
+ myProperty
+
+ BaseDataVariableType
+ ModellingRule_Mandatory
+ ns=1;s=RobotType
+
+
+ SomeDefaultValueString
+
+
+
+ RobotType
+
+ BaseObjectType
+ ns=1;s=myProperty
+
+
+
\ No newline at end of file