blob: 2319439a0c51a281e661be6bbe284453778ab950 [file] [log] [blame]
/*
* Copyright (c) 2022 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Pauker (TU Wien) pauker@ift.at
* Thomas Fruhwirth (TU Wien) thomas.fruehwirth@tuwien.ac.at
* Saadia Dhouib (CEA LIST) saadia.dhouib@cea.fr
* Fadwa Tmar (CEA LIST) fadwa.tmar@cea.fr
*******************************************************************************/
library Properties;
import Common.Helpers;
import ClassDiagram.References;
import ClassDiagram.Operations;
//import ClassDiagram.Enumerations;
modeltype UML uses uml('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 "strict" uses 'http://www.eclipse.org/emf/2002/Ecore';
modeltype OPCUA_Robotics_Profile uses 'http://Papyrus/OPCUARoboticsProfile';
helper UML::Class::transformPropertiesAndLinkToUANode(inout uanode : OPCUA::UANode, inout nodeset : OPCUA::UANodeSetType) {
// transform primitive properties of the class
nodeset.uAVariable += self.ownedElement->selectByType(UML::Property)->select(x| x.type.oclIsKindOf(UML::PrimitiveType))->map property2UAVariable(uanode)->asOrderedSet();
//TODO transform primitiveType from OPC UA Library
nodeset.uAVariable += self.ownedElement->selectByType(UML::Property)->select(x| x.type.name.find('Int16') > 0)->map property2UAVariable(uanode)->asOrderedSet();
// transform non-primitive properties of the class
// case 1a: property that represents an instance of a class --> property2UAObject
nodeset.uAObject += self.ownedElement->selectByType(UML::Property)->select(x| x.association = null and x.type.oclIsTypeOf(UML::Class))->map property2UAObject(uanode, nodeset);
// case 1b: property that represents an instance of a state machine --> property2UAObject
nodeset.uAObject += self.ownedElement->selectByType(UML::Property)->select(x| x.association = null and x.type.oclIsTypeOf(UML::StateMachine))->map property2UAObject(uanode, nodeset);
// case 2a: aggregation --> property2UAObject
nodeset.uAObject += self.ownedElement->selectByType(UML::Property)->select(x| x.association <> null and x.aggregation = UML::AggregationKind::composite)->map property2UAObject(uanode, nodeset);
// case 2b: composition --> property2UAObject
nodeset.uAObject += self.ownedElement->selectByType(UML::Property)->select(x| x.association <> null and x.aggregation = UML::AggregationKind::shared)->map property2UAObject(uanode, nodeset);
// case 3: association --> property2UAReference
uanode._references.reference += self.ownedElement->selectByType(UML::Property)->select(x| x.association <> null and x.aggregation = UML::AggregationKind::none)->map property2UAReference(nodeset);
// if the class inherits from another class, also the properties of the parent class need to be added to the uanode
// moved to Classes.qvto and Instances.qvto
/*
if(self.generalization->size() > 0 and self.generalization->asList()->first().general.oclIsTypeOf(UML::Class)) {
self.generalization->asList()->first().general.oclAsType(UML::Class).transformPropertiesAndLinkToUANode(uanode, nodeset);
};
*/
// transform ports typed by primitive types
nodeset.uAVariable += self.ownedElement->selectByType(UML::Port)->select(x| x.type.oclIsKindOf(UML::PrimitiveType))->map port2UAVariable(uanode)->asOrderedSet();
nodeset.uAVariable += self.ownedElement->selectByType(UML::Port)->select(x| x.type.toString().find("Int16")>0)->map port2UAVariable(uanode)->asOrderedSet();
//transform ports typed by enumeration
nodeset.uAVariable += self.ownedElement->selectByType(UML::Port)->select(x| x.type.oclIsKindOf(UML::Enumeration))->map port2UAVariableEnum(uanode,nodeset)->asOrderedSet();
//self.ownedElement->selectByType(UML::Port)->select(x| x.type.oclIsKindOf(UML::Enumeration))->forEach(portTypedByEnumeration){
//}
//TODO transform ports typed by Interface
}
mapping UML::Property::property2UAVariable(inout parent : OPCUA::UANode ) : OPCUA::UAVariable {
log("property2UAVariable for UML element " + self.name);
// set attributs of the OPCUA::UAVariable
nodeId := self.createNodeId(false);
browseName := self.createBrowseName();
displayName := object OPCUA::LocalizedText{value := browseName};
// set the datatype and maybe the value of the UA::Variable
if(self.type.toString().find("Int16") > 0) {
dataType := getIdOrAlias("Int16");
if(self.defaultValue <> null) {
var feature := TYPES::DocumentRoot.oclAsType(EClass).getEStructuralFeature("int16");
value := object OPCUA::ValueType1{};
value.oclAsType(EObject).eSet(feature, self.defaultValue.oclAsType(UML::LiteralInteger).value);
};
} else 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::LiteralString).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 or self.type.toString().find("Double") > 0 or 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
parent._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := nodeId};
parentNodeId := parent.nodeId;
// add references
_references := object OPCUA::ListOfReferences{};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := getIdOrAlias("BaseDataVariableType")};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasModellingRule"); value := getIdOrAlias("ModellingRule_Mandatory")}; // TODO replace with correct modelling rule
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := parent.nodeId; isForward := false};
}
mapping UML::Port::port2UAVariableEnum(inout parent : OPCUA::UANode, inout nodeset : OPCUA::UANodeSetType) : OPCUA::UAVariable {
log("port2UAVariable for UML element " + self.name);
// set attributs of the OPCUA::UAVariable
nodeId := self.createNodeId();
browseName := self.createBrowseName();
displayName := object OPCUA::LocalizedText{value := browseName};
// create the Enumeration UADataType
var enumDataType :OPCUA::UADataType:=self.type.oclAsType(UML::Enumeration)->enumeration2OPCUADataType(nodeset)->asSequence()->first();
nodeset.uADataType+=enumDataType;
// set the datatype and maybe the value of the UA::Variable
log("enum nodeID : "+ enumDataType.nodeId);
dataType :=enumDataType.nodeId;
if(self.defaultValue <> null) {
var feature := TYPES::DocumentRoot.oclAsType(EClass).getEStructuralFeature("int16");
value := object OPCUA::ValueType1{};
value.oclAsType(EObject).eSet(feature, self.defaultValue.oclAsType(UML::LiteralInteger).value);
};
// link the OPCUA::UAVariable to the parent via a HasComponent reference
parent._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := nodeId};
parentNodeId := parent.nodeId;
// add references
_references := object OPCUA::ListOfReferences{};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := getIdOrAlias("BaseDataVariableType")};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasModellingRule"); value := getIdOrAlias("ModellingRule_Mandatory")}; // TODO replace with correct modelling rule
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := parent.nodeId; isForward := false};
}
mapping UML::Port::port2UAVariable(inout parent : OPCUA::UANode) : OPCUA::UAVariable {
log("port2UAVariable for UML element " + self.name);
// set attributs of the OPCUA::UAVariable
nodeId := self.createNodeId(false);
browseName := self.createBrowseName();
displayName := object OPCUA::LocalizedText{value := browseName};
// set the datatype and maybe the value of the UA::Variable
if(self.type.toString().find("Int16") > 0) {
dataType := getIdOrAlias("Int16");
if(self.defaultValue <> null) {
var feature := TYPES::DocumentRoot.oclAsType(EClass).getEStructuralFeature("int16");
value := object OPCUA::ValueType1{};
value.oclAsType(EObject).eSet(feature, self.defaultValue.oclAsType(UML::LiteralInteger).value);
};
} else 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::LiteralString).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 or self.type.toString().find("Double") > 0 or 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
parent._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := nodeId};
parentNodeId := parent.nodeId;
// add references
_references := object OPCUA::ListOfReferences{};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := getIdOrAlias("BaseDataVariableType")};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasModellingRule"); value := getIdOrAlias("ModellingRule_Mandatory")}; // TODO replace with correct modelling rule
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := parent.nodeId; isForward := false};
}
// the property is more complex than a simple primitive type or variable, e.g., it represents some class, state machine, composition or aggregation
mapping UML::Property::property2UAObject(inout parent : OPCUA::UANode, inout nodeset : OPCUA::UANodeSetType) : OPCUA::UAObject {
if(self.name <> null) {
log("property2UAObject for UML element " + self.name);
} else {
log("property2UAObject for unnamed UML element " + self.toString());
};
// set attributs of the OPCUA::UAObject
nodeId := self.createNodeId(false);
if(self.name <> null) { // compositions and aggregations possibly are not named, use the name of the referenced class instead
browseName := self.createBrowseName();
} else {
browseName := self.type.name;
};
displayName := object OPCUA::LocalizedText{value := browseName};
// link the OPCUA::UAObject to the parent via a HasComponent reference
parent._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := nodeId};
parentNodeId := parent.nodeId;
// add references
_references := object OPCUA::ListOfReferences{};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := self.type.createNodeId()}; // it is assumed that the corresponding type (e.g., the class or state machine) is transformed elsewhere
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := parent.nodeId; isForward := false};
// set the modelling rule; note that -1 means infitiy (*); therefore, for 0..* the limits are lower=0 and upper=-1
var modelingRuleReference := object OPCUA::Reference{referenceType := getIdOrAlias("HasModellingRule")};
if(self.lower = 0 and self.upper = 1) {
modelingRuleReference.value := getIdOrAlias("ModellingRule_Optional");
}
else if(self.lower = 1 and self.upper = 1) {
modelingRuleReference.value := getIdOrAlias("ModellingRule_Mandatory");
}
else if(self.lower = 0 and self.upper = -1) {
modelingRuleReference.value := getIdOrAlias("ModellingRule_OptionalPlaceholder");
}
else if(self.lower = 1 and self.upper = -1) {
modelingRuleReference.value := getIdOrAlias("ModellingRule_MandatoryPlaceholder");
};
_references.reference += modelingRuleReference;
// if the property refers to a state machine, the current state variable needs to be added to the opc ua object
// TODO: maybe in the future it would be useful to automatically add all mandatory OPC UA Nodes of all supertypes, e.g. the CurrentState Variable for any custom StateMachineType
// TODO: maybe this should be moved to Classes.qvto and Instances.qvto
if(self.type.oclIsTypeOf(UML::StateMachine)) {
log("property is a state machine");
var currentState := object OPCUA::UAVariable{};
currentState.nodeId := self.createNodeId(false);
currentState.browseName := "CurrentState";
currentState.displayName := object OPCUA::LocalizedText{value := currentState.browseName};
currentState.dataType := getIdOrAlias("LocalizedText");
currentState.parentNodeId := nodeId;
currentState._references := object OPCUA::ListOfReferences{};
currentState._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := nodeId; isForward := false};
currentState._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := getIdOrAlias("FiniteStateVariableType")};
currentState._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasModellingRule"); value := getIdOrAlias("ModellingRule_Mandatory")};
// link the OPCUA::UAVariable currentState to the parent via a HasComponent reference
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := currentState.nodeId};
// add the currentState variable to the nodeset
nodeset.uAVariable += currentState;
// and also add the Id Property of the CurrentStateVariable
var id := object OPCUA::UAVariable{};
id.nodeId := self.createNodeId(false);
id.browseName := "Id";
id.displayName := object OPCUA::LocalizedText{value := currentState.browseName};
id.dataType := getIdOrAlias("NodeId");
id.parentNodeId := currentState.nodeId;
id._references := object OPCUA::ListOfReferences{};
id._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasProperty"); value := currentState.nodeId; isForward := false};
id._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := getIdOrAlias("PropertyType")};
id._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasModellingRule"); value := getIdOrAlias("ModellingRule_Mandatory")};
// link the OPCUA::UAVariable id to the parent via a HasProperty reference
currentState._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasProperty"); value := id.nodeId};
// add the id variable to the nodeset
nodeset.uAVariable += id;
} else {
log("property is not a state machine");
};
}
mapping UML::Property::property2SafetyStateObject(inout safetyStateFolder: OPCUA::UAObject, inout nodeset : OPCUA::UANodeSetType) : OPCUA::UAObject {
if(self.name <> null) {
log("property2UAObject for UML element " + self.name);
} else {
log("property2UAObject for unnamed UML element " + self.toString());
};
// set attributs of the OPCUA::UAObject
nodeId := self.createNodeId(false);
if(self.name <> null) { // compositions and aggregations possibly are not named, use the name of the referenced class instead
browseName := self.createBrowseName();
} else {
browseName := self.type.name;
};
displayName := object OPCUA::LocalizedText{value := browseName};
// link the OPCUA::UAObject to the parent via a HasComponent reference
safetyStateFolder._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := nodeId};
parentNodeId := safetyStateFolder.nodeId;
// add references
//TODO generate ns dinamically
_references := object OPCUA::ListOfReferences{};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "ns=3;i=1013"};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := safetyStateFolder.nodeId; isForward := false};
}
mapping UML::Property::property2MotionDeviceObject(inout motionDevicesFolder: OPCUA::UAObject, inout nodeset : OPCUA::UANodeSetType) : OPCUA::UAObject {
if(self.name <> null) {
log("property2UAObject for UML element " + self.name);
} else {
log("property2UAObject for unnamed UML element " + self.toString());
};
// set attributs of the OPCUA::UAObject
nodeId := self.createNodeId(false);
if(self.name <> null) { // compositions and aggregations possibly are not named, use the name of the referenced class instead
browseName := self.createBrowseName();
} else {
browseName := self.type.name;
};
displayName := object OPCUA::LocalizedText{value := browseName};
// link the OPCUA::UAObject to the parent via a HasComponent reference
motionDevicesFolder._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := nodeId};
parentNodeId := motionDevicesFolder.nodeId;
// add references
//TODO generate ns dinamically
_references := object OPCUA::ListOfReferences{};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "ns=3;i=1004"};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := motionDevicesFolder.nodeId; isForward := false};
//Create a floder Axes and add Axes inside the stereotype properties inside it
var AxesFolder := object OPCUA::UAObject{parentNodeId:=result.nodeId;nodeId := self.createNodeId(false);browseName:="3:Axes"};
AxesFolder._references:= object OPCUA::ListOfReferences{};
AxesFolder._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := getIdOrAlias("FolderType")};
AxesFolder.displayName:= (object OPCUA::LocalizedText {value := "Axes"})->asOrderedSet();
AxesFolder.description:=(object OPCUA::LocalizedText {value := "Axes is a container for one or more instances of the AxisType"})->asOrderedSet();
AxesFolder._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := nodeId};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := AxesFolder.nodeId};
nodeset.uAObject+=AxesFolder;
//add axes to the axesFolder
//TODO make a choice if we apply AxesType on the property or the type or both ?
//Add non CS variables to parameterSet AxisType
//add AxisState
//create Enumeration AxisStateEnumeation as a DataType
//AddAxisStateEnumeration(nodeset,AxisStateEnum, self);
var NewAxisStateEnumeration : UADataType := object OPCUA::UADataType{browseName:="1:AxisStateEnumeration";nodeId := self.createNodeId(false) };
NewAxisStateEnumeration.displayName:=object OPCUA::LocalizedText {value := "AxisStateEnumeration" };
NewAxisStateEnumeration._references:= object OPCUA::ListOfReferences{};
NewAxisStateEnumeration._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasSubtype"); isForward:=false;value := getIdOrAlias("Enumeration")};
var def :DataTypeDefinition:= object OPCUA::DataTypeDefinition{name:="NewAxisStateEnumeration"};
var dataField :DataTypeField:=object OPCUA::DataTypeField{value:= 236; name:="JOINT_SHUTTING_DOWN_MODE" };
def.field+=dataField;
dataField :=object OPCUA::DataTypeField{value:=237 ; name:="JOINT_PART_D_CALIBRATION_MODE" };
def.field+=dataField;
dataField :=object OPCUA::DataTypeField{value:=238 ; name:="JOINT_BACKDRIVE_MODE" };
def.field+=dataField;
dataField :=object OPCUA::DataTypeField{value:=239 ; name:="JOINT_POWER_OFF_MODE" };
def.field+=dataField;
dataField :=object OPCUA::DataTypeField{value:=245 ; name:="JOINT_NOT_RESPONDING_MODE" };
def.field+=dataField;
dataField :=object OPCUA::DataTypeField{value:=246 ; name:="JOINT_MOTOR_INITIALISATION_MODE" };
def.field+=dataField;
dataField :=object OPCUA::DataTypeField{value:=247 ; name:="JOINT_BOOTING_MODE" };
def.field+=dataField;
dataField :=object OPCUA::DataTypeField{value:=248 ; name:="JOINT_PART_D_CALIBRATION_ERROR_MODE" };
def.field+=dataField;
dataField :=object OPCUA::DataTypeField{value:=249 ; name:="JOINT_BOOTLOADER_MODE" };
def.field+=dataField;
dataField :=object OPCUA::DataTypeField{value:=250 ; name:="JOINT_CALIBRATION_MODE" };
def.field+=dataField;
dataField :=object OPCUA::DataTypeField{value:=252 ; name:="JOINT_FAULT_MODE" };
def.field+=dataField;
dataField :=object OPCUA::DataTypeField{value:=253 ; name:="JOINT_RUNNING_MODE" };
def.field+=dataField;
dataField :=object OPCUA::DataTypeField{value:=255 ; name:="JOINT_IDLE_MODE" };
def.field+=dataField;
NewAxisStateEnumeration.definition:=def;
//Add literals
nodeset.uADataType+=NewAxisStateEnumeration;
//create a Varibale "EnumStrings" as a property of the data Enum
var StringVariable := object OPCUA::UAVariable{dataType:=getIdOrAlias("LocalizedText");parentNodeId:=NewAxisStateEnumeration.nodeId;nodeId := self.createNodeId(false);browseName:="EnumStrings"; accessLevel:=3;arrayDimensions:="0";valueRank:=1};
StringVariable._references:= object OPCUA::ListOfReferences{};
StringVariable._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=68"};
StringVariable.displayName:= (object OPCUA::LocalizedText {value := "EnumStrings"})->asOrderedSet();
StringVariable._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasProperty"); isForward:=false; value := NewAxisStateEnumeration.nodeId};
var listLiterals :=object ListOfLocalizedText{
localizedText+= object TYPES::LocalizedText{ text:="JOINT_SHUTTING_DOWN_MODE"; locale:=""};
localizedText+= object TYPES::LocalizedText{ text:="JOINT_PART_D_CALIBRATION_MODE"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="JOINT_BACKDRIVE_MODE"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="JOINT_POWER_OFF_MODE"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="JOINT_NOT_RESPONDING_MODE"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="JOINT_MOTOR_INITIALISATION_MODE"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="JOINT_BOOTING_MODE"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="JOINT_PART_D_CALIBRATION_ERROR_MODE"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="JOINT_BOOTLOADER_MODE"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="JOINT_CALIBRATION_MODE"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="JOINT_FAULT_MODE"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="JOINT_RUNNING_MODE"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="JOINT_IDLE_MODE"; locale:=""};
};
// var setOfEnumString := object OrderedSet(String){};
// setOfEnumString+="JOINT_PART_D_CALIBRATION_MODE";
// setOfEnumString+="JOINT_BACKDRIVE_MODE";
//
var feature := TYPES::DocumentRoot.oclAsType(EClass).getEStructuralFeature("listOfLocalizedText");
StringVariable.value := object OPCUA::ValueType1{};
StringVariable.value.oclAsType(EObject).eSet(feature, listLiterals);
nodeset.uAVariable+=StringVariable;
NewAxisStateEnumeration._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasProperty"); value := StringVariable.nodeId};
nodeset.uAObject+=self.type.ownedElement -> selectByType(UML::Property) -> select(p|(p.getAppliedStereotypes()->exists(s|s.name='AxisType')))-> map property2AxesObject(AxesFolder, nodeset, NewAxisStateEnumeration);
//Create a floder PowerTrains and add PowerTrains inside the stereotype properties inside it
var PowerTrainsFolder := object OPCUA::UAObject{parentNodeId:=result.nodeId;nodeId := self.createNodeId(false);browseName:="3:PowerTrains"};
PowerTrainsFolder._references:= object OPCUA::ListOfReferences{};
PowerTrainsFolder._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := getIdOrAlias("FolderType")};
PowerTrainsFolder.displayName:= (object OPCUA::LocalizedText {value := "PowerTrains"})->asOrderedSet();
PowerTrainsFolder.description:=(object OPCUA::LocalizedText {value := "PowerTrains is a container for one or more instances of the PowerTrainType."})->asOrderedSet();
PowerTrainsFolder._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := nodeId};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := PowerTrainsFolder.nodeId};
nodeset.uAObject+=PowerTrainsFolder;
//add PowerTrains to the PowerTrainsFolder
//TODO make a choice if we apply PowerTrainsType on the property or the type or both ?
nodeset.uAObject+=self.type.ownedElement -> selectByType(UML::Property) -> select(p|(p.getAppliedStereotypes()->exists(s|s.name='PowerTrainType')))-> map property2PowerTrainsObject(PowerTrainsFolder, nodeset);
// create ParameterSet of MotionDeviceType UAObject and add reference to it
var ParameterSet_MotionDeviceType := object OPCUA::UAObject{parentNodeId:=result.nodeId;nodeId := self.createNodeId(false);browseName:="2:ParameterSet"};
ParameterSet_MotionDeviceType._references:= object OPCUA::ListOfReferences{};
ParameterSet_MotionDeviceType._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=58"};
ParameterSet_MotionDeviceType.displayName:= (object OPCUA::LocalizedText {value := "ParameterSet"})->asOrderedSet();
ParameterSet_MotionDeviceType.description:=(object OPCUA::LocalizedText {value := "Flat list of Parameters"})->asOrderedSet();
ParameterSet_MotionDeviceType._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := nodeId};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := ParameterSet_MotionDeviceType.nodeId};
nodeset.uAObject+=ParameterSet_MotionDeviceType;
// var EnumDataType =self.oclAsType(OPCUA_Robotics_Profile::MotionDeviceType).ParameterSetMotionDeviceType.Mode.oclAsType(Property).type.oclAsType(UML::Enumeration)->enumeration2OPCUADataType(nodeset);
log ("enumeration :"+ self.oclAsType(OPCUA_Robotics_Profile::MotionDeviceType).ParameterSetMotionDeviceType.Mode.toString());
addVariableToParameterSet("Mode", "Int16" ,ParameterSet_MotionDeviceType, self, nodeset);
addVariableToParameterSet("RobotIntensity", "Int16" ,ParameterSet_MotionDeviceType, self, nodeset);
addVariableToParameterSet("isPowerButtonPressed", "Boolean" ,ParameterSet_MotionDeviceType, self, nodeset);
addVariableToParameterSet("isTeachButtonPressed", "Boolean" ,ParameterSet_MotionDeviceType, self, nodeset);
addVariableToParameterSet("isPowerOnRobot", "Boolean" ,ParameterSet_MotionDeviceType, self, nodeset);
//ParameterSet_MotionDeviceType.
//Add ModeEnum and varibale to parameterSet
//Add ModeEnumType(nodeset,AxisStateEnum, self);
var NewModeEnumType : UADataType := object OPCUA::UADataType{browseName:="1:ModeEnumType";nodeId := self.createNodeId(false) };
NewModeEnumType.displayName:=object OPCUA::LocalizedText {value := "ModeEnumType" };
NewModeEnumType._references:= object OPCUA::ListOfReferences{};
NewModeEnumType._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasSubtype"); isForward:=false;value := getIdOrAlias("Enumeration")};
var enumDef :DataTypeDefinition:= object OPCUA::DataTypeDefinition{name:="ModeEnumerationType"};
var dataFieldMode :DataTypeField:=object OPCUA::DataTypeField{value:= 236; name:="JOINT_SHUTTING_DOWN_MODE" };
enumDef.field+=dataFieldMode;
dataFieldMode :=object OPCUA::DataTypeField{value:=0 ; name:="DISCONNECTED" };
enumDef.field+=dataFieldMode;
dataFieldMode :=object OPCUA::DataTypeField{value:=1 ; name:="CONFIRM_SAFETY" };
enumDef.field+=dataFieldMode;
dataFieldMode :=object OPCUA::DataTypeField{value:=2 ; name:="BOOTING" };
enumDef.field+=dataFieldMode;
dataFieldMode :=object OPCUA::DataTypeField{value:=3 ; name:="POWER_OFF" };
enumDef.field+=dataFieldMode;
dataFieldMode :=object OPCUA::DataTypeField{value:=4 ; name:="POWER_ON" };
enumDef.field+=dataFieldMode;
dataFieldMode :=object OPCUA::DataTypeField{value:=5 ; name:="IDLE" };
enumDef.field+=dataFieldMode;
dataFieldMode :=object OPCUA::DataTypeField{value:=6 ; name:="BACKDRIVE" };
enumDef.field+=dataFieldMode;
dataFieldMode :=object OPCUA::DataTypeField{value:=7 ; name:="RUNNING" };
enumDef.field+=dataFieldMode;
NewModeEnumType.definition:=enumDef;
//Add literals
nodeset.uADataType+=NewModeEnumType;
//create a Varibale "EnumStrings" as a property of the data Enum
var StringVar := object OPCUA::UAVariable{dataType:=getIdOrAlias("LocalizedText");parentNodeId:=NewModeEnumType.nodeId;nodeId := self.createNodeId(false);browseName:="EnumStrings"; accessLevel:=3;arrayDimensions:="0";valueRank:=1};
StringVar._references:= object OPCUA::ListOfReferences{};
StringVar._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=68"};
StringVar.displayName:= (object OPCUA::LocalizedText {value := "EnumStrings"})->asOrderedSet();
StringVar._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasProperty"); isForward:=false; value := NewModeEnumType.nodeId};
var literalList :=object ListOfLocalizedText{
localizedText+= object TYPES::LocalizedText{ text:="DISCONNECTED"; locale:=""};
localizedText+= object TYPES::LocalizedText{ text:="CONFIRM_SAFETY"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="BOOTING"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="POWER_OFF"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="POWER_ON"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="IDLE"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="BACKDRIVE"; locale:=""};
localizedText+= object TYPES::LocalizedText{text:="RUNNING"; locale:=""};
};
var featurevar := TYPES::DocumentRoot.oclAsType(EClass).getEStructuralFeature("listOfLocalizedText");
StringVar.value := object OPCUA::ValueType1{};
StringVar.value.oclAsType(EObject).eSet(featurevar, literalList);
nodeset.uAVariable+=StringVar;
NewModeEnumType._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasProperty"); value := StringVar.nodeId};
//add modeVarible typed by ModeEnumerateion to ParameterSet of MotionDeviceType
var ModeVariable := object OPCUA::UAVariable{dataType:=NewModeEnumType.nodeId;parentNodeId:=ParameterSet_MotionDeviceType.nodeId;nodeId := self.createNodeId(false);browseName:="1:ModeEnum"; accessLevel:=3};
ModeVariable._references:= object OPCUA::ListOfReferences{};
ModeVariable._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=63"};
ModeVariable.displayName:= (object OPCUA::LocalizedText {value := "ModeEnum"})->asOrderedSet();
ModeVariable._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := ParameterSet_MotionDeviceType.nodeId};
ModeVariable.description:=(object OPCUA::LocalizedText {value := "The ModeVariable variable provides the axis State, it is not a part of CS Robotics."})->asOrderedSet();
nodeset.uAVariable+=ModeVariable;
ParameterSet_MotionDeviceType._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := ModeVariable.nodeId};
}
mapping UML::Property::property2AxesObject(inout parent: OPCUA::UAObject, inout nodeset : OPCUA::UANodeSetType, inout AxisStateEnum : OPCUA::UADataType) : OPCUA::UAObject {
if(self.name <> null) {
log("property2AxesObject for UML element " + self.name);
} else {
log("property2AxesObject for unnamed UML element " + self.toString());
};
// set attributs of the OPCUA::UAObject
nodeId := self.createNodeId();
if(self.name <> null) {
browseName := self.createBrowseName();
} else {
browseName := self.type.name;
};
displayName := object OPCUA::LocalizedText{value := browseName};
// link the OPCUA::UAObject to the parent via a HasComponent reference
parent._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := nodeId};
parentNodeId := parent.nodeId;
// add references
//TODO generate ns dinamically
_references := object OPCUA::ListOfReferences{};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "ns=3;i=16601"};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := parent.nodeId; isForward := false};
// create AdditionalLoad object and add reference to it
var AdditionalLoad := object OPCUA::UAObject{parentNodeId:=result.nodeId;nodeId := self.createNodeId(false);browseName:="3:AdditionalLoad"};
AdditionalLoad._references:= object OPCUA::ListOfReferences{};
AdditionalLoad._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "ns=3;i=1018"};
AdditionalLoad.displayName:= (object OPCUA::LocalizedText {value := "AdditionalLoad"})->asOrderedSet();
AdditionalLoad.description:=(object OPCUA::LocalizedText {value := "The additional load which is mounted on this axis. E.g. for process-need a transformer for welding."})->asOrderedSet();
AdditionalLoad._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := nodeId};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := AdditionalLoad.nodeId};
nodeset.uAObject+=AdditionalLoad;
//add mass UAVariable to the AdditionalLoad
var Mass := object OPCUA::UAVariable{dataType:="Double";parentNodeId:=AdditionalLoad.nodeId;nodeId := self.createNodeId(false);browseName:="3:Mass"; accessLevel:=3};
Mass._references:= object OPCUA::ListOfReferences{};
Mass._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=17497"};
Mass.displayName:= (object OPCUA::LocalizedText {value := "Mass"})->asOrderedSet();
Mass.description:=(object OPCUA::LocalizedText {value := "The weight of the load mounted on one mounting point."})->asOrderedSet();
Mass._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := AdditionalLoad.nodeId};
AdditionalLoad._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := Mass.nodeId};
nodeset.uAVariable+=Mass;
//add EngineeringUnits Variable to Mass
var EngineeringUnits := object OPCUA::UAVariable{dataType:=getIdOrAlias("EUInformation");parentNodeId:=Mass.nodeId;nodeId := self.createNodeId(false);browseName:="EngineeringUnits"; accessLevel:=3};
EngineeringUnits._references:= object OPCUA::ListOfReferences{};
EngineeringUnits._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=68"};
EngineeringUnits.displayName:= (object OPCUA::LocalizedText {value := "EngineeringUnits"})->asOrderedSet();
EngineeringUnits._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := Mass.nodeId};
nodeset.uAVariable+=EngineeringUnits;
Mass._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasProperty"); value := EngineeringUnits.nodeId};
// create MotionProfile UAVariable and add reference to it
var MotionProfile := object OPCUA::UAVariable{dataType:=getIdOrAlias("AxisMotionProfileEnumeration");parentNodeId:=result.nodeId;nodeId := self.createNodeId(false);browseName:="3:MotionProfile"; accessLevel:=3};
MotionProfile._references:= object OPCUA::ListOfReferences{};
MotionProfile._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=68"};
MotionProfile.displayName:= (object OPCUA::LocalizedText {value := "MotionProfile"})->asOrderedSet();
MotionProfile._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := nodeId};
MotionProfile.description:=(object OPCUA::LocalizedText {value := "The kind of axis motion as defined with the AxisMotionProfileEnumeration."})->asOrderedSet();
nodeset.uAVariable+=MotionProfile;
_references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasProperty"); value := MotionProfile.nodeId};
// create ParameterSet of Axes UAObject and add reference to it
var AxesParameterSet := object OPCUA::UAObject{parentNodeId:=result.nodeId;nodeId := self.createNodeId(false);browseName:="2:ParameterSet"};
AxesParameterSet._references:= object OPCUA::ListOfReferences{};
AxesParameterSet._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=58"};
AxesParameterSet.displayName:= (object OPCUA::LocalizedText {value := "ParameterSet"})->asOrderedSet();
AxesParameterSet.description:=(object OPCUA::LocalizedText {value := "Flat list of Parameters"})->asOrderedSet();
AxesParameterSet._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := nodeId};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := AxesParameterSet.nodeId};
nodeset.uAObject+=AxesParameterSet;
// variables ActualSpeed to ParameterSet of Axes
var ActualSpeed := object OPCUA::UAVariable{dataType:=getIdOrAlias("Double");parentNodeId:=AxesParameterSet.nodeId;nodeId := self.createNodeId(false);browseName:="3:ActualSpeed"; accessLevel:=3};
ActualSpeed._references:= object OPCUA::ListOfReferences{};
ActualSpeed._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=17497"};
ActualSpeed.displayName:= (object OPCUA::LocalizedText {value := "ActualSpeed"})->asOrderedSet();
ActualSpeed._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := AxesParameterSet.nodeId};
ActualSpeed.description:=(object OPCUA::LocalizedText {value := "The axis speed on load side (after gear/spindle) inclusive Unit."})->asOrderedSet();
nodeset.uAVariable+=ActualSpeed;
AxesParameterSet._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := ActualSpeed.nodeId};
//add EngineeringUnits_ActualSpeed Variable to ActualSpeed
var EngineeringUnits_ActualSpeed := object OPCUA::UAVariable{dataType:=getIdOrAlias("EUInformation");parentNodeId:=ActualSpeed.nodeId;nodeId := self.createNodeId(false);browseName:="EngineeringUnits"; accessLevel:=3};
EngineeringUnits_ActualSpeed._references:= object OPCUA::ListOfReferences{};
EngineeringUnits_ActualSpeed._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=68"};
EngineeringUnits_ActualSpeed.displayName:= (object OPCUA::LocalizedText {value := "EngineeringUnits"})->asOrderedSet();
EngineeringUnits_ActualSpeed._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := ActualSpeed.nodeId};
nodeset.uAVariable+=EngineeringUnits_ActualSpeed;
ActualSpeed._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasProperty"); value := EngineeringUnits_ActualSpeed.nodeId};
// variables ActualPosition to ParameterSet of Axes
var ActualPosition := object OPCUA::UAVariable{dataType:=getIdOrAlias("Double");parentNodeId:=AxesParameterSet.nodeId;nodeId := self.createNodeId(false);browseName:="3:ActualPosition"; accessLevel:=3};
ActualPosition._references:= object OPCUA::ListOfReferences{};
ActualPosition._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=17497"};
ActualPosition.displayName:= (object OPCUA::LocalizedText {value := "ActualPosition"})->asOrderedSet();
ActualPosition._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := AxesParameterSet.nodeId};
ActualPosition.description:=(object OPCUA::LocalizedText {value := "The axis position inclusive Unit and RangeOfMotion.</"})->asOrderedSet();
nodeset.uAVariable+=ActualPosition;
AxesParameterSet._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := ActualPosition.nodeId};
//add EngineeringUnits_ActualPosition Variable to ActualPosition
var EngineeringUnits_ActualPosition := object OPCUA::UAVariable{dataType:=getIdOrAlias("EUInformation") ;parentNodeId:=ActualPosition.nodeId;nodeId := self.createNodeId(false);browseName:="EngineeringUnits"; accessLevel:=3};
EngineeringUnits_ActualPosition._references:= object OPCUA::ListOfReferences{};
EngineeringUnits_ActualPosition._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=68"};
EngineeringUnits_ActualPosition.displayName:= (object OPCUA::LocalizedText {value := "EngineeringUnits"})->asOrderedSet();
EngineeringUnits_ActualPosition._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := ActualPosition.nodeId};
nodeset.uAVariable+=EngineeringUnits_ActualPosition;
ActualPosition._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasProperty"); value := EngineeringUnits_ActualPosition.nodeId};
// variables ActualAcceleration to ParameterSet of Axes
var ActualAcceleration := object OPCUA::UAVariable{dataType:=getIdOrAlias("Double");parentNodeId:=AxesParameterSet.nodeId;nodeId := self.createNodeId(false);browseName:="3:ActualAcceleration"; accessLevel:=3};
ActualAcceleration._references:= object OPCUA::ListOfReferences{};
ActualAcceleration._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=17497"};
ActualAcceleration.displayName:= (object OPCUA::LocalizedText {value := "ActualAcceleration"})->asOrderedSet();
ActualAcceleration._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := AxesParameterSet.nodeId};
ActualAcceleration.description:=(object OPCUA::LocalizedText {value := "The ActualAcceleration variable provides the axis acceleration. Applicable acceleration limits of the axis shall be provided by the EURange property of the AnalogUnitType."})->asOrderedSet();
nodeset.uAVariable+=ActualAcceleration;
AxesParameterSet._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := ActualAcceleration.nodeId};
//add EngineeringUnits_ActualAcceleration Variable to ActualAcceleration
var EngineeringUnits_ActualAcceleration := object OPCUA::UAVariable{dataType:=getIdOrAlias("EUInformation");parentNodeId:=ActualAcceleration.nodeId;nodeId := self.createNodeId(false);browseName:="EngineeringUnits"; accessLevel:=3};
EngineeringUnits_ActualAcceleration._references:= object OPCUA::ListOfReferences{};
EngineeringUnits_ActualAcceleration._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=68"};
EngineeringUnits_ActualAcceleration.displayName:= (object OPCUA::LocalizedText {value := "EngineeringUnits"})->asOrderedSet();
EngineeringUnits_ActualAcceleration._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := ActualAcceleration.nodeId};
nodeset.uAVariable+=EngineeringUnits_ActualAcceleration;
ActualAcceleration._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasProperty"); value := EngineeringUnits_ActualAcceleration.nodeId};
//Add Property typed by the AxisStateEnumeration to the AxisType or ParameterSet
log("***AxisStateEnum.nodeId : "+AxisStateEnum.toString());
var AxisStateEnumVariable := object OPCUA::UAVariable{dataType:=AxisStateEnum.nodeId;parentNodeId:=AxesParameterSet.nodeId;nodeId := self.createNodeId(false);browseName:="1:AxisStateEnum"; accessLevel:=3};
AxisStateEnumVariable._references:= object OPCUA::ListOfReferences{};
AxisStateEnumVariable._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=63"};
AxisStateEnumVariable.displayName:= (object OPCUA::LocalizedText {value := "AxisStateEnum"})->asOrderedSet();
AxisStateEnumVariable._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := AxesParameterSet.nodeId};
AxisStateEnumVariable.description:=(object OPCUA::LocalizedText {value := "The AxisStateEnumVariable variable provides the axis State, it is not a part of CS Robotics."})->asOrderedSet();
nodeset.uAVariable+=AxisStateEnumVariable;
AxesParameterSet._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := AxisStateEnumVariable.nodeId};
//Add Property typed by the AxisStateInt to the AxisType or ParameterSet
var AxisStateIntVariable := object OPCUA::UAVariable{dataType:=getIdOrAlias("Int16");parentNodeId:=AxesParameterSet.nodeId;nodeId := self.createNodeId(false);browseName:="1:AxisStateInt"; accessLevel:=3};
AxisStateIntVariable._references:= object OPCUA::ListOfReferences{};
AxisStateIntVariable._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=63"};
AxisStateIntVariable.displayName:= (object OPCUA::LocalizedText {value := "AxisStateInt"})->asOrderedSet();
AxisStateIntVariable._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := AxesParameterSet.nodeId};
AxisStateIntVariable.description:=(object OPCUA::LocalizedText {value := "The AxisStateIntVariable variable provides the axis State, it is not a part of CS Robotics."})->asOrderedSet();
nodeset.uAVariable+=AxisStateIntVariable;
AxesParameterSet._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := AxisStateIntVariable.nodeId};
}
mapping UML::Property::property2PowerTrainsObject(inout parent: OPCUA::UAObject, inout nodeset : OPCUA::UANodeSetType) : OPCUA::UAObject {
if(self.name <> null) {
log("property2PowerTrainsObject for UML element " + self.name);
} else {
log("property2PowerTrainsObject for unnamed UML element " + self.toString());
};
// set attributs of the OPCUA::UAObject
nodeId := self.createNodeId();
if(self.name <> null) {
browseName := self.createBrowseName();
} else {
browseName := self.type.name;
};
displayName := object OPCUA::LocalizedText{value := browseName};
// link the OPCUA::UAObject to the parent via a HasComponent reference
parent._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := nodeId};
parentNodeId := parent.nodeId;
// add references
//TODO generate ns dinamically
_references := object OPCUA::ListOfReferences{};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "ns=3;i=16794"};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := parent.nodeId; isForward := false};
description:=(object OPCUA::LocalizedText {value := "PowerTrains is a container for one or more instances of the PowerTrainType."})->asOrderedSet();
// If the powerTrain has a MotorIdentifier
//log("self.getValue: "+self.getValue(self.getAppliedStereotype('OPC_UA_Robotics_CS::PowerTrainType'),'Motor').toString());
//log("self.getValue.oclasType: "+self.getValue(self.getAppliedStereotype('OPC_UA_Robotics_CS::PowerTrainType'),'Motor').oclAsType(OPCUA_Robotics_Profile::MotorType).toString());
if self.hasValue(self.getAppliedStereotype('OPC_UA_Robotics_CS::PowerTrainType'),'Motor') then {
nodeset.uAObject+=self.getValue(self.getAppliedStereotype('OPC_UA_Robotics_CS::PowerTrainType'),'Motor').oclAsType(OPCUA_Robotics_Profile::MotorType) -> map property2MotorIdentifier(result, nodeset);
}endif;
}
mapping OPCUA_Robotics_Profile::MotorType::property2MotorIdentifier(inout parent: OPCUA::UAObject, inout nodeset : OPCUA::UANodeSetType) : OPCUA::UAObject {
if(self.base_Class.name <> null) {
assert error (self.base_Class.name <> null) with log ("property Motor of PowerTrain must be an instance of MotorType = please geev a property isntead of a Block: " + self.base_Class.name.toString());
};
if(self.base_Property.name <> null) {
log("property2MotorIdentifierObject for UML element " + self.base_Property.name);
} else {
log("property2MotorIdentifierObject for unnamed UML element " + self.toString());
};
// set attributs of the OPCUA::UAObject
nodeId := self.base_Property.oclAsType(UML::Element).createNodeId();
browseName := "3:MotorIdentifier";
displayName := object OPCUA::LocalizedText{value := "MotorIdentifier"};
// link the OPCUA::UAObject to the parent via a HasComponent reference
parent._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := nodeId};
parentNodeId := parent.nodeId;
// add references
//TODO generate ns dinamically
_references := object OPCUA::ListOfReferences{};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "ns=3;i=1019"};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := parent.nodeId; isForward := false};
// if (self.Manufacturer<>null ){
// log("Manufacturer is not null"+self.Manufacturer.value);
// var manufacturer := object OPCUA::UAVariable{};
// manufacturer.nodeId := self.base_Class.oclAsType(UML::Element).createNodeId(false);
// manufacturer.browseName := "2:Manufacturer";
// manufacturer.displayName := object OPCUA::LocalizedText{value := "Manufacturer"};
// manufacturer.dataType := getIdOrAlias("LocalizedText");
// manufacturer.parentNodeId := nodeId;
// manufacturer._references := object OPCUA::ListOfReferences{};
// manufacturer._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := nodeId; isForward := false};
// manufacturer._references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=68"};
// var manufacturerLT:= object TYPES::LocalizedText{text :=self.Manufacturer.value};
// //var manufacturerLT2:= object OPCUA::LocalizedText{value :=self.Manufacturer.value};
//
// var feature := TYPES::DocumentRoot.oclAsType(EClass).getEStructuralFeature("localizedText");
// manufacturer.value := object OPCUA::ValueType1{};
// manufacturer.value.oclAsType(EObject).eSet(feature, manufacturerLT);
//
// // link the OPCUA::UAVariable manufacturer to the parent via a HasComponent reference
// _references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := manufacturer.nodeId};
// nodeset.uAVariable+=manufacturer;
// };
// add varibale ParameterSet to MotorIdentifier
// log("*******"+self.toString());
// log("*******"+self.base_Property.oclAsType(UML::Element).toString());
// log("*******"+self.base_Property.oclAsType(UML::Element).createNodeId(false));
var ParameterSet_MotorIdentifier := object OPCUA::UAObject{parentNodeId:=result.nodeId;nodeId :=self.base_Property.oclAsType(UML::Element).createNodeId(false);browseName:="2:ParameterSet"};
ParameterSet_MotorIdentifier._references:= object OPCUA::ListOfReferences{};
ParameterSet_MotorIdentifier._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=58"};
ParameterSet_MotorIdentifier.displayName:= (object OPCUA::LocalizedText {value := "ParameterSet"})->asOrderedSet();
ParameterSet_MotorIdentifier.description:=(object OPCUA::LocalizedText {value := "Flat list of Parameters"})->asOrderedSet();
ParameterSet_MotorIdentifier._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := result.nodeId};
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := ParameterSet_MotorIdentifier.nodeId};
nodeset.uAObject+=ParameterSet_MotorIdentifier;
// variables MotorTemperature to ParameterSet_MotorIdentifier of Axes
var MotorTemperature := object OPCUA::UAVariable{dataType:=getIdOrAlias("Double");parentNodeId:=ParameterSet_MotorIdentifier.nodeId;nodeId := self.base_Property.oclAsType(UML::Element).createNodeId(false);browseName:="3:MotorTemperature"; accessLevel:=3};
MotorTemperature._references:= object OPCUA::ListOfReferences{};
MotorTemperature._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=17497"};
MotorTemperature.displayName:= (object OPCUA::LocalizedText {value := "MotorTemperature"})->asOrderedSet();
MotorTemperature._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := ParameterSet_MotorIdentifier.nodeId};
MotorTemperature.description:=(object OPCUA::LocalizedText {value := "The motor temperature provides the temperature of the motor. If there is no temperature sensor the value is set to \"null\"."})->asOrderedSet();
nodeset.uAVariable+=MotorTemperature;
ParameterSet_MotorIdentifier._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := MotorTemperature.nodeId};
//add EngineeringUnits_MotorTemperature Variable to MotorTemperature
var EngineeringUnits_MotorTemperature := object OPCUA::UAVariable{dataType:=getIdOrAlias("EUInformation");parentNodeId:=MotorTemperature.nodeId;nodeId := self.base_Property.oclAsType(UML::Element).createNodeId(false);browseName:="EngineeringUnits"; accessLevel:=3};
EngineeringUnits_MotorTemperature._references:= object OPCUA::ListOfReferences{};
EngineeringUnits_MotorTemperature._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=68"};
EngineeringUnits_MotorTemperature.displayName:= (object OPCUA::LocalizedText {value := "EngineeringUnits"})->asOrderedSet();
EngineeringUnits_MotorTemperature._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := MotorTemperature.nodeId};
nodeset.uAVariable+=EngineeringUnits_MotorTemperature;
MotorTemperature._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasProperty"); value := EngineeringUnits_MotorTemperature.nodeId};
// ad a non CS robotics variable MotorIntensity to ParameterSet_MotorIdentifier of Axes
var MotorIntensity := object OPCUA::UAVariable{dataType:=getIdOrAlias("Int16");parentNodeId:=ParameterSet_MotorIdentifier.nodeId;nodeId := self.base_Property.oclAsType(UML::Element).createNodeId(false);browseName:="3:MotorIntensity"; accessLevel:=3};
MotorIntensity._references:= object OPCUA::ListOfReferences{};
MotorIntensity._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=17497"};
MotorIntensity.displayName:= (object OPCUA::LocalizedText {value := "MotorIntensity"})->asOrderedSet();
MotorIntensity._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := ParameterSet_MotorIdentifier.nodeId};
MotorIntensity.description:=(object OPCUA::LocalizedText {value := "The motor temperature provides the temperature of the motor. If there is no temperature sensor the value is set to \"null\"."})->asOrderedSet();
nodeset.uAVariable+=MotorIntensity;
ParameterSet_MotorIdentifier._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); value := MotorIntensity.nodeId};
//add EngineeringUnits_MotorIntensity Variable to MotorIntensity
var EngineeringUnits_MotorIntensity := object OPCUA::UAVariable{dataType:=getIdOrAlias("EUInformation");parentNodeId:=MotorIntensity.nodeId;nodeId := self.base_Property.oclAsType(UML::Element).createNodeId(false);browseName:="EngineeringUnits"; accessLevel:=3};
EngineeringUnits_MotorIntensity._references:= object OPCUA::ListOfReferences{};
EngineeringUnits_MotorIntensity._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=68"};
EngineeringUnits_MotorIntensity.displayName:= (object OPCUA::LocalizedText {value := "EngineeringUnits"})->asOrderedSet();
EngineeringUnits_MotorIntensity._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasComponent"); isForward:=false; value := MotorIntensity.nodeId};
nodeset.uAVariable+=EngineeringUnits_MotorIntensity;
MotorIntensity._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasProperty"); value := EngineeringUnits_MotorIntensity.nodeId};
}
mapping UML::Enumeration::enumeration2OPCUADataType(inout nodeset : OPCUA::UANodeSetType) : OPCUA::UADataType {
log("enumeration2OPCUADataType for UML enumeration " + self.name);
// set attributes of the OPCUA::UADataType
browseName := self.createBrowseName();
nodeId := self.createNodeId();
displayName := (object OPCUA::LocalizedText {value := browseName})->asOrderedSet();
//TODO Add mapping rule accourding to th applied stereotypes self.getAppliedStereotypes()
// create the list of references object
_references := object OPCUA::ListOfReferences{};
// if the class has no other supertypes, use the BaseObjectType as supertype
_references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasSubtype"); value := getIdOrAlias("Enumeration"); isForward := false};
// transform properties of the class
// if the class inherits from another class, also the properties of the parent class need to be added to the result
// transform primitive-type-properties of the corresponding class that are not defined as slots
// and repeat this for all superclasses
// transform owned literal to Fields ;
definition:= object DataTypeDefinition{name := self.name;
field+= self.ownedLiteral -> map Literal2OPCUAField()};
//create a Varibale "EnumStrings" as a property of the data Enum
var StringVariable := object OPCUA::UAVariable{dataType:=getIdOrAlias("LocalizedText");parentNodeId:=result.nodeId;nodeId := self.createNodeId(false);browseName:="EnumStrings"; accessLevel:=3;arrayDimensions:="0";valueRank:=1};
StringVariable._references:= object OPCUA::ListOfReferences{};
StringVariable._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasTypeDefinition"); value := "i=68"};
StringVariable.displayName:= (object OPCUA::LocalizedText {value := "EnumStrings"})->asOrderedSet();
StringVariable._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasProperty"); isForward:=false; value := result.nodeId};
//TODO Set the Value of the Variable
// .value.any:=createFeatureMapEntry(TYPES::LocalizedText.oclAsType(StructuralFeature),object TYPES::LocalizedText{text:=self.Manufacturer.value});
// StringVariable.value:= object set::ValueType1{any:= createFeatureMapEntry(text,"") };
nodeset.uAVariable+=StringVariable;
result._references.reference +=object OPCUA::Reference{referenceType := getIdOrAlias("HasProperty"); value := StringVariable.nodeId};
}
mapping UML::EnumerationLiteral::Literal2OPCUAField() : OPCUA::DataTypeField {
name:=self.name;
value:=1;
var l := self.specification;
value:= l.oclAsType(LiteralInteger).value;
//log("name of the LiteralInteger "+l.oclAsType(LiteralInteger).value.oclAsType(UML::PrimitiveType).);
}