Update to new Symbol names

parent ba6162e8
Pipeline #95245 passed with stage
in 5 minutes and 37 seconds
package de.monticore.lang.monticar.generator.cpp;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.cpp.converter.ExecuteMethodGenerator;
import de.monticore.lang.monticar.generator.cpp.converter.OptimizationSymbolHandler;
import de.monticore.lang.monticar.generator.cpp.optimizationSolver.solver.Solver;
import de.monticore.lang.monticar.generator.cpp.optimizationSolver.solver.SolverOptions;
import de.monticore.lang.monticar.generator.middleware.impls.GeneratorImpl;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import java.io.File;
......@@ -18,7 +17,7 @@ import java.util.List;
*
* @author Christoph Richter
*/
public class GeneratorEMAMOpt2CPP extends GeneratorCPP implements GeneratorImpl {
public class GeneratorEMAMOpt2CPP extends GeneratorCPP{
// fields
private OptimizationSymbolHandler executeMethodGeneratorOpt = new OptimizationSymbolHandler();
......@@ -41,8 +40,7 @@ public class GeneratorEMAMOpt2CPP extends GeneratorCPP implements GeneratorImpl
mathOptFunctionFixer.setSuccessor(MathFunctionFixer.getInstance());
}
@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<>();
files.addAll(generateFiles(componentInstanceSymbol, taggingResolver));
if (isGenerateCMakeEnabled())
......@@ -50,8 +48,7 @@ public class GeneratorEMAMOpt2CPP extends GeneratorCPP implements GeneratorImpl
return files;
}
@Override
public boolean willAccept(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
public boolean willAccept(EMAComponentInstanceSymbol componentInstanceSymbol) {
return true;
}
......
package de.monticore.lang.monticar.generator.cpp;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.cpp.optimizationSolver.solver.Solver;
import de.monticore.lang.monticar.generator.cpp.resolver.Resolver;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
......@@ -76,7 +76,7 @@ public class GeneratorEMAMOpt2CppCli {
String outputPath = cliArgs.getOptionValue(OPTION_OUTPUT_PATH.getOpt());
TaggingResolver symTab = EMAMOpt2CPPSymbolTableHelper.getInstance().createSymTabAndTaggingResolver(new String[]{modelsDirPath.toString()});
Resolver resolver = new Resolver(symTab);
ExpandedComponentInstanceSymbol componentSymbol = resolveSymbol(resolver, rootModelName);
EMAComponentInstanceSymbol componentSymbol = resolveSymbol(resolver, rootModelName);
GeneratorEMAMOpt2CPP g = new GeneratorEMAMOpt2CPP();
g.setUseAlgebraicOptimizations(false);
g.setUseThreadingOptimization(false);
......@@ -116,8 +116,8 @@ public class GeneratorEMAMOpt2CppCli {
}
}
private static ExpandedComponentInstanceSymbol resolveSymbol(Resolver resolver, String rootModelName) {
ExpandedComponentInstanceSymbol componentSymbol = (ExpandedComponentInstanceSymbol) resolver.getExpandedComponentInstanceSymbol(rootModelName).orElse(null);
private static EMAComponentInstanceSymbol resolveSymbol(Resolver resolver, String rootModelName) {
EMAComponentInstanceSymbol componentSymbol = (EMAComponentInstanceSymbol) resolver.getEMAComponentInstanceSymbol(rootModelName).orElse(null);
if (componentSymbol == null) {
Log.error("could not resolve component " + rootModelName);
return null;
......
package de.monticore.lang.monticar.generator;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.cpp.EMAMOpt2CPPSymbolTableHelper;
import de.monticore.lang.monticar.generator.cpp.GeneratorEMAMOpt2CPP;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import org.junit.Test;
......@@ -16,9 +17,10 @@ public class CarModelGenerationTest extends BasicGenerationTest {
private static TaggingResolver symtab = EMAMOpt2CPPSymbolTableHelper.getInstance().createSymTabAndTaggingResolver("src/test/resources");
protected static List<File> doGenerateModel(String fullModelName) throws IOException {
ExpandedComponentInstanceSymbol componentInstanceSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve(fullModelName, ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = symtab.<EMAComponentInstanceSymbol>resolve(fullModelName, EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
GeneratorEMAMOpt2CMake generator = new GeneratorEMAMOpt2CMake();
GeneratorEMAMOpt2CPP generator = new GeneratorEMAMOpt2CPP();
generator.setGenerateCMake(true);
generator.setGenerationTargetPath("./target/generated-sources-cmake/" + fullModelName.substring(fullModelName.lastIndexOf(".") + 1, fullModelName.length()) + "/src/");
return generator.generate(componentInstanceSymbol, symtab);
}
......
package de.monticore.lang.monticar.generator;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.cpp.EMAMOpt2CPPSymbolTableHelper;
import de.monticore.lang.monticar.generator.cpp.GeneratorEMAMOpt2CPP;
import de.monticore.lang.monticar.generator.cpp.optimizationSolver.solver.Solver;
import de.monticore.lang.monticar.generator.middleware.impls.GeneratorImpl;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import org.junit.Test;
......@@ -27,16 +26,12 @@ public class GeneratorCplexSolverTest {
private static TaggingResolver symtab = EMAMOpt2CPPSymbolTableHelper.getInstance().createSymTabAndTaggingResolver("src/test/resources");
protected static List<File> doGenerateModel(String fullModelName) throws IOException {
ExpandedComponentInstanceSymbol componentInstanceSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve(fullModelName, ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = symtab.<EMAComponentInstanceSymbol>resolve(fullModelName, EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
GeneratorEMAMOpt2CMake generator = new GeneratorEMAMOpt2CMake();
for (GeneratorImpl gi : generator.getGeneratorImpls()) {
if (gi instanceof GeneratorEMAMOpt2CPP) {
GeneratorEMAMOpt2CPP g = (GeneratorEMAMOpt2CPP) gi;
g.setPreferedSolver(Solver.Cplex);
g.setForceUsePreferredSolver(true);
}
}
GeneratorEMAMOpt2CPP generator = new GeneratorEMAMOpt2CPP();
generator.setGenerateCMake(true);
generator.setPreferedSolver(Solver.Cplex);
generator.setForceUsePreferredSolver(true);
generator.setGenerationTargetPath("./target/generated-sources-cmake/cplex/" + fullModelName.substring(fullModelName.lastIndexOf(".") + 1, fullModelName.length()) + "/src/");
return generator.generate(componentInstanceSymbol, symtab);
}
......
package de.monticore.lang.monticar.generator;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.cpp.EMAMOpt2CPPSymbolTableHelper;
import de.monticore.lang.monticar.generator.cpp.GeneratorEMAMOpt2CPP;
import de.monticore.lang.monticar.generator.middleware.impls.GeneratorImpl;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import org.junit.Test;
......@@ -26,17 +25,14 @@ public class GeneratorEMAMOpt2CMakeTest extends BasicGenerationTest {
private static TaggingResolver symtab = EMAMOpt2CPPSymbolTableHelper.getInstance().createSymTabAndTaggingResolver("src/test/resources");
protected static List<File> doGenerateModel(String fullModelName) throws IOException {
ExpandedComponentInstanceSymbol componentInstanceSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve(fullModelName, ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = symtab.<EMAComponentInstanceSymbol>resolve(fullModelName, EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
GeneratorEMAMOpt2CMake generator = new GeneratorEMAMOpt2CMake();
GeneratorEMAMOpt2CPP generator = new GeneratorEMAMOpt2CPP();
generator.setGenerationTargetPath("./target/generated-sources-cmake/" + fullModelName.substring(fullModelName.lastIndexOf(".") + 1, fullModelName.length()) + "/src/");
for (GeneratorImpl g : generator.getGeneratorImpls()) {
GeneratorEMAMOpt2CPP gen = (GeneratorEMAMOpt2CPP) g;
gen.setGenerateCMake(true);
gen.setGenerateTests(true);
gen.setCheckModelDir(true);
gen.setModelsDirPath(Paths.get("src/test/resources"));
}
generator.setGenerateCMake(true);
generator.setGenerateTests(true);
generator.setCheckModelDir(true);
generator.setModelsDirPath(Paths.get("src/test/resources"));
return generator.generate(componentInstanceSymbol, symtab);
}
......
package de.monticore.lang.monticar.generator;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.cpp.EMAMOpt2CPPSymbolTableHelper;
import de.monticore.lang.monticar.generator.cpp.GeneratorCPP;
import de.monticore.lang.monticar.generator.cpp.GeneratorEMAMOpt2CPP;
......@@ -29,7 +29,7 @@ public class GeneratorEMAMOpt2CPPTest extends BasicGenerationTest {
* helper method to generate optimization models in CPP code
*/
protected static List<File> doGenerateOptimizationModel(String modelName) throws IOException {
ExpandedComponentInstanceSymbol componentSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve(String.format("de.rwth.monticar.optimization.%s", modelName), ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentSymbol = symtab.<EMAComponentInstanceSymbol>resolve(String.format("de.rwth.monticar.optimization.%s", modelName), EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentSymbol);
GeneratorCPP generator = new GeneratorEMAMOpt2CPP();
generator.setGenerationTargetPath("./target/generated-sources-cpp/testMath/optimizationSolver/" + modelName);
......
package de.monticore.lang.monticar.generator;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.cpp.EMAMOpt2CPPSymbolTableHelper;
import de.monticore.lang.monticar.generator.cpp.GeneratorEMAMOpt2CPP;
import de.monticore.lang.monticar.generator.cpp.optimizationSolver.solver.Solver;
......@@ -18,7 +18,7 @@ public class TrajectoryControllerTest extends BasicGenerationTest {
@Test
public void generateTrajectoryControllerMPCBicycle() throws IOException {
TaggingResolver symtab = EMAMOpt2CPPSymbolTableHelper.getInstance().createSymTabAndTaggingResolver("src/test/resources");
ExpandedComponentInstanceSymbol componentInstanceSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve("de.rwth.monticar.mpc.trajectoryControllerMPC", ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = symtab.<EMAComponentInstanceSymbol>resolve("de.rwth.monticar.mpc.trajectoryControllerMPC", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
GeneratorEMAMOpt2CPP generator = new GeneratorEMAMOpt2CPP();
generator.setGenerateAutopilotAdapter(true);
......
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