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
## Generator
The new middleware generator needs to the following methods
* `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.
* `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).
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 @@
<!-- .. SE-Libraries .................................................. -->
<se-commons.version>1.7.7</se-commons.version>
<Embedded-montiarc-math-generator.version>0.0.26-SNAPSHOT</Embedded-montiarc-math-generator.version>
<Embedded-montiarc-math-roscpp-generator.version>0.0.4-SNAPSHOT</Embedded-montiarc-math-roscpp-generator.version>
<Embedded-montiarc-math-rosmsg-generator.version>0.0.3-SNAPSHOT</Embedded-montiarc-math-rosmsg-generator.version>
<EMADL.version>0.2.3</EMADL.version>
<EMADL2CPP.version>0.2.4</EMADL2CPP.version>
<!--TODO: remove with update to next emam version -->
<struct.version>0.0.18-SNAPSHOT</struct.version>
<Embedded-montiarc-math-generator.version>0.1.3-SNAPSHOT</Embedded-montiarc-math-generator.version>
<Embedded-montiarc-math-roscpp-generator.version>0.1.1-SNAPSHOT</Embedded-montiarc-math-roscpp-generator.version>
<EMADL.version>0.2.4</EMADL.version>
<EMADL2CPP.version>0.2.6-SNAPSHOT</EMADL2CPP.version>
<!--TODO: remove with update to new emam version-->
<Tagging.version>0.0.6</Tagging.version>
......@@ -52,6 +53,12 @@
</properties>
<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 -->
<dependency>
<groupId>com.google.code.gson</groupId>
......@@ -89,12 +96,6 @@
<version>${Embedded-montiarc-math-roscpp-generator.version}</version>
</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 -->
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
......
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.middleware.helpers.FileHelper;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
......@@ -15,7 +15,7 @@ import java.util.Objects;
public class CMakeGenerator extends StarBridgeGenerator {
@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()
.map(this::getImplSubdir)
.filter(Objects::isNull)
......@@ -31,7 +31,7 @@ public class CMakeGenerator extends StarBridgeGenerator {
return res;
}
protected File generateCMake(ExpandedComponentInstanceSymbol componentInstanceSymbol) throws IOException {
protected File generateCMake(EMAComponentInstanceSymbol componentInstanceSymbol) throws IOException {
FileContent fileContent = new FileContent();
fileContent.setFileName("CMakeLists.txt");
StringBuilder content = new StringBuilder();
......
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.middleware.helpers.*;
import de.monticore.lang.monticar.generator.middleware.impls.GeneratorImpl;
......@@ -24,12 +24,12 @@ public class DistributedTargetGenerator extends CMakeGenerator {
}
@Override
public List<File> generate(ExpandedComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
Map<ExpandedComponentInstanceSymbol, GeneratorImpl> generatorMap = new HashMap<>();
public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
Map<EMAComponentInstanceSymbol, GeneratorImpl> generatorMap = new HashMap<>();
fixComponentInstance(componentInstanceSymbol);
List<ExpandedComponentInstanceSymbol> clusterSubcomponents = ClusterHelper.getClusterSubcomponents(componentInstanceSymbol);
List<EMAComponentInstanceSymbol> clusterSubcomponents = ClusterHelper.getClusterSubcomponents(componentInstanceSymbol);
if (clusterSubcomponents.size() > 0) {
clusterSubcomponents.forEach(clusterECIS -> {
String nameTargetLanguage = NameHelper.getNameTargetLanguage(clusterECIS.getFullName());
......@@ -42,7 +42,7 @@ public class DistributedTargetGenerator extends CMakeGenerator {
List<File> files = new ArrayList<>();
for (ExpandedComponentInstanceSymbol comp : generatorMap.keySet()) {
for (EMAComponentInstanceSymbol comp : generatorMap.keySet()) {
files.addAll(generatorMap.get(comp).generate(comp, taggingResolver));
//add empty generator to subDirs so that CMakeLists.txt will be generated correctly
subDirs.add(NameHelper.getNameTargetLanguage(comp.getFullName()));
......@@ -73,12 +73,12 @@ public class DistributedTargetGenerator extends CMakeGenerator {
return res;
}
private void fixComponentInstance(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
private void fixComponentInstance(EMAComponentInstanceSymbol componentInstanceSymbol) {
RosHelper.fixRosConnectionSymbols(componentInstanceSymbol);
}
@Override
protected File generateCMake(ExpandedComponentInstanceSymbol componentInstanceSymbol) throws IOException {
protected File generateCMake(EMAComponentInstanceSymbol componentInstanceSymbol) throws IOException {
FileContent fileContent = new FileContent();
fileContent.setFileName("CMakeLists.txt");
StringBuilder content = new StringBuilder();
......
......@@ -2,7 +2,7 @@ package de.monticore.lang.monticar.generator.middleware;
import com.google.gson.Gson;
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.monticar.emadl.generator.EMADLAbstractSymtab;
import de.monticore.lang.monticar.emadl.generator.EMADLGeneratorCli;
......@@ -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) {
Log.error("0x5FFAE: The given component cannot be resolved.");
......
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.cpp.converter.ComponentConverter;
import de.monticore.lang.monticar.generator.middleware.helpers.FileHelper;
......@@ -17,7 +17,7 @@ import java.util.stream.Collectors;
public class MiddlewareGenerator extends CMakeGenerator {
@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
String subdir = "coordinator/";
this.add(new GeneratorImpl() {
......@@ -30,7 +30,7 @@ public class MiddlewareGenerator extends CMakeGenerator {
return files;
}
private FileContent generateIAdapter(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
private FileContent generateIAdapter(EMAComponentInstanceSymbol componentInstanceSymbol) {
FileContent res = new FileContent();
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
res.setFileName("IAdapter_" + name + ".h");
......@@ -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());
......@@ -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();
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
......
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.tagging._symboltable.TaggingResolver;
import de.se_rwth.commons.logging.Log;
......@@ -34,7 +34,7 @@ public class StarBridgeGenerator implements GeneratorImpl {
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<>();
generatorImpls.forEach((key, value) -> {
if (key.willAccept(componentInstanceSymbol)) {
......
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.MutableScope;
import de.monticore.symboltable.Symbol;
......@@ -19,40 +26,40 @@ public class ClusterHelper {
private ClusterHelper() {
}
public static List<Set<ExpandedComponentInstanceSymbol>> getClusters(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
Graph<ExpandedComponentInstanceSymbol, DefaultEdge> graph = new SimpleGraph<>(DefaultEdge.class);
public static List<Set<EMAComponentInstanceSymbol>> getClusters(EMAComponentInstanceSymbol componentInstanceSymbol) {
Graph<EMAComponentInstanceSymbol, DefaultEdge> graph = new SimpleGraph<>(DefaultEdge.class);
componentInstanceSymbol.getSubComponents().forEach(graph::addVertex);
graph.addVertex(componentInstanceSymbol);
componentInstanceSymbol.getConnectors().stream()
componentInstanceSymbol.getConnectorInstances().stream()
.filter(c -> !(c.getSourcePort().getMiddlewareSymbol().isPresent() && c.getTargetPort().getMiddlewareSymbol().isPresent()))
.forEach(c -> {
ExpandedComponentInstanceSymbol compSource = c.getSourcePort().getComponentInstance().orElse(null);
ExpandedComponentInstanceSymbol compTarget = c.getTargetPort().getComponentInstance().orElse(null);
EMAComponentInstanceSymbol compSource = c.getSourcePort().getComponentInstance();
EMAComponentInstanceSymbol compTarget = c.getTargetPort().getComponentInstance();
if (compSource == null || compTarget == null)
Log.error("ComponentInstance of source or target not found!");
if(!compSource.equals(compTarget))
if (!compSource.equals(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();
if (instanceSetSize != 1) {
Log.warn("0x8EFC3: The supercomponent can only be connected to subcomponents via middleware ports!");
return new ArrayList<>();
}
//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);
List<Set<ExpandedComponentInstanceSymbol>> res = connectivityInspector.connectedSets();
List<Set<EMAComponentInstanceSymbol>> res = connectivityInspector.connectedSets();
return res;
}
public static List<ExpandedComponentInstanceSymbol> getClusterSubcomponents(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
List<Set<ExpandedComponentInstanceSymbol>> clusters = getClusters(componentInstanceSymbol);
List<ExpandedComponentInstanceSymbol> res = new ArrayList<>();
public static List<EMAComponentInstanceSymbol> getClusterSubcomponents(EMAComponentInstanceSymbol componentInstanceSymbol) {
List<Set<EMAComponentInstanceSymbol>> clusters = getClusters(componentInstanceSymbol);
List<EMAComponentInstanceSymbol> res = new ArrayList<>();
int[] i = {0};
clusters.forEach(c -> {
if (c.size() == 1) {
......@@ -79,13 +86,13 @@ public class ClusterHelper {
// 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 normal: handled(let comp connect)
private static ExpandedComponentInstanceSymbol createECISFromCluster(ExpandedComponentInstanceSymbol inst, Set<ExpandedComponentInstanceSymbol> cluster, String clusterName) {
Set<PortSymbol> curClusterPorts = cluster.stream().flatMap(ecis -> ecis.getPortsList().stream()).collect(Collectors.toSet());
Set<PortSymbol> combinedPorts = new HashSet<>();
private static EMAComponentInstanceSymbol createECISFromCluster(EMAComponentInstanceSymbol inst, Set<EMAComponentInstanceSymbol> cluster, String clusterName) {
Set<EMAPortInstanceSymbol> curClusterPorts = cluster.stream().flatMap(ecis -> ecis.getPortInstanceList().stream()).collect(Collectors.toSet());
Set<EMAPortInstanceSymbol> combinedPorts = new HashSet<>();
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
.filter(c -> combinedPorts.contains(c.getSourcePort()) && combinedPorts.contains(c.getTargetPort()))
//remove all connections from super -> super and warn
......@@ -97,19 +104,20 @@ public class ClusterHelper {
return true;
})
//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());
Collection<PortSymbol> mwPorts = curClusterPorts.stream()
Collection<EMAPortInstanceSymbol> mwPorts = curClusterPorts.stream()
.filter(p -> p.getMiddlewareSymbol().isPresent())
.collect(Collectors.toSet());
List<PortSymbol> tmpPorts = mwPorts.stream()
//TODO: use EMAPortSymbol and EMAConnectorSymbol
List<EMAPortSymbol> tmpPorts = mwPorts.stream()
.filter(p -> p.getMiddlewareSymbol().isPresent())
.map(p -> {
String sourcePortName;
String targetPortName;
String subName = p.getComponentInstance().get().getName();
String subName = p.getComponentInstance().getName();
if (p.isIncoming()) {
sourcePortName = p.getName();
targetPortName = subName + "." + p.getName();
......@@ -117,7 +125,7 @@ public class ClusterHelper {
sourcePortName = subName + "." + p.getName();
targetPortName = p.getName();
}
ConnectorSymbol tmpConnector = ConnectorSymbol.builder()
EMAConnectorSymbol tmpConnector = EMAConnectorSymbol.builder()
.setSource(sourcePortName)
.setTarget(targetPortName)
.build();
......@@ -127,9 +135,9 @@ public class ClusterHelper {
.collect(Collectors.toList());
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));
ExpandedComponentInstanceSymbol res = new ExpandedComponentInstanceBuilder()
EMAComponentInstanceSymbol res = new EMAComponentInstanceBuilder()
.setName(clusterName)
.setSymbolReference(inst.getComponentType())
.addPorts(tmpPorts)
......
package de.monticore.lang.monticar.generator.middleware.helpers;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ConnectorSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortSymbol;
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.lang.embeddedmontiarc.tagging.middleware.MiddlewareSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosConnectionSymbol;
import de.monticore.lang.monticar.generator.rosmsg.GeneratorRosMsg;
......@@ -16,15 +16,15 @@ public class RosHelper {
}
public static void fixRosConnectionSymbols(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
componentInstanceSymbol.getConnectors().stream()
public static void fixRosConnectionSymbols(EMAComponentInstanceSymbol componentInstanceSymbol) {
componentInstanceSymbol.getConnectorInstances().stream()
.filter(connectorSymbol -> connectorSymbol.getSourcePort().isRosPort() && connectorSymbol.getTargetPort().isRosPort())
.forEach(connectorSymbol -> {
if (Objects.equals(connectorSymbol.getSourcePort().getComponentInstance().orElse(null), componentInstanceSymbol)) {
if (Objects.equals(connectorSymbol.getSourcePort().getComponentInstance(), componentInstanceSymbol)) {
//In port of supercomp
inferRosConnectionIfPossible(connectorSymbol.getSourcePort(), connectorSymbol.getTargetPort());
generateRosConnectionIfPossible(connectorSymbol);
} else if (Objects.equals(connectorSymbol.getTargetPort().getComponentInstance().orElse(null), componentInstanceSymbol)) {
} else if (Objects.equals(connectorSymbol.getTargetPort().getComponentInstance(), componentInstanceSymbol)) {
//out port of supercomp
inferRosConnectionIfPossible(connectorSymbol.getTargetPort(), connectorSymbol.getSourcePort());
generateRosConnectionIfPossible(connectorSymbol);
......@@ -37,7 +37,7 @@ public class RosHelper {
}
//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 targetTag = connectorSymbol.getTargetPort().getMiddlewareSymbol().orElse(null);
if (sourceTag == null || targetTag == null || !sourceTag.isKindOf(RosConnectionSymbol.KIND) || !targetTag.isKindOf(RosConnectionSymbol.KIND)) {
......@@ -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 targetTag = targetPort.getMiddlewareSymbol().orElse(null);
if (sourceTag == null || targetTag == null || !sourceTag.isKindOf(RosConnectionSymbol.KIND) || !targetTag.isKindOf(RosConnectionSymbol.KIND)) {
......
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.cmake.CMakeConfig;
import de.monticore.lang.monticar.generator.cpp.GeneratorCPP;
......@@ -28,7 +28,7 @@ public class CPPGenImpl implements GeneratorImpl {
}
@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<>();
generatorCPP.setGenerationTargetPath(generationTargetPath);
......
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAPortInstanceSymbol;
import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.middleware.helpers.FileHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.NameHelper;
......@@ -19,7 +19,7 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl {
private String generationTargetPath;
@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<>();
res.add(FileHelper.generateFile(generationTargetPath, generateCMake(componentInstanceSymbol)));
......@@ -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 content = TemplateHelper.getDummyAdapterTemplate()
.replace("${compName}", name);
......@@ -45,16 +45,16 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl {
}
@Override
public boolean willAccept(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
return componentInstanceSymbol.getPortsList().stream()
.map(PortSymbol::getMiddlewareSymbol)
public boolean willAccept(EMAComponentInstanceSymbol componentInstanceSymbol) {
return componentInstanceSymbol.getPortInstanceList().stream()
.map(EMAPortInstanceSymbol::getMiddlewareSymbol)
.filter(Optional::isPresent)
.map(Optional::get)
.filter(mws -> mws.isKindOf(DummyMiddlewareSymbol.KIND))
.count() > 0;
}
private FileContent generateCMake(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
private FileContent generateCMake(EMAComponentInstanceSymbol componentInstanceSymbol) {
FileContent res = new FileContent();
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
String content = TemplateHelper.getDummyCmakeTemplate()
......
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.emadl.generator.Backend;
import de.monticore.lang.monticar.emadl.generator.EMADLGenerator;
import de.monticore.lang.monticar.generator.FileContent;
......@@ -32,7 +32,7 @@ public class EMADLGeneratorImpl implements GeneratorImpl {
@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<>();
emadlGenerator.setGenerationTargetPath(generationTargetPath);
......
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.tagging._symboltable.TaggingResolver;
import java.io.File;
......@@ -9,7 +9,7 @@ import java.util.ArrayList;
import java.util.List;
public interface GeneratorImpl {
default List<File> generate(ExpandedComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
default List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
return new ArrayList<>();
}
......@@ -17,7 +17,7 @@ public interface GeneratorImpl {
}
default boolean willAccept(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
default boolean willAccept(EMAComponentInstanceSymbol componentInstanceSymbol) {
return true;
}
}
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.tagging._symboltable.TaggingResolver;
import de.se_rwth.commons.logging.Log;
......@@ -14,7 +14,7 @@ public class ODVGenImpl implements GeneratorImpl {
private String generationTargetPath;
@Override
public List<File> generate(ExpandedComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
//TODO: implement ODV generator in new Project(e.g. EMAM2ODV)
Log.warn("ODV is not yet implemented!");
return new ArrayList<>();
......@@ -26,7 +26,7 @@ public class ODVGenImpl implements GeneratorImpl {
}
@Override
public boolean willAccept(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
public boolean willAccept(EMAComponentInstanceSymbol componentInstanceSymbol) {
//TODO: check if component has ODV Ports
return true;
}
......
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAPortInstanceSymbol;
import de.monticore.lang.monticar.generator.roscpp.GeneratorRosCpp;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.se_rwth.commons.logging.Log;
......@@ -25,7 +25,7 @@ public class RosCppGenImpl implements GeneratorImpl {
}
@Override
public List<File> generate(ExpandedComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
generatorRosCpp.setGenerationTargetPath(generationTargetPath);
return generatorRosCpp.generateFiles(componentInstanceSymbol, taggingResolver);
}
......@@ -36,10 +36,8 @@ public class RosCppGenImpl implements GeneratorImpl {
}
@Override
public boolean willAccept(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
boolean result = componentInstanceSymbol.getPortsList().stream()
.filter(PortSymbol::isRosPort)
.count() > 0;
public boolean willAccept(EMAComponentInstanceSymbol componentInstanceSymbol) {
boolean result = componentInstanceSymbol.getPortInstanceList().stream().anyMatch(EMAPortInstanceSymbol::isRosPort);
if(!result){
Log.warn("GeneratorRosCpp: No ROS Ports found! Ignoring component " + componentInstanceSymbol.getName());
}
......
package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAPortInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosToEmamTagSchema;
import de.monticore.lang.monticar.generator.middleware.helpers.ClusterHelper;
import de.monticore.lang.monticar.generator.middleware.impls.CPPGenImpl;
......@@ -29,15 +29,15 @@ public class ClusterTest extends AbstractSymtabTest {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver("src/test/resources/");
RosToEmamTagSchema.registerTagTypes(taggingResolver);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("tests.dist.distComp", ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("tests.dist.distComp", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
List<Set<ExpandedComponentInstanceSymbol>> clusters = ClusterHelper.getClusters(componentInstanceSymbol);
List<Set<EMAComponentInstanceSymbol>> clusters = ClusterHelper.getClusters(componentInstanceSymbol);
assertTrue(clusters.size() == 2);
Set<ExpandedComponentInstanceSymbol> cluster1 = new HashSet<>();
Set<ExpandedComponentInstanceSymbol> cluster2 = new HashSet<>();
Set<EMAComponentInstanceSymbol> cluster1 = new HashSet<>();
Set<EMAComponentInstanceSymbol> cluster2 = new HashSet<>();
cluster1.add(componentInstanceSymbol.getSubComponent("sub1").orElse(null));
cluster2.add(componentInstanceSymbol.getSubComponent("sub2").orElse(null));
......@@ -51,14 +51,14 @@ public class ClusterTest extends AbstractSymtabTest {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver("src/test/resources/");
RosToEmamTagSchema.registerTagTypes(taggingResolver);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("tests.dist.twoCompCluster", ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("tests.dist.twoCompCluster", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
List<Set<ExpandedComponentInstanceSymbol>> clusters = ClusterHelper.getClusters(componentInstanceSymbol);
List<Set<EMAComponentInstanceSymbol>> clusters = ClusterHelper.getClusters(componentInstanceSymbol);
Set<ExpandedComponentInstanceSymbol> cluster1 = new HashSet<>();
Set<ExpandedComponentInstanceSymbol> cluster2 = new HashSet<>();
Set<EMAComponentInstanceSymbol> cluster1 = new HashSet<>();
Set<EMAComponentInstanceSymbol> cluster2 = new HashSet<>();
cluster1.add(componentInstanceSymbol.getSubComponent("sub1").orElse(null));
cluster2.add(componentInstanceSymbol.getSubComponent("sub2").orElse(null));
......@@ -67,26 +67,26 @@ public class ClusterTest extends AbstractSymtabTest {
assertTrue(clusters.contains(cluster1));
assertTrue(clusters.contains(cluster2));
List<ExpandedComponentInstanceSymbol> clusterComps = ClusterHelper.getClusterSubcomponents(componentInstanceSymbol);
List<EMAComponentInstanceSymbol> clusterComps = ClusterHelper.getClusterSubcomponents(componentInstanceSymbol);
assertTrue(clusterComps.size() == 2);
ExpandedComponentInstanceSymbol clusterComp1 = clusterComps.get(0);
ExpandedComponentInstanceSymbol clusterComp2 = clusterComps.get(1);
EMAComponentInstanceSymbol clusterComp1 = clusterComps.get(0);
EMAComponentInstanceSymbol clusterComp2 = clusterComps.get(1);
assertTrue(clusterComp1.getName().equals("sub1"));
assertTrue(clusterComp1.getPort("rosOut").isPresent());
assertTrue(clusterComp1.getPortInstance("rosOut").isPresent());
PortSymbol rosIn = clusterComp2.getPort("rosIn").orElse(null);
ExpandedComponentInstanceSymbol sub2 = clusterComp2.getSubComponent("sub2").orElse(null);
ExpandedComponentInstanceSymbol sub3 = clusterComp2.getSubComponent("sub3").orElse(null);
EMAPortInstanceSymbol rosIn = clusterComp2.getPortInstance("rosIn").orElse(null);
EMAComponentInstanceSymbol sub2 = clusterComp2.getSubComponent("sub2").orElse(null);
EMAComponentInstanceSymbol sub3 = clusterComp2.getSubComponent("sub3").orElse(null);
assertNotNull(rosIn);
assertNotNull(sub2);
assertNotNull(sub3);
PortSymbol sub2NoRosOut = sub2.getPort("noRosOut").orElse(null);
PortSymbol sub3NoRosIn = sub3.getPort("noRosIn").orElse(null);
PortSymbol sub3RosIn = sub3.getPort("rosIn").orElse(null);
EMAPortInstanceSymbol sub2NoRosOut = sub2.getPortInstance("noRosOut").orElse(null);
EMAPortInstanceSymbol sub3NoRosIn = sub3.getPortInstance("noRosIn").orElse(null);
EMAPortInstanceSymbol sub3RosIn = sub3.getPortInstance("rosIn").orElse(null);
assertNotNull(sub2NoRosOut);
assertNotNull(sub3NoRosIn);
......@@ -102,7 +102,7 @@ public class ClusterTest extends AbstractSymtabTest {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver("src/test/resources/");
RosToEmamTagSchema.registerTagTypes(taggingResolver);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("tests.dist.twoCompCluster", ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("tests.dist.twoCompCluster", EMAComponentInstanceSymbol.KIND).orElse(null);