Commit 8b30b74c authored by Philipp Görick's avatar Philipp Görick

Added algorithm to flatten architecture.

parent d976c589
Pipeline #94867 failed with stages
in 5 minutes and 29 seconds
package de.monticore.lang.monticar.generator.middleware;
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.monticar.generator.middleware.clustering.AutomaticClusteringHelper;
......@@ -98,6 +99,36 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
}
@Test
public void testFlattenAlgorithm1(){
TaggingResolver taggingResolver = AbstractSymtabTest.createSymTabAndTaggingResolver(TEST_PATH);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("lab.overallSystem", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = AutomaticClusteringHelper.flattenArchitecture(componentInstanceSymbol);
assertNotNull(newComponentInstanceSymbol);
Collection<ExpandedComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
Collection<ConnectorSymbol> connectors = newComponentInstanceSymbol.getConnectors();
assertEquals(10, subComponents.size());
assertEquals(20, connectors.size());
}
@Test
public void testFlattenAlgorithm2(){
TaggingResolver taggingResolver = AbstractSymtabTest.createSymTabAndTaggingResolver(TEST_PATH);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("lab.spanningSystem", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = AutomaticClusteringHelper.flattenArchitecture(componentInstanceSymbol);
assertNotNull(newComponentInstanceSymbol);
Collection<ExpandedComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
Collection<ConnectorSymbol> connectors = newComponentInstanceSymbol.getConnectors();
assertEquals(20, subComponents.size());
assertEquals(40, connectors.size());
}
// todo: gotta move this thing later, just temporarily here for testing purposes
public static Dataset[] getClustering(Dataset data, SparseMatrix matrix) {
......
package lab;
component SpanningSystem{
ports in Q input,
out Q output;
instance OverallSystem overallSystem1;
instance OverallSystem overallSystem2;
connect input -> OverallSystem1.input[1];
connect input -> OverallSystem1.input[2];
connect input -> OverallSystem1.input[3];
connect input -> OverallSystem1.input[4];
connect OverallSystem1.output[4] -> output;
connect OverallSystem1.output[1] -> output;
connect OverallSystem1.output[2] -> output;
connect OverallSystem1.output[3] -> output;
connect input -> OverallSystem2.input[1];
connect input -> OverallSystem2.input[2];
connect input -> OverallSystem2.input[3];
connect input -> OverallSystem2.input[4];
connect OverallSystem2.output[4] -> output;
connect OverallSystem2.output[1] -> output;
connect OverallSystem2.output[2] -> output;
connect OverallSystem2.output[3] -> output;
}
\ 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