Commit 66847ec3 authored by Rakshit Mittal's avatar Rakshit Mittal
Browse files

added library support to avoid changes made to library-based classifiers

parent fe36eec1
......@@ -33,15 +33,17 @@ import org.osate.aadl2.ModalPropertyValue
import org.osate.aadl2.modelsupport.util.AadlUtil
import org.osate.aadl2.PropertySet
import fr.mem4csd.osatedim.viatra.preference.DIMPreferences
import org.osate.aadl2.ModelUnit
import fr.mem4csd.osatedim.viatra.utils.LibraryUtils
import org.osate.aadl2.ModeBinding
class DIMTransformationDeltaInplace extends DIMTransformationRules{
extension EventDrivenTransformation transformation
protected PublicPackageSection aadlPackage
public extension EventDrivenTransformation transformation
new(SystemInstance topSystemInst, ViatraQueryEngine engine, DIMPreferences preferences) {
this.topSystemInst = topSystemInst
this.aadlPackage = topSystemInst.componentClassifier.owner as PublicPackageSection
this.aadlPublicPackage = topSystemInst.componentClassifier.owner as PublicPackageSection
this.engine = engine
this.preferences = preferences;
componentRules = new DIMTransformationRulesComponent
......@@ -103,39 +105,57 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
// .addRule(flowspecinstance2declarative)
.build
}
// Top-level SystemInstance transformation
///////////////////////////////////////////////
// TOP-LEVEL SYSTEM INSTANCE DEINSTANTIATION //
///////////////////////////////////////////////
val topSystemInstance2Declarative = createRule(FindSystem.Matcher.querySpecification)
.action(CRUDActivationStateEnum.UPDATED) [
systeminst.componentImplementation.set(namedElement_Name,systeminst.name+".imp")
println("DIM: Top-level system instance "+systeminst.name+" updated")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
// SubComponentInstance transformation
///////////////////////////////////////////
// SUBCOMPONENT INSTANCE DEINSTANTIATION //
///////////////////////////////////////////
val componentInstance2Declarative = createRule(FindSubcomponent.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if (subcompinst.subcomponent === null) {
componentRules.componentInstanceCreatedDIM(subcompinst, aadlPackage)
componentRules.componentInstanceCreatedDIM(subcompinst)
if (preferences.isInheritProperty()) {
transformationUtils.elementCreationPropertyInheritance(subcompinst, propertyRules)
}
if (preferences.isInheritMode()) {
transformationUtils.elementCreationModeInheritance(subcompinst)
}
println("DIM: Component instance "+subcompinst.name+" de-instantiated")
} else {
println("DIM: Declarative of component instance "+subcompinst.name+" already exists!")
}
].action(CRUDActivationStateEnum.UPDATED) [
subcompinst.subcomponent.set(namedElement_Name, subcompinst.name)
if (subcompinst.classifier.eContainer !== aadlPackage) {
aadlPackage.add(packageSection_ImportedUnit, subcompinst.classifier.eContainer)
// Subcomponent name change
if (subcompinst.name !== subcompinst.subcomponent.name) {
changeParentSubcomponentDefinition(subcompinst, subcompinst.eContainer as ComponentInstance)
subcompinst.subcomponent.set(namedElement_Name, subcompinst.name)
subcompinst.classifier.set(namedElement_Name, subcompinst.name)
println("DIM: Name of component instance "+subcompinst.name+" updated")
}
// Subcomponent classifier change
if (subcompinst.classifier !== subcompinst.subcomponent.classifier) {
if (LibraryUtils.isLibraryClassifier(subcompinst.classifier,aadlPublicPackage)) {
aadlPublicPackage.add(packageSection_ImportedUnit, subcompinst.classifier.eContainer.eContainer as ModelUnit)
}
changeParentSubcomponentDefinition(subcompinst, subcompinst.eContainer as ComponentInstance)
println("DIM: Classifier of component instance "+subcompinst.name+" updated")
}
subcompinst.subcomponent.set(subcomponent_Classifier, subcompinst.classifier)
println("DIM: Component instance "+subcompinst.name+" updated")
].action(CRUDActivationStateEnum.DELETED) [
changeParentSubcomponentDefinition(subcompinst, subcompinst.eContainer as ComponentInstance)
componentRules.componentInstanceDeletedDIM(subcompinst)
println("DIM: Component instance "+subcompinst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
// FeatureInstance transformation
//////////////////////////////////////
// FEATURE INSTANCE DEINSTANTIATION //
//////////////////////////////////////
val featureInstance2Declarative = createRule(FindFeature.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if (featinst.feature === null) {
......@@ -148,27 +168,40 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
println("DIM: Declarative of feature instance "+featinst.name+" already exists!")
}
].action(CRUDActivationStateEnum.UPDATED) [
featinst.feature.set(namedElement_Name,featinst.name)
// Feature Direction
// Feature name change
if (featinst.feature.name !== featinst.name) {
featureRules.featureChangedParentSubcomponentDefinition(featinst)
featinst.feature.set(namedElement_Name,featinst.name)
println("DIM: Name of feature instance "+featinst.name+" updated")
}
// Feature direction change
if (featinst.feature instanceof DirectedFeature) {
if (featinst.direction == DirectionType.IN) {
featinst.feature.set(directedFeature_In,true)
featinst.feature.set(directedFeature_Out,false)
} else if (featinst.direction == DirectionType.OUT) {
featinst.feature.set(directedFeature_In,false)
featinst.feature.set(directedFeature_Out,true)
} else {
featinst.feature.set(directedFeature_In,true)
featinst.feature.set(directedFeature_Out,true)
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)
if (featinst.direction == DirectionType.IN) {
featinst.feature.set(directedFeature_In,true)
featinst.feature.set(directedFeature_Out,false)
} else if (featinst.direction == DirectionType.OUT) {
featinst.feature.set(directedFeature_In,false)
featinst.feature.set(directedFeature_Out,true)
} else {
featinst.feature.set(directedFeature_In,true)
featinst.feature.set(directedFeature_Out,true)
}
println("DIM: Direction of feature instance "+featinst.name+" updated")
}
}
println("DIM: Feature instance "+featinst.name+" updated")
].action(CRUDActivationStateEnum.DELETED) [
featureRules.featureChangedParentSubcomponentDefinition(featinst)
featureRules.featureInstanceDeletedDIM(featinst)
println("DIM: Feature instance "+featinst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
// ConnectionInstance transformation
/////////////////////////////////////////
// CONNECTION INSTANCE DEINSTANTIATION //
/////////////////////////////////////////
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) {
......@@ -181,13 +214,16 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
println("DIM: Declarative of connection instance "+conninst.name+" already exists!")
}
].action(CRUDActivationStateEnum.UPDATED) [
println("DIM: WARNING: Connection instance "+conninst.name+" updated. Connection instance update synchronization not supported in this version of OSATE-DIM!")
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)
println("DIM: Connection instance "+conninst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
// ModeInstance Transformation
///////////////////////////////////
// MODE INSTANCE DEINSTANTIATION //
///////////////////////////////////
val modeInstance2Declarative = createRule(FindMode.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if(modeinst.mode === null) {
......@@ -197,8 +233,39 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
println("DIM: Declarative of mode instance "+modeinst.name+" already exists!")
}
].action(CRUDActivationStateEnum.UPDATED) [
modeinst.mode.set(namedElement_Name, modeinst.name)
println("DIM: Mode instance "+modeinst.name+" updated")
// Mode name change
if (modeinst.name !== modeinst.mode.name) {
modeRules.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)
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)
if (modeinst.derived == true) {
(modeinst.mode.eContainer as ComponentClassifier).set(componentClassifier_DerivedModes, true)
var modebind = compinst.subcomponent.createChild(subcomponent_OwnedModeBinding, modeBinding)
modebind.set(modeBinding_DerivedMode, modeinst.mode)
if (!modeinst.parents.isEmpty) {
modebind.set(modeBinding_ParentMode, modeinst.parents.get(0).mode)
}
} else {
(modeinst.mode.eContainer as ComponentClassifier).set(componentClassifier_DerivedModes, false)
for (ModeBinding modeBind : compinst.subcomponent.ownedModeBindings) {
if (modeBind.derivedMode == modeinst.mode) {
modeBind.eContainer.remove(subcomponent_OwnedModeBinding, modeBind)
}
}
}
println("DIM: Derived value of mode instance "+modeinst.name+" updated")
}
].action(CRUDActivationStateEnum.DELETED) [
(modeinst.mode.eContainer as ComponentClassifier).remove(componentClassifier_OwnedMode, modeinst.mode)
println("DIM: Mode instance "+modeinst.name+" deleted")
......@@ -219,8 +286,10 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
(modeinst.mode.eContainer as ComponentClassifier).remove(componentClassifier_OwnedMode, modeinst.mode)
println("DIM: Mode instance "+modeinst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
// ModeTransitionInstance Transformation
/////////////////////////////////////////////
// MODETRANSITION INSTANCE DEINSTANTIATION //
/////////////////////////////////////////////
val modeTransitionInstance2Declarative = createRule(FindModeTransition.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if(modetransinst.modeTransition === null) {
......@@ -240,12 +309,14 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
println("DIM: ModeTransition instance "+modetransinst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
// PropertyAssociation Instance Transformation
//////////////////////////////////////////////////
// PROPERTY ASSOCIATION INSTANCE TRANSFORMATION //
//////////////////////////////////////////////////
val propertyInstance2Declarative = createRule(FindProperty.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if(propinst.propertyAssociation === null) {
if (!PropertyUtils.isInheritedProperty(propinst)) {
propertyRules.propertyInstanceCreatedDIM(propinst, aadlPackage)
propertyRules.propertyInstanceCreatedDIM(propinst, aadlPublicPackage)
println("DIM: Property instance "+propinst.property.name+" de-instantiated")
} else {
println("DIM: Property instance "+propinst.property.name+" inherited")
......@@ -255,12 +326,12 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
}
].action(CRUDActivationStateEnum.UPDATED)[
if (propinst.property !== null) {
if (!aadlPackage.importedUnits.contains(propinst.property.eContainer)) {
if (aadlPackage.noAnnexes === true) {
aadlPackage.set(packageSection_NoAnnexes, false)
if (!aadlPublicPackage.importedUnits.contains(propinst.property.eContainer)) {
if (aadlPublicPackage.noAnnexes === true) {
aadlPublicPackage.set(packageSection_NoAnnexes, false)
}
if (!AadlUtil.isPredeclaredPropertySet((propinst.property.eContainer as PropertySet).name)) {
aadlPackage.add(packageSection_ImportedUnit, propinst.property.eContainer)
aadlPublicPackage.add(packageSection_ImportedUnit, propinst.property.eContainer)
}
}
propinst.propertyAssociation.set(propertyAssociation_Property, propinst.property)
......@@ -291,10 +362,10 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
propertyRules.propertyValueCreatedDIM(propinst, modpropinst, propvalinst)
].action(CRUDActivationStateEnum.UPDATED) [
if (PropertyUtils.isInheritedProperty(PropertyUtils.getContainingPropertyAssociationInstance(propvalinst))) {
propertyRules.propertyInstanceCreatedDIM(PropertyUtils.getContainingPropertyAssociationInstance(propvalinst), aadlPackage)
propertyRules.propertyInstanceCreatedDIM(PropertyUtils.getContainingPropertyAssociationInstance(propvalinst), aadlPublicPackage)
println("DIM: Inherited property instance "+PropertyUtils.getContainingPropertyAssociationInstance(propvalinst).property.name+" value updated")
} else {
propertyRules.propertyValueUpdatedDIM(propvalinst, aadlPackage)
propertyRules.propertyValueUpdatedDIM(propvalinst, aadlPublicPackage)
println("DIM: Property instance "+PropertyUtils.getContainingPropertyAssociationInstance(propvalinst).property.name+" value updated")
}
].addLifeCycle(Lifecycles.getDefault(true, true)).build
......
......@@ -2,10 +2,17 @@ package fr.mem4csd.osatedim.viatra.transformations
import fr.mem4csd.osatedim.viatra.preference.DIMPreferences
import fr.mem4csd.osatedim.viatra.queries.DIMQueriesInplace
import fr.mem4csd.osatedim.viatra.utils.LibraryUtils
import org.eclipse.emf.ecore.util.EcoreUtil
import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
import org.eclipse.viatra.transformation.runtime.emf.modelmanipulation.IModelManipulations
import org.eclipse.viatra.transformation.runtime.emf.rules.eventdriven.EventDrivenTransformationRuleFactory
import org.osate.aadl2.Aadl2Package
import org.osate.aadl2.ComponentCategory
import org.osate.aadl2.ComponentClassifier
import org.osate.aadl2.ComponentImplementation
import org.osate.aadl2.PublicPackageSection
import org.osate.aadl2.instance.ComponentInstance
import org.osate.aadl2.instance.InstancePackage
import org.osate.aadl2.instance.SystemInstance
......@@ -24,8 +31,69 @@ class DIMTransformationRules {
protected SystemInstance topSystemInst
protected ViatraQueryEngine engine
protected DIMPreferences preferences
protected PublicPackageSection aadlPublicPackage
def SystemInstance getTopSystemInst() {
return topSystemInst;
}
protected def void changeParentSubcomponentDefinition(ComponentInstance compinst, ComponentInstance parentcompinst) {
var extensionList = LibraryUtils.getAllInheritingParentImplementations(compinst.subcomponent, parentcompinst)
var extensionIndex = LibraryUtils.getClosestLibraryImplementationIndex(extensionList, aadlPublicPackage)
if (extensionIndex !== -1) {
var ComponentImplementation previousImp
for (ComponentImplementation currentcompimp : extensionList.reverse) {
if (extensionList.indexOf(currentcompimp) < extensionList.size - extensionIndex) {
var compimpcopy = EcoreUtil.copy(currentcompimp)
aadlPublicPackage.add(packageSection_OwnedClassifier, compimpcopy)
compimpcopy.set(namedElement_Name,currentcompimp.name+"_dimcopy")
if(extensionList.indexOf(currentcompimp) == 0) {
var newSubcomp = LibraryUtils.getCopySubcomponent(compinst.subcomponent,compimpcopy)
compinst.set(componentInstance_Subcomponent, newSubcomp)
} else {
compimpcopy.set(componentImplementation_Extended, previousImp)
}
previousImp = compimpcopy
} else {
if (parentcompinst == topSystemInst || !LibraryUtils.isSubcomponentAffectingLibrary(parentcompinst.subcomponent,parentcompinst.eContainer as ComponentInstance,aadlPublicPackage)) {
if (extensionList.indexOf(currentcompimp) == extensionList.size - extensionIndex) {
currentcompimp.set(componentImplementation_Extended, previousImp)
}
} else {
var compimpcopy = EcoreUtil.copy(currentcompimp)
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) {
parentcompinst.set(componentInstance_Classifier, compimpcopy)
changeParentSubcomponentDefinition(parentcompinst, parentcompinst.eContainer as ComponentInstance)
}
}
}
}
} else if (parentcompinst != topSystemInst && LibraryUtils.isSubcomponentAffectingLibrary(parentcompinst.subcomponent,parentcompinst.eContainer as ComponentInstance,aadlPublicPackage)) {
changeParentSubcomponentDefinition(parentcompinst, parentcompinst.eContainer as ComponentInstance)
}
setSubcomponentType(compinst, compinst.classifier)
}
protected def setSubcomponentType(ComponentInstance compinst, ComponentClassifier compimp) {
switch (compinst.category) {
case ComponentCategory.ABSTRACT :compinst.subcomponent.set(abstractSubcomponent_AbstractSubcomponentType, compimp)
case ComponentCategory.BUS : compinst.subcomponent.set(busSubcomponent_BusSubcomponentType, compimp)
case ComponentCategory.DATA : compinst.subcomponent.set(dataSubcomponent_DataSubcomponentType, compimp)
case ComponentCategory.DEVICE : compinst.subcomponent.set(deviceSubcomponent_DeviceSubcomponentType, compimp)
case ComponentCategory.MEMORY : compinst.subcomponent.set(memorySubcomponent_MemorySubcomponentType, compimp)
case ComponentCategory.PROCESS : compinst.subcomponent.set(processSubcomponent_ProcessSubcomponentType, compimp)
case ComponentCategory.PROCESSOR : compinst.subcomponent.set(processorSubcomponent_ProcessorSubcomponentType, compimp)
case ComponentCategory.SUBPROGRAM : compinst.subcomponent.set(subprogramSubcomponent_SubprogramSubcomponentType, compimp)
case ComponentCategory.SUBPROGRAM_GROUP : compinst.subcomponent.set(subprogramGroupSubcomponent_SubprogramGroupSubcomponentType, compimp)
case ComponentCategory.SYSTEM : compinst.subcomponent.set(systemSubcomponent_SystemSubcomponentType, compimp)
case ComponentCategory.THREAD : compinst.subcomponent.set(threadSubcomponent_ThreadSubcomponentType, compimp)
case ComponentCategory.THREAD_GROUP : compinst.subcomponent.set(threadGroupSubcomponent_ThreadGroupSubcomponentType, compimp)
case ComponentCategory.VIRTUAL_BUS : compinst.subcomponent.set(virtualBusSubcomponent_VirtualBusSubcomponentType, compimp)
case ComponentCategory.VIRTUAL_PROCESSOR : compinst.subcomponent.set(virtualProcessorSubcomponent_VirtualProcessorSubcomponentType, compimp)
}
}
}
\ No newline at end of file
......@@ -11,6 +11,9 @@ 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
class DIMTransformationRulesConnection extends DIMTransformationRules {
......@@ -38,22 +41,49 @@ class DIMTransformationRulesConnection extends DIMTransformationRules {
currentcompinst
}
}
var feataddcomptype = (feataddcompinst.classifier as ComponentImplementation).type
featureRules.featureCreation(feataddcompinst, feataddcomptype, conninst.source as FeatureInstance)
// 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
}
}
if (!(complist.indexOf(currentcompinst) == complist.size-1)) {
currentdestfeat.set(namedElement_Name,conninst.name+"_feat")
currentdestfeat.set(directedFeature_In,true)
currentdestfeat.set(directedFeature_Out,true)
// Destination FeatureInstance Creation
var currentdestfeatinst = feataddcompinst.createChild(componentInstance_FeatureInstance,featureInstance)
currentdestfeatinst.set(featureInstance_Category, (conninst.source as FeatureInstance).category)
currentdestfeatinst.set(featureInstance_Direction, DirectionType.IN_OUT)
currentdestfeatinst.set(namedElement_Name, conninst.name+"_feat")
currentdestfeatinst.set(featureInstance_Feature, currentdestfeat)
// Parent Component Implementation Creation
if (currentcompinst !== topSystemInst) {
if (currentcompinst.classifier instanceof ComponentType || LibraryUtils.isLibraryClassifier(currentcompinst.classifier, aadlPublicPackage)) {
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
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) {
......@@ -81,7 +111,7 @@ class DIMTransformationRulesConnection extends DIMTransformationRules {
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)
......@@ -168,6 +198,7 @@ class DIMTransformationRulesConnection extends DIMTransformationRules {
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)
......@@ -178,4 +209,46 @@ class DIMTransformationRulesConnection extends DIMTransformationRules {
}
}
}
protected def connectionDeletedParentSubcomponentDefinition(ConnectionReference connref) {
var compinst = connref.context as ComponentInstance
var extensionList = LibraryUtils.getAllInheritingParentImplementations(connref.connection, compinst)
var extensionIndex = LibraryUtils.getClosestLibraryImplementationIndex(extensionList, aadlPublicPackage)
if (extensionIndex != -1) {
var ComponentImplementation previousImp
for (ComponentImplementation currentcompimp : extensionList.reverse) {
if (extensionList.indexOf(currentcompimp) < extensionList.size - extensionIndex) {
var compimpcopy = EcoreUtil.copy(currentcompimp)
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.isSubcomponentAffectingLibrary(compinst.subcomponent,compinst.eContainer as ComponentInstance,aadlPublicPackage)) {
if (extensionList.indexOf(currentcompimp) == extensionList.size - extensionIndex) {
currentcompimp.set(componentImplementation_Extended, previousImp)
}
} else {
var compimpcopy = EcoreUtil.copy(currentcompimp)
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 && LibraryUtils.isSubcomponentAffectingLibrary(compinst.subcomponent,compinst.eContainer as ComponentInstance,aadlPublicPackage)) {
changeParentSubcomponentDefinition(compinst, compinst.eContainer as ComponentInstance)
}
setSubcomponentType(compinst,compinst.classifier)
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package fr.mem4csd.osatedim.viatra.transformations
import org.osate.aadl2.instance.InstanceObject
import org.osate.aadl2.PropertyAssociation
import org.osate.aadl2.instance.ComponentInstance
class DIMTransformationRulesExtension extends DIMTransformationRules {
......@@ -13,4 +14,9 @@ class DIMTransformationRulesExtension extends DIMTransformationRules {
}
}
}
def elementCreationModeInheritance(ComponentInstance instance) {
throw new UnsupportedOperationException("TODO: auto-generated method stub")
}
}
\ No newline at end of file
package fr.mem4csd.osatedim.viatra.transformations
import org.osate.aadl2.instance.ComponentInstance
import org.osate.aadl2.ComponentType
import org.osate.aadl2.instance.FeatureInstance
import fr.mem4csd.osatedim.viatra.utils.LibraryUtils
import org.osate.aadl2.AbstractType
import org.osate.aadl2.BusType
import org.osate.aadl2.ComponentCategory
import org.osate.aadl2.instance.FeatureCategory
import org.osate.aadl2.ComponentImplementation
import org.osate.aadl2.ComponentType
import org.osate.aadl2.DataType
import org.osate.aadl2.DeviceType
import org.osate.aadl2.DirectedFeature
import org.osate.aadl2.DirectionType
import org.osate.aadl2.AbstractType
import org.osate.aadl2.BusType
import org.osate.aadl2.DataType
import org.osate.aadl2.MemoryType
import org.osate.aadl2.ModelUnit
import org.osate.aadl2.ProcessType
import org.osate.aadl2.ProcessorType