Commit 9e82cbd1 authored by Nils Kaminski's avatar Nils Kaminski
Browse files

DynamicHelper header

parent d3a600d6
package de.monticore.lang.monticar.generator.cpp.Dynamics;
import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.cpp.template.AllTemplates;
public class DynamicHelper {
public static String fileName = "DynamicHelper";
public static FileContent getDynamicHelperFileContent() {
FileContent fileContent = new FileContent();
fileContent.setFileName(fileName + ".h");
String fileContentString = AllTemplates.generateDynamicHelper();
fileContent.setFileContent(fileContentString);
return fileContent;
}
}
......@@ -6,6 +6,7 @@ import de.monticore.lang.math._symboltable.MathStatementsSymbol;
import de.monticore.lang.monticar.generator.*;
import de.monticore.lang.monticar.generator.cmake.CMakeConfig;
import de.monticore.lang.monticar.generator.cmake.CMakeFindModule;
import de.monticore.lang.monticar.generator.cpp.Dynamics.DynamicHelper;
import de.monticore.lang.monticar.generator.cpp.Dynamics.EventPortValueCheck;
import de.monticore.lang.monticar.generator.cpp.converter.MathConverter;
import de.monticore.lang.monticar.generator.cpp.converter.TypeConverter;
......@@ -162,8 +163,14 @@ public class GeneratorCPP implements Generator {
//TODO: add Events Value Helper
if(!((EMADynamicComponentInstanceSymbol) componentInstanceSymbol).getEventHandlers().isEmpty())
fileContents.add(EventPortValueCheck.getEventPortValueCheckFileContent());
if(((EMADynamicComponentInstanceSymbol)componentInstanceSymbol).isDynamicInstance()){
fileContents.add(DynamicHelper.getDynamicHelperFileContent());
}
}
if (shouldGenerateMainClass()) {
//fileContents.add(getMainClassFileContent(componentInstanceSymbol, fileContents.get(0)));
} else if (shouldGenerateSimulatorInterface()) {
......
......@@ -82,64 +82,6 @@ public class EventConverter {
return number > 0;
}
@Deprecated
protected static boolean generateDynamicConnectEvent(EMADynamicEventHandlerInstanceSymbol event, EMAComponentInstanceSymbol componentSymbol, Method executeMethod, BluePrintCPP bluePrint ) {
// EMADynamicComponentInstanceSymbol dynComp = (EMADynamicComponentInstanceSymbol)componentSymbol;
//
// for(EMADynamicConnectorInstanceSymbol connector : event.getConnectorsDynamic()){
// EMADynamicConnectorInstanceSymbol dynConnect = (EMADynamicConnectorInstanceSymbol) connector;
//
//// body.addInstruction(new TargetCodeInstruction(
//// "// connect: "+dynConnect.getSource()+" -> "+dynConnect.getTarget()+"\n"
//// ));
//
// String afterComponent = "";
// String sourceName = dynConnect.getSource();
// String targetName = dynConnect.getTarget();
// EMAPortInstanceSymbol target = dynConnect.getTargetPort();
//
// if(dynConnect.isDynamicSourceNewPort()){
// if(sourceName.contains(".")){
// //TODO target hat eine komponente
// }else{
// sourceName = EMAPortSymbol.getNameWithoutArrayBracketPart(sourceName);
// sourceName = String.format("%s[_%s_dynPortID]", sourceName, sourceName);
// }
// }
//
// if(dynConnect.isDynamicTargetNewPort()){
// if(targetName.contains(".")){
// //TODO target hat eine komponente
// System.out.println("bla bla");
// }else{
// targetName = EMAPortSymbol.getNameWithoutArrayBracketPart(targetName);
// targetName = String.format("%s[_%s_dynPortID]", targetName, targetName);
// }
// }
//
// Optional<VariableType> vt = TypeConverter.getVariableTypeForMontiCarTypeName(target.getTypeReference().getName());
// generateEventDynamicConnectVecotr(vt.get().getTypeNameTargetLanguage(), bluePrint);
//
//
// body.addInstruction(new TargetCodeInstruction(String.format(
//// "// connect: "+sourceName+" - "+targetName+"\n"
// "__dynamic_%s_connect.push_back({%s, &%s, &%s});\n", vt.get().getTypeNameTargetLanguage(), afterComponent, sourceName, targetName
// )));
//
//// executeMethod.addInstruction(new TargetCodeInstruction(
//// "executeDynamicConnects("+afterComponent+");\n"
//// ));
// executeMethod.addInstruction(new ExecuteDynamicConnects(afterComponent));
// }
//
return true;
}
public static void generatePVCNextMethod(BluePrintCPP bluePrint){
Method next = new Method("next", "void");
next.setPublic(false);
......
......@@ -27,6 +27,8 @@ public final class AllTemplates {
private static final Template SERVER_WRAPPER;
private static final Template DYNAMICS_EVENT_PortValueCheker;
private static final Template DYNAMICS_EVENT_DynamicHelper;
static {
Configuration conf = new Configuration(Configuration.VERSION_2_3_23);
......@@ -43,6 +45,7 @@ public final class AllTemplates {
AUTOPILOT_ADAPTER = conf.getTemplate("/autopilotadapter/AutopilotAdapter.ftl");
SERVER_WRAPPER = conf.getTemplate("/serverwrapper/ServerWrapper.ftl");
DYNAMICS_EVENT_PortValueCheker = conf.getTemplate("/dynamics/events_port_value_check_h.ftl");
DYNAMICS_EVENT_DynamicHelper = conf.getTemplate("/dynamics/dynamic_port_request_connect_helper_h.ftl");
} catch (IOException e) {
String msg = "could not load templates";
Log.error(msg, e);
......@@ -84,6 +87,10 @@ public final class AllTemplates {
return generateWithoutData(DYNAMICS_EVENT_PortValueCheker);
}
public static String generateDynamicHelper(){
return generateWithoutData(DYNAMICS_EVENT_DynamicHelper);
}
private static String generate(Template template, ViewModelBase viewModelBase) {
return generate(template, TemplateHelper.getDataForTemplate(viewModelBase));
......
//
// DynamicHelper.h
// TestForMa2
//
// Created by Nils Kaminski on 20.10.18.
// Copyright © 2018 Nils Kaminski. All rights reserved.
//
#ifndef DynamicHelper_h
#define DynamicHelper_h
......
//
// PortValueCheck.h
// TestForMa2
//
// Created by Nils Kaminski on 18.10.18.
// Copyright © 2018 Nils Kaminski. All rights reserved.
//
#ifndef PortValueCheck_h
#define PortValueCheck_h
......
Supports Markdown
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