Added Test for distributed component with a struct

parent 0577810a
......@@ -24,6 +24,12 @@ public class DistributedTargetGenerator extends CMakeGenerator {
//this.add(rosMsgImpl,"rosmsg/");
}
@Override
public void setGenerationTargetPath(String path) {
super.setGenerationTargetPath(path);
rosMsgImpl.setGenerationTargetPath(generationTargetPath + (generationTargetPath.endsWith("/") ? "" : "/") + "rosMsg/");
}
@Override
public List<File> generate(ExpandedComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
Map<PortSymbol, RosConnectionSymbol> resolvedTags = TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
......@@ -59,6 +65,7 @@ public class DistributedTargetGenerator extends CMakeGenerator {
}
files.addAll(cmakeListsGenerator.generate(componentInstanceSymbol, taggingResolver));
files.addAll(rosMsgImpl.generate(componentInstanceSymbol, taggingResolver));
return files;
}
......
......@@ -10,6 +10,7 @@ import de.monticore.lang.monticar.generator.middleware.impls.DummyMiddlewareSymb
import de.monticore.lang.monticar.generator.middleware.impls.RosCppGenImpl;
import de.monticore.lang.monticar.generator.roscpp.helper.TagHelper;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import org.junit.Ignore;
import org.junit.Test;
import java.io.File;
......@@ -98,6 +99,27 @@ public class GenerationTest extends AbstractSymtabTest {
distributedTargetGenerator.generate(componentInstanceSymbol, taggingResolver);
}
//TODO: implement feature
@Ignore
@Test
public void testDistributedStructTargetGenerator() throws IOException {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver("src/test/resources/");
RosToEmamTagSchema.registerTagTypes(taggingResolver);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("tests.dist.distWithStructComp", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
DistributedTargetGenerator distributedTargetGenerator = new DistributedTargetGenerator();
distributedTargetGenerator.setGenerationTargetPath("./target/generated-sources-cmake/distributedStruct/src/");
distributedTargetGenerator.add(new CPPGenImpl(), "cpp");
distributedTargetGenerator.add(new RosCppGenImpl(), "roscpp");
distributedTargetGenerator.generate(componentInstanceSymbol, taggingResolver);
}
@Test
public void testMutliMwGenerateAll() throws IOException {
testMutliMw("allMw", true, true);
......
package tests.dist;
import tests.struct.Position;
component DistWithStructComp{
port out Position resOut;
component SubComp1{
ports out Position out1,
out Position out2;
implementation Math{
out1.longitude = out1.longitude + 1;
out1.latitude = out1.latitude - 1;
out2.longitude = out2.longitude + 10;
out2.latitude = out2.latitude - 10;
}
}
component SubComp2{
ports in Position in1,
in Position in2,
out Position resOut;
implementation Math{
resOut.longitude = in1.longitude + in2.longitude;
resOut.latitude = in1.latitude + in2.latitude;
}
}
instance SubComp1 sub1;
instance SubComp2 sub2;
connect sub1.out1 -> sub2.in1;
connect sub1.out2 -> sub2.in2;
connect sub2.resOut -> resOut;
}
\ No newline at end of file
package tests.dist;
conforms to de.monticore.lang.monticar.generator.roscpp.RosToEmamTagSchema;
tags StructDist{
tag distWithStructComp.sub1.out1 with RosConnection;
tag distWithStructComp.sub1.out2 with RosConnection;
tag distWithStructComp.sub2.in1 with RosConnection;
tag distWithStructComp.sub2.in2 with RosConnection;
tag distWithStructComp.sub2.resOut with RosConnection;
tag distWithStructComp.resOut with RosConnection;
}
\ No newline at end of file
package tests.struct;
struct Position{
Q longitude;
Q latitude;
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment