Skip to content

Commit

Permalink
Mirror example case study
Browse files Browse the repository at this point in the history
  • Loading branch information
TomWerm committed Sep 11, 2023
1 parent b30314a commit 09e4ce4
Show file tree
Hide file tree
Showing 49 changed files with 3,248 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Eclipse/Java
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*.class

# Genenerated Files
src-gen/

# Xtend
xtend-gen/
*._trace
*.xtendbin

# Maven
target/
.mvn/wrapper/maven-wrapper.jar

# Custom
EvaluationData
*.DS_Store
*.polyglot
*.pom.tycho
8 changes: 8 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<extensions>
<extension>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-build</artifactId>
<version>3.0.4</version>
</extension>
</extensions>
18 changes: 18 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.1/apache-maven-3.9.1-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
21 changes: 21 additions & 0 deletions bundles/tools.vitruv.applications.simulinkautosar/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="src-gen">
<attributes>
<attribute name="ignore_optional_problems" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="xtend-gen">
<attributes>
<attribute name="ignore_optional_problems" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Empty file.
45 changes: 45 additions & 0 deletions bundles/tools.vitruv.applications.simulinkautosar/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tools.vitruv.applications.simulinkautosar</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
<filteredResources>
<filter>
<id>1686732736986</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: tools.vitruv.applications.simulinkautosar
Bundle-SymbolicName: tools.vitruv.applications.simulinkautosar;singleton:=true
Bundle-Version: 3.0.1.qualifier
Bundle-Vendor: vitruv.tools
Export-Package: tools.vitruv.applications.simulinkautosar
Require-Bundle: edu.kit.ipd.sdq.activextendannotations,
edu.kit.ipd.sdq.commons.util.emf,
edu.kit.ipd.sdq.commons.util.java,
tools.vitruv.framework.applications,
tools.vitruv.dsls.reactions.runtime,
edu.kit.ipd.sdq.metamodels.autosar,
edu.kit.ipd.sdq.metamodels.simulink
Bundle-RequiredExecutionEnvironment: JavaSE-17
Automatic-Module-Name: tools.vitruv.applications.simulinkautosar
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source.. = src/,\
src-gen/,\
xtend-gen/
output.. = target/classes/
bin.includes = META-INF/,\
.,\
plugin.xml
16 changes: 16 additions & 0 deletions bundles/tools.vitruv.applications.simulinkautosar/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>

<!--
-->

<plugin>
<extension
id="SimuLinkAutoSARApplication"
name="SimuLink-AutoSAR Application"
point="tools.vitruv.framework.applications.application">
<application
class="tools.vitruv.applications.simulinkautosar.SimuLinkAutoSARApplication"></application>
</extension>

</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package tools.vitruv.applications.simulinkautosar;

import java.util.HashSet;
import java.util.Set;

import tools.vitruv.framework.applications.VitruvApplication;
import tools.vitruv.change.propagation.ChangePropagationSpecification;

public class AutoSARSimuLinkApplication implements VitruvApplication {

@Override
public Set<ChangePropagationSpecification> getChangePropagationSpecifications() {
Set<ChangePropagationSpecification> specs = new HashSet<ChangePropagationSpecification>();
specs.add(new AutoSARToSimuLinkChangePropagationSpecification());
specs.add(new SimuLinkToAutoSARChangePropagationSpecification());
return specs;
}

@Override
public String getName() {
return "SimuLink <> AutoSAR";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package tools.vitruv.applications.simulinkautosar

class AutoSARToSimuLinkChangePropagationSpecification extends mir.reactions.autoSARToSimulink.AutoSARToSimulinkChangePropagationSpecification{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package tools.vitruv.applications.simulinkautosar

class SimuLinkToAutoSARChangePropagationSpecification extends mir.reactions.simuLinkTOAutoSAR.SimuLinkTOAutoSARChangePropagationSpecification {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import edu.kit.ipd.sdq.metamodels.autosar.AutoSARPackage
import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.common.util.URIUtil
import edu.kit.ipd.sdq.metamodels.simulink.SimuLinkFactory
import edu.kit.ipd.sdq.metamodels.simulink.SimuLinkPackage
import edu.kit.ipd.sdq.metamodels.simulink.SimulinkModel
import tools.vitruv.dsls.reactions.runtime.helper.PersistenceHelper

import "edu.kit.ipd.sdq.metamodels.autosar" as AutoSAR
import "edu.kit.ipd.sdq.metamodels.simulink" as SimuLink

reactions: autoSARToSimulinkTypePropagation
in reaction to changes in AutoSAR
execute actions in SimuLink




routine detectOrCreateSimuLinkModel(EObject alreadyPersistedEObject) {
match {
require absence of SimuLink::SimulinkModel corresponding to SimuLinkPackage.Literals.SIMULINK_MODEL
}
update {

val rootModelFile = "model" + "/" + "model" + ".arxml"
// Check if a model at the specified path already exists; create one if necessary
var SimulinkModel SimuLinkRootModel = null
if (alreadyPersistedEObject === null) {
// no objects persisted jet -> can't automatically retrieve projectPath
throw new UnsupportedOperationException(
"Cannot persist/load a SimuLink::SimuLinkModel without any previously persisted elements.")
}
val uri = PersistenceHelper.getURIFromSourceProjectFolder(alreadyPersistedEObject, rootModelFile)
if (URIUtil.existsResourceAtUri(uri)) {
// The resource is only found if it was previously persisted, which only happens after the change propagation terminates.
// This should not be a problem, as long as any created model is registered on creation, to prevent creating a second one.
val resource = alreadyPersistedEObject.eResource.resourceSet.getResource(uri, true)
SimuLinkRootModel = resource.allContents.filter(SimulinkModel).head
}
if (SimuLinkRootModel === null) {
// The resource didn't exist, or did not contain a uml::Model object
SimuLinkRootModel = SimuLinkFactory.eINSTANCE.createSimulinkModel()
SimuLinkRootModel.name = "model"
persistProjectRelative(alreadyPersistedEObject, SimuLinkRootModel, rootModelFile)
}
if (SimuLinkRootModel !== null) {
registerSimuLinkModelInCorrespondenceModel(SimuLinkRootModel)
}
}
}


routine registerSimuLinkModelInCorrespondenceModel(SimuLink::SimulinkModel uModel) {
match {
require absence of SimuLink::SimulinkModel corresponding to SimuLinkPackage.Literals.SIMULINK_MODEL
}
update {
addCorrespondenceBetween(uModel, SimuLinkPackage.Literals.SIMULINK_MODEL)
}
}


reaction AutoSARModelAdded{

after element AutoSAR::AutoSARModel inserted as root
call {

checkIfModelCorrespondenceExists(newValue)
createOrFindSimuLinkModel(newValue)
}
}


routine createOrFindSimuLinkModel(AutoSAR::AutoSARModel autoSARModel) {
match {
require absence of SimuLink::SimulinkModel corresponding to autoSARModel
}
update {
checkIfModelExists(autoSARModel)

}
}

routine checkIfModelExists(AutoSAR::AutoSARModel autoSARModel){
match{
val SimuLinkModel = retrieve optional SimuLink::SimulinkModel corresponding to SimuLinkPackage.Literals.SIMULINK_MODEL
}
update{

if(!SimuLinkModel.isPresent){
createSimuLinkModel(autoSARModel)
}


}


}


routine createSimuLinkModel(AutoSAR::AutoSARModel autoSARModel) {
update {
val simuLinkModel = SimuLinkFactory.eINSTANCE.createSimulinkModel()
simuLinkModel.name = autoSARModel.name
var rootModelFile = "model" + "/" + "model" + ".arxml"
persistProjectRelative(autoSARModel,simuLinkModel,rootModelFile)
addCorrespondenceBetween(SimuLinkPackage.Literals.SIMULINK_MODEL, simuLinkModel)
addCorrespondenceBetween(simuLinkModel, autoSARModel)
}
}



routine checkIfModelCorrespondenceExists(AutoSAR::AutoSARModel newModel){

match{
val alreadyCorrespondingModels = retrieve many AutoSAR::AutoSARModel corresponding to AutoSARPackage.Literals.AUTO_SAR_MODEL
check !alreadyCorrespondingModels.contains(newModel)
}
update{

addCorrespondenceBetween(newModel,AutoSARPackage.Literals.AUTO_SAR_MODEL)
}

}


reaction AutoSARElementNameChanged{
after attribute replaced at AutoSAR::AutoSARElement[name]
call changeSimulinkElementName(affectedEObject)
}


routine changeSimulinkElementName(AutoSAR::AutoSARElement autoSARElement){
match {
val SimuLinkElement = retrieve SimuLink::SimulinkElement corresponding to autoSARElement
}
update{
SimuLinkElement.name = autoSARElement.name
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import "edu.kit.ipd.sdq.metamodels.autosar" as AutoSAR
import "edu.kit.ipd.sdq.metamodels.simulink" as SimuLink

reactions: autoSARToSimulink
in reaction to changes in AutoSAR
execute actions in SimuLink

import autoSARToSimulinkTypePropagation using qualified names
import autoSARToSimulinkTComponentsToBlocks using qualified names
import autoSARToSimulinkPorts using qualified names



Loading

0 comments on commit 09e4ce4

Please sign in to comment.