Commit 53bedb68 authored by Alexander David Hellwig's avatar Alexander David Hellwig
Browse files

Added simple model for the lab

parent a6bc669f
Pipeline #80164 passed with stage
in 3 minutes and 44 seconds
......@@ -19,6 +19,7 @@ import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static junit.framework.TestCase.assertTrue;
......@@ -317,4 +318,28 @@ public class GenerationTest extends AbstractSymtabTest {
starBridgeGenerator.generate(componentInstanceSymbol, taggingResolver);
assertTrue(Log.getFindings().isEmpty());
}
@Test
public void testLabComp() throws IOException{
TaggingResolver taggingResolver = createSymTabAndTaggingResolver(TEST_PATH);
RosToEmamTagSchema.registerTagTypes(taggingResolver);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("lab.system", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
//make sure the middleware tags are loaded
Map<PortSymbol, RosConnectionSymbol> tags = TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
DistributedTargetGenerator middlewareGenerator = new DistributedTargetGenerator();
middlewareGenerator.setGenerationTargetPath("./target/generated-sources-cmake/lab/src/");
//generator for component itself
middlewareGenerator.add(new CPPGenImpl(), "cpp");
//generator for the ros connection
middlewareGenerator.add(new RosCppGenImpl(), "roscpp");
middlewareGenerator.generate(componentInstanceSymbol, taggingResolver);
}
}
package lab;
component Alex{
ports in Z loop,
out Z out1;
implementation Math{
out1 = loop * loop;
}
}
\ No newline at end of file
package lab;
component Combine{
ports in Z in1,
in Z in2,
in Z in3,
in Z in4,
out Z out1;
implementation Math{
out1 = (in1 + in2 + in3 + in4) % 16;
}
}
\ No newline at end of file
package lab;
component DinhAn{
ports in Z loop,
out Z out1;
implementation Math{
static Z counter = 0;
counter = counter + 1;
out1 = (counter + 1) + loop;
}
}
\ No newline at end of file
package lab;
conforms to de.monticore.lang.monticar.generator.roscpp.RosToEmamTagSchema;
tags LabTags {
//syntax: tag $port with RosConnection = {topic=($topicName,$topicType), msgField=$fieldOfTopicType};
tag system.alex.out1 with RosConnection = {topic=(/combine_in1,std_msgs/Int32), msgField=data};
tag system.dinhAn.out1 with RosConnection = {topic=(/combine_in2,std_msgs/Int32), msgField=data};
tag system.philipp.out1 with RosConnection = {topic=(/combine_in3,std_msgs/Int32), msgField=data};
tag system.michael.out1 with RosConnection = {topic=(/combine_in4,std_msgs/Int32), msgField=data};
tag system.combine.in1 with RosConnection = {topic=(/combine_in1,std_msgs/Int32), msgField=data};
tag system.combine.in2 with RosConnection ={topic=(/combine_in2,std_msgs/Int32), msgField=data};
tag system.combine.in3 with RosConnection = {topic=(/combine_in3,std_msgs/Int32), msgField=data};
tag system.combine.in4 with RosConnection = {topic=(/combine_in4,std_msgs/Int32), msgField=data};
tag system.alex.loop with RosConnection = {topic=(/combine_out,std_msgs/Int32), msgField=data};
tag system.dinhAn.loop with RosConnection = {topic=(/combine_out,std_msgs/Int32), msgField=data};
tag system.philipp.loop with RosConnection = {topic=(/combine_out,std_msgs/Int32), msgField=data};
tag system.michael.loop with RosConnection = {topic=(/combine_out,std_msgs/Int32), msgField=data};
tag system.combine.out1 with RosConnection = {topic=(/combine_out,std_msgs/Int32), msgField=data};
}
\ No newline at end of file
package lab;
component Michael{
ports in Z loop,
out Z out1;
implementation Math{
out1 = loop;
}
}
\ No newline at end of file
package lab;
component Philipp{
ports in Z loop,
out Z out1;
implementation Math{
out1 = loop + 1;
}
}
\ No newline at end of file
package lab;
component System{
instance Alex alex;
instance DinhAn dinhAn;
instance Philipp philipp;
instance Michael michael;
instance Combine combine;
connect alex.out1 -> combine.in1;
connect dinhAn.out1 -> combine.in2;
connect philipp.out1 -> combine.in3;
connect michael.out1 -> combine.in4;
connect combine.out1 -> alex.loop;
connect combine.out1 -> dinhAn.loop;
connect combine.out1 -> philipp.loop;
connect combine.out1 -> michael.loop;
}
\ 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