Die Migration der Bereiche "Docker Registry" und "Artifiacts" ist fast abgeschlossen. Die letzten Daten werden im Laufe des heutigen Abend (05.08.2021) noch vollständig hochgeladen. Das Anlegen neuer Images und Artifacts funktioniert bereits wieder.

Commit bdb75fc2 authored by Georg Vinogradov's avatar Georg Vinogradov
Browse files

Add simple .emam component to project

parent e7130675
Pipeline #154936 passed with stage
in 1 minute and 59 seconds
......@@ -5,11 +5,10 @@ import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instance
import java.io.File;
import java.util.List;
@SuppressWarnings("unused")
public class GeneratorMqtt
{
private List<File> generateMqttAdapter(EMAComponentInstanceSymbol component)
List<File> generateMqttAdapter(EMAComponentInstanceSymbol component)
{
return null;
......
package de.monticore.lang.monticar.generator.mqtt.template;
// Used to fill .ftl files
public class MqttAdapterModel {
}
......@@ -13,7 +13,7 @@ public class MqttTemplates {
private static final Template PrettyPrint;
// Choosing .ftl files for templates
// Loading .ftl files
static {
Configuration conf = new Configuration(Configuration.VERSION_2_3_23);
conf.setDefaultEncoding("UTF-8");
......
package com.emam2mqtt;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* Unit test for simple App.
*/
public class AppTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}
package de.monticore.lang.monticar.generator.mqtt;
/*
* Copyright (c) 2015 RWTH Aachen. All rights reserved.
*
* http://www.se-rwth.de/
*/
import de.monticore.ModelingLanguageFamily;
import de.monticore.io.paths.ModelPath;
import de.monticore.lang.embeddedmontiarc.LogConfig;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarcmath._symboltable.EmbeddedMontiArcMathLanguage;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosToEmamTagSchema;
import de.monticore.lang.monticar.Utils;
import de.monticore.lang.monticar.enumlang._symboltable.EnumLangLanguage;
import de.monticore.lang.monticar.streamunits._symboltable.StreamUnitsLanguage;
import de.monticore.lang.monticar.struct._symboltable.StructLanguage;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.GlobalScope;
import de.monticore.symboltable.Scope;
import org.junit.Assert;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static org.junit.Assert.assertTrue;
/**
* Common methods for symboltable tests
*/
public class AbstractSymtabTest {
public AbstractSymtabTest() {
}
public static TaggingResolver createSymTabAndTaggingResolver(String... modelPath) {
Scope scope = createSymTab(modelPath);
TaggingResolver taggingResolver = new TaggingResolver(scope, Arrays.asList(modelPath));
RosToEmamTagSchema.registerTagTypes(taggingResolver);
return taggingResolver;
}
public static Scope createSymTab(String... modelPath) {
ModelingLanguageFamily fam = new ModelingLanguageFamily();
EmbeddedMontiArcMathLanguage montiArcLanguage = new EmbeddedMontiArcMathLanguage();
fam.addModelingLanguage(montiArcLanguage);
fam.addModelingLanguage(new StreamUnitsLanguage());
fam.addModelingLanguage(new StructLanguage());
fam.addModelingLanguage(new EnumLangLanguage());
ModelPath mp = new ModelPath(new Path[0]);
String[] var4 = modelPath;
int var5 = modelPath.length;
for(int var6 = 0; var6 < var5; ++var6) {
String m = var4[var6];
mp.addEntry(Paths.get(m));
}
LogConfig.init();
GlobalScope scope = new GlobalScope(mp, fam);
Utils.addBuiltInTypes(scope);
return scope;
}
public static void testFilesAreEqual(List<File> files, String restPath) {
assertTrue(files.size() > 0);
for (File f : files) {
File fileTarget = new File("./src/test/resources/results/" + restPath + f.getName());
// System.out.println("" + fileTarget.exists() + "Exists:");
// System.out.println(f.getName() + " " + fileTarget.getName() + "Comparing:");
assertTrue(areBothFilesEqual(f, fileTarget));
}
}
public static void testFilesAreEqual(List<File> files, String relResultPath, String basePath) {
String resultPath = "src/test/resources/results/";
for (File f : files) {
File tmpFile = new File(basePath);
String relativePath = f.getAbsolutePath().replace(tmpFile.getAbsolutePath(), "");
File fileTarget = new File(resultPath + relResultPath + relativePath);
assertTrue(areBothFilesEqual(f, fileTarget));
}
}
public static boolean areBothFilesEqual(File file1, File file2) {
if (!file1.exists()) {
Assert.fail("file does not exist: " + file1.getAbsolutePath());
return false;
}
if (!file2.exists()) {
Assert.fail("file does not exist: " + file2.getAbsolutePath());
return false;
}
List<String> lines1;
List<String> lines2;
try {
lines1 = Files.readAllLines(file1.toPath());
lines2 = Files.readAllLines(file2.toPath());
} catch (IOException e) {
e.printStackTrace();
Assert.fail("IO error: " + e.getMessage());
return false;
}
lines1 = discardEmptyLines(lines1);
lines1 = discardCommentLines(lines1);
lines2 = discardEmptyLines(lines2);
lines2 = discardCommentLines(lines2);
if (lines1.size() != lines2.size()) {
Assert.fail(
"files have different number of lines: "
+ file1.getAbsolutePath()
+ " has " + lines1.size()
+ " lines and " + file2.getAbsolutePath() + " has " + lines2.size() + " lines"
);
return false;
}
int len = lines1.size();
for (int i = 0; i < len; i++) {
String l1 = lines1.get(i);
String l2 = lines2.get(i);
Assert.assertEquals("files differ in " + i + " line: "
+ file1.getAbsolutePath()
+ " has " + l1
+ " and " + file2.getAbsolutePath() + " has " + l2,
l1,
l2
);
}
return true;
}
private static List<String> discardEmptyLines(List<String> lines) {
return lines.stream()
.map(String::trim)
.filter(l -> !l.isEmpty())
.collect(Collectors.toList());
}
private static List<String> discardCommentLines(List<String> lines) {
return lines.stream()
.map(String::trim)
.filter(l -> !l.startsWith("//"))
.collect(Collectors.toList());
}
}
package de.monticore.lang.monticar.generator.mqtt;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosToEmamTagSchema;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import static org.junit.Assert.assertNotNull;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.junit.Test;
public class PrettyPrintGenerationTest extends AbstractSymtabTest {
@Test
public void testPrettyPrint() throws IOException {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver("src/test/resources/");
// Ros schema is used for now
RosToEmamTagSchema.registerTagTypes(taggingResolver);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("tests.a.compA", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
/*
Optional<EMAPortInstanceSymbol> port = componentInstanceSymbol.getPortInstance("rosOut");
System.out.println("is the port incoming: "+port.get().isIncoming());
*/
GeneratorMqtt generatorMqtt = new GeneratorMqtt();
List<File> files = generatorMqtt.generateMqttAdapter(componentInstanceSymbol);
}
}
package tests.a;
component CompA{
port in Q portA;
port in Q portB;
port out Q portC;
port out Q PortD;
implementation Math{
portA = portD;
}
}
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