Commit f3bb5fe5 authored by Rakshit Mittal's avatar Rakshit Mittal
Browse files

debugged component deinstantiation; refactored rules

parent 7c2987b7
......@@ -36,6 +36,8 @@ import fr.mem4csd.osatedim.viatra.preference.DIMPreferences
import org.osate.aadl2.ModelUnit
import fr.mem4csd.osatedim.viatra.utils.LibraryUtils
import org.osate.aadl2.ModeBinding
import org.osate.aadl2.modelsupport.FileNameConstants
import org.eclipse.emf.common.util.URI
class DIMTransformationDeltaInplace extends DIMTransformationRules{
......@@ -46,22 +48,11 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
this.aadlPublicPackage = topSystemInst.componentClassifier.owner as PublicPackageSection
this.engine = engine
this.preferences = preferences;
componentRules = new DIMTransformationRulesComponent(manipulation)
featureRules = new DIMTransformationRulesFeature(manipulation)
connectionRules = new DIMTransformationRulesConnection(manipulation)
modeRules = new DIMTransformationRulesMode(manipulation)
propertyRules = new DIMTransformationRulesProperty(manipulation)
transformationUtils = new DIMTransformationRulesExtension(manipulation)
prepare(engine)
this.dimResource = topSystemInst.eResource.resourceSet.getResource(URI.createURI("../fr.mem4csd.osatedim.viatra/src/fr/mem4csd/osatedim/viatra/preference/DIM_Properties").appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true).getContents().get(0) as PropertySet;
prepare(engine)
createTransformation
}
DIMTransformationRulesComponent componentRules
DIMTransformationRulesFeature featureRules
DIMTransformationRulesConnection connectionRules
DIMTransformationRulesMode modeRules
DIMTransformationRulesProperty propertyRules
def execute() {
transformation.executionSchema.startUnscheduledExecution
}
......@@ -119,12 +110,12 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val componentInstance2Declarative = createRule(FindSubcomponent.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if (subcompinst.subcomponent === null) {
componentRules.componentInstanceCreatedDIM(subcompinst)
componentInstanceCreatedDIM(subcompinst)
if (preferences.isInheritProperty()) {
transformationUtils.elementCreationPropertyInheritance(subcompinst, propertyRules)
elementCreationPropertyInheritance(subcompinst)
}
if (preferences.isInheritMode()) {
transformationUtils.elementCreationModeInheritance(subcompinst)
elementCreationModeInheritance(subcompinst)
}
println("DIM: Component instance "+subcompinst.name+" de-instantiated")
} else {
......@@ -148,7 +139,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
}
].action(CRUDActivationStateEnum.DELETED) [
changeParentSubcomponentDefinition(subcompinst, subcompinst.eContainer as ComponentInstance)
componentRules.componentInstanceDeletedDIM(subcompinst)
componentInstanceDeletedDIM(subcompinst)
println("DIM: Component instance "+subcompinst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
......@@ -158,9 +149,9 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val featureInstance2Declarative = createRule(FindFeature.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if (featinst.feature === null) {
featureRules.featureInstanceCreatedDIM(featinst)
featureInstanceCreatedDIM(featinst)
if (preferences.isInheritProperty) {
transformationUtils.elementCreationPropertyInheritance(featinst, propertyRules)
elementCreationPropertyInheritance(featinst)
}
println("DIM: Feature instance "+featinst.name+" de-instantiated")
} else {
......@@ -169,7 +160,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
].action(CRUDActivationStateEnum.UPDATED) [
// Feature name change
if (featinst.feature.name !== featinst.name) {
featureRules.featureChangedParentSubcomponentDefinition(featinst)
featureChangedParentSubcomponentDefinition(featinst)
featinst.feature.set(namedElement_Name,featinst.name)
println("DIM: Name of feature instance "+featinst.name+" updated")
}
......@@ -178,7 +169,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
if ((featinst.direction == DirectionType.IN && !((featinst.feature as DirectedFeature).in && !(featinst.feature as DirectedFeature).out)) ||
(featinst.direction == DirectionType.OUT && !(!(featinst.feature as DirectedFeature).in && (featinst.feature as DirectedFeature).out)) ||
(featinst.direction == DirectionType.IN_OUT && !((featinst.feature as DirectedFeature).in && (featinst.feature as DirectedFeature).out))) {
featureRules.featureChangedParentSubcomponentDefinition(featinst)
featureChangedParentSubcomponentDefinition(featinst)
if (featinst.direction == DirectionType.IN) {
featinst.feature.set(directedFeature_In,true)
featinst.feature.set(directedFeature_Out,false)
......@@ -193,8 +184,8 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
}
}
].action(CRUDActivationStateEnum.DELETED) [
featureRules.featureChangedParentSubcomponentDefinition(featinst)
featureRules.featureInstanceDeletedDIM(featinst)
featureChangedParentSubcomponentDefinition(featinst)
featureInstanceDeletedDIM(featinst)
println("DIM: Feature instance "+featinst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
......@@ -204,9 +195,9 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val connectionInstance2Declarative = createRule(FindConnection.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if (conninst.connectionReferences.size < InstanceHierarchyUtils.getPathBetweenComponentInstance(conninst.source.eContainer as ComponentInstance,conninst.destination.eContainer as ComponentInstance).size) {
connectionRules.connectionInstanceCreatedDIM(conninst, featureRules)
connectionInstanceCreatedDIM(conninst)
if (preferences.isInheritProperty) {
transformationUtils.elementCreationPropertyInheritance(conninst, propertyRules)
elementCreationPropertyInheritance(conninst)
}
println("DIM: Connection instance "+conninst.name+" de-instantiated")
} else {
......@@ -216,7 +207,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
println("DIM: WARNING: Connection instance "+conninst.name+" updated. Connection instance update synchronization not supported in OSATE-DIM!")
println("To modify connection instance, delete it and attach a refined connectionInstance at the appropriate location!!")
].action(CRUDActivationStateEnum.DELETED) [
connectionRules.connectionInstanceDeletedDIM(conninst)
connectionInstanceDeletedDIM(conninst)
println("DIM: Connection instance "+conninst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
......@@ -226,7 +217,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val modeInstance2Declarative = createRule(FindMode.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if(modeinst.mode === null) {
modeRules.modeInstanceCreatedDIM(modeinst)
modeInstanceCreatedDIM(modeinst)
println("DIM: Mode instance "+modeinst.name+" de-instantiated")
} else {
println("DIM: Declarative of mode instance "+modeinst.name+" already exists!")
......@@ -234,20 +225,20 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
].action(CRUDActivationStateEnum.UPDATED) [
// Mode name change
if (modeinst.name !== modeinst.mode.name) {
modeRules.modeChangedParentSubcomponentDefinition(modeinst)
modeChangedParentSubcomponentDefinition(modeinst)
modeinst.mode.set(namedElement_Name, modeinst.name)
println("DIM: Name of mode instance "+modeinst.name+" updated")
}
// Mode initial boolean changed
if (modeinst.initial !== modeinst.mode.initial) {
modeRules.modeChangedParentSubcomponentDefinition(modeinst)
modeChangedParentSubcomponentDefinition(modeinst)
modeinst.mode.set(mode_Initial, modeinst.initial)
println("DIM: Initial value of mode instance "+modeinst.name+" updated")
}
// Mode binding added/changed
var compinst = modeinst.eContainer as ComponentInstance
if (modeinst.derived !== compinst.classifier.derivedModes) {
modeRules.modeChangedParentSubcomponentDefinition(modeinst)
modeChangedParentSubcomponentDefinition(modeinst)
if (modeinst.derived == true) {
(modeinst.mode.eContainer as ComponentClassifier).set(componentClassifier_DerivedModes, true)
var modebind = compinst.subcomponent.createChild(subcomponent_OwnedModeBinding, modeBinding)
......@@ -266,7 +257,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
println("DIM: Derived value of mode instance "+modeinst.name+" updated")
}
].action(CRUDActivationStateEnum.DELETED) [
modeRules.modeChangedParentSubcomponentDefinition(modeinst)
modeChangedParentSubcomponentDefinition(modeinst)
(modeinst.mode.eContainer as ComponentClassifier).remove(componentClassifier_OwnedMode, modeinst.mode)
println("DIM: Mode instance "+modeinst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
......@@ -274,13 +265,13 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val derivedModeInstance2Declarative = createRule(FindDerivedMode.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if(modeinst.mode === null) {
modeRules.modeInstanceCreatedDIM(modeinst)
modeInstanceCreatedDIM(modeinst)
println("DIM: Mode instance "+modeinst.name+" de-instantiated")
} else {
println("DIM: Declarative of mode instance "+modeinst.name+" already exists!")
}
].action(CRUDActivationStateEnum.UPDATED) [
modeRules.modeChangedParentSubcomponentDefinition(modeinst)
modeChangedParentSubcomponentDefinition(modeinst)
// Mode name change
if (modeinst.name !== modeinst.mode.name) {
modeinst.mode.set(namedElement_Name, modeinst.name)
......@@ -312,7 +303,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
println("DIM: Derived value of mode instance "+modeinst.name+" updated")
}
].action(CRUDActivationStateEnum.DELETED) [
modeRules.modeChangedParentSubcomponentDefinition(modeinst)
modeChangedParentSubcomponentDefinition(modeinst)
(modeinst.mode.eContainer as ComponentClassifier).remove(componentClassifier_OwnedMode, modeinst.mode)
println("DIM: Mode instance "+modeinst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
......@@ -323,16 +314,16 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val modeTransitionInstance2Declarative = createRule(FindModeTransition.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if(modetransinst.modeTransition === null) {
modeRules.modeTransitionInstanceCreatedDIM(modetransinst)
modeTransitionInstanceCreatedDIM(modetransinst)
if (preferences.isInheritProperty) {
transformationUtils.elementCreationPropertyInheritance(modetransinst, propertyRules)
elementCreationPropertyInheritance(modetransinst)
}
println("DIM: ModeTransition instance "+modetransinst.name+" de-instantiated")
} else {
println("DIM: Declarative of mode transition instance "+modetransinst.name+" already exists!")
}
].action(CRUDActivationStateEnum.UPDATED) [
modeRules.modeTransChangedParentSubcomponentDefinition(modetransinst)
modeTransChangedParentSubcomponentDefinition(modetransinst)
// Mode transition name change
if (modetransinst.name !== modetransinst.modeTransition.name) {
modetransinst.modeTransition.set(namedElement_Name, modetransinst.name)
......@@ -349,7 +340,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
println("DIM: Destination of mode transition instance "+modetransinst.name+" updated")
}
].action(CRUDActivationStateEnum.DELETED) [
modeRules.modeTransChangedParentSubcomponentDefinition(modetransinst)
modeTransChangedParentSubcomponentDefinition(modetransinst)
(modetransinst.modeTransition.eContainer as ComponentClassifier).remove(componentClassifier_OwnedModeTransition, modetransinst.modeTransition)
println("DIM: ModeTransition instance "+modetransinst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
......@@ -361,7 +352,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
.action(CRUDActivationStateEnum.CREATED) [
if(propinst.propertyAssociation === null) {
if (!PropertyUtils.isInheritedProperty(propinst)) {
propertyRules.propertyInstanceCreatedDIM(propinst, aadlPublicPackage)
propertyInstanceCreatedDIM(propinst, aadlPublicPackage)
println("DIM: Property instance "+propinst.property.name+" de-instantiated")
} else {
println("DIM: Property instance "+propinst.property.name+" inherited")
......@@ -388,7 +379,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val modalProperty2Declarative = createRule(FindModalProperty.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
propertyRules.modalPropertyCreatedDIM(modpropinst)
modalPropertyCreatedDIM(modpropinst)
].action(CRUDActivationStateEnum.UPDATED) [
// ModalPropertyValue inModes
if (!(modpropinst.inModes.isEmpty())) {
......@@ -404,13 +395,13 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val propertyval2declarative = createRule(FindPropertyValue.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED)[
propertyRules.propertyValueCreatedDIM(propinst, modpropinst, propvalinst)
propertyValueCreatedDIM(propinst, modpropinst, propvalinst)
].action(CRUDActivationStateEnum.UPDATED) [
if (PropertyUtils.isInheritedProperty(PropertyUtils.getContainingPropertyAssociationInstance(propvalinst))) {
propertyRules.propertyInstanceCreatedDIM(PropertyUtils.getContainingPropertyAssociationInstance(propvalinst), aadlPublicPackage)
propertyInstanceCreatedDIM(PropertyUtils.getContainingPropertyAssociationInstance(propvalinst), aadlPublicPackage)
println("DIM: Inherited property instance "+PropertyUtils.getContainingPropertyAssociationInstance(propvalinst).property.name+" value updated")
} else {
propertyRules.propertyValueUpdatedDIM(propvalinst, aadlPublicPackage)
propertyValueUpdatedDIM(propvalinst, aadlPublicPackage)
println("DIM: Property instance "+PropertyUtils.getContainingPropertyAssociationInstance(propvalinst).property.name+" value updated")
}
].addLifeCycle(Lifecycles.getDefault(true, true)).build
......
package fr.mem4csd.osatedim.viatra.transformations
import org.osate.aadl2.instance.ConnectionInstance
import fr.mem4csd.osatedim.viatra.utils.InstanceHierarchyUtils
import org.osate.aadl2.instance.ComponentInstance
import org.osate.aadl2.instance.FeatureInstance
import org.osate.aadl2.ComponentImplementation
import org.osate.aadl2.instance.ConnectionKind
import org.osate.aadl2.Feature
import org.osate.aadl2.instance.ConnectionReference
import org.osate.aadl2.ComponentCategory
import org.osate.aadl2.ComponentType
import org.osate.aadl2.DirectionType
import fr.mem4csd.osatedim.viatra.utils.LibraryUtils
import org.osate.aadl2.ModelUnit
import org.eclipse.emf.ecore.util.EcoreUtil
import org.eclipse.viatra.transformation.runtime.emf.modelmanipulation.IModelManipulations
import org.eclipse.emf.common.util.EList
import org.osate.aadl2.ComponentClassifier
class DIMTransformationRulesConnection extends DIMTransformationRules {
new(IModelManipulations manipulation) {
this.manipulation = manipulation
}
extension IModelManipulations manipulation
protected def connectionInstanceCreatedDIM(ConnectionInstance conninst, DIMTransformationRulesFeature featureRules) {
var complist = InstanceHierarchyUtils.getPathBetweenComponentInstance(conninst.source.eContainer as ComponentInstance,conninst.destination.eContainer as ComponentInstance)
for (ComponentInstance currentcompinst : complist) {
// Source Feature Selection
var currentsrcfeat = {
if (complist.indexOf(currentcompinst) == 0) {
(conninst.source as FeatureInstance).feature
} else {
(conninst.connectionReferences.get(conninst.connectionReferences.size - 1).destination as FeatureInstance).feature
}
}
// Destination Feature Selection/Creation
var ComponentInstance feataddcompinst
var currentdestfeat = {
if (complist.indexOf(currentcompinst) == complist.size-1) {
(conninst.destination as FeatureInstance).feature
} else {
feataddcompinst = {
if (complist.get(complist.indexOf(currentcompinst)+1).eContainer() == currentcompinst) {
complist.get(complist.indexOf(currentcompinst)+1)
} else {
currentcompinst
}
}
// Destination FeatureInstance Creation
var currentdestfeatinst = feataddcompinst.createChild(componentInstance_FeatureInstance,featureInstance) as FeatureInstance
currentdestfeatinst.set(featureInstance_Category, (conninst.source as FeatureInstance).category)
currentdestfeatinst.set(featureInstance_Direction, DirectionType.IN_OUT)
currentdestfeatinst.set(namedElement_Name, conninst.name+"_feat")
featureRules.featureInstanceCreatedDIM(currentdestfeatinst)
currentdestfeatinst.feature
}
}
// Parent Component Implementation Creation
if (currentcompinst !== topSystemInst) {
if (currentcompinst.classifier instanceof ComponentType || (LibraryUtils.isLibraryClassifier(currentcompinst.classifier, aadlPublicPackage) || (LibraryUtils.isReusedClassifier(currentcompinst.classifier,engine) && !preferences.modifyReused))) {
var compimp = {
switch (currentcompinst.category) {
case ComponentCategory.ABSTRACT : aadlPublicPackage.createChild(packageSection_OwnedClassifier,abstractImplementation)
case ComponentCategory.BUS : aadlPublicPackage.createChild(packageSection_OwnedClassifier,busImplementation)
case ComponentCategory.DATA : aadlPublicPackage.createChild(packageSection_OwnedClassifier,dataImplementation)
case ComponentCategory.DEVICE : aadlPublicPackage.createChild(packageSection_OwnedClassifier,deviceImplementation)
case ComponentCategory.MEMORY : aadlPublicPackage.createChild(packageSection_OwnedClassifier,memoryImplementation)
case ComponentCategory.PROCESS : aadlPublicPackage.createChild(packageSection_OwnedClassifier,processImplementation)
case ComponentCategory.PROCESSOR : aadlPublicPackage.createChild(packageSection_OwnedClassifier,processorImplementation)
case ComponentCategory.SUBPROGRAM : aadlPublicPackage.createChild(packageSection_OwnedClassifier,subprogramImplementation)
case ComponentCategory.SUBPROGRAM_GROUP : aadlPublicPackage.createChild(packageSection_OwnedClassifier,subprogramGroupImplementation)
case ComponentCategory.SYSTEM : aadlPublicPackage.createChild(packageSection_OwnedClassifier,systemImplementation)
case ComponentCategory.THREAD : aadlPublicPackage.createChild(packageSection_OwnedClassifier,threadImplementation)
case ComponentCategory.THREAD_GROUP : aadlPublicPackage.createChild(packageSection_OwnedClassifier,threadGroupImplementation)
case ComponentCategory.VIRTUAL_BUS : aadlPublicPackage.createChild(packageSection_OwnedClassifier,virtualBusImplementation)
case ComponentCategory.VIRTUAL_PROCESSOR : aadlPublicPackage.createChild(packageSection_OwnedClassifier,virtualProcessorImplementation)
}
} as ComponentImplementation
transformationUtils.classifierCreationDIMPropertyAddition(compimp)
compimp.set(namedElement_Name, currentcompinst.name+".impl")
if (currentcompinst.classifier instanceof ComponentType) {
compimp.set(componentImplementation_Type, currentcompinst.classifier)
} else {
compimp.set(componentImplementation_Extended, currentcompinst.classifier)
}
if (LibraryUtils.isLibraryClassifier(currentcompinst.classifier, aadlPublicPackage)) {
aadlPublicPackage.add(packageSection_ImportedUnit, currentcompinst.classifier.eContainer.eContainer as ModelUnit)
}
currentcompinst.set(componentInstance_Classifier, compimp)
changeParentSubcomponentDefinition(currentcompinst, currentcompinst.eContainer as ComponentInstance)
}
}
// Connection Creation
var connadd = {
switch (conninst.kind) {
case ConnectionKind.ACCESS_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedAccessConnection, accessConnection)
case ConnectionKind.FEATURE_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedFeatureConnection, featureConnection)
case ConnectionKind.FEATURE_GROUP_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedFeatureGroupConnection, featureGroupConnection)
case ConnectionKind.PARAMETER_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedParameterConnection, parameterConnection)
case ConnectionKind.PORT_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedPortConnection, portConnection)
default : null
}
}
connadd.set(namedElement_Name, currentsrcfeat.name+"_"+(currentdestfeat as Feature).name)
var connaddsrcelem = connadd.createChild(connection_Source,connectedElement)
connaddsrcelem.set(connectedElement_ConnectionEnd, currentsrcfeat)
if (complist.indexOf(currentcompinst) == 0) {
connaddsrcelem.set(connectedElement_Context, (conninst.source.eContainer as ComponentInstance).subcomponent)
} else {
connaddsrcelem.set(connectedElement_Context, (conninst.connectionReferences.get(conninst.connectionReferences.size - 1).destination.eContainer as ComponentInstance).subcomponent)
}
var connadddestelem = connadd.createChild(connection_Destination,connectedElement)
connadddestelem.set(connectedElement_ConnectionEnd, currentdestfeat)
if (complist.indexOf(currentcompinst) == complist.size-1) {
connadddestelem.set(connectedElement_Context,(conninst.destination.eContainer as ComponentInstance).subcomponent)
} else if (complist.get(complist.indexOf(currentcompinst)+1).eContainer() == currentcompinst) {
connadddestelem.set(connectedElement_Context,complist.get(complist.indexOf(currentcompinst)+1).subcomponent)
} else {
connadddestelem.set(connectedElement_Context,currentcompinst.subcomponent)
}
connadd.set(connection_Bidirectional, conninst.bidirectional)
// Trace Creation
var connref = conninst.createChild(connectionInstance_ConnectionReference, connectionReference)
connref.set(connectionReference_Connection,connadd)
connref.set(connectionReference_Context,currentcompinst)
connref.set(connectionReference_Reverse, false)
connref.set(connectionReference_Source,conninst.source)
connref.set(connectionReference_Destination,conninst.destination)
}
}
protected def connectionInstanceFoundDIM(ConnectionInstance conninst) {
for (ConnectionReference connref: conninst.connectionReferences) {
var currentsrcfeat = (connref.source as FeatureInstance).feature
var currentdestfeat = (connref.destination as FeatureInstance).feature
var currentcompinst = connref.context
// ComponentImplementationCreation
if (currentcompinst.classifier instanceof ComponentType) {
var compimp = {
switch (currentcompinst.category) {
case ComponentCategory.ABSTRACT : aadlPackage.createChild(packageSection_OwnedClassifier,abstractImplementation)
case ComponentCategory.BUS : aadlPackage.createChild(packageSection_OwnedClassifier,busImplementation)
case ComponentCategory.DATA : aadlPackage.createChild(packageSection_OwnedClassifier,dataImplementation)
case ComponentCategory.DEVICE : aadlPackage.createChild(packageSection_OwnedClassifier,deviceImplementation)
case ComponentCategory.MEMORY : aadlPackage.createChild(packageSection_OwnedClassifier,memoryImplementation)
case ComponentCategory.PROCESS : aadlPackage.createChild(packageSection_OwnedClassifier,processImplementation)
case ComponentCategory.PROCESSOR : aadlPackage.createChild(packageSection_OwnedClassifier,processorImplementation)
case ComponentCategory.SUBPROGRAM : aadlPackage.createChild(packageSection_OwnedClassifier,subprogramImplementation)
case ComponentCategory.SUBPROGRAM_GROUP : aadlPackage.createChild(packageSection_OwnedClassifier,subprogramGroupImplementation)
case ComponentCategory.SYSTEM : aadlPackage.createChild(packageSection_OwnedClassifier,systemImplementation)
case ComponentCategory.THREAD : aadlPackage.createChild(packageSection_OwnedClassifier,threadImplementation)
case ComponentCategory.THREAD_GROUP : aadlPackage.createChild(packageSection_OwnedClassifier,threadGroupImplementation)
case ComponentCategory.VIRTUAL_BUS : aadlPackage.createChild(packageSection_OwnedClassifier,virtualBusImplementation)
case ComponentCategory.VIRTUAL_PROCESSOR : aadlPackage.createChild(packageSection_OwnedClassifier,virtualProcessorImplementation)
}
} as ComponentImplementation
transformationUtils.classifierCreationDIMPropertyAddition(compimp)
compimp.set(namedElement_Name, currentcompinst.classifier.name+".impl")
compimp.set(componentImplementation_Type,currentcompinst.classifier)
currentcompinst.set(componentInstance_Classifier, compimp)
switch (currentcompinst.category) {
case ComponentCategory.ABSTRACT : currentcompinst.subcomponent.set(abstractSubcomponent_AbstractSubcomponentType, compimp)
case ComponentCategory.BUS : currentcompinst.subcomponent.set(busSubcomponent_BusSubcomponentType, compimp)
case ComponentCategory.DATA : currentcompinst.subcomponent.set(dataSubcomponent_DataSubcomponentType, compimp)
case ComponentCategory.DEVICE : currentcompinst.subcomponent.set(deviceSubcomponent_DeviceSubcomponentType, compimp)
case ComponentCategory.MEMORY : currentcompinst.subcomponent.set(memorySubcomponent_MemorySubcomponentType, compimp)
case ComponentCategory.PROCESS : currentcompinst.subcomponent.set(processSubcomponent_ProcessSubcomponentType, compimp)
case ComponentCategory.PROCESSOR : currentcompinst.subcomponent.set(processorSubcomponent_ProcessorSubcomponentType, compimp)
case ComponentCategory.SUBPROGRAM : currentcompinst.subcomponent.set(subprogramSubcomponent_SubprogramSubcomponentType, compimp)
case ComponentCategory.SUBPROGRAM_GROUP : currentcompinst.subcomponent.set(subprogramGroupSubcomponent_SubprogramGroupSubcomponentType, compimp)
case ComponentCategory.SYSTEM : currentcompinst.subcomponent.set(systemSubcomponent_SystemSubcomponentType, compimp)
case ComponentCategory.THREAD : currentcompinst.subcomponent.set(threadSubcomponent_ThreadSubcomponentType, compimp)
case ComponentCategory.THREAD_GROUP : currentcompinst.subcomponent.set(threadGroupSubcomponent_ThreadGroupSubcomponentType, compimp)
case ComponentCategory.VIRTUAL_BUS : currentcompinst.subcomponent.set(virtualBusSubcomponent_VirtualBusSubcomponentType, compimp)
case ComponentCategory.VIRTUAL_PROCESSOR : currentcompinst.subcomponent.set(virtualProcessorSubcomponent_VirtualProcessorSubcomponentType, compimp)
}
}
var connadd = {
switch (conninst.kind) {
case ConnectionKind.ACCESS_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedAccessConnection, accessConnection)
case ConnectionKind.FEATURE_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedFeatureConnection, featureConnection)
case ConnectionKind.FEATURE_GROUP_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedFeatureGroupConnection, featureGroupConnection)
case ConnectionKind.PARAMETER_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedParameterConnection, parameterConnection)
case ConnectionKind.PORT_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedPortConnection, portConnection)
default : null
}
}
connadd.set(namedElement_Name, (connref.source.eContainer as ComponentInstance).name+"_"+connref.source.name+"_"+(connref.destination.eContainer as ComponentInstance).name+"_"+connref.destination.name)
connadd.set(connection_Bidirectional, conninst.bidirectional)
var connaddsrcelem = connadd.createChild(connection_Source, connectedElement)
connaddsrcelem.set(connectedElement_ConnectionEnd, currentsrcfeat)
if (connref.source.eContainer != connref.context) {
connaddsrcelem.set(connectedElement_Context, (connref.source.eContainer as ComponentInstance).subcomponent)
}
var connadddestelem = connadd.createChild(connection_Destination, connectedElement)
connadddestelem.set(connectedElement_ConnectionEnd, currentdestfeat)
if (connref.destination.eContainer != connref.context) {
connadddestelem.set(connectedElement_Context, (connref.destination.eContainer as ComponentInstance).subcomponent)
}
// Trace Creation
connref.set(connectionReference_Connection,connadd)
}
}
protected def connectionInstanceDeletedDIM (ConnectionInstance conninst) {
for (connref : conninst.connectionReferences) {
var currentcompinst = connref.context
connectionDeletedParentSubcomponentDefinition(connref)
switch (conninst.kind) {
case ConnectionKind.ACCESS_CONNECTION : (currentcompinst.classifier as ComponentImplementation).remove(componentImplementation_OwnedAccessConnection, connref.connection)
case ConnectionKind.FEATURE_CONNECTION : (currentcompinst.classifier as ComponentImplementation).remove(componentImplementation_OwnedFeatureConnection, connref.connection)
case ConnectionKind.FEATURE_GROUP_CONNECTION : (currentcompinst.classifier as ComponentImplementation).remove(componentImplementation_OwnedFeatureGroupConnection, connref.connection)
case ConnectionKind.PARAMETER_CONNECTION : (currentcompinst.classifier as ComponentImplementation).remove(componentImplementation_OwnedParameterConnection, connref.connection)
case ConnectionKind.PORT_CONNECTION : (currentcompinst.classifier as ComponentImplementation).remove(componentImplementation_OwnedPortConnection, connref.connection)
default: {}
}
}
}
protected def connectionDeletedParentSubcomponentDefinition(ConnectionReference connref) {
var compinst = connref.context as ComponentInstance
var EList<? extends ComponentClassifier> extensionList = LibraryUtils.getAllInheritingParentImplementations(connref.connection, compinst)
var libraryIndex = LibraryUtils.getClosestLibraryImplementationIndex(extensionList, aadlPublicPackage)
var reusedIndex = LibraryUtils.getClosestReusedClassifierIndex(extensionList, engine)
var extensionIndex = {
if (preferences.modifyReused) {
libraryIndex
} else {
if (libraryIndex == -1) {
reusedIndex
} else if (reusedIndex == -1) {
libraryIndex
} else {
Math.min(reusedIndex, libraryIndex)
}
}
}
if (extensionIndex != -1) {
var ComponentImplementation previousImp
for (ComponentClassifier currentcompimp : extensionList.reverse) {
if (extensionList.indexOf(currentcompimp) < extensionList.size - extensionIndex) {
var compimpcopy = EcoreUtil.copy(currentcompimp) as ComponentImplementation
transformationUtils.classifierCreationDIMPropertyAddition(compimpcopy)
aadlPublicPackage.add(packageSection_OwnedClassifier, compimpcopy)
compimpcopy.set(namedElement_Name,currentcompimp.name+"_dimcopy")
if(extensionList.indexOf(currentcompimp) == 0) {
var newConn = LibraryUtils.getCopyConnection(connref.connection, compimpcopy)
connref.set(connectionReference_Connection, newConn)
} else {
compimpcopy.set(componentImplementation_Extended, previousImp)
}
previousImp = compimpcopy
} else {
if (compinst == topSystemInst || !LibraryUtils.isAffectingSubcomponent(compinst.subcomponent,compinst.eContainer as ComponentInstance,aadlPublicPackage, engine, preferences.modifyReused)) {
if (extensionList.indexOf(currentcompimp) == extensionList.size - extensionIndex) {
currentcompimp.set(componentImplementation_Extended, previousImp)
}
} else {
var compimpcopy = EcoreUtil.copy(currentcompimp) as ComponentImplementation
transformationUtils.classifierCreationDIMPropertyAddition(compimpcopy)
aadlPublicPackage.add(packageSection_OwnedClassifier, compimpcopy)
compimpcopy.set(namedElement_Name,currentcompimp.name+"_dimcopy")
compimpcopy.set(componentImplementation_Extended, previousImp)
previousImp = compimpcopy
if (extensionList.indexOf(currentcompimp) === extensionList.size - 1) {
compinst.set(componentInstance_Classifier, compimpcopy)
changeParentSubcomponentDefinition(compinst, compinst.eContainer as ComponentInstance)
}
}
}
}
} else if (compinst != topSystemInst &a