Commit d0f4e93a authored by Alexander David Hellwig's avatar Alexander David Hellwig

Merge branch 'experiments_lab' into ML_clustering

parents c980d343 b9658df5
Pipeline #81382 failed with stage
in 3 minutes and 24 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;
......@@ -339,4 +340,28 @@ public class GenerationTest extends AbstractSymtabTest {
assertFalse(filenames.stream().anyMatch(fn -> fn.endsWith("rosMsg/CMakeLists.txt")));
}
@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 Q input,
out Q out1;
implementation Math{
out1 = input * input;
}
}
\ No newline at end of file
package lab;
component Combine{
ports in Q in1,
in Q in2,
in Q in3,
in Q in4,
out Q out1;
implementation Math{
out1 = cos(in1 + in2 + in3 + in4);
}
}
\ No newline at end of file
package lab;
component DinhAn{
ports in Q input,
out Q out1;
implementation Math{
static Q counter = 0;
counter = counter + 0.05;
out1 = input + counter;
}
}
\ 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.rosIn[1] with RosConnection = {topic=(/in1,std_msgs/Float64), msgField=data};
tag system.rosIn[2] with RosConnection = {topic=(/in2,std_msgs/Float64), msgField=data};
tag system.rosIn[3] with RosConnection = {topic=(/in3,std_msgs/Float64), msgField=data};
tag system.rosIn[4] with RosConnection = {topic=(/in4,std_msgs/Float64), msgField=data};
tag system.alex.input with RosConnection = {topic=(/in1,std_msgs/Float64), msgField=data};
tag system.dinhAn.input with RosConnection = {topic=(/in2,std_msgs/Float64), msgField=data};
tag system.philipp.input with RosConnection = {topic=(/in3,std_msgs/Float64), msgField=data};
tag system.michael.input with RosConnection = {topic=(/in4,std_msgs/Float64), msgField=data};
tag system.alex.out1 with RosConnection = {topic=(/combine_in1,std_msgs/Float64), msgField=data};
tag system.dinhAn.out1 with RosConnection = {topic=(/combine_in2,std_msgs/Float64), msgField=data};
tag system.philipp.out1 with RosConnection = {topic=(/combine_in3,std_msgs/Float64), msgField=data};
tag system.michael.out1 with RosConnection = {topic=(/combine_in4,std_msgs/Float64), msgField=data};
tag system.combine.in1 with RosConnection = {topic=(/combine_in1,std_msgs/Float64), msgField=data};
tag system.combine.in2 with RosConnection ={topic=(/combine_in2,std_msgs/Float64), msgField=data};
tag system.combine.in3 with RosConnection = {topic=(/combine_in3,std_msgs/Float64), msgField=data};
tag system.combine.in4 with RosConnection = {topic=(/combine_in4,std_msgs/Float64), msgField=data};
tag system.combine.out1 with RosConnection = {topic=(/combine_out,std_msgs/Float64), msgField=data};
tag system.rosOut with RosConnection = {topic=(/combine_out,std_msgs/Float64), msgField=data};
}
\ No newline at end of file
package lab;
component Michael{
ports in Q input,
out Q out1;
implementation Math{
out1 = input + input;
}
}
package lab;
component Philipp{
ports in Q input,
out Q out1;
implementation Math{
out1 = input + 1;
}
}
\ No newline at end of file
package lab;
component System{
ports in Q rosIn[4],
out Q rosOut;
instance Alex alex;
instance DinhAn dinhAn;
instance Philipp philipp;
instance Michael michael;
instance Combine combine;
connect rosIn[1] -> alex.input;
connect rosIn[2] -> dinhAn.input;
connect rosIn[3] -> philipp.input;
connect rosIn[4] -> michael.input;
connect alex.out1 -> combine.in1;
connect dinhAn.out1 -> combine.in2;
connect philipp.out1 -> combine.in3;
connect michael.out1 -> combine.in4;
connect combine.out1 -> rosOut;
}
\ No newline at end of file
#!/bin/bash
cd target/generated-sources-cmake/lab/
rm -rf build
mkdir build
cd build
cmake ../src
make -j4
\ No newline at end of file
#!/bin/bash
# Kill all spawned subshells on exit
trap 'kill $(jobs -p)' EXIT
cd target/generated-sources-cmake/lab/
cd build
./lab_system_alex/coordinator/Coordinator_lab_system_alex -t 1000 &
./lab_system_dinhAn/coordinator/Coordinator_lab_system_dinhAn -t 1000 &
./lab_system_michael/coordinator/Coordinator_lab_system_michael -t 1000 &
./lab_system_philipp/coordinator/Coordinator_lab_system_philipp -t 1000 &
./lab_system_combine/coordinator/Coordinator_lab_system_combine -t 1000
\ 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