Skip to content
Snippets Groups Projects
Commit 3e491fa7 authored by fortissBot's avatar fortissBot
Browse files

Added C/H files for components and some patches, added code generation, added includes to system.h

refs 7863
parent 51ed8e0e
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,8 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generator.executable;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.funcCall;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.expression.model.terms.IExpressionTerm;
import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable;
......@@ -41,24 +43,24 @@ public class LaserRangeFinderSensorExecutable extends GenericReceiverExecutable
/** {@inheritDoc} */
@Override
public IExpressionTerm getInitialization() {
return super.getInitialization();
return funcCall("lrf_init");
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) {
return super.getNoValGuardAccessor(logicalSignal);
return funcCall("lrf_is_noval");
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getTermination() {
return super.getTermination();
return funcCall("lrf_term");
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) {
return super.getValueReadAccessor(logicalSignal);
return funcCall("lrf_get_distance");
}
}
......@@ -18,6 +18,7 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
package org.fortiss.af3.platform.raspberry.generator.executable;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.funcCall;
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFacade.addUserHeaderInclude;
import static org.fortiss.af3.generator.common.utils.SourceModelElementFactory.createByteContentUnitForPluginFile;
import java.io.IOException;
......@@ -35,6 +36,7 @@ import org.fortiss.af3.component.model.generator.LocalFunction;
import org.fortiss.af3.expression.model.terms.IExpressionTerm;
import org.fortiss.af3.expression.model.terms.imperative.IStatementTerm;
import org.fortiss.af3.generator.common.model.c.CSourcePackage;
import org.fortiss.af3.generator.common.model.source.SourceUnit;
import org.fortiss.af3.platform.generic.generator.executable.GenericExecutionUnitExecutable;
import org.fortiss.af3.platform.language.executable.IInitializableExecutable;
import org.fortiss.af3.platform.language.executable.IReadableExecutable;
......@@ -59,6 +61,9 @@ import org.fortiss.tooling.kernel.extension.data.ITransformationContext;
*/
public class RaspberryPIExecutable extends GenericExecutionUnitExecutable {
private static final String SRC_LIB_SUB_PACKAGE_NAME = "src-lib";
private static final String INC_LIB_SUB_PACKAGE_NAME = "inc-lib";
/** Constructor. */
public RaspberryPIExecutable(ExecutionUnit modelElement) {
super(modelElement);
......@@ -74,23 +79,63 @@ public class RaspberryPIExecutable extends GenericExecutionUnitExecutable {
super.createExecutionUnitSourcePackage(name, deployedComponents, deployedPorts,
context);
// Add source/header files here --> TODO
// TODO: doesn't work since not recognized by configure script
// add src-lib/inc-lib sub packages (= folders in deployment)
// CSourcePackage sub =
// AF3GeneratorCommonLanguagesCFactory.eINSTANCE.createCSourcePackage();
// sub.setBaseLocation(SRC_LIB_SUB_PACKAGE_NAME);
// pkg.getSubPackages().add(sub);
// sub = AF3GeneratorCommonLanguagesCFactory.eINSTANCE.createCSourcePackage();
// sub.setBaseLocation(INC_LIB_SUB_PACKAGE_NAME);
// pkg.getSubPackages().add(sub);
// get system.h to add references to self-defined inc files
SourceUnit system = pkg.getSrcGenPackage().findSourceUnitByName("system.c");
// pkg.getIncGenPackage().findSourceUnitByName("system.h");
// Add source/header files here to be copied into the deployment directory
try {
// add main
/** COMPONENTS **/
addFile(pkg, "src/main.c");
// add IO
// reference is added by GenericExecutableBase -> only add file
addFile(pkg, "inc/io.h");
addFile(pkg, "src/io.c");
// add CAN
addFile(pkg, "inc/CanConnector.h");
addFile(pkg, "src/CanConnector.c");
// add all components including references
addFilesWithReference(pkg, system, "CanConnector");
addFilesWithReference(pkg, system, "Gamepad");
addFilesWithReference(pkg, system, "GPIO");
addFilesWithReference(pkg, system, "IMU");
addFilesWithReference(pkg, system, "LaserRangeFinder");
addFilesWithReference(pkg, system, "LaserScanner");
addFilesWithReference(pkg, system, "PWM");
/** LIBRARIES **/
// TODO: will fail during a build since not defined in Makefile
// add fix for dictionary, simply overwrite incorrect version (TODO!!)
// add UART lib
// addFile(pkg, "inc-lib/uart.h");
// addFile(pkg, "src-lib/uart.c");
addFile(pkg, "inc/libuart.h");
addFile(pkg, "src/libuart.c");
/** FIXES AND PATCHES **/
// overwrite data_dictionary, the new one has all functions
// required for the simulation commented out so there are no
// conflicts
addFile(pkg, "inc-gen/data_dictionary.h");
addFile(pkg, "src-gen/data_dictionary.c");
// overwrite Makedefs, the new one uses -std=gnu99 instead of -std=c99
// so libuart compiles properly
addFile(pkg, "Makedefs");
} catch(IOException | URISyntaxException e) {
throw new RuntimeException("could not add header and source files from lib", e);
}
......@@ -98,12 +143,23 @@ public class RaspberryPIExecutable extends GenericExecutionUnitExecutable {
return pkg;
}
private static void addFilesWithReference(CSourcePackage pkg, SourceUnit source,
String fileWithoutExtension) throws IOException, URISyntaxException {
addFile(pkg, "src/" + fileWithoutExtension + ".c");
addFile(pkg, "inc/" + fileWithoutExtension + ".h");
addSystemCReference(source, fileWithoutExtension);
}
private static void addFile(CSourcePackage pkg, String file) throws IOException,
URISyntaxException {
pkg.addUnit(createByteContentUnitForPluginFile(AF3PlatformRaspberryActivator.PLUGIN_ID,
"lib", file, false));
}
private static void addSystemCReference(SourceUnit source, String reference) {
addUserHeaderInclude(source, reference);
}
/** {@inheritDoc} */
@Override
protected ComponentFunction createInitializeFunction(
......
......@@ -92,7 +92,7 @@ public class RaspberryModelElementFactory {
/** Creates a {@link SensorGamepad} */
public static SensorGamepad createGamepadSensor() {
SensorGamepad connector = ModelFactory.eINSTANCE.createSensorGamepad();
connector.setName("Gamepad_In");
connector.setName("Gamepad");
createConnectorLayout(connector);
return connector;
}
......@@ -100,7 +100,7 @@ public class RaspberryModelElementFactory {
/** Creates a {@link SensorIMU}. */
public static SensorIMU createSensorIMU() {
SensorIMU connector = ModelFactory.eINSTANCE.createSensorIMU();
connector.setName("IMU_In");
connector.setName("IMU");
createConnectorLayout(connector);
return connector;
}
......@@ -108,7 +108,7 @@ public class RaspberryModelElementFactory {
/** Creates a {@link SensorLaserRangeFinder}. */
public static SensorLaserRangeFinder createSensorLaserRangeFinder() {
SensorLaserRangeFinder connector = ModelFactory.eINSTANCE.createSensorLaserRangeFinder();
connector.setName("LaserRangeFinder_In");
connector.setName("LaserRangeFinder");
createConnectorLayout(connector);
return connector;
}
......@@ -116,7 +116,7 @@ public class RaspberryModelElementFactory {
/** Creates a {@link SensorLaserScanner}. */
public static SensorLaserScanner createSensorLaserScanner() {
SensorLaserScanner connector = ModelFactory.eINSTANCE.createSensorLaserScanner();
connector.setName("LaserScanner_In");
connector.setName("LaserScanner");
createConnectorLayout(connector);
return connector;
}
......@@ -132,7 +132,7 @@ public class RaspberryModelElementFactory {
/** Creates a {@link ActuatorPWM}. */
public static ActuatorPWM createActuatorPWM() {
ActuatorPWM connector = ModelFactory.eINSTANCE.createActuatorPWM();
connector.setName("PWM_Out");
connector.setName("PWM");
createConnectorLayout(connector);
return connector;
}
......@@ -164,7 +164,7 @@ public class RaspberryModelElementFactory {
/** Creates a {@link Button2}. */
public static Button2 createButton2() {
Button2 button = GamepadFactory.eINSTANCE.createButton2();
button.setName("Button1_Circle_");
button.setName("Button2_Circle");
createConnectorLayout(button);
return button;
}
......@@ -185,6 +185,14 @@ public class RaspberryModelElementFactory {
return button;
}
/** Creates a {@link ButtonR1}. */
public static ButtonR1 createButtonR1() {
ButtonR1 button = GamepadFactory.eINSTANCE.createButtonR1();
button.setName("ButtonR1");
createConnectorLayout(button);
return button;
}
/** Creates a {@link ButtonL1}. */
public static ButtonL1 createButtonL1() {
ButtonL1 button = GamepadFactory.eINSTANCE.createButtonL1();
......@@ -209,14 +217,6 @@ public class RaspberryModelElementFactory {
return button;
}
/** Creates a {@link ButtonR1}. */
public static ButtonR1 createButtonR1() {
ButtonR1 button = GamepadFactory.eINSTANCE.createButtonR1();
button.setName("ButtonR1");
createConnectorLayout(button);
return button;
}
/** Creates a {@link Left_StickX_Position}. */
public static Left_StickX_Position createLeftStickX() {
Left_StickX_Position button = GamepadFactory.eINSTANCE.createLeft_StickX_Position();
......
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