Skip to content
Snippets Groups Projects
Commit afb1f322 authored by Sergey Zverlov's avatar Sergey Zverlov
Browse files

small changes

refs 2505
parent 238a89c8
No related branches found
No related tags found
No related merge requests found
......@@ -49,8 +49,16 @@ public class BusExecutable extends TransmissionUnitExecutableBase<TransmissionUn
public void createAllFiles(SourcePackage pack, Map<ExecutionUnit, List<Port>> euPortsPair,
Map<ExecutionUnit, List<Component>> euComponentList, Component topComponent,
int deploymentID) {
// TODO Auto-generated method stub
checkTypesOfOutputPorts(euPortsPair);
}
/** Collects the information about type and bounds of all OutputPorts. */
public void checkTypesOfOutputPorts(Map<ExecutionUnit, List<Port>> portsToCheck) {
// TODO: Look at all ports, which are OutputPorts (instanceof OutputPort)
// save for each port the type (i.e.: int) and the upper+lower bounds
// create a simple string template for the output
}
}
......@@ -17,8 +17,6 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generator.executable;
import static org.fortiss.af3.generator.common.utils.SourceModelElementFactory.createStaticContentSourceUnit;
import java.util.List;
import java.util.Map;
......@@ -28,7 +26,6 @@ import org.fortiss.af3.generator.common.model.source.SourcePackage;
import org.fortiss.af3.platform.language.executable.TransmissionUnitExecutableBase;
import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.platform.model.TransmissionUnit;
import org.fortiss.af3.platform.raspberry.templates.RaspberryTemplateLoader;
/**
*
......@@ -52,24 +49,7 @@ public class CANBusExecutable extends TransmissionUnitExecutableBase<Transmissio
public void createAllFiles(SourcePackage pack, Map<ExecutionUnit, List<Port>> euPortsPair,
Map<ExecutionUnit, List<Component>> euComponentList, Component topComponent,
int deploymentID) {
createMakeFileUsingTemplate(pack, "test_targetName");
// createMakeMK(pack);
createMakeMKUsingTemplate(pack);
}
/*
* More elegant way of creating files but not working right now. Problem with the special
* characters (i.e. $) in MakeFileTemplate.stg
*/
private void createMakeFileUsingTemplate(SourcePackage pack, String exName) {
String content = RaspberryTemplateLoader.getMakeFileTemplate(exName).toString();
pack.addUnit(createStaticContentSourceUnit("Makefile", content, false));
}
private void createMakeMKUsingTemplate(SourcePackage pack) {
String content = RaspberryTemplateLoader.getMakeMkFileTemplate().toString();
pack.addUnit(createStaticContentSourceUnit("make.mk", content, false));
System.out.println("hello");
}
}
......@@ -36,6 +36,7 @@ import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFacade
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createCSourcePackage;
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createConfigureFile;
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createMakedefsFile;
import static org.fortiss.af3.generator.common.utils.SourceModelElementFactory.createStaticContentSourceUnit;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.TransformationUtils.createTransformedObjectFor;
......@@ -59,8 +60,11 @@ import org.fortiss.af3.expression.model.terms.IExpressionTerm;
import org.fortiss.af3.expression.model.terms.imperative.Assignment;
import org.fortiss.af3.expression.model.terms.imperative.IStatementTerm;
import org.fortiss.af3.expression.model.terms.imperative.StatementSequence;
import org.fortiss.af3.expression.utils.ExpressionModelElementFactory;
import org.fortiss.af3.generator.common.model.c.CImplementationFile;
import org.fortiss.af3.generator.common.model.c.CSourcePackage;
import org.fortiss.af3.generator.common.model.source.SourcePackage;
import org.fortiss.af3.generator.common.model.source.StaticContentSourceUnit;
import org.fortiss.af3.platform.AF3PlatformActivator;
import org.fortiss.af3.platform.language.executable.ExecutableBase;
import org.fortiss.af3.platform.language.executable.ExecutionUnitExecutableBase;
......@@ -77,6 +81,7 @@ import org.fortiss.af3.platform.model.generic.GenericReceiver;
import org.fortiss.af3.platform.model.generic.GenericTransceiver;
import org.fortiss.af3.platform.model.generic.GenericTransmitter;
import org.fortiss.af3.platform.raspberry.model.Core;
import org.fortiss.af3.platform.raspberry.templates.RaspberryTemplateLoader;
import org.fortiss.tooling.kernel.extension.data.ITransformationContext;
import org.fortiss.tooling.kernel.extension.exception.TransformationFailedException;
......@@ -148,7 +153,7 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac
ComponentProgram program = createComponentProgram("system", init, step);
program.getLocalFunctions().add(createTerminationFunction(usedUnits));
program.getLocalFunctions().add(createReadInputFunction(deployedPorts, usedTransceivers));
program.getLocalFunctions().add(createMainFunction());
// Fill the system program with the component sub-programs
try {
// deployed components
......@@ -183,9 +188,25 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac
sourcePackage.getUnits().add(createConfigureFile(modelElement.getName()));
sourcePackage.getUnits().add(createMakedefsFile());
sourcePackage.getUnits().add(createMakeFileUsingTemplate(sourcePackage, "testName"));
sourcePackage.getSrcGenPackage().getUnits().add(createMakeMKUsingTemplate(sourcePackage));
sourcePackage.getSrcPackage().getUnits().add(createMakeMKUsingTemplate(sourcePackage));
sourcePackage.getIncPackage().getUnits().add(createMakeMKUsingTemplate(sourcePackage));
sourcePackage.getIncGenPackage().getUnits().add(createMakeMKUsingTemplate(sourcePackage));
sourcePackage.getUnits().add(createMakeMKUsingTemplate(sourcePackage));
return sourcePackage;
}
private StaticContentSourceUnit createMakeFileUsingTemplate(SourcePackage pack, String exName) {
String content = RaspberryTemplateLoader.getMakeFileTemplate(exName).toString();
return createStaticContentSourceUnit("Makefile", content, false);
}
private StaticContentSourceUnit createMakeMKUsingTemplate(SourcePackage pack) {
String content = RaspberryTemplateLoader.getMakeMkFileTemplate().toString();
return createStaticContentSourceUnit("make.mk", content, false);
}
/** Adds the platform connectors includes. */
private void fixSystemCImports(CImplementationFile system,
Set<PlatformConnectorUnit> usedUnits, Set<GenericTransceiver> usedTransceivers) {
......@@ -297,6 +318,25 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac
}
}
/** Creates the main function. */
protected LocalFunction createMainFunction() {
List<IStatementTerm> body = new ArrayList<IStatementTerm>();
String content = "while(1) \n";
content += "{\n";
content += "printf(\"Loop\\n\"); \n";
content += "run_system(); \n";
content += "sleep(1); \n";
content += "} \n";
Assignment customAssignment =
assignment(ExpressionModelElementFactory.definedConst(content));
body.add(assignment(funcCall("initialize_system")));
body.add(customAssignment);
body.add(assignment(funcCall("terminate_system")));
return createLocalFunction("main", null, sequence(body));
}
/** Creates the read input function. */
protected LocalFunction createReadInputFunction(
List<Pair<PlatformConnectorUnit, Port>> deployedPorts,
......
group MainFileTemplate;
MainFileTemplate(headerFile) ::= <<
MainFileTemplate() ::= <<
#include "$headerFile$"
int main(int argc, char *argv[]) {
initialize_ports();
int main()
{
initialize_system();
while (1) {
while(1)
{
printf("Loop\n");
run_system();
sleep(1);
}
terminate_system();
}
>>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment