Update to new EMA Version

parent 54eb1d19
...@@ -10,9 +10,9 @@ for your new MiddlewareSymbol. Make sure to load all your tags before starting g ...@@ -10,9 +10,9 @@ for your new MiddlewareSymbol. Make sure to load all your tags before starting g
## Generator ## Generator
The new middleware generator needs to the following methods The new middleware generator needs to the following methods
* `setGenerationTargetPath(String path)`: Sets the directory the generated files are written to. * `setGenerationTargetPath(String path)`: Sets the directory the generated files are written to.
* `boolean willAccept(ExpandedComponentInstanceSymbol componentInstanceSymbol)`: Signals the DistributedTargetGenerator if the middleware generator will generate useful files for the given component. * `boolean willAccept(EMAComponentInstanceSymbol componentInstanceSymbol)`: Signals the DistributedTargetGenerator if the middleware generator will generate useful files for the given component.
* Example: If a Component without RosConnections is passed to the ROS generator, it will reject it. * Example: If a Component without RosConnections is passed to the ROS generator, it will reject it.
* `List<File> generate(ExpandedComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver)`: Generates all files(Adapter + CMake) for the given Component. * `List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver)`: Generates all files(Adapter + CMake) for the given Component.
These 3 methods are combined in the Interface [GeneratorImpl](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/generators/EMAM2Middleware/blob/master/src/main/java/de/monticore/lang/monticar/generator/middleware/impls/GeneratorImpl.java). These 3 methods are combined in the Interface [GeneratorImpl](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/generators/EMAM2Middleware/blob/master/src/main/java/de/monticore/lang/monticar/generator/middleware/impls/GeneratorImpl.java).
To avoid a cyclic dependency between the new middleware generator and EMAM2Middleware, it is advised to write a small wrapper in EMAM2Middleware instead of implementing the Interface directly. See [RosCppGenImpl](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/generators/EMAM2Middleware/blob/master/src/main/java/de/monticore/lang/monticar/generator/middleware/impls/RosCppGenImpl.java) for an example. To avoid a cyclic dependency between the new middleware generator and EMAM2Middleware, it is advised to write a small wrapper in EMAM2Middleware instead of implementing the Interface directly. See [RosCppGenImpl](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/generators/EMAM2Middleware/blob/master/src/main/java/de/monticore/lang/monticar/generator/middleware/impls/RosCppGenImpl.java) for an example.
......
...@@ -18,11 +18,12 @@ ...@@ -18,11 +18,12 @@
<!-- .. SE-Libraries .................................................. --> <!-- .. SE-Libraries .................................................. -->
<se-commons.version>1.7.7</se-commons.version> <se-commons.version>1.7.7</se-commons.version>
<Embedded-montiarc-math-generator.version>0.0.26-SNAPSHOT</Embedded-montiarc-math-generator.version> <!--TODO: remove with update to next emam version -->
<Embedded-montiarc-math-roscpp-generator.version>0.0.4-SNAPSHOT</Embedded-montiarc-math-roscpp-generator.version> <struct.version>0.0.18-SNAPSHOT</struct.version>
<Embedded-montiarc-math-rosmsg-generator.version>0.0.3-SNAPSHOT</Embedded-montiarc-math-rosmsg-generator.version> <Embedded-montiarc-math-generator.version>0.1.3-SNAPSHOT</Embedded-montiarc-math-generator.version>
<EMADL.version>0.2.3</EMADL.version> <Embedded-montiarc-math-roscpp-generator.version>0.1.1-SNAPSHOT</Embedded-montiarc-math-roscpp-generator.version>
<EMADL2CPP.version>0.2.4</EMADL2CPP.version> <EMADL.version>0.2.4</EMADL.version>
<EMADL2CPP.version>0.2.6-SNAPSHOT</EMADL2CPP.version>
<!--TODO: remove with update to new emam version--> <!--TODO: remove with update to new emam version-->
<Tagging.version>0.0.6</Tagging.version> <Tagging.version>0.0.6</Tagging.version>
...@@ -52,6 +53,12 @@ ...@@ -52,6 +53,12 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>struct</artifactId>
<version>${struct.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson --> <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
...@@ -89,12 +96,6 @@ ...@@ -89,12 +96,6 @@
<version>${Embedded-montiarc-math-roscpp-generator.version}</version> <version>${Embedded-montiarc-math-roscpp-generator.version}</version>
</dependency> </dependency>
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-rosmsg-generator</artifactId>
<version>${Embedded-montiarc-math-rosmsg-generator.version}</version>
</dependency>
<!-- EMADL Dependencies --> <!-- EMADL Dependencies -->
<dependency> <dependency>
<groupId>de.monticore.lang.monticar</groupId> <groupId>de.monticore.lang.monticar</groupId>
......
package de.monticore.lang.monticar.generator.middleware; package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.FileContent; import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.middleware.helpers.FileHelper; import de.monticore.lang.monticar.generator.middleware.helpers.FileHelper;
import de.monticore.lang.tagging._symboltable.TaggingResolver; import de.monticore.lang.tagging._symboltable.TaggingResolver;
...@@ -15,7 +15,7 @@ import java.util.Objects; ...@@ -15,7 +15,7 @@ import java.util.Objects;
public class CMakeGenerator extends StarBridgeGenerator { public class CMakeGenerator extends StarBridgeGenerator {
@Override @Override
public List<File> generate(ExpandedComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException { public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
long notInSubdirs = getGeneratorImpls().stream() long notInSubdirs = getGeneratorImpls().stream()
.map(this::getImplSubdir) .map(this::getImplSubdir)
.filter(Objects::isNull) .filter(Objects::isNull)
...@@ -31,7 +31,7 @@ public class CMakeGenerator extends StarBridgeGenerator { ...@@ -31,7 +31,7 @@ public class CMakeGenerator extends StarBridgeGenerator {
return res; return res;
} }
protected File generateCMake(ExpandedComponentInstanceSymbol componentInstanceSymbol) throws IOException { protected File generateCMake(EMAComponentInstanceSymbol componentInstanceSymbol) throws IOException {
FileContent fileContent = new FileContent(); FileContent fileContent = new FileContent();
fileContent.setFileName("CMakeLists.txt"); fileContent.setFileName("CMakeLists.txt");
StringBuilder content = new StringBuilder(); StringBuilder content = new StringBuilder();
......
package de.monticore.lang.monticar.generator.middleware; package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.FileContent; import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.middleware.helpers.*; import de.monticore.lang.monticar.generator.middleware.helpers.*;
import de.monticore.lang.monticar.generator.middleware.impls.GeneratorImpl; import de.monticore.lang.monticar.generator.middleware.impls.GeneratorImpl;
...@@ -24,12 +24,12 @@ public class DistributedTargetGenerator extends CMakeGenerator { ...@@ -24,12 +24,12 @@ public class DistributedTargetGenerator extends CMakeGenerator {
} }
@Override @Override
public List<File> generate(ExpandedComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException { public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
Map<ExpandedComponentInstanceSymbol, GeneratorImpl> generatorMap = new HashMap<>(); Map<EMAComponentInstanceSymbol, GeneratorImpl> generatorMap = new HashMap<>();
fixComponentInstance(componentInstanceSymbol); fixComponentInstance(componentInstanceSymbol);
List<ExpandedComponentInstanceSymbol> clusterSubcomponents = ClusterHelper.getClusterSubcomponents(componentInstanceSymbol); List<EMAComponentInstanceSymbol> clusterSubcomponents = ClusterHelper.getClusterSubcomponents(componentInstanceSymbol);
if (clusterSubcomponents.size() > 0) { if (clusterSubcomponents.size() > 0) {
clusterSubcomponents.forEach(clusterECIS -> { clusterSubcomponents.forEach(clusterECIS -> {
String nameTargetLanguage = NameHelper.getNameTargetLanguage(clusterECIS.getFullName()); String nameTargetLanguage = NameHelper.getNameTargetLanguage(clusterECIS.getFullName());
...@@ -42,7 +42,7 @@ public class DistributedTargetGenerator extends CMakeGenerator { ...@@ -42,7 +42,7 @@ public class DistributedTargetGenerator extends CMakeGenerator {
List<File> files = new ArrayList<>(); List<File> files = new ArrayList<>();
for (ExpandedComponentInstanceSymbol comp : generatorMap.keySet()) { for (EMAComponentInstanceSymbol comp : generatorMap.keySet()) {
files.addAll(generatorMap.get(comp).generate(comp, taggingResolver)); files.addAll(generatorMap.get(comp).generate(comp, taggingResolver));
//add empty generator to subDirs so that CMakeLists.txt will be generated correctly //add empty generator to subDirs so that CMakeLists.txt will be generated correctly
subDirs.add(NameHelper.getNameTargetLanguage(comp.getFullName())); subDirs.add(NameHelper.getNameTargetLanguage(comp.getFullName()));
...@@ -73,12 +73,12 @@ public class DistributedTargetGenerator extends CMakeGenerator { ...@@ -73,12 +73,12 @@ public class DistributedTargetGenerator extends CMakeGenerator {
return res; return res;
} }
private void fixComponentInstance(ExpandedComponentInstanceSymbol componentInstanceSymbol) { private void fixComponentInstance(EMAComponentInstanceSymbol componentInstanceSymbol) {
RosHelper.fixRosConnectionSymbols(componentInstanceSymbol); RosHelper.fixRosConnectionSymbols(componentInstanceSymbol);
} }
@Override @Override
protected File generateCMake(ExpandedComponentInstanceSymbol componentInstanceSymbol) throws IOException { protected File generateCMake(EMAComponentInstanceSymbol componentInstanceSymbol) throws IOException {
FileContent fileContent = new FileContent(); FileContent fileContent = new FileContent();
fileContent.setFileName("CMakeLists.txt"); fileContent.setFileName("CMakeLists.txt");
StringBuilder content = new StringBuilder(); StringBuilder content = new StringBuilder();
......
...@@ -2,7 +2,7 @@ package de.monticore.lang.monticar.generator.middleware; ...@@ -2,7 +2,7 @@ package de.monticore.lang.monticar.generator.middleware;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonReader;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosToEmamTagSchema; import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosToEmamTagSchema;
import de.monticore.lang.monticar.emadl.generator.EMADLAbstractSymtab; import de.monticore.lang.monticar.emadl.generator.EMADLAbstractSymtab;
import de.monticore.lang.monticar.emadl.generator.EMADLGeneratorCli; import de.monticore.lang.monticar.emadl.generator.EMADLGeneratorCli;
...@@ -127,7 +127,7 @@ public final class DistributedTargetGeneratorCli { ...@@ -127,7 +127,7 @@ public final class DistributedTargetGeneratorCli {
} }
}); });
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve(cliParameters.getRootModel(), ExpandedComponentInstanceSymbol.KIND).orElse(null); EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve(cliParameters.getRootModel(), EMAComponentInstanceSymbol.KIND).orElse(null);
if (componentInstanceSymbol == null) { if (componentInstanceSymbol == null) {
Log.error("0x5FFAE: The given component cannot be resolved."); Log.error("0x5FFAE: The given component cannot be resolved.");
......
package de.monticore.lang.monticar.generator.middleware; package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.FileContent; import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.cpp.converter.ComponentConverter; import de.monticore.lang.monticar.generator.cpp.converter.ComponentConverter;
import de.monticore.lang.monticar.generator.middleware.helpers.FileHelper; import de.monticore.lang.monticar.generator.middleware.helpers.FileHelper;
...@@ -17,7 +17,7 @@ import java.util.stream.Collectors; ...@@ -17,7 +17,7 @@ import java.util.stream.Collectors;
public class MiddlewareGenerator extends CMakeGenerator { public class MiddlewareGenerator extends CMakeGenerator {
@Override @Override
public List<File> generate(ExpandedComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException { public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
//Add dummy GeneratorImpl for the subdir //Add dummy GeneratorImpl for the subdir
String subdir = "coordinator/"; String subdir = "coordinator/";
this.add(new GeneratorImpl() { this.add(new GeneratorImpl() {
...@@ -30,7 +30,7 @@ public class MiddlewareGenerator extends CMakeGenerator { ...@@ -30,7 +30,7 @@ public class MiddlewareGenerator extends CMakeGenerator {
return files; return files;
} }
private FileContent generateIAdapter(ExpandedComponentInstanceSymbol componentInstanceSymbol) { private FileContent generateIAdapter(EMAComponentInstanceSymbol componentInstanceSymbol) {
FileContent res = new FileContent(); FileContent res = new FileContent();
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName()); String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
res.setFileName("IAdapter_" + name + ".h"); res.setFileName("IAdapter_" + name + ".h");
...@@ -39,7 +39,7 @@ public class MiddlewareGenerator extends CMakeGenerator { ...@@ -39,7 +39,7 @@ public class MiddlewareGenerator extends CMakeGenerator {
} }
private FileContent generateCoordinator(ExpandedComponentInstanceSymbol componentInstanceSymbol, List<File> files) { private FileContent generateCoordinator(EMAComponentInstanceSymbol componentInstanceSymbol, List<File> files) {
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName()); String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
...@@ -80,7 +80,7 @@ public class MiddlewareGenerator extends CMakeGenerator { ...@@ -80,7 +80,7 @@ public class MiddlewareGenerator extends CMakeGenerator {
} }
private FileContent generateCoordinatorCMakeList(ExpandedComponentInstanceSymbol componentInstanceSymbol, List<File> files) { private FileContent generateCoordinatorCMakeList(EMAComponentInstanceSymbol componentInstanceSymbol, List<File> files) {
FileContent res = new FileContent(); FileContent res = new FileContent();
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName()); String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
......
package de.monticore.lang.monticar.generator.middleware; package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.middleware.impls.GeneratorImpl; import de.monticore.lang.monticar.generator.middleware.impls.GeneratorImpl;
import de.monticore.lang.tagging._symboltable.TaggingResolver; import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.Log;
...@@ -34,7 +34,7 @@ public class StarBridgeGenerator implements GeneratorImpl { ...@@ -34,7 +34,7 @@ public class StarBridgeGenerator implements GeneratorImpl {
this.generationTargetPath = path.endsWith("/") ? path : path + "/"; this.generationTargetPath = path.endsWith("/") ? path : path + "/";
} }
public List<File> generate(ExpandedComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException { public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
List<File> result = new ArrayList<>(); List<File> result = new ArrayList<>();
generatorImpls.forEach((key, value) -> { generatorImpls.forEach((key, value) -> {
if (key.willAccept(componentInstanceSymbol)) { if (key.willAccept(componentInstanceSymbol)) {
......
package de.monticore.lang.monticar.generator.middleware.helpers; package de.monticore.lang.monticar.generator.middleware.helpers;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.*; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAConnectorBuilder;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAConnectorSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAPortBuilder;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAPortSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceBuilder;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAConnectorInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAPortInstanceSymbol;
import de.monticore.symboltable.CommonScope; import de.monticore.symboltable.CommonScope;
import de.monticore.symboltable.MutableScope; import de.monticore.symboltable.MutableScope;
import de.monticore.symboltable.Symbol; import de.monticore.symboltable.Symbol;
...@@ -19,40 +26,40 @@ public class ClusterHelper { ...@@ -19,40 +26,40 @@ public class ClusterHelper {
private ClusterHelper() { private ClusterHelper() {
} }
public static List<Set<ExpandedComponentInstanceSymbol>> getClusters(ExpandedComponentInstanceSymbol componentInstanceSymbol) { public static List<Set<EMAComponentInstanceSymbol>> getClusters(EMAComponentInstanceSymbol componentInstanceSymbol) {
Graph<ExpandedComponentInstanceSymbol, DefaultEdge> graph = new SimpleGraph<>(DefaultEdge.class); Graph<EMAComponentInstanceSymbol, DefaultEdge> graph = new SimpleGraph<>(DefaultEdge.class);
componentInstanceSymbol.getSubComponents().forEach(graph::addVertex); componentInstanceSymbol.getSubComponents().forEach(graph::addVertex);
graph.addVertex(componentInstanceSymbol); graph.addVertex(componentInstanceSymbol);
componentInstanceSymbol.getConnectors().stream() componentInstanceSymbol.getConnectorInstances().stream()
.filter(c -> !(c.getSourcePort().getMiddlewareSymbol().isPresent() && c.getTargetPort().getMiddlewareSymbol().isPresent())) .filter(c -> !(c.getSourcePort().getMiddlewareSymbol().isPresent() && c.getTargetPort().getMiddlewareSymbol().isPresent()))
.forEach(c -> { .forEach(c -> {
ExpandedComponentInstanceSymbol compSource = c.getSourcePort().getComponentInstance().orElse(null); EMAComponentInstanceSymbol compSource = c.getSourcePort().getComponentInstance();
ExpandedComponentInstanceSymbol compTarget = c.getTargetPort().getComponentInstance().orElse(null); EMAComponentInstanceSymbol compTarget = c.getTargetPort().getComponentInstance();
if (compSource == null || compTarget == null) if (compSource == null || compTarget == null)
Log.error("ComponentInstance of source or target not found!"); Log.error("ComponentInstance of source or target not found!");
if(!compSource.equals(compTarget)) if (!compSource.equals(compTarget))
graph.addEdge(compSource, compTarget); graph.addEdge(compSource, compTarget);
}); });
ConnectivityInspector<ExpandedComponentInstanceSymbol, DefaultEdge> connectivityInspector = new ConnectivityInspector<>(graph); ConnectivityInspector<EMAComponentInstanceSymbol, DefaultEdge> connectivityInspector = new ConnectivityInspector<>(graph);
int instanceSetSize = connectivityInspector.connectedSetOf(componentInstanceSymbol).size(); int instanceSetSize = connectivityInspector.connectedSetOf(componentInstanceSymbol).size();
if (instanceSetSize != 1) { if (instanceSetSize != 1) {
Log.warn("0x8EFC3: The supercomponent can only be connected to subcomponents via middleware ports!"); Log.warn("0x8EFC3: The supercomponent can only be connected to subcomponents via middleware ports!");
return new ArrayList<>(); return new ArrayList<>();
} }
//All subcomps are connected via non mw -> only highest level needs to be generated //All subcomps are connected via non mw -> only highest level needs to be generated
if(instanceSetSize != componentInstanceSymbol.getSubComponents().size() + 1) if (instanceSetSize != componentInstanceSymbol.getSubComponents().size() + 1)
graph.removeVertex(componentInstanceSymbol); graph.removeVertex(componentInstanceSymbol);
List<Set<ExpandedComponentInstanceSymbol>> res = connectivityInspector.connectedSets(); List<Set<EMAComponentInstanceSymbol>> res = connectivityInspector.connectedSets();
return res; return res;
} }
public static List<ExpandedComponentInstanceSymbol> getClusterSubcomponents(ExpandedComponentInstanceSymbol componentInstanceSymbol) { public static List<EMAComponentInstanceSymbol> getClusterSubcomponents(EMAComponentInstanceSymbol componentInstanceSymbol) {
List<Set<ExpandedComponentInstanceSymbol>> clusters = getClusters(componentInstanceSymbol); List<Set<EMAComponentInstanceSymbol>> clusters = getClusters(componentInstanceSymbol);
List<ExpandedComponentInstanceSymbol> res = new ArrayList<>(); List<EMAComponentInstanceSymbol> res = new ArrayList<>();
int[] i = {0}; int[] i = {0};
clusters.forEach(c -> { clusters.forEach(c -> {
if (c.size() == 1) { if (c.size() == 1) {
...@@ -79,13 +86,13 @@ public class ClusterHelper { ...@@ -79,13 +86,13 @@ public class ClusterHelper {
// Sub Ros -> Super Ros: handled(let ros connect) // Sub Ros -> Super Ros: handled(let ros connect)
// Sub Ros -> Sub Ros: do nothing, wrapper and therefore the mw does not affect this level // Sub Ros -> Sub Ros: do nothing, wrapper and therefore the mw does not affect this level
// Sub Ros -> Sub normal: handled(let comp connect) // Sub Ros -> Sub normal: handled(let comp connect)
private static ExpandedComponentInstanceSymbol createECISFromCluster(ExpandedComponentInstanceSymbol inst, Set<ExpandedComponentInstanceSymbol> cluster, String clusterName) { private static EMAComponentInstanceSymbol createECISFromCluster(EMAComponentInstanceSymbol inst, Set<EMAComponentInstanceSymbol> cluster, String clusterName) {
Set<PortSymbol> curClusterPorts = cluster.stream().flatMap(ecis -> ecis.getPortsList().stream()).collect(Collectors.toSet()); Set<EMAPortInstanceSymbol> curClusterPorts = cluster.stream().flatMap(ecis -> ecis.getPortInstanceList().stream()).collect(Collectors.toSet());
Set<PortSymbol> combinedPorts = new HashSet<>(); Set<EMAPortInstanceSymbol> combinedPorts = new HashSet<>();
combinedPorts.addAll(curClusterPorts); combinedPorts.addAll(curClusterPorts);
combinedPorts.addAll(inst.getPortsList()); combinedPorts.addAll(inst.getPortInstanceList());
Set<ConnectorSymbol> tmpConnectiors = inst.getConnectors().stream() Set<EMAConnectorSymbol> tmpConnectiors = inst.getConnectorInstances().stream()
//remove all connections that use subcomponents not in cluster //remove all connections that use subcomponents not in cluster
.filter(c -> combinedPorts.contains(c.getSourcePort()) && combinedPorts.contains(c.getTargetPort())) .filter(c -> combinedPorts.contains(c.getSourcePort()) && combinedPorts.contains(c.getTargetPort()))
//remove all connections from super -> super and warn //remove all connections from super -> super and warn
...@@ -97,19 +104,20 @@ public class ClusterHelper { ...@@ -97,19 +104,20 @@ public class ClusterHelper {
return true; return true;
}) })
//remove all connections super <-> cluster //remove all connections super <-> cluster
.filter(c -> !(inst.getPortsList().contains(c.getSourcePort()) || (inst.getPortsList().contains(c.getTargetPort())))) .filter(c -> !(inst.getPortInstanceList().contains(c.getSourcePort()) || (inst.getPortInstanceList().contains(c.getTargetPort()))))
.collect(Collectors.toSet()); .collect(Collectors.toSet());
Collection<PortSymbol> mwPorts = curClusterPorts.stream() Collection<EMAPortInstanceSymbol> mwPorts = curClusterPorts.stream()
.filter(p -> p.getMiddlewareSymbol().isPresent()) .filter(p -> p.getMiddlewareSymbol().isPresent())
.collect(Collectors.toSet()); .collect(Collectors.toSet());
List<PortSymbol> tmpPorts = mwPorts.stream() //TODO: use EMAPortSymbol and EMAConnectorSymbol
List<EMAPortSymbol> tmpPorts = mwPorts.stream()
.filter(p -> p.getMiddlewareSymbol().isPresent()) .filter(p -> p.getMiddlewareSymbol().isPresent())
.map(p -> { .map(p -> {
String sourcePortName; String sourcePortName;
String targetPortName; String targetPortName;
String subName = p.getComponentInstance().get().getName(); String subName = p.getComponentInstance().getName();
if (p.isIncoming()) { if (p.isIncoming()) {
sourcePortName = p.getName(); sourcePortName = p.getName();
targetPortName = subName + "." + p.getName(); targetPortName = subName + "." + p.getName();
...@@ -117,7 +125,7 @@ public class ClusterHelper { ...@@ -117,7 +125,7 @@ public class ClusterHelper {
sourcePortName = subName + "." + p.getName(); sourcePortName = subName + "." + p.getName();
targetPortName = p.getName(); targetPortName = p.getName();
} }
ConnectorSymbol tmpConnector = ConnectorSymbol.builder() EMAConnectorSymbol tmpConnector = EMAConnectorSymbol.builder()
.setSource(sourcePortName) .setSource(sourcePortName)
.setTarget(targetPortName) .setTarget(targetPortName)
.build(); .build();
...@@ -127,9 +135,9 @@ public class ClusterHelper { ...@@ -127,9 +135,9 @@ public class ClusterHelper {
.collect(Collectors.toList()); .collect(Collectors.toList());
Set<ResolvingFilter<? extends Symbol>> resolvingFilters = inst.getSpannedScope().getResolvingFilters(); Set<ResolvingFilter<? extends Symbol>> resolvingFilters = inst.getSpannedScope().getResolvingFilters();
List<ExpandedComponentInstanceSymbol> tmpSubcomps = cluster.stream().map(ExpandedComponentInstanceBuilder::clone).collect(Collectors.toList()); List<EMAComponentInstanceSymbol> tmpSubcomps = cluster.stream().map(EMAComponentInstanceBuilder::clone).collect(Collectors.toList());
tmpSubcomps.forEach(sc -> ((CommonScope) sc.getSpannedScope()).setResolvingFilters(resolvingFilters)); tmpSubcomps.forEach(sc -> ((CommonScope) sc.getSpannedScope()).setResolvingFilters(resolvingFilters));
ExpandedComponentInstanceSymbol res = new ExpandedComponentInstanceBuilder() EMAComponentInstanceSymbol res = new EMAComponentInstanceBuilder()
.setName(clusterName) .setName(clusterName)
.setSymbolReference(inst.getComponentType()) .setSymbolReference(inst.getComponentType())
.addPorts(tmpPorts) .addPorts(tmpPorts)
......
package de.monticore.lang.monticar.generator.middleware.helpers; package de.monticore.lang.monticar.generator.middleware.helpers;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ConnectorSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAConnectorInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAPortInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.MiddlewareSymbol; import de.monticore.lang.embeddedmontiarc.tagging.middleware.MiddlewareSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosConnectionSymbol; import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosConnectionSymbol;
import de.monticore.lang.monticar.generator.rosmsg.GeneratorRosMsg; import de.monticore.lang.monticar.generator.rosmsg.GeneratorRosMsg;
...@@ -16,15 +16,15 @@ public class RosHelper { ...@@ -16,15 +16,15 @@ public class RosHelper {
} }
public static void fixRosConnectionSymbols(ExpandedComponentInstanceSymbol componentInstanceSymbol) { public static void fixRosConnectionSymbols(EMAComponentInstanceSymbol componentInstanceSymbol) {
componentInstanceSymbol.getConnectors().stream() componentInstanceSymbol.getConnectorInstances().stream()
.filter(connectorSymbol -> connectorSymbol.getSourcePort().isRosPort() && connectorSymbol.getTargetPort().isRosPort()) .filter(connectorSymbol -> connectorSymbol.getSourcePort().isRosPort() && connectorSymbol.getTargetPort().isRosPort())
.forEach(connectorSymbol -> { .forEach(connectorSymbol -> {
if (Objects.equals(connectorSymbol.getSourcePort().getComponentInstance().orElse(null), componentInstanceSymbol)) { if (Objects.equals(connectorSymbol.getSourcePort().getComponentInstance(), componentInstanceSymbol)) {
//In port of supercomp //In port of supercomp
inferRosConnectionIfPossible(connectorSymbol.getSourcePort(), connectorSymbol.getTargetPort()); inferRosConnectionIfPossible(connectorSymbol.getSourcePort(), connectorSymbol.getTargetPort());
generateRosConnectionIfPossible(connectorSymbol); generateRosConnectionIfPossible(connectorSymbol);
} else if (Objects.equals(connectorSymbol.getTargetPort().getComponentInstance().orElse(null), componentInstanceSymbol)) { } else if (Objects.equals(connectorSymbol.getTargetPort().getComponentInstance(), componentInstanceSymbol)) {
//out port of supercomp //out port of supercomp
inferRosConnectionIfPossible(connectorSymbol.getTargetPort(), connectorSymbol.getSourcePort()); inferRosConnectionIfPossible(connectorSymbol.getTargetPort(), connectorSymbol.getSourcePort());
generateRosConnectionIfPossible(connectorSymbol); generateRosConnectionIfPossible(connectorSymbol);
...@@ -37,7 +37,7 @@ public class RosHelper { ...@@ -37,7 +37,7 @@ public class RosHelper {
} }
//Cannot be moved to GeneratorRosCpp: target port name needed for topic name //Cannot be moved to GeneratorRosCpp: target port name needed for topic name
private static void generateRosConnectionIfPossible(ConnectorSymbol connectorSymbol) { private static void generateRosConnectionIfPossible(EMAConnectorInstanceSymbol connectorSymbol) {
MiddlewareSymbol sourceTag = connectorSymbol.getSourcePort().getMiddlewareSymbol().orElse(null); MiddlewareSymbol sourceTag = connectorSymbol.getSourcePort().getMiddlewareSymbol().orElse(null);
MiddlewareSymbol targetTag = connectorSymbol.getTargetPort().getMiddlewareSymbol().orElse(null); MiddlewareSymbol targetTag = connectorSymbol.getTargetPort().getMiddlewareSymbol().orElse(null);
if (sourceTag == null || targetTag == null || !sourceTag.isKindOf(RosConnectionSymbol.KIND) || !targetTag.isKindOf(RosConnectionSymbol.KIND)) { if (sourceTag == null || targetTag == null || !sourceTag.isKindOf(RosConnectionSymbol.KIND) || !targetTag.isKindOf(RosConnectionSymbol.KIND)) {
...@@ -72,7 +72,7 @@ public class RosHelper { ...@@ -72,7 +72,7 @@ public class RosHelper {
} }
} }
private static void inferRosConnectionIfPossible(PortSymbol sourcePort, PortSymbol targetPort) { private static void inferRosConnectionIfPossible(EMAPortInstanceSymbol sourcePort, EMAPortInstanceSymbol targetPort) {
MiddlewareSymbol sourceTag = sourcePort.getMiddlewareSymbol().orElse(null); MiddlewareSymbol sourceTag = sourcePort.getMiddlewareSymbol().orElse(null);
MiddlewareSymbol targetTag = targetPort.getMiddlewareSymbol().orElse(null); MiddlewareSymbol targetTag = targetPort.getMiddlewareSymbol().orElse(null);
if (sourceTag == null || targetTag == null || !sourceTag.isKindOf(RosConnectionSymbol.KIND) || !targetTag.isKindOf(RosConnectionSymbol.KIND)) { if (sourceTag == null || targetTag == null || !sourceTag.isKindOf(RosConnectionSymbol.KIND) || !targetTag.isKindOf(RosConnectionSymbol.KIND)) {
......
package de.monticore.lang.monticar.generator.middleware.impls; package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.FileContent; import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.cmake.CMakeConfig; import de.monticore.lang.monticar.generator.cmake.CMakeConfig;
import de.monticore.lang.monticar.generator.cpp.GeneratorCPP; import de.monticore.lang.monticar.generator.cpp.GeneratorCPP;
...@@ -28,7 +28,7 @@ public class CPPGenImpl implements GeneratorImpl { ...@@ -28,7 +28,7 @@ public class CPPGenImpl implements GeneratorImpl {
} }
@Override @Override
public List<File> generate(ExpandedComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException { public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
List<File> files = new ArrayList<>(); List<File> files = new ArrayList<>();
generatorCPP.setGenerationTargetPath(generationTargetPath); generatorCPP.setGenerationTargetPath(generationTargetPath);
......
package de.monticore.lang.monticar.generator.middleware.impls; package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAPortInstanceSymbol;
import de.monticore.lang.monticar.generator.FileContent; import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.middleware.helpers.FileHelper; import de.monticore.lang.monticar.generator.middleware.helpers.FileHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.NameHelper; import de.monticore.lang.monticar.generator.middleware.helpers.NameHelper;
...@@ -19,7 +19,7 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl { ...@@ -19,7 +19,7 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl {
private String generationTargetPath; private String generationTargetPath;
@Override @Override
public List<File> generate(ExpandedComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException { public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
List<File> res = new ArrayList<>(); List<File> res = new ArrayList<>();
res.add(FileHelper.generateFile(generationTargetPath, generateCMake(componentInstanceSymbol))); res.add(FileHelper.generateFile(generationTargetPath, generateCMake(componentInstanceSymbol)));
...@@ -28,7 +28,7 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl { ...@@ -28,7 +28,7 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl {
} }
private FileContent generateAdapter(ExpandedComponentInstanceSymbol componentInstanceSymbol) { private FileContent generateAdapter(EMAComponentInstanceSymbol componentInstanceSymbol) {
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName()); String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
String content = TemplateHelper.getDummyAdapterTemplate() String content = TemplateHelper.getDummyAdapterTemplate()
.replace("${compName}", name); .replace("${compName}", name);
...@@ -45,16 +45,16 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl { ...@@ -45,16 +45,16 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl {
} }
@Override @Override
public boolean willAccept(ExpandedComponentInstanceSymbol componentInstanceSymbol) { public boolean willAccept(EMAComponentInstanceSymbol componentInstanceSymbol) {
return componentInstanceSymbol.getPortsList().stream() return componentInstanceSymbol.getPortInstanceList().stream()
.map(PortSymbol::getMiddlewareSymbol) .map(EMAPortInstanceSymbol::getMiddlewareSymbol)
.filter(Optional::isPresent) .filter(Optional::isPresent)
.map(Optional::get) .map(Optional::get)
.filter(mws -> mws.isKindOf(DummyMiddlewareSymbol.KIND)) .filter(mws -> mws.isKindOf(DummyMiddlewareSymbol.KIND))
.count() > 0; .count() > 0;
} }
private FileContent generateCMake(ExpandedComponentInstanceSymbol c