Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mbe-tools
OSATE-DIM
Commits
eeedecc0
Commit
eeedecc0
authored
Jun 14, 2022
by
Rakshit Mittal
Browse files
sync
parent
1d9ca4fe
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
fr.mem4csd.osatedim.tests/cases/ramses-ref-linux/delta-outplace/instances/sampled-communications-local-communications_refined_model_impl_Instance.aaxl2
0 → 100644
View file @
eeedecc0
This diff is collapsed.
Click to expand it.
fr.mem4csd.osatedim.tests/src/fr/mem4csd/osatedim/tests/InplaceModifications.java
View file @
eeedecc0
...
...
@@ -11,6 +11,7 @@ import org.osate.aadl2.ComponentCategory;
import
org.osate.aadl2.DirectionType
;
import
org.osate.aadl2.EnumerationType
;
import
org.osate.aadl2.IntegerLiteral
;
import
org.osate.aadl2.ListType
;
import
org.osate.aadl2.ListValue
;
import
org.osate.aadl2.ModalPropertyValue
;
import
org.osate.aadl2.NamedElement
;
...
...
@@ -291,18 +292,18 @@ public class InplaceModifications{
RecordValue
propval
=
(
RecordValue
)
((
ListValue
)
modprop
.
createOwnedValue
(
Aadl2Package
.
eINSTANCE
.
getListValue
())).
createOwnedListElement
(
Aadl2Package
.
eINSTANCE
.
getRecordValue
());
BasicPropertyAssociation
unitprop
=
propval
.
createOwnedFieldValue
();
unitprop
.
setProperty
(
(
Property
)
((
RecordType
)
ramsesResource
.
getOwnedPropertyTypes
().
get
(
0
)).
getOwnedFields
().
get
(
0
));
unitprop
.
setProperty
(((
RecordType
)
ramsesResource
.
getOwnedPropertyTypes
().
get
(
0
)).
getOwnedFields
().
get
(
0
));
((
InstanceReferenceValue
)
unitprop
.
createOwnedValue
(
InstancePackage
.
eINSTANCE
.
getInstanceReferenceValue
())).
setReferencedInstanceObject
(
core
);
BasicPropertyAssociation
startprop
=
propval
.
createOwnedFieldValue
();
startprop
.
setProperty
(
(
Property
)
((
RecordType
)
ramsesResource
.
getOwnedPropertyTypes
().
get
(
0
)).
getOwnedFields
().
get
(
1
));
startprop
.
setProperty
(((
RecordType
)
ramsesResource
.
getOwnedPropertyTypes
().
get
(
0
)).
getOwnedFields
().
get
(
1
));
IntegerLiteral
startint
=
(
IntegerLiteral
)
startprop
.
createOwnedValue
(
Aadl2Package
.
eINSTANCE
.
getIntegerLiteral
());
startint
.
setValue
(
start
);
startint
.
setBase
(
0
);
startint
.
setUnit
(((
UnitsType
)
aadlProjectResource
.
getOwnedPropertyTypes
().
get
(
16
)).
findLiteral
(
"ms"
));
BasicPropertyAssociation
endprop
=
propval
.
createOwnedFieldValue
();
endprop
.
setProperty
(
(
Property
)
((
RecordType
)
ramsesResource
.
getOwnedPropertyTypes
().
get
(
0
)).
getOwnedFields
().
get
(
2
));
endprop
.
setProperty
(((
RecordType
)
ramsesResource
.
getOwnedPropertyTypes
().
get
(
0
)).
getOwnedFields
().
get
(
2
));
IntegerLiteral
endint
=
(
IntegerLiteral
)
endprop
.
createOwnedValue
(
Aadl2Package
.
eINSTANCE
.
getIntegerLiteral
());
endint
.
setValue
(
stop
);
endint
.
setBase
(
0
);
...
...
@@ -311,13 +312,13 @@ public class InplaceModifications{
private
void
addExecutionSlotsProperty
(
ComponentInstance
thread
,
Integer
val1
,
Integer
val2
,
SystemOperationMode
som1
,
ComponentInstance
core
)
{
PropertyAssociationInstance
prop
=
(
PropertyAssociationInstance
)
thread
.
createOwnedPropertyAssociation
();
prop
.
setProperty
((
Property
)
((
RecordType
)
ramsesResource
.
getOwnedPropert
yTypes
().
get
(
0
)).
getOwnedField
s
().
get
(
6
));
prop
.
setProperty
((
Property
)
ramsesResource
.
getOwnedPropert
ie
s
().
get
(
6
));
addExecutionSlotModalProperty
(
prop
,
val1
,
val2
,
som1
,
core
);
}
private
void
addTwoExecutionSlotsProperty
(
ComponentInstance
thread
,
Integer
val1
,
Integer
val2
,
Integer
val3
,
Integer
val4
,
SystemOperationMode
som1
,
SystemOperationMode
som2
,
ComponentInstance
core
)
{
PropertyAssociationInstance
prop
=
(
PropertyAssociationInstance
)
thread
.
createOwnedPropertyAssociation
();
prop
.
setProperty
((
Property
)
((
RecordType
)
ramsesResource
.
getOwnedPropert
yTypes
().
get
(
0
)).
getOwnedField
s
().
get
(
6
));
prop
.
setProperty
((
Property
)
ramsesResource
.
getOwnedPropert
ie
s
().
get
(
6
));
addExecutionSlotModalProperty
(
prop
,
val1
,
val2
,
som1
,
core
);
addExecutionSlotModalProperty
(
prop
,
val3
,
val4
,
som2
,
core
);
}
...
...
@@ -331,38 +332,43 @@ public class InplaceModifications{
SystemOperationMode
som1
=
null
,
som2
=
null
;
for
(
SystemOperationMode
som
:
topSystemInst
.
getSystemOperationModes
())
{
if
(
som
.
getName
()
==
"som_1"
)
{
som1
=
som
;}
else
if
(
som
.
getName
()
==
"som_2"
)
{
som2
=
som
;}
if
(
som
.
getName
().
endsWith
(
"1"
))
{
som1
=
som
;
}
else
{
som2
=
som
;
}
}
ComponentInstance
core1
=
null
,
core2
=
null
;
for
(
ComponentInstance
core
:
cpu
.
getAllComponentInstances
(
ComponentCategory
.
PROCESSOR
))
{
if
(
core
.
getName
()
==
"core1"
)
{
core1
=
core
;}
else
if
(
core
.
getName
()
==
"core2"
)
{
core2
=
core
;}
if
(
core
.
getName
().
endsWith
(
"1"
))
{
core1
=
core
;
}
else
{
core2
=
core
;
}
}
for
(
ComponentInstance
thread
:
topSystemInst
.
getAllComponentInstances
(
ComponentCategory
.
PROCESS
).
get
(
0
).
getAllComponentInstances
(
ComponentCategory
.
THREAD_GROUP
).
get
(
0
).
getAllComponentInstances
(
ComponentCategory
.
THREAD
))
{
if
(
thread
.
getName
()
==
"Avoid"
)
{
if
(
thread
.
getName
()
.
contentEquals
(
"Avoid"
)
)
{
addTwoExecutionSlotsProperty
(
thread
,
0
,
300
,
0
,
300
,
som1
,
som2
,
core1
);
}
else
if
(
thread
.
getName
()
==
"Nav"
)
{
}
else
if
(
thread
.
getName
()
.
contentEquals
(
"Nav"
)
)
{
addTwoExecutionSlotsProperty
(
thread
,
300
,
900
,
300
,
1100
,
som1
,
som2
,
core1
);
}
else
if
(
thread
.
getName
()
==
"Stab"
)
{
}
else
if
(
thread
.
getName
()
.
contentEquals
(
"Stab"
)
)
{
addTwoExecutionSlotsProperty
(
thread
,
900
,
1100
,
1100
,
1600
,
som1
,
som2
,
core1
);
}
else
if
(
thread
.
getName
()
==
"Log"
)
{
}
else
if
(
thread
.
getName
()
.
contentEquals
(
"Log"
)
)
{
addExecutionSlotsProperty
(
thread
,
1100
,
1300
,
som1
,
core1
);
}
else
if
(
thread
.
getName
()
==
"Com"
)
{
}
else
if
(
thread
.
getName
()
.
contentEquals
(
"Com"
)
)
{
addExecutionSlotsProperty
(
thread
,
1300
,
1600
,
som1
,
core1
);
}
else
if
(
thread
.
getName
()
==
"Video"
)
{
}
else
if
(
thread
.
getName
()
.
contentEquals
(
"Video"
)
)
{
addExecutionSlotsProperty
(
thread
,
0
,
600
,
som1
,
core2
);
}
else
if
(
thread
.
getName
()
==
"GPS"
)
{
}
else
if
(
thread
.
getName
()
.
contentEquals
(
"GPS"
)
)
{
addExecutionSlotsProperty
(
thread
,
600
,
800
,
som1
,
core2
);
}
else
if
(
thread
.
getName
()
==
"Rec"
)
{
}
else
if
(
thread
.
getName
()
.
contentEquals
(
"Rec"
)
)
{
addExecutionSlotsProperty
(
thread
,
800
,
1000
,
som1
,
core2
);
}
}
}
protected
void
createComponentInplace
(
ComponentInstance
comp
)
{
}
protected
void
updateComponentInplace
(
ComponentInstance
comp
)
{
...
...
fr.mem4csd.osatedim.tests/src/fr/mem4csd/osatedim/tests/TestDeltaInplace.java
View file @
eeedecc0
...
...
@@ -4,6 +4,8 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import
org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
;
import
org.eclipse.viatra.query.runtime.emf.EMFScope
;
import
org.junit.jupiter.api.Test
;
import
org.osate.aadl2.ComponentCategory
;
import
org.osate.aadl2.instance.ComponentInstance
;
import
org.osate.aadl2.instance.SystemInstance
;
import
fr.mem4csd.osatedim.viatra.preference.DIMPreferences
;
...
...
@@ -25,11 +27,10 @@ public class TestDeltaInplace extends TestAbstract {
ResourceSet
resSet
=
prepareTestResources
(
inputModelName
);
aadlResource
=
resSet
.
getResource
(((
SystemInstance
)
aaxlResource
.
getContents
().
get
(
0
)).
getComponentImplementation
().
eResource
().
getURI
(),
true
);
modifications
=
new
InplaceModifications
((
SystemInstance
)
aaxlResource
.
getContents
().
get
(
0
));
}
@Test
public
void
testMCDAG
Inplace
()
throws
Exception
{
public
void
testMCDAG
()
throws
Exception
{
computeFinalBaseDirectory
(
0
,
1
);
DIMTransformationDeltaInplace
transformation
=
initiateDIMTransformationDeltaInplace
(
"declarative_main_impl_Instance"
);
modifications
.
modifyMCDAGInplace
(
transformation
.
getTopSystemInst
());
...
...
@@ -38,7 +39,7 @@ public class TestDeltaInplace extends TestAbstract {
}
@Test
public
void
testRAMSES
Inplace
()
throws
Exception
{
public
void
testRAMSES
()
throws
Exception
{
computeFinalBaseDirectory
(
1
,
1
);
DIMTransformationDeltaInplace
transformation
=
initiateDIMTransformationDeltaInplace
(
"sampled-communications_main_linux_Instance"
);
modifications
.
modifyRAMSESInplace
(
transformation
.
getTopSystemInst
());
...
...
@@ -50,13 +51,36 @@ public class TestDeltaInplace extends TestAbstract {
public
void
testExperimentComponentCreation
()
throws
Exception
{
computeFinalBaseDirectory
(
2
,
1
);
DIMTransformationDeltaInplace
transformation
=
initiateDIMTransformationDeltaInplace
(
"sampled-communications_main_linux_Instance"
);
modifications
.
createComponentInplace
(
transformation
.
getTopSystemInst
());
ComponentInstance
proc
=
topSystemInst
.
getAllComponentInstances
(
ComponentCategory
.
PROCESS
).
get
(
0
);
ComponentInstance
viewer
=
proc
.
createComponentInstance
();
viewer
.
setName
(
"the_viewer"
);
viewer
.
setCategory
(
ComponentCategory
.
THREAD
);
topSystemInst
.
eResource
().
save
(
null
);
aadlResource
.
save
(
null
);
transformation
.
dispose
();
doComparisonTest
(
"sampled-communications_main_linux_Instance"
);
}
@Test
public
void
testExperimentComponentUpdation
()
throws
Exception
{
public
void
testExperimentComponentUpdationName
()
throws
Exception
{
computeFinalBaseDirectory
(
1
,
1
);
DIMTransformationDeltaInplace
transformation
=
initiateDIMTransformationDeltaInplace
(
"sampled-communications_main_linux_Instance"
);
modifications
.
updateComponentInplace
(
transformation
.
getTopSystemInst
());
transformation
.
dispose
();
doComparisonTest
(
"sampled-communications_main_linux_Instance"
);
}
@Test
public
void
testExperimentComponentUpdationCategory
()
throws
Exception
{
computeFinalBaseDirectory
(
1
,
1
);
DIMTransformationDeltaInplace
transformation
=
initiateDIMTransformationDeltaInplace
(
"sampled-communications_main_linux_Instance"
);
modifications
.
updateComponentInplace
(
transformation
.
getTopSystemInst
());
transformation
.
dispose
();
doComparisonTest
(
"sampled-communications_main_linux_Instance"
);
}
@Test
public
void
testExperimentComponentUpdationClassifier
()
throws
Exception
{
computeFinalBaseDirectory
(
1
,
1
);
DIMTransformationDeltaInplace
transformation
=
initiateDIMTransformationDeltaInplace
(
"sampled-communications_main_linux_Instance"
);
modifications
.
updateComponentInplace
(
transformation
.
getTopSystemInst
());
...
...
fr.mem4csd.osatedim.viatra/.aadlbin-gen/src-aadl/.DIM_Properties.aadlbin
View file @
eeedecc0
No preview for this file type
fr.mem4csd.osatedim.viatra/.aadlbin-gen/src-aadl/.gitignore
0 → 100644
View file @
eeedecc0
/.DIM_Properties.aadlbin
fr.mem4csd.osatedim.viatra/plugin.xml
View file @
eeedecc0
...
...
@@ -12,6 +12,8 @@
<query-specification
fqn=
"fr.mem4csd.osatedim.viatra.queries.findProperty"
/>
<query-specification
fqn=
"fr.mem4csd.osatedim.viatra.queries.findModalProperty"
/>
<query-specification
fqn=
"fr.mem4csd.osatedim.viatra.queries.findPropertyValue"
/>
<query-specification
fqn=
"fr.mem4csd.osatedim.viatra.queries.hasRecordValue"
/>
<query-specification
fqn=
"fr.mem4csd.osatedim.viatra.queries.listHasRecordValue"
/>
<query-specification
fqn=
"fr.mem4csd.osatedim.viatra.queries.findNullValueProperty"
/>
</group>
</extension>
...
...
fr.mem4csd.osatedim.viatra/src/fr/mem4csd/osatedim/viatra/queries/DIMQueriesInplace.vql
View file @
eeedecc0
...
...
@@ -79,23 +79,36 @@ pattern findModalProperty(propinst: PropertyAssociationInstance, modpropinst : M
pattern
findPropertyValue
(
propinst
:
PropertyAssociationInstance
,
modpropinst
:
ModalPropertyValue
,
propvalinst
:
PropertyValue
)
{
find
findModalProperty
(
propinst
,
modpropinst
);
neg
find
hasRecordValue
(
modpropinst
,
_
);
ModalPropertyValue
.
ownedValue
(
modpropinst
,
propvalinst
);
}
or
{
find
findModalProperty
(
propinst
,
modpropinst
);
ModalPropertyValue
.
ownedValue
(
modpropinst
,
recvalinst
);
RecordValue
.
ownedFieldValue
.
ownedValue
(
recvalinst
,
propvalinst
);
RecordValue
.
ownedFieldValue
(
recvalinst
,
basicpropassoc
);
BasicPropertyAssociation
.
ownedValue
(
basicpropassoc
,
propvalinst
);
}
or
{
find
findModalProperty
(
propinst
,
modpropinst
);
ModalPropertyValue
.
ownedValue
(
modpropinst
,
listvalinst
);
neg
find
listHasRecordValue
(
listvalinst
,
_
);
ListValue
.
ownedListElement
(
listvalinst
,
propvalinst
);
neg
RecordValue
(
propvalinst
);
}
or
{
find
findModalProperty
(
propinst
,
modpropinst
);
ModalPropertyValue
.
ownedValue
(
modpropinst
,
listvalinst
);
ListValue
.
ownedListElement
(
listvalinst
,
listrecvalinst
);
RecordValue
.
ownedFieldValue
.
ownedValue
(
listrecvalinst
,
propvalinst
);
RecordValue
.
ownedFieldValue
(
listrecvalinst
,
basicpropassoc
);
BasicPropertyAssociation
.
ownedValue
(
basicpropassoc
,
propvalinst
);
}
pattern
hasRecordValue
(
modpropval
:
ModalPropertyValue
,
recordval
:
RecordValue
)
{
ModalPropertyValue
.
ownedValue
(
modpropval
,
recordval
);
}
pattern
listHasRecordValue
(
listval
:
ListValue
,
recordval
:
RecordValue
)
{
ListValue
.
ownedListElement
(
listval
,
recordval
);
}
pattern
findNullValueProperty
(
propassoc
:
PropertyAssociation
)
{
neg
PropertyAssociation
.
ownedValue
(
propassoc
,
_
);
...
...
fr.mem4csd.osatedim.viatra/src/fr/mem4csd/osatedim/viatra/transformations/DIMTransformationDeltaInplace.xtend
View file @
eeedecc0
...
...
@@ -36,8 +36,10 @@ 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
import
org
.
osate
.
aadl2
.
ComponentType
import
org
.
osate
.
aadl2
.
ComponentCategory
import
org
.
eclipse
.
emf
.
common
.
util
.
EList
import
org
.
osate
.
aadl2
.
ComponentImplementation
class
DIMTransformationDeltaInplace
extends
DIMTransformationRules
{
...
...
@@ -48,7 +50,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
this
.
aadlPublicPackage
=
topSystemInst
.
componentClassifier
.
owner
as
PublicPackageSection
this
.
engine
=
engine
this
.
preferences
=
preferences
;
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
;
//
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
}
...
...
@@ -123,11 +125,103 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
}
].
action
(
CRUDActivationStateEnum
.
UPDATED
)
[
//
Component
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"
)
if
(
!subcompinst.name.isNullOrEmpty) {
if
(
!subcompinst.name.contentEquals(subcompinst.subcomponent.name)) {
changeParentSubcomponentDefinition
(
subcompinst
,
subcompinst
.
eContainer
as
ComponentInstance
)
subcompinst
.
subcomponent
.
set
(
namedElement_Name
,
subcompinst
.
name
)
if
(
subcompinst
.
classifier
.
name
.
isNullOrEmpty
)
{
if
(
subcompinst
.
classifier
instanceof
ComponentType
)
{
subcompinst
.
classifier
.
set
(
namedElement_Name
,
subcompinst
.
name
)
}
else
{
subcompinst
.
classifier
.
set
(
namedElement_Name
,
subcompinst
.
name
+
".impl"
)
}
}
println
(
"DIM: Name of component instance "
+
subcompinst
.
name
+
" updated"
)
}
}
//
Component
category
update
if
(
subcompinst
.
category
!== subcompinst.subcomponent.category) {
var
compinst
=
subcompinst
.
eContainer
as
ComponentInstance
changeParentSubcomponentDefinition
(
subcompinst
,
compinst
)
var
newcompimp
=
{
switch
(
compinst
.
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
newcompimp
.
set
(
componentImplementation_Extended
,
subcompinst
.
subcomponent
.
eContainer
)
newcompimp
.
set
(
componentImplementation_Type
,
(
subcompinst
.
subcomponent
.
eContainer
as
ComponentImplementation
).
type
)
newcompimp
.
set
(
namedElement_Name
,
(
subcompinst
.
subcomponent
.
eContainer
as
ComponentImplementation
).
name
+
"_ext"
)
var
newsubcomp
=
createSubcomponentInsideComponentImplementation
(
newcompimp
,
subcompinst
)
newsubcomp
.
set
(
subcomponent_Refined
,
subcompinst
.
subcomponent
)
var
EList
<?
extends
ComponentClassifier
>
extensionList
=
LibraryUtils
.
getAllInheritingParentImplementations
(
subcompinst
.
subcomponent
,
subcompinst
.
eContainer
as
ComponentInstance
)
if
(
extensionList
.
size
>
1
)
{
extensionList
.
get
(
extensionList
.
size
-
2
).
set
(
componentImplementation_Extended
,
newcompimp
)
}
else
{
compinst
.
set
(
componentInstance_Classifier
,
newcompimp
)
setSubcomponentType
(
compinst
,
newcompimp
)
}
var
ComponentClassifier
subcompclass
=
{
if
(
subcompinst
.
classifier
instanceof
ComponentType
)
{
switch
(
subcompinst
.
category
)
{
case
ComponentCategory
.
ABSTRACT
:
aadlPublicPackage
.
createChild
(
packageSection_OwnedClassifier
,
abstractType
)
case
ComponentCategory
.
BUS
:
aadlPublicPackage
.
createChild
(
packageSection_OwnedClassifier
,
busType
)
case
ComponentCategory
.
DATA
:
aadlPublicPackage
.
createChild
(
packageSection_OwnedClassifier
,
dataType
)
case
ComponentCategory
.
DEVICE
:
aadlPublicPackage
.
createChild
(
packageSection_OwnedClassifier
,
deviceType
)
case
ComponentCategory
.
MEMORY
:
aadlPublicPackage
.
createChild
(
packageSection_OwnedClassifier
,
memoryType
)
case
ComponentCategory
.
PROCESS
:
aadlPublicPackage
.
createChild
(
packageSection_OwnedClassifier
,
processType
)
case
ComponentCategory
.
PROCESSOR
:
aadlPublicPackage
.
createChild
(
packageSection_OwnedClassifier
,
processorType
)
case
ComponentCategory
.
SUBPROGRAM
:
aadlPublicPackage
.
createChild
(
packageSection_OwnedClassifier
,
subprogramType
)
case
ComponentCategory
.
SUBPROGRAM_GROUP
:
aadlPublicPackage
.
createChild
(
packageSection_OwnedClassifier
,
subprogramGroupType
)
case
ComponentCategory
.
SYSTEM
:
aadlPublicPackage
.
createChild
(
packageSection_OwnedClassifier
,
systemType
)
case
ComponentCategory
.
THREAD
:
aadlPublicPackage
.
createChild
(
packageSection_OwnedClassifier
,
threadType
)
case
ComponentCategory
.
THREAD_GROUP
:
aadlPublicPackage
.
createChild
(
packageSection_OwnedClassifier
,
threadGroupType
)
case
ComponentCategory
.
VIRTUAL_BUS
:
aadlPublicPackage
.
createChild
(
packageSection_OwnedClassifier
,
virtualBusType
)
case
ComponentCategory
.
VIRTUAL_PROCESSOR
:
aadlPublicPackage
.
createChild
(
packageSection_OwnedClassifier
,
virtualProcessorType
)
}
}
else
{
switch
(
subcompinst
.
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
ComponentClassifier
subcompclass
.
set
(
namedElement_Name
,
subcompinst
.
classifier
.
name
+
"_ext"
)
if
(
subcompinst
.
classifier
instanceof
ComponentType
)
{
subcompclass
.
set
(
componentType_Extended
,
subcompinst
.
classifier
)
}
else
{
subcompclass
.
set
(
componentImplementation_Extended
,
subcompinst
.
classifier
)
subcompclass
.
set
(
componentImplementation_Type
,
(
subcompinst
.
classifier
as
ComponentImplementation
).
type
)
}
subcompinst
.
set
(
componentInstance_Classifier
,
subcompclass
)
subcompinst
.
set
(
componentInstance_Subcomponent
,
newsubcomp
)
setSubcomponentType
(
subcompinst
,
subcompclass
)
println
(
"DIM: Category of component instance "
+
subcompinst
.
name
+
" updated"
)
}
//
Component
classifier
change
if
(
subcompinst
.
classifier
!== subcompinst.subcomponent.classifier) {
...
...
@@ -138,7 +232,9 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
println
(
"DIM: Classifier of component instance "
+
subcompinst
.
name
+
" updated"
)
}
].
action
(
CRUDActivationStateEnum
.
DELETED
)
[
changeParentSubcomponentDefinition
(
subcompinst
,
subcompinst
.
eContainer
as
ComponentInstance
)
if
(
LibraryUtils
.
isAffectingSubcomponent
(
subcompinst
.
subcomponent
,
subcompinst
.
eContainer
as
ComponentInstance
,
aadlPublicPackage
,
engine
,
preferences
.
modifyReused
))
{
changeParentSubcomponentDefinition
(
subcompinst
,
subcompinst
.
eContainer
as
ComponentInstance
)
}
componentInstanceDeletedDIM
(
subcompinst
)
println
(
"DIM: Component instance "
+
subcompinst
.
name
+
" deleted"
)
].
addLifeCycle
(
Lifecycles
.
getDefault
(
true
,
true
)).
build
...
...
@@ -353,7 +449,11 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
if
(
propinst
.
propertyAssociation
===
null
)
{
if
(
!PropertyUtils.isInheritedProperty(propinst)) {
propertyInstanceCreatedDIM
(
propinst
,
aadlPublicPackage
)
println
(
"DIM: Property instance "
+
propinst
.
property
.
name
+
" de-instantiated"
)
if
(
propinst
.
property
!== null) {
println
(
"DIM: Property instance "
+
propinst
.
property
.
name
+
" de-instantiated"
)
}
else
{
println
(
"DIM: Property instance in object "
+(
propinst
.
eContainer
as
InstanceObject
).
name
+
" de-instantiated"
)
}
}
else
{
println
(
"DIM: Property instance "
+
propinst
.
property
.
name
+
" inherited"
)
}
...
...
@@ -361,7 +461,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
println
(
"DIM: Declarative of property instance "
+
propinst
.
property
.
name
+
" already exists!"
)
}
].
action
(
CRUDActivationStateEnum
.
UPDATED
)[
if
(
propinst
.
property
!==
null
) {
if
(
propinst
.
property
!==
propinst.propertyAssociation.property
) {
if
(
!aadlPublicPackage.importedUnits.contains(propinst.property.eContainer)) {
if
(
aadlPublicPackage
.
noAnnexes
===
true
)
{
aadlPublicPackage
.
set
(
packageSection_NoAnnexes
,
false
)
...
...
@@ -371,6 +471,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
}
}
propinst
.
propertyAssociation
.
set
(
propertyAssociation_Property
,
propinst
.
property
)
println
(
"DIM: Property of property instance "
+
propinst
.
property
.
name
+
" updated"
)
}
].
action
(
CRUDActivationStateEnum
.
DELETED
)
[
propinst
.
propertyAssociation
.
eContainer
.
remove
(
namedElement_OwnedPropertyAssociation
,
propinst
.
propertyAssociation
)
...
...
@@ -379,7 +480,12 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val
modalProperty2Declarative
=
createRule
(
FindModalProperty
.
Matcher
.
querySpecification
)
.
action
(
CRUDActivationStateEnum
.
CREATED
)
[
modalPropertyCreatedDIM
(
modpropinst
)
if
(
PropertyUtils
.
getDeclarativeModalPropertyValue
(
modpropinst
,
(
modpropinst
.
eContainer
as
PropertyAssociationInstance
).
propertyAssociation
)
===
null
)
{
if
(
!PropertyUtils.isInheritedProperty(propinst)) {
modalPropertyCreatedDIM
(
modpropinst
)
println
(
"DIM: Modal property instance for property "
+
propinst
.
property
.
name
+
" (for "
+(
propinst
.
eContainer
as
InstanceObject
).
name
+
") de-instantiated"
)
}
}
].
action
(
CRUDActivationStateEnum
.
UPDATED
)
[
//
ModalPropertyValue
inModes
if
(
!(modpropinst.inModes.isEmpty())) {
...
...
@@ -388,6 +494,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
for
(
Mode
modpropmode
:
modpropinst
.
inModes
)
{
PropertyUtils
.
getDeclarativeModalPropertyValue
(
modpropinst
,
(
modpropinst
.
eContainer
as
PropertyAssociationInstance
).
propertyAssociation
).
add
(
modalElement_InMode
,
ModeUtils
.
findObjectModeInstInSOM
(
modpropinst
.
eContainer
.
eContainer
as
InstanceObject
,
modpropmode
as
SystemOperationMode
).
mode
)
}
println
(
"DIM: Modes in modal property instance for property "
+
propinst
.
property
.
name
+
" (for "
+(
propinst
.
eContainer
as
InstanceObject
).
name
+
") refreshed"
)
}
].
action
(
CRUDActivationStateEnum
.
DELETED
)
[
modpropinst
.
eContainer
.
remove
(
propertyAssociation_OwnedValue
,
PropertyUtils
.
getDeclarativeModalPropertyValue
(
modpropinst
,
(
modpropinst
.
eContainer
as
PropertyAssociationInstance
).
propertyAssociation
))
...
...
@@ -395,7 +502,12 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val
propertyval2declarative
=
createRule
(
FindPropertyValue
.
Matcher
.
querySpecification
)
.
action
(
CRUDActivationStateEnum
.
CREATED
)[
propertyValueCreatedDIM
(
propinst
,
modpropinst
,
propvalinst
)
if
(
!PropertyUtils.isInheritedProperty(propinst)) {
if
(
PropertyUtils
.
getDeclarativeModalPropertyValue
(
modpropinst
,
propinst
.
propertyAssociation
).
ownedValue
===
null
)
{
propertyValueCreatedDIM
(
propinst
,
modpropinst
,
propvalinst
)
println
(
"DIM: Value of property "
+
propinst
.
property
.
name
+
" (for "
+(
propinst
.
eContainer
as
InstanceObject
).
name
+
") de-instantiated"
)
}
}
].
action
(
CRUDActivationStateEnum
.
UPDATED
)
[
if
(
PropertyUtils
.
isInheritedProperty
(
PropertyUtils
.
getContainingPropertyAssociationInstance
(
propvalinst
)))
{
propertyInstanceCreatedDIM
(
PropertyUtils
.
getContainingPropertyAssociationInstance
(
propvalinst
),
aadlPublicPackage
)
...
...
fr.mem4csd.osatedim.viatra/src/fr/mem4csd/osatedim/viatra/transformations/DIMTransformationRules.xtend
View file @
eeedecc0
This diff is collapsed.
Click to expand it.
fr.mem4csd.osatedim.viatra/src/fr/mem4csd/osatedim/viatra/utils/LibraryUtils.java
View file @
eeedecc0
...
...
@@ -15,6 +15,7 @@ import org.osate.aadl2.NamedElement;
import
org.osate.aadl2.PackageSection
;
import
org.osate.aadl2.Subcomponent
;
import
org.osate.aadl2.instance.ComponentInstance
;
import
org.osate.aadl2.instance.SystemInstance
;
import
fr.mem4csd.osatedim.viatra.queries.FindComponent
;
...
...
@@ -26,7 +27,12 @@ public class LibraryUtils {
public
static
EList
<
ComponentImplementation
>
getAllInheritingParentImplementations
(
ClassifierFeature
child
,
ComponentInstance
parent
)
{
final
EList
<
ComponentImplementation
>
returnList
=
new
BasicEList
<
ComponentImplementation
>();
ComponentImplementation
parentcomp
=
(
ComponentImplementation
)
parent
.
getClassifier
();
ComponentImplementation
parentcomp
;
if
(
parent
.
getClassifier
()
==
null
)
{
parentcomp
=
((
SystemInstance
)
parent
).
getComponentImplementation
();
}
else
{
parentcomp
=
(
ComponentImplementation
)
parent
.
getClassifier
();
}
returnList
.
add
(
parentcomp
);
while
(
parentcomp
!=
child
.
eContainer
())
{
parentcomp
=
parentcomp
.
getExtended
();
...
...
@@ -35,7 +41,9 @@ public class LibraryUtils {
return
returnList
;
}
public
static
Integer
getExtensionIndex
(
Integer
libraryIndex
,
Integer
reusedIndex
,
Boolean
modifyReused
)
{
public
static
Integer
computeExtensionIndex
(
EList
<?
extends
ComponentClassifier
>
extensionList
,
PackageSection
aadlPublicPackage
,
ViatraQueryEngine
engine
,
Boolean
modifyReused
)
{
final
Integer
libraryIndex
=
LibraryUtils
.
getClosestLibraryImplementationIndex
(
extensionList
,
aadlPublicPackage
);
final
Integer
reusedIndex
=
LibraryUtils
.
getClosestReusedClassifierIndex
(
extensionList
,
engine
)
;
if
(
modifyReused
)
{
return
libraryIndex
;
}
else
{
...
...
@@ -67,7 +75,12 @@ public class LibraryUtils {
public
static
EList
<
ComponentClassifier
>
getAllInheritingParentClassifiers
(
NamedElement
element
,
ComponentInstance
compinst
)
{
final
EList
<
ComponentClassifier
>
returnList
=
new
BasicEList
<
ComponentClassifier
>();
ComponentClassifier
compclass
=
compinst
.
getClassifier
();
ComponentClassifier
compclass
;
if
(
compinst
.
getClassifier
()
==
null
)
{
compclass
=
((
SystemInstance
)
compinst
).
getComponentImplementation
();
}
else
{
compclass
=
compinst
.
getClassifier
();
}
returnList
.
add
(
compclass
);
while
(
compclass
!=
element
.
eContainer
())
{
compclass
=
(
ComponentClassifier
)
compclass
.
getExtended
();
...
...
fr.mem4csd.osatedim.viatra/src/fr/mem4csd/osatedim/viatra/utils/PropertyUtils.java
View file @
eeedecc0
...
...
@@ -163,6 +163,9 @@ public class PropertyUtils {
}
public
static
ModalPropertyValue
getDeclarativeModalPropertyValue
(
ModalPropertyValue
modpropinst
,
PropertyAssociation
propassoc
)
{
if
(
propassoc
.
getOwnedValues
().
size
()
==
1
)
{
return
propassoc
.
getOwnedValues
().
get
(
0
);
}
for
(
ModalPropertyValue
modprop
:
propassoc
.
getOwnedValues
())
{
if
(
modprop
.
getInModes
().
containsAll
(
ModeUtils
.
getAllDeclarativeModes
(
modpropinst
))
&&
ModeUtils
.
getAllDeclarativeModes
(
modpropinst
).
containsAll
(
modprop
.
getInModes
()))
{
return
modprop
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment