Skip to content
Snippets Groups Projects
Commit e26d122c authored by Johannes Eder's avatar Johannes Eder
Browse files

made raspberry a execution unit in order to enable deployment

deleted mk template files
refs 7681
parent 91a1c225
No related branches found
No related tags found
No related merge requests found
Showing
with 1 addition and 410 deletions
......@@ -19,7 +19,7 @@
</eAnnotations>
</eOperations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="RaspberryPi3" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//GenericPlatformUnit platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ICommunicationMaster platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//IBoardPlatformArchitectureElement #//IBoardDomain"/>
<eClassifiers xsi:type="ecore:EClass" name="RaspberryPi3" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//GenericPlatformUnit platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ICommunicationMaster platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//IBoardPlatformArchitectureElement #//IBoardDomain platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ExecutionUnit"/>
<eClassifiers xsi:type="ecore:EClass" name="Sensor" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Receiver platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//IBoardPlatformArchitectureElement platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ICommunicationMaster #//IBoardDomain platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//IPlatformPort platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//IPlatformIOResource"/>
<eClassifiers xsi:type="ecore:EClass" name="Actuator" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Transmitter platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//IBoardPlatformArchitectureElement platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ICommunicationMaster #//IBoardDomain platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//IPlatformPort platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//IPlatformIOResource"/>
<eClassifiers xsi:type="ecore:EClass" name="SensorIn" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Receiver platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//IIpCorePlatformArchitectureElement platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ICommunicationMaster #//IProcessorDomain platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//IPlatformPort platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//IPlatformIOResource"/>
......
/*--------------------------------------------------------------------------+
$Id: RaspberryMakefileGeneration.java 16640 2016-04-13 13:18:00Z zverlov $
| |
| Copyright 2016 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generated.files;
/**
*
* @author zverlov
* @author $Author: zverlov $
* @version $Rev: 16640 $
* @ConQAT.Rating RED Hash:
*/
public class RaspberryFileGeneration {
/** Information relevant to the ports. */
private String text;
/** Contents of the PortsInfo. */
private String content;
/** Constructor. */
public RaspberryFileGeneration(String specs) {
this.text = specs;
this.content = "";
}
/** Calls the methods that create the portSpecs. */
public void createInfofile() {
content += text;
}
/** Return the current content of the portSpecs. */
public String getContent() {
return this.content;
}
}
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2016 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generated.files;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
/**
*
* @author zverlov
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public class RaspberryMakeMKGeneration {
/** Contents of make.mk. */
private String content;
/** Constructor. */
public RaspberryMakeMKGeneration() {
this.content = "";
}
/** Main methods for creation of make.mk. */
/**
* public void createMakeMK(){
*
* }
*/
/**
* @throws FileNotFoundException
* @throws UnsupportedEncodingException
*/
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
}
/** Return content. */
public String getContent() {
return this.content;
}
}
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2016 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generated.files;
/**
*
* @author zverlov
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public class RaspberryMakefileGeneration {
/** The name of the executable. */
private String binaryTargetName;
/** Contents of the Makefile. */
private String content;
/** Constructor. */
public RaspberryMakefileGeneration(String targetName) {
this.binaryTargetName = targetName;
this.content = "";
}
/** Calls the methods that create the Makefile. */
public void createMakefile() {
// TODO: needs to be implemented
printFirstTwoLines();
// ....
}
/** This methods is only an example. */
private void printFirstTwoLines() {
content += "SHELL := /bin/bash" + "\n\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";
}
/** Return the current content of the Makefile. */
public String getContent() {
return this.content;
}
}
group MainFileTemplate;
MainFileTemplate() ::= <<
int main()
{
initialize_system();
while(1)
{
printf("Loop\n");
run_system();
sleep(1);
}
terminate_system();
}
>>
\ No newline at end of file
group MakeFileTemplate;
MakeFileTemplate(binaryName) ::= <<
SHELL := /bin/bash
TARGET = $binaryName$
C_SRC := \$(wildcard *.c)
CPP_SRC := \$(wildcard *.cpp)
H_SRC := \$(wildcard *.h)
LIBRARY :=
INCLUDE_PATH := -I.
LIBRARY_PATH := -L.
CC = gcc
CC_FLAGS = -Wall -O3 -Wno-unused-variable
CCXX = g++
CCXX_FLAGS = -Wall -O3 -Wno-unused-variable
LIBRARY := -lwiringPi -lwiringPiDev
LD = ld
LD_FLAGS =
#include makefile fragments in subdirectories if they exist
-include ./*/make.mk
OBJECTS = \$(patsubst %.c, %.o, \$(C_SRC))
OBJECTS += \$(patsubst %.cpp, %.o, \$(CPP_SRC))
RAMDISK_DIR = /mnt/ramdisk
# make ramdisj target creates and mounts a tempfs drive
#OBJ_DIR = \$(RAMDISK_DIR)/objs
OBJ_DIR = objs
OBJS = \$(addprefix \$(OBJ_DIR)/, \$(OBJECTS))
DEPS = \$(patsubst %.o, %.o.d, \$(OBJS))
all: \$(TARGET) silent
#include all rules generated by gcc into the makefile
-include \$(DEPS)
#dummy target to that we don't get unnecessary mesages ( target is up to date & co)
silent:
@:
\$(TARGET): \$(OBJS)
@echo Linking
@\$(CCXX) \$(LD_FLAGS) \$(LIBRARY_PATH) -o \$(TARGET) \$^ \$(LIBRARY)
#create output directory if it doesn't exist
#generate dependency file for current file
# .o and .d are targets of the rule
# create blank targets for each source/header file. Used to update .d files when you delete a file
\$(OBJ_DIR)/%.o: %.c
@mkdir -p \$(@D)
@echo Building \$<
@\$(CC) \$(CC_FLAGS) \$(INCLUDE_PATH) \$(ARGS) -c \$< -o \$@
@echo -n "\$@.d \$(@D)/" > \$@.d
@\$(CC) \$(CC_FLAGS) \$(INCLUDE_PATH) \$(ARGS) -MM \$< \>> \$@.d
@cp \$@.d \$<.tp
@sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\\$\$//' -e '/^\$\$/ d' -e 's/\$\$/ :/' < \$<.tp \>> \$@.d
@rm -f \$<.tp
\$(OBJ_DIR)/%.o: %.cpp
@mkdir -p \$(@D)
@echo Building \$<
@\$(CCXX) \$(CCXX_FLAGS) \$(INCLUDE_PATH) \$(ARGS) -c \$< -o \$@
@echo -n "\$@.d \$(@D)/" > \$@.d
@\$(CCXX) \$(CCXX_FLAGS) \$(INCLUDE_PATH) \$(ARGS) -MM \$< \>> \$@.d
@cp \$@.d \$<.tp
@sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\\$\$//' -e '/^\$\$/ d' -e 's/\$\$/ :/' < \$<.tp \>> \$@.d
@rm -f \$<.tp
clean:
@echo Removing objects directory
@rm -rf \$(OBJ_DIR)
@echo Removing target
@rm -f \$(TARGET)
#http://blog.jgc.org/2015/04/the-one-line-you-should-add-to-every.html
print-%: ; @echo \$*=\$(\$*)
test:
@echo \$(@D)
@echo \$(DEPS)
@echo \$(OBJECTS2)
@echo Test
@echo \$(C_SRC)
@echo Test
@echo \$(H_SRC)
@echo Test
@echo \$(LIBRARY)
run: all
@./\$(TARGET)
ramdisk:
sudo mkdir \$(RAMDISK_DIR)
sudo mount -t tmpfs -o size=512m tmpfs \$(RAMDISK_DIR)
.PHONY: test deploy all ramdisk
>>
\ No newline at end of file
group MakeMkTemplate;
MakeMkTemplate() ::= <<
SELF_DIR = \$(dir \$(lastword \$(MAKEFILE_LIST)))
C_SRC += \$(wildcard \$(SELF_DIR)/*.c)
CPP_SRC += \$(wildcard \$(SELF_DIR)/*.cpp)
H_SRC += \$(wildcard \$(SELF_DIR)/*.h)
INCLUDE_PATH += \$ -I"\$(SELF_DIR)"
LIBRARY_PATH += #-L"\$(SELF_DIR)"
#include makefile fragments in subdirectories if they exist
-include \$(SELF_DIR)/*/make.mk
>>
\ No newline at end of file
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2016 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.templates;
import static org.fortiss.af3.generator.common.AF3GeneratorCommonActivator.getDefault;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import java.io.IOException;
import java.io.InputStreamReader;
import org.antlr.stringtemplate.StringTemplate;
import org.antlr.stringtemplate.StringTemplateGroup;
import org.antlr.stringtemplate.language.DefaultTemplateLexer;
/**
*
* @author zverlov
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public class RaspberryTemplateLoader {
/**
* @param contextClass
* @param stgName
* @return the string template group for a given context class and template group name
*/
public static StringTemplateGroup loadResourceSTG(Class<?> contextClass, String stgName) {
InputStreamReader in =
new InputStreamReader(contextClass.getResourceAsStream(stgName +
(stgName.contains(".") ? "" : ".stg")));
StringTemplateGroup templates = new StringTemplateGroup(in, DefaultTemplateLexer.class);
try {
in.close();
} catch(IOException e) {
error(getDefault(), "AF3 generator could not load stringtemplate " + stgName + ".", e);
}
return templates;
}
/** Returns the Template of a Makefile for the Raspberry Platform. */
public static StringTemplate getMakeFileTemplate(String binaryName) {
StringTemplate template =
loadResourceSTG(RaspberryTemplateLoader.class, "MakeFileTemplate").getInstanceOf(
"MakeFileTemplate");
template.setAttribute("binaryName", binaryName);
return template;
}
/** Returns the Template of make.mk file for the Raspberry Platform. */
public static StringTemplate getMakeMkFileTemplate() {
StringTemplate template =
loadResourceSTG(RaspberryTemplateLoader.class, "MakeMkTemplate").getInstanceOf(
"MakeMkTemplate");
return template;
}
/**
* @param string
* @return
*/
public static StringTemplate getMainFileTemplate(String headerFile) {
StringTemplate template =
loadResourceSTG(RaspberryTemplateLoader.class, "MainFileTemplate").getInstanceOf(
"MainFileTemplate");
template.setAttribute("headerFile", headerFile);
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