Skip to content
Snippets Groups Projects
Commit 71fd9cc2 authored by Zabir Haider Khan's avatar Zabir Haider Khan
Browse files

make and port types

parent c38f822b
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,9 @@ $Id$ ...@@ -17,6 +17,9 @@ $Id$
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generated.files; package org.fortiss.af3.platform.raspberry.generated.files;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
/** /**
* *
* @author zverlov * @author zverlov
...@@ -34,7 +37,29 @@ public class RaspberryMakeMKGeneration { ...@@ -34,7 +37,29 @@ public class RaspberryMakeMKGeneration {
} }
/** Main methods for creation of make.mk. */ /** Main methods for creation of make.mk. */
/**
* public void createMakeMK(){
*
* }
*/
/**
* @throws FileNotFoundException
* @throws UnsupportedEncodingException
*/
public void createMakeMK() { public void createMakeMK() {
/*
* FileInputStream fis = new FileInputStream("C:\\Users\\Khan\\Desktop\\make.txt");
* InputStreamReader in = new InputStreamReader(fis, "US-ASCII");// UTF-8
*
* content += in;
*/
content +=
"test:\n @echo $(@D)\n @echo $(DEPS)\n @echo $(OBJECTS2)\n @echo Test\n @echo $(C_SRC)\n @echo Test\n @echo $(H_SRC)\n @echo Test\n @echo $(LIBRARY)\n";
content +=
"run: all\n @./$(TARGET)\n\nramdisk:\n sudo mkdir $(RAMDISK_DIR)\n sudo mount -t tmpfs -o size=512m tmpfs $(RAMDISK_DIR)\n\n\n.PHONY: test deploy all ramdisk ";
// FileOutputStream fos = new FileOutputStream("test.txt");
// TODO: needs to be implemented // TODO: needs to be implemented
} }
......
...@@ -48,7 +48,11 @@ public class RaspberryMakefileGeneration { ...@@ -48,7 +48,11 @@ public class RaspberryMakefileGeneration {
/** This methods is only an example. */ /** This methods is only an example. */
private void printFirstTwoLines() { private void printFirstTwoLines() {
content += "SHELL := /bin/bash" + "\n\n"; content += "SHELL := /bin/bash" + "\n\n";
content += "TARGET = " + binaryTargetName + "\n"; content += "TARGET = " + binaryTargetName + "\n\n";
content += "C_SRC := $(wildcard *.c)\n";
content += "CPP_SRC := $(wildcard *.cpp)\n";
content += "H_SRC := $(wildcard *.h)\n";
content += "H_SRC := $(wildcard *.h)\n";
} }
......
...@@ -26,24 +26,25 @@ package org.fortiss.af3.platform.raspberry.generated.files; ...@@ -26,24 +26,25 @@ package org.fortiss.af3.platform.raspberry.generated.files;
*/ */
public class RaspberryPortTypeGeneration { public class RaspberryPortTypeGeneration {
private String status; /** Information relevant to the ports. */
private String portInfo;
/** Contents of the PortsInfo. */ /** Contents of the PortsInfo. */
private String content; private String content;
/** Constructor. */ /** Constructor. */
public RaspberryPortTypeGeneration(String info) { public RaspberryPortTypeGeneration(String portSpecs) {
this.status = info; this.portInfo = portSpecs;
this.content = ""; this.content = "";
} }
/** Calls the methods that create the Infofile. */ /** Calls the methods that create the portSpecs. */
public void createInfofile() { public void createInfofile() {
content += status; content += portInfo;
} }
/** Return the current content of the Infofile. */ /** Return the current content of the portSpecs. */
public String getContent() { public String getContent() {
return this.content; return this.content;
} }
......
...@@ -17,15 +17,21 @@ $Id$ ...@@ -17,15 +17,21 @@ $Id$
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generator.executable; 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.List;
import java.util.Map; import java.util.Map;
import org.fortiss.af3.component.model.Component; import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.component.model.OutputPort;
import org.fortiss.af3.component.model.Port; import org.fortiss.af3.component.model.Port;
import org.fortiss.af3.component.model.PortSpecification;
import org.fortiss.af3.generator.common.model.source.SourcePackage; import org.fortiss.af3.generator.common.model.source.SourcePackage;
import org.fortiss.af3.platform.language.executable.TransmissionUnitExecutableBase; import org.fortiss.af3.platform.language.executable.TransmissionUnitExecutableBase;
import org.fortiss.af3.platform.model.ExecutionUnit; import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.platform.model.TransmissionUnit; import org.fortiss.af3.platform.model.TransmissionUnit;
import org.fortiss.af3.platform.raspberry.generated.files.RaspberryPortTypeGeneration;
/** /**
* *
...@@ -49,16 +55,52 @@ public class BusExecutable extends TransmissionUnitExecutableBase<TransmissionUn ...@@ -49,16 +55,52 @@ public class BusExecutable extends TransmissionUnitExecutableBase<TransmissionUn
public void createAllFiles(SourcePackage pack, Map<ExecutionUnit, List<Port>> euPortsPair, public void createAllFiles(SourcePackage pack, Map<ExecutionUnit, List<Port>> euPortsPair,
Map<ExecutionUnit, List<Component>> euComponentList, Component topComponent, Map<ExecutionUnit, List<Component>> euComponentList, Component topComponent,
int deploymentID) { int deploymentID) {
checkTypesOfOutputPorts(euPortsPair); checkTypesOfOutputPorts(pack, euPortsPair);
} }
/** Collects the information about type and bounds of all OutputPorts. */ /** Collects the information about type and bounds of all OutputPorts. */
public void checkTypesOfOutputPorts(Map<ExecutionUnit, List<Port>> portsToCheck) { public void checkTypesOfOutputPorts(SourcePackage pack,
Map<ExecutionUnit, List<Port>> portsToCheck) {
// TODO: Look at all ports, which are OutputPorts (instanceof OutputPort) // TODO: Look at all ports, which are OutputPorts (instanceof OutputPort)
// save for each port the type (i.e.: int) and the upper+lower bounds // save for each port the type (i.e.: int) and the upper+lower bounds
// create a simple string template for the output // create a simple string template for the output
// String Keys;
String logPortSpecs = new String();
String portName = new String();
String portType = new String();
Object[] ecus = portsToCheck.keySet().toArray();
for(Object ecu : ecus) { // Iterate over number of Cores
for(Object port : portsToCheck.get(ecu)) { // Iterate over Number of Ports.
if(port instanceof InputPort) {
portName = ((InputPort)port).getName();
PortSpecification portSpecIn =
(PortSpecification)((InputPort)port).getSpecifications().get(0);
portType = portSpecIn.getType().toString();
// logPortSpecification(portName, portSpecIn, "Input");
logPortSpecs +=
"Input PortName: " + portName + "\nType: " + portType + "\n\n";
} else if(port instanceof OutputPort) {
portName = ((OutputPort)port).getName();
PortSpecification portSpecOut =
(PortSpecification)((OutputPort)port).getSpecifications().get(0);
portType = portSpecOut.getType().toString();
// logPortSpecification(portName, portSpecOut, "Output");
logPortSpecs +=
"Output PortName: " + portName + "\nType: " + portType + "\n\n";
} else {
System.out.println("Not a port!");
}
}
}
RaspberryPortTypeGeneration rspPortInfoGen = new RaspberryPortTypeGeneration(logPortSpecs);
rspPortInfoGen.createInfofile();
pack.addUnit(createStaticContentSourceUnit("PortSpecifications",
rspPortInfoGen.getContent(), false));
} }
} }
...@@ -17,6 +17,8 @@ $Id$ ...@@ -17,6 +17,8 @@ $Id$
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generator.executable; 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.List;
import java.util.Map; import java.util.Map;
...@@ -26,6 +28,7 @@ import org.fortiss.af3.generator.common.model.source.SourcePackage; ...@@ -26,6 +28,7 @@ import org.fortiss.af3.generator.common.model.source.SourcePackage;
import org.fortiss.af3.platform.language.executable.TransmissionUnitExecutableBase; import org.fortiss.af3.platform.language.executable.TransmissionUnitExecutableBase;
import org.fortiss.af3.platform.model.ExecutionUnit; import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.platform.model.TransmissionUnit; import org.fortiss.af3.platform.model.TransmissionUnit;
import org.fortiss.af3.platform.raspberry.templates.RaspberryTemplateLoader;
/** /**
* *
...@@ -49,7 +52,19 @@ public class CANBusExecutable extends TransmissionUnitExecutableBase<Transmissio ...@@ -49,7 +52,19 @@ public class CANBusExecutable extends TransmissionUnitExecutableBase<Transmissio
public void createAllFiles(SourcePackage pack, Map<ExecutionUnit, List<Port>> euPortsPair, public void createAllFiles(SourcePackage pack, Map<ExecutionUnit, List<Port>> euPortsPair,
Map<ExecutionUnit, List<Component>> euComponentList, Component topComponent, Map<ExecutionUnit, List<Component>> euComponentList, Component topComponent,
int deploymentID) { int deploymentID) {
System.out.println("hello"); createMakeFileUsingTemplate(pack, "test_targetName");
createMakeMKUsingTemplate(pack);
}
/** Creates a Makefile for an executable with a certain target name. */
private void createMakeFileUsingTemplate(SourcePackage pack, String targetName) {
String content = RaspberryTemplateLoader.getMakeFileTemplate(targetName).toString();
pack.addUnit(createStaticContentSourceUnit("Makefile", content, false));
} }
/** Creates the make.mk file. */
private void createMakeMKUsingTemplate(SourcePackage pack) {
String content = RaspberryTemplateLoader.getMakeMkTemplate().toString();
pack.addUnit(createStaticContentSourceUnit("make.mk", content, false));
}
} }
...@@ -55,11 +55,17 @@ public class RaspberryTemplateLoader { ...@@ -55,11 +55,17 @@ public class RaspberryTemplateLoader {
/** Returns the Template of a Makefile for the Raspberry Platform. */ /** Returns the Template of a Makefile for the Raspberry Platform. */
public static StringTemplate getMakeFileTemplate(String binaryName) { public static StringTemplate getMakeFileTemplate(String binaryName) {
/*
* return loadResourceSTG(RaspberryTemplateLoader.class, "MakeFileTemplate").getInstanceOf(
* "MakeFileTemplate");
*/
StringTemplate template = StringTemplate template =
loadResourceSTG(RaspberryTemplateLoader.class, "MakeFileTemplate").getInstanceOf( loadResourceSTG(RaspberryTemplateLoader.class, "MakeFileTemplate").getInstanceOf(
"MakeFileTemplate"); "MakeFileTemplate");
template.setAttribute("binaryName", binaryName); template.setAttribute("binaryName", binaryName);
return template; return template;
} }
/** Returns the Template of make.mk file for the Raspberry Platform. */ /** Returns the Template of make.mk file for the Raspberry Platform. */
...@@ -81,4 +87,13 @@ public class RaspberryTemplateLoader { ...@@ -81,4 +87,13 @@ public class RaspberryTemplateLoader {
template.setAttribute("headerFile", headerFile); template.setAttribute("headerFile", headerFile);
return template; return template;
} }
public static StringTemplate getMakeMkTemplate() {
StringTemplate template =
loadResourceSTG(RaspberryTemplateLoader.class, "MakeMkTemplate").getInstanceOf(
"MakeMkTemplate");
// template.setAttribute("binaryName", binaryName);
return template;
}
} }
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