Skip to content
Snippets Groups Projects
Commit 05654e41 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

Bugfixes in Models conference platform generator.

parent 46919fc6
No related branches found
No related tags found
No related merge requests found
ButtonGeneratorExtension.java 6ee031e2318652fe5e509165b5ea5ea17cc47588 RED
ButtonGeneratorExtension.java 2d276aa27b5182dc40cda1c72193e5c220eaf91f RED
ButtonTransform.java 8c701414e4a92490f088c1e01be805e54a93b932 YELLOW
LCDGeneratorExtension.java a2b76fdf24ed63bd7c8dcc68c22b011d366fe1bf RED
LCDTransform.java cc49241c94e042be03e776965c4577b04cfc1273 YELLOW
LEDGeneratorExtension.java be5ae603cfe2f7015d7b3d40e46013f1e2e01d74 RED
LEDGeneratorExtension.java 5f77b600180a765347a613660adf3cdf109da2e6 RED
LEDTransform.java e90532398e21ec4f3d8c0e4358e0d802fc93bb4a YELLOW
PotiGeneratorExtension.java d866773c7a0bd51fcf9bece96fd529d4e2b28514 RED
PotiTransform.java c534fa6f1cf98474be4f2fb5d405be8626f472e4 YELLOW
......
......@@ -48,7 +48,7 @@ public final class ButtonGeneratorExtension extends WiringPiLibraryGeneratorExte
/** {@inheritDoc} */
@Override
public String getReadCode(InputPort logicalSignal, String targetVariable) {
return targetVariable + " = digitalRead(" + getPinNumber() + ");\n";
return targetVariable + " = digitalRead(" + getPinNumber() + ") ? 0 : 1;\n";
}
/** {@inheritDoc} */
......@@ -61,22 +61,22 @@ public final class ButtonGeneratorExtension extends WiringPiLibraryGeneratorExte
private String getPinNumber() {
String btnUID = modelElement.getUid();
if(BUTTON_LEFT_UID.equals(btnUID)) {
return "0"; // FIXME
return "27";
}
if(BUTTON_RIGHT_UID.equals(btnUID)) {
return "0"; // FIXME
return "26";
}
if(BUTTON_A_UID.equals(btnUID)) {
return "0"; // FIXME
return "6";
}
if(BUTTON_B_UID.equals(btnUID)) {
return "0"; // FIXME
return "5";
}
if(BUTTON_C_UID.equals(btnUID)) {
return "0"; // FIXME
return "4";
}
if(BUTTON_D_UID.equals(btnUID)) {
return "0"; // FIXME
return "1";
}
return "UNKNOWN_MODEL_ELEMENT_UID";
}
......
......@@ -48,29 +48,30 @@ public final class LEDGeneratorExtension extends WiringPiLibraryGeneratorExtensi
@Override
public String getWriteCode(OutputPort logicalSignal, String value) {
String pin = getPinNumber();
return "digitalWrite(" + pin + ", (" + value + " == 0 ? LOW : HIGH));\n";
return "digitalWrite(" + pin + ", (" + value + " == 1 ? LOW : HIGH));\n";
}
/** {@inheritDoc} */
@Override
public String getNoValWriteCode(OutputPort logicalSignal) {
return null;
String pin = getPinNumber();
return "digitalWrite(" + pin + ", HIGH);\n";
}
/** Returns the pin number for the given button UID. */
private String getPinNumber() {
String btnUID = modelElement.getUid();
if(LED_LEFT_UID.equals(btnUID)) {
return "0"; // FIXME
return "23";
}
if(LED_RIGHT_UID.equals(btnUID)) {
return "0"; // FIXME
return "7";
}
if(LED_RED_UID.equals(btnUID)) {
return "0"; // FIXME
return "2";
}
if(LED_WHITE_UID.equals(btnUID)) {
return "0"; // FIXME
return "3";
}
return "UNKNOWN_MODEL_ELEMENT_UID";
}
......
......@@ -4,5 +4,5 @@ CanTransmissionCatalog.java 959d488ebec4ae6a50c3f699d42aad535b1ae0c3 YELLOW
ConsoleOutputGeneratorExtension.java 031444f629b6027f07f1d91db3e6f49563b27612 YELLOW
MultiUnitMainGenerator.java 458754b89c2d79db3fee08baa444424772e40fb7 RED
PWMActuatorGeneratorExtension.java edc94d4cdd6a0c2da7a3c0e9b314e50ca087443c YELLOW
RaspberryPIGeneratorExtension.java 2cd95ddc54d7562bd9fa0b8a4018c25eda01b5a8 RED
SingleUnitMainGenerator.java 44096a99b4bfc46f24f893487fad206a94d512e9 RED
RaspberryPIGeneratorExtension.java ec972e3f77054ae98abf46784a874225708d6a58 RED
SingleUnitMainGenerator.java c8e0c098fe8fcf298926cd17cf5ddd4e71457b02 RED
......@@ -18,11 +18,14 @@ package org.fortiss.af3.platform.raspberry.generator.extension;
import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.isAtomicComponent;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.createDataDictionary;
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createCSourcePackage;
import static org.fortiss.af3.generator.common.utils.SourceModelElementFactory.createByteContentUnitForPluginFileInRCP;
import static org.fortiss.af3.platform.raspberry.AF3PlatformRaspberryActivator.PLUGIN_ID;
import static org.fortiss.af3.platform.raspberry.generator.templates.RasPiCTemplates.getConfigureFile;
import static org.fortiss.af3.platform.raspberry.generator.templates.RasPiCTemplates.getEclipseCDTProjectFile;
import static org.fortiss.af3.platform.raspberry.generator.templates.RasPiCTemplates.getEclipseProjectFile;
import static org.fortiss.af3.platform.raspberry.generator.templates.RasPiCTemplates.getMakedefsFile;
import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.findAtomicTransmissionUnits;
import static org.fortiss.tooling.kernel.utils.IdentifierUtils.getIdentifier;
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;
......@@ -46,6 +49,7 @@ import org.fortiss.af3.expression.model.DataDictionary;
import org.fortiss.af3.expression.model.terms.IExpressionTerm;
import org.fortiss.af3.generator.common.model.c.AF3GeneratorCommonLanguagesCFactory;
import org.fortiss.af3.generator.common.model.c.CSourcePackage;
import org.fortiss.af3.generator.common.model.source.ByteContentUnit;
import org.fortiss.af3.platform.language.executable.ExecutableBase;
import org.fortiss.af3.platform.language.executable.ExecutionUnitExecutableBase;
import org.fortiss.af3.platform.model.ExecutionUnit;
......@@ -108,6 +112,7 @@ public class RaspberryPIGeneratorExtension extends
this.context = context;
findDeploymentAndLookForCanTransmissionCatalog();
createGeneratorResultSourcePackage(name);
addDefaultHeadersAndLibrary();
analyzePlatformElementsAndCopyCode(deployedPorts);
try {
addEclipseCProjectFiles();
......@@ -122,6 +127,36 @@ public class RaspberryPIGeneratorExtension extends
return generatorResult;
}
/** Adds the headers and AF3 Pi HAL library, which are always required. */
private void addDefaultHeadersAndLibrary() {
addAF3PiHALLibraryFileContent();
addAF3PiHALHeaderFileContent("af3.h");
addAF3PiHALHeaderFileContent("cansocket.h");
addAF3PiHALHeaderFileContent("canthread.h");
addAF3PiHALHeaderFileContent("debugprint.h");
addAF3PiHALHeaderFileContent("timeutil.h");
}
/** Adds the content of the AF3 Pi HAL library file. */
private void addAF3PiHALLibraryFileContent() {
ByteContentUnit bcu =
createByteContentUnitForPluginFileInRCP(PLUGIN_ID, "code-gen-hal/lib",
"libaf3pihal.a", false);
generatorResult.getSubPackage(LIB_SUB_PACKAGE_NAME).addUnit(bcu);
includedLibraries.add("af3pihal");
includedLibraries.add("rt");
includedLibraries.add("pthread");
}
/** Adds the content of the given AF3 Pi HAL header file. */
private void addAF3PiHALHeaderFileContent(String headerFileName) {
ByteContentUnit bcu =
createByteContentUnitForPluginFileInRCP(AF3PlatformRaspberryActivator.PLUGIN_ID,
"code-gen-hal/inc/af3pihal", headerFileName, false);
generatorResult.getSubPackage(INC_LIB_SUB_PACKAGE_NAME).addUnit(bcu);
includedHeaders.add(headerFileName);
}
/**
* Adds the libraries and header files required by the used platform elements and returns the
* set of header file names.
......@@ -279,7 +314,8 @@ public class RaspberryPIGeneratorExtension extends
for(String s : includedLibraries) {
sb.append(s).append(' ');
}
generatorResult.addUnit(getConfigureFile(modelElement.getName(), sb.toString()));
String unitName = getIdentifier(modelElement);
generatorResult.addUnit(getConfigureFile(unitName, sb.toString()));
generatorResult.addUnit(getMakedefsFile());
}
......
......@@ -19,6 +19,7 @@ import static org.fortiss.af3.component.generator.c.ComponentProgramToCSourcePac
import static org.fortiss.af3.component.generator.component.ComponentFunctionIdentifierUtils.getInitializeFunctionName;
import static org.fortiss.af3.component.generator.component.PortVariableUtils.getPortIdentifier;
import static org.fortiss.af3.platform.raspberry.generator.templates.RasPiCTemplates.getSingleUnitMainCFile;
import static org.fortiss.tooling.kernel.utils.IdentifierUtils.getIdentifier;
import java.util.HashMap;
import java.util.HashSet;
......@@ -89,8 +90,9 @@ class SingleUnitMainGenerator {
String initCode = createInitCode();
String sensorVariables = createVariables();
String workerCode = createWorkerCode(deployedComponents, deployedPorts);
return getSingleUnitMainCFile(executionUnit.getName(), executionUnit.getCycleTime(),
includes, initCode, auxFuns, workerCode, sensorVariables);
String unitName = getIdentifier(executionUnit);
return getSingleUnitMainCFile(unitName, executionUnit.getCycleTime(), includes, initCode,
auxFuns, workerCode, sensorVariables);
}
/** Creates the code for auxiliary functions. */
......
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