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

Added auxiliary function generation and ultrasonic brick sensor.

parent b4d96d06
No related branches found
No related tags found
No related merge requests found
Showing
with 28915 additions and 99 deletions
...@@ -169,6 +169,19 @@ ...@@ -169,6 +169,19 @@
</objectClass> </objectClass>
</target> </target>
</transformationProvider> </transformationProvider>
<transformationProvider
transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.brick.UltraSonicTransformation">
<source>
<objectClass
objectClass="org.fortiss.af3.platform.raspberry.model.brick.UltraSonicSensor">
</objectClass>
</source>
<target>
<objectClass
objectClass="org.fortiss.af3.platform.raspberry.generator.executable.brick.UltraSonicSensorExecutable">
</objectClass>
</target>
</transformationProvider>
<transformationProvider <transformationProvider
transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.PWMActuatorTransformation"> transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.PWMActuatorTransformation">
<source> <source>
......
...@@ -6,4 +6,4 @@ HeaderCopyGenerator.java 18239a3adae35256e32dad19df9d8f38acbf7e66 RED ...@@ -6,4 +6,4 @@ HeaderCopyGenerator.java 18239a3adae35256e32dad19df9d8f38acbf7e66 RED
MultiUnitMainGenerator.java 458754b89c2d79db3fee08baa444424772e40fb7 RED MultiUnitMainGenerator.java 458754b89c2d79db3fee08baa444424772e40fb7 RED
PWMActuatorExecutable.java d5d75c70ec12a3e008f744ff15b3c103b5d57f6c YELLOW PWMActuatorExecutable.java d5d75c70ec12a3e008f744ff15b3c103b5d57f6c YELLOW
RaspberryPIExecutable.java cafff8199da9cc59688289c9c26097e6872e9702 RED RaspberryPIExecutable.java cafff8199da9cc59688289c9c26097e6872e9702 RED
SingleUnitMainGenerator.java fe13cbffac938bb7d93b3eece4ff7884c3878075 YELLOW SingleUnitMainGenerator.java 1b9e47102a2a938e2f41fbb9f171d06d140ac86c RED
...@@ -83,11 +83,43 @@ class SingleUnitMainGenerator { ...@@ -83,11 +83,43 @@ class SingleUnitMainGenerator {
/** Creates the main.c file for deployments with a single execution units. */ /** Creates the main.c file for deployments with a single execution units. */
public AbstractUnit createSingleUnitMain() { public AbstractUnit createSingleUnitMain() {
String includes = createIncludes(); String includes = createIncludes();
String auxFuns = createAuxiliaryFunctions();
String initCode = createInitCode(); String initCode = createInitCode();
String sensorVariables = createVariables(); String sensorVariables = createVariables();
String workerCode = createWorkerCode(deployedComponents, deployedPorts); String workerCode = createWorkerCode(deployedComponents, deployedPorts);
return getSingleUnitMainCFile(executionUnit.getName(), executionUnit.getCycleTime(), return getSingleUnitMainCFile(executionUnit.getName(), executionUnit.getCycleTime(),
includes, initCode, workerCode, sensorVariables); includes, initCode, auxFuns, workerCode, sensorVariables);
}
/** Creates the code for auxiliary functions. */
private String createAuxiliaryFunctions() {
StringBuilder sb = new StringBuilder();
Set<String> singletonInitDone = new HashSet<>();
for(PlatformConnectorUnit pcu : platformConnector2ExecutableBase.keySet()) {
ExecutableBase<?> exec = platformConnector2ExecutableBase.get(pcu);
String sPostfix = null;
if(exec instanceof ISingletonInitializationExecutable) {
ISingletonInitializationExecutable singletonExec =
(ISingletonInitializationExecutable)exec;
// check if function definition was already included
String ident = singletonExec.getSingletonIdentifier();
sPostfix = singletonPostfixMap.get(ident);
if(!singletonInitDone.contains(ident)) {
singletonInitDone.add(ident);
String def = singletonExec.getSingletonAuxiliaryFunctions(sPostfix);
sb.append(def != null ? def : "");
}
}
// sPostfix is set by first if-block or remains null
if(exec instanceof IInstanceInitializationExecutable) {
IInstanceInitializationExecutable initExec =
(IInstanceInitializationExecutable)exec;
String iPostfix = instancePostfixMap.get(initExec);
String def = initExec.getInstanceAuxiliaryFunctions(iPostfix, sPostfix);
sb.append(def != null ? def : "");
}
}
return sb.toString();
} }
/** Creates the includes of the system headers. */ /** Creates the includes of the system headers. */
...@@ -137,24 +169,26 @@ class SingleUnitMainGenerator { ...@@ -137,24 +169,26 @@ class SingleUnitMainGenerator {
Set<String> singletonInitDone = new HashSet<>(); Set<String> singletonInitDone = new HashSet<>();
for(PlatformConnectorUnit pcu : platformConnector2ExecutableBase.keySet()) { for(PlatformConnectorUnit pcu : platformConnector2ExecutableBase.keySet()) {
ExecutableBase<?> exec = platformConnector2ExecutableBase.get(pcu); ExecutableBase<?> exec = platformConnector2ExecutableBase.get(pcu);
String sPrefix = null; String sPostfix = null;
if(exec instanceof ISingletonInitializationExecutable) { if(exec instanceof ISingletonInitializationExecutable) {
ISingletonInitializationExecutable singletonExec = ISingletonInitializationExecutable singletonExec =
(ISingletonInitializationExecutable)exec; (ISingletonInitializationExecutable)exec;
// check if variable declaration was already included // check if variable declaration was already included
String ident = singletonExec.getSingletonIdentifier(); String ident = singletonExec.getSingletonIdentifier();
sPrefix = singletonPostfixMap.get(ident); sPostfix = singletonPostfixMap.get(ident);
if(!singletonInitDone.contains(ident)) { if(!singletonInitDone.contains(ident)) {
singletonInitDone.add(ident); singletonInitDone.add(ident);
sb.append(singletonExec.getSingletonVariableDeclarationCode(sPrefix)); String def = singletonExec.getSingletonVariableDeclarationCode(sPostfix);
sb.append(def != null ? def : "");
} }
} }
// sPrefix is set by first if-block or remains null // sPostfix is set by first if-block or remains null
if(exec instanceof IInstanceInitializationExecutable) { if(exec instanceof IInstanceInitializationExecutable) {
IInstanceInitializationExecutable initExec = IInstanceInitializationExecutable initExec =
(IInstanceInitializationExecutable)exec; (IInstanceInitializationExecutable)exec;
String iPrefix = instancePostfixMap.get(initExec); String iPostfix = instancePostfixMap.get(initExec);
sb.append(initExec.getVariableDeclaration(iPrefix, sPrefix)); String def = initExec.getVariableDeclaration(iPostfix, sPostfix);
sb.append(def != null ? def : "");
} }
} }
return sb.toString(); return sb.toString();
...@@ -192,22 +226,6 @@ class SingleUnitMainGenerator { ...@@ -192,22 +226,6 @@ class SingleUnitMainGenerator {
// // extractRGBforLEDButton(p); // // extractRGBforLEDButton(p);
// // } // // }
// } // }
// if(useUS) {
// sb.append("uint16_t ultra_sonic_A;\n");
// sb.append("uint64_t us_A_last_cb_time = 0;\n");
// sb.append("char* uid_us_A = \"zpW\";\n");
// sb.append("void us_A_callback(uint16_t distance, void *data) {\n");
// sb.append("ultra_sonic_A = distance;\n");
// sb.append("us_A_last_cb_time = time_util_get_current_micros();\n");
// sb.append("}\n");
// sb.append("uint16_t ultra_sonic_B;\n");
// sb.append("uint64_t us_B_last_cb_time = 0;\n");
// sb.append("char* uid_us_B = \"zqN\";\n");
// sb.append("void us_B_callback(uint16_t distance, void *data) {\n");
// sb.append("ultra_sonic_B = distance;\n");
// sb.append("us_B_last_cb_time = time_util_get_current_micros();\n");
// sb.append("}\n\n");
// }
// if(useLaser) { // if(useLaser) {
// sb.append("int16_t laser_distance;\n"); // sb.append("int16_t laser_distance;\n");
// sb.append("uint64_t laser_last_cb_time = 0;\n"); // sb.append("uint64_t laser_last_cb_time = 0;\n");
...@@ -296,17 +314,17 @@ class SingleUnitMainGenerator { ...@@ -296,17 +314,17 @@ class SingleUnitMainGenerator {
/** Creates the read code for the given receiver and port. */ /** Creates the read code for the given receiver and port. */
private String createWriteCode(Transmitter transmitter, OutputPort outport) { private String createWriteCode(Transmitter transmitter, OutputPort outport) {
ExecutableBase<?> exec = platformConnector2ExecutableBase.get(transmitter); ExecutableBase<?> exec = platformConnector2ExecutableBase.get(transmitter);
String sPrefix = null; String sPostfix = null;
if(exec instanceof ISingletonExecutable) { if(exec instanceof ISingletonExecutable) {
sPrefix = sPostfix =
singletonPostfixMap.get(((ISingletonExecutable)exec).getSingletonIdentifier()); singletonPostfixMap.get(((ISingletonExecutable)exec).getSingletonIdentifier());
} }
String iPrefix = instancePostfixMap.get(exec); String iPostfix = instancePostfixMap.get(exec);
if(exec instanceof IWriteableExecutable) { if(exec instanceof IWriteableExecutable) {
IWriteableExecutable wexec = (IWriteableExecutable)exec; IWriteableExecutable wexec = (IWriteableExecutable)exec;
String sourceVariable = getPortIdentifier(outport); String sourceVariable = getPortIdentifier(outport);
String writeCode = wexec.getWriteCode(iPrefix, sPrefix, outport, sourceVariable); String writeCode = wexec.getWriteCode(iPostfix, sPostfix, outport, sourceVariable);
String novalCode = wexec.getNoValWriteCode(iPrefix, sPrefix, outport); String novalCode = wexec.getNoValWriteCode(iPostfix, sPostfix, outport);
if(novalCode != null) { if(novalCode != null) {
String novalVariable = getPortNoValIdentifier(sourceVariable); String novalVariable = getPortNoValIdentifier(sourceVariable);
return "if (" + novalVariable + ") {\n" + novalCode + "}\n else {\n" + writeCode + return "if (" + novalVariable + ") {\n" + novalCode + "}\n else {\n" + writeCode +
...@@ -321,23 +339,23 @@ class SingleUnitMainGenerator { ...@@ -321,23 +339,23 @@ class SingleUnitMainGenerator {
/** Creates the read code for the given receiver and port. */ /** Creates the read code for the given receiver and port. */
private String createReadCode(Receiver receiver, InputPort inport) { private String createReadCode(Receiver receiver, InputPort inport) {
ExecutableBase<?> exec = platformConnector2ExecutableBase.get(receiver); ExecutableBase<?> exec = platformConnector2ExecutableBase.get(receiver);
String sPrefix = null; String sPostfix = null;
if(exec instanceof ISingletonExecutable) { if(exec instanceof ISingletonExecutable) {
sPrefix = sPostfix =
singletonPostfixMap.get(((ISingletonExecutable)exec).getSingletonIdentifier()); singletonPostfixMap.get(((ISingletonExecutable)exec).getSingletonIdentifier());
} }
String iPrefix = instancePostfixMap.get(exec); String iPostfix = instancePostfixMap.get(exec);
if(exec instanceof IReadableExecutable) { if(exec instanceof IReadableExecutable) {
IReadableExecutable rexec = (IReadableExecutable)exec; IReadableExecutable rexec = (IReadableExecutable)exec;
String targetVariable = getPortIdentifier(inport); String targetVariable = getPortIdentifier(inport);
String readCode = rexec.getReadCode(iPrefix, sPrefix, inport, targetVariable); String readCode = rexec.getReadCode(iPostfix, sPostfix, inport, targetVariable);
String novalCode = rexec.getNoValReadCode(iPrefix, sPrefix, inport); String novalCode = rexec.getNoValReadCode(iPostfix, sPostfix, inport);
if(novalCode != null) { if(novalCode != null) {
return "if (" + novalCode + ") {\n" + readCode + "}\""; return "if (" + novalCode + ") {\n" + readCode + "}\"";
} }
return readCode; return readCode;
} }
return "FIXME\"No executable available to read " + inport.getName() + " from " + return "FIXME(\"No executable available to read " + inport.getName() + " from " +
receiver.getName() + "\");\n"; receiver.getName() + "\");\n";
} }
...@@ -347,23 +365,25 @@ class SingleUnitMainGenerator { ...@@ -347,23 +365,25 @@ class SingleUnitMainGenerator {
Set<String> singletonInitDone = new HashSet<>(); Set<String> singletonInitDone = new HashSet<>();
for(PlatformConnectorUnit pcu : platformConnector2ExecutableBase.keySet()) { for(PlatformConnectorUnit pcu : platformConnector2ExecutableBase.keySet()) {
ExecutableBase<?> exec = platformConnector2ExecutableBase.get(pcu); ExecutableBase<?> exec = platformConnector2ExecutableBase.get(pcu);
String sPrefix = null; String sPostfix = null;
if(exec instanceof ISingletonInitializationExecutable) { if(exec instanceof ISingletonInitializationExecutable) {
ISingletonInitializationExecutable singletonExec = ISingletonInitializationExecutable singletonExec =
(ISingletonInitializationExecutable)exec; (ISingletonInitializationExecutable)exec;
String ident = singletonExec.getSingletonIdentifier(); String ident = singletonExec.getSingletonIdentifier();
sPrefix = singletonPostfixMap.get(ident); sPostfix = singletonPostfixMap.get(ident);
if(!singletonInitDone.contains(ident)) { if(!singletonInitDone.contains(ident)) {
singletonInitDone.add(ident); singletonInitDone.add(ident);
sb.append(singletonExec.getSingletonInitializationCode(sPrefix)); String code = singletonExec.getSingletonInitializationCode(sPostfix);
sb.append(code != null ? code : "");
} }
} }
// sPrefix is set in the first if-block or is null // sPostfix is set in the first if-block or is null
if(exec instanceof IInstanceInitializationExecutable) { if(exec instanceof IInstanceInitializationExecutable) {
IInstanceInitializationExecutable initExec = IInstanceInitializationExecutable initExec =
(IInstanceInitializationExecutable)exec; (IInstanceInitializationExecutable)exec;
String iPrefix = instancePostfixMap.get(initExec); String iPostfix = instancePostfixMap.get(initExec);
sb.append(initExec.getInitializationCode(iPrefix, sPrefix)); String code = initExec.getInitializationCode(iPostfix, sPostfix);
sb.append(code != null ? code : "");
} }
} }
return sb.toString(); return sb.toString();
...@@ -400,40 +420,6 @@ class SingleUnitMainGenerator { ...@@ -400,40 +420,6 @@ class SingleUnitMainGenerator {
// String port = executionUnit.getCameraServerPort(); // String port = executionUnit.getCameraServerPort();
// sb.append("camera_client_initialize(\"" + addr + "\", \"" + port + "\");\n"); // sb.append("camera_client_initialize(\"" + addr + "\", \"" + port + "\");\n");
// } // }
// if(useUS || useLaser || useDigits || useACC) {
// sb.append("IPConnection brick_connection;\n");
// sb.append("ipcon_create(&brick_connection);\n");
// sb.append("if(ipcon_connect(&brick_connection, BRICK_HOST, BRICK_PORT) < 0) {\n");
// sb.append("perror(\"Failed to connect to brick sub-system.\");\n");
// sb.append("return 1;\n");
// sb.append("}\n\n");
// }
// if(useUS) {
// System.out.println("useUs");
// for(Pair<PlatformConnectorUnit, Port> p : deployedPorts) {
// if(createdUsSensors >= 2)
// break;
// if(p.getFirst() instanceof UltraSonicSensor) {
// UltraSonicSensor sensor = (UltraSonicSensor)p.getFirst();
// if(createdUsSensors == 0) {
// sb.append("DistanceUS DistanceUS_A;\n");
// sb.append("uid_us_A = \"" + sensor.getUniqueBrickletID() + "\";\n");
// sb.append("distance_us_create(&DistanceUS_A, \"" +
// sensor.getUniqueBrickletID() + "\", &brick_connection);\n");
// sb.append("distance_us_register_callback(&DistanceUS_A, DISTANCE_US_CALLBACK_DISTANCE, (void*)us_A_callback, NULL);\n");
// sb.append("distance_us_set_distance_callback_period(&DistanceUS_A, 10);\n");
// } else if(createdUsSensors == 1) {
// sb.append("DistanceUS DistanceUS_B;\n");
// sb.append("uid_us_B = \"" + sensor.getUniqueBrickletID() + "\";\n");
// sb.append("distance_us_create(&DistanceUS_B, \"" +
// sensor.getUniqueBrickletID() + "\", &brick_connection);\n");
// sb.append("distance_us_register_callback(&DistanceUS_B, DISTANCE_US_CALLBACK_DISTANCE, (void*)us_B_callback, NULL);\n");
// sb.append("distance_us_set_distance_callback_period(&DistanceUS_B, 10);\n");
// }
// createdUsSensors++;
// }
// }
// }
// if(useLaser) { // if(useLaser) {
// for(Pair<PlatformConnectorUnit, Port> p : deployedPorts) { // for(Pair<PlatformConnectorUnit, Port> p : deployedPorts) {
// if(p.getFirst() instanceof LaserRangeSensor) { // if(p.getFirst() instanceof LaserRangeSensor) {
......
BrickExecutableBase.java d2a673b444a431747e479c92c2e880c2c5b95251 RED BrickExecutableBase.java e50fae1024e2f95953ff5cb2b56eb0250918021c YELLOW
UltraSonicSensorExecutable.java 118f81db427f895bc447dbb5c57aab47a0c1a1d7 RED UltraSonicSensorExecutable.java 7e121aa85b389b04f4e30fa54d695331082cb4b6 YELLOW
...@@ -41,7 +41,7 @@ abstract class BrickExecutableBase<T extends EObject> extends BrickLibraryExecut ...@@ -41,7 +41,7 @@ abstract class BrickExecutableBase<T extends EObject> extends BrickLibraryExecut
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getSingletonVariableDeclarationCode(String singletonPostfix) { public String getSingletonVariableDeclarationCode(String singletonPostfix) {
return "IPConnection " + getConnectionVariable(singletonPostfix) + ";\n"; return "static IPConnection " + getConnectionVariable(singletonPostfix) + ";\n";
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
...@@ -65,6 +65,6 @@ abstract class BrickExecutableBase<T extends EObject> extends BrickLibraryExecut ...@@ -65,6 +65,6 @@ abstract class BrickExecutableBase<T extends EObject> extends BrickLibraryExecut
/** Returns the connection variable name. */ /** Returns the connection variable name. */
protected final String getConnectionVariable(String postfix) { protected final String getConnectionVariable(String postfix) {
return "brick_connection" + postfix; return "brick_connection_" + postfix;
} }
} }
...@@ -42,34 +42,46 @@ public class UltraSonicSensorExecutable extends BrickExecutableBase<UltraSonicSe ...@@ -42,34 +42,46 @@ public class UltraSonicSensorExecutable extends BrickExecutableBase<UltraSonicSe
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getVariableDeclaration(String postfix, String singletonPostfix) { public String getVariableDeclaration(String postfix, String singletonPostfix) {
return null; StringBuilder sb = new StringBuilder();
sb.append("static DistanceUS ultra_sonic_device_" + postfix + ";\n");
sb.append("static uint16_t ultra_sonic_value_" + postfix + " = 0;\n");
sb.append("static uint64_t ultra_sonic_last_cb_time_" + postfix + " = 0;\n");
return sb.toString();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getInstanceAuxiliaryFunctions(String postfix, String singletonPostfix) { public String getInstanceAuxiliaryFunctions(String postfix, String singletonPostfix) {
// TODO Auto-generated method stub StringBuilder sb = new StringBuilder();
return null; sb.append("void ultra_sonic_callback_" + postfix + "(uint16_t distance, void *data) {\n");
sb.append("ultra_sonic_value_" + postfix + " = distance;\n");
sb.append("ultra_sonic_last_cb_time_" + postfix + " = time_util_get_current_micros();\n");
sb.append("}\n\n");
return sb.toString();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getInitializationCode(String postfix, String singletonPostfix) { public String getInitializationCode(String postfix, String singletonPostfix) {
// TODO Auto-generated method stub StringBuilder sb = new StringBuilder();
return null; sb.append("distance_us_create(&ultra_sonic_device_" + postfix + ", \"" +
modelElement.getUniqueBrickletID() + "\", &" +
getConnectionVariable(singletonPostfix) + ");\n");
sb.append("distance_us_register_callback(&ultra_sonic_device_" + postfix +
", DISTANCE_US_CALLBACK_DISTANCE, (void*)ultra_sonic_callback_" + postfix +
", NULL);\n");
sb.append("distance_us_set_distance_callback_period(&ultra_sonic_device_" + postfix +
", 10);\n");
return sb.toString();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getReadCode(String prefix, String singletonPrefix, InputPort logicalSignal, public String getReadCode(String postfix, String singletonPostfix, InputPort logicalSignal,
String targetVariable) { String targetVariable) {
// sb.append("DistanceUS DistanceUS_A;\n"); StringBuilder sb = new StringBuilder();
// sb.append("uid_us_A = \"" + sensor.getUniqueBrickletID() + "\";\n"); sb.append(targetVariable + " = " + "ultra_sonic_value_" + postfix + ";\n");
// sb.append("distance_us_create(&DistanceUS_A, \"" + return sb.toString();
// sensor.getUniqueBrickletID() + "\", &brick_connection);\n");
// sb.append("distance_us_register_callback(&DistanceUS_A, DISTANCE_US_CALLBACK_DISTANCE, (void*)us_A_callback, NULL);\n");
// sb.append("distance_us_set_distance_callback_period(&DistanceUS_A, 10);\n");
return null;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
......
...@@ -20,6 +20,6 @@ Left_StickYExecutable.java cc2b36f9bca913dc1956f34495cf9c77acb13c88 YELLOW ...@@ -20,6 +20,6 @@ Left_StickYExecutable.java cc2b36f9bca913dc1956f34495cf9c77acb13c88 YELLOW
R2PositionExecutable.java 19f778392841d02d281fd856564b75e1333dffaa YELLOW R2PositionExecutable.java 19f778392841d02d281fd856564b75e1333dffaa YELLOW
Right_StickXExecutable.java 97656a2ae56a70eac88153b123f2cd9c584af967 YELLOW Right_StickXExecutable.java 97656a2ae56a70eac88153b123f2cd9c584af967 YELLOW
Right_StickYExecutable.java f3d942123ca47d0ddbf32f4f46bfaf2b21732653 YELLOW Right_StickYExecutable.java f3d942123ca47d0ddbf32f4f46bfaf2b21732653 YELLOW
RumblepadExecutableBase.java be65c6bb0b4d6a86123c616787fe4bf2ddcc68a1 YELLOW RumblepadExecutableBase.java 39b4d75bed6526d82f5baa420b2415b271157df9 YELLOW
SimpleRumbleFeatureExecutable.java 413b6fb3f5847f0d09f52341c98b95f74c352016 YELLOW SimpleRumbleFeatureExecutable.java 413b6fb3f5847f0d09f52341c98b95f74c352016 YELLOW
StickExecutableBase.java 4e1188b3e3a3b6d53a6387d2cf472c89c27b7449 YELLOW StickExecutableBase.java 4e1188b3e3a3b6d53a6387d2cf472c89c27b7449 YELLOW
...@@ -35,7 +35,7 @@ abstract class RumblepadExecutableBase<T extends EObject> extends PiHALLibraryEx ...@@ -35,7 +35,7 @@ abstract class RumblepadExecutableBase<T extends EObject> extends PiHALLibraryEx
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final String getSingletonVariableDeclarationCode(String singletonPostfix) { public final String getSingletonVariableDeclarationCode(String singletonPostfix) {
return "static gamepad_configuration_t rumblepad_config_" + singletonPostfix + ";\n"; return "static rumblepad_configuration_t rumblepad_config_" + singletonPostfix + ";\n";
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
...@@ -54,7 +54,7 @@ abstract class RumblepadExecutableBase<T extends EObject> extends PiHALLibraryEx ...@@ -54,7 +54,7 @@ abstract class RumblepadExecutableBase<T extends EObject> extends PiHALLibraryEx
sb.append(postfixedVar + "->device_id = \"/dev/input/js0\";\n"); sb.append(postfixedVar + "->device_id = \"/dev/input/js0\";\n");
sb.append(postfixedVar + "->waiting_sleep_in_micros = 50;\n"); sb.append(postfixedVar + "->waiting_sleep_in_micros = 50;\n");
sb.append(postfixedVar + "->axis_callback = NULL;\n"); sb.append(postfixedVar + "->axis_callback = NULL;\n");
sb.append(postfixedVar + "->button_callback = NULL;"); sb.append(postfixedVar + "->button_callback = NULL;\n");
sb.append("rumblepad_initialize(" + postfixedVar + ");\n\n"); sb.append("rumblepad_initialize(" + postfixedVar + ");\n\n");
return sb.toString(); return sb.toString();
} }
......
RasPiCTemplates.java d9eeaef85fefbd705275be87b2be5aaa5f78c6f7 YELLOW RasPiCTemplates.java 6a3abac9f5ac98e0162118e608562aa2a7a1953c YELLOW
...@@ -55,13 +55,14 @@ public final class RasPiCTemplates { ...@@ -55,13 +55,14 @@ public final class RasPiCTemplates {
} }
/** Returns the 'main.c' file configured using the given arguments. */ /** Returns the 'main.c' file configured using the given arguments. */
public static AbstractUnit public static AbstractUnit getSingleUnitMainCFile(String unitName, int cycletimeInMillis,
getSingleUnitMainCFile(String unitName, int cycletimeInMillis, String systemIncludes, String systemIncludes, String systemInitCode, String auxFunction, String workerCode,
String systemInitCode, String workerCode, String sensorVariables) { String sensorVariables) {
StringTemplate template = makeTemplate("SingleUnitMainFile.stg", "MainFile"); StringTemplate template = makeTemplate("SingleUnitMainFile.stg", "MainFile");
template.setAttribute("UNIT_NAME", unitName); template.setAttribute("UNIT_NAME", unitName);
template.setAttribute("CYCLE_TIME_IN_MILLIS", cycletimeInMillis); template.setAttribute("CYCLE_TIME_IN_MILLIS", cycletimeInMillis);
template.setAttribute("SYSTEM_INCLUDES", systemIncludes); template.setAttribute("SYSTEM_INCLUDES", systemIncludes);
template.setAttribute("AUXILIARY_FUNCTIONS", auxFunction);
template.setAttribute("SYSTEM_INIT_CODE", systemInitCode); template.setAttribute("SYSTEM_INIT_CODE", systemInitCode);
template.setAttribute("WORKER_CODE", workerCode); template.setAttribute("WORKER_CODE", workerCode);
template.setAttribute("SENSOR_VARIABLES", sensorVariables); template.setAttribute("SENSOR_VARIABLES", sensorVariables);
......
...@@ -4,6 +4,7 @@ MainFile(UNIT_NAME, ...@@ -4,6 +4,7 @@ MainFile(UNIT_NAME,
CYCLE_TIME_IN_MILLIS, CYCLE_TIME_IN_MILLIS,
SYSTEM_INCLUDES, SYSTEM_INCLUDES,
SYSTEM_INIT_CODE, SYSTEM_INIT_CODE,
AUXILIARY_FUNCTIONS,
WORKER_CODE, WORKER_CODE,
SENSOR_VARIABLES) ::= << SENSOR_VARIABLES) ::= <<
// due to current data dictionary declaration of GENTYPE_boolean // due to current data dictionary declaration of GENTYPE_boolean
...@@ -29,6 +30,8 @@ const int cycle_time = $CYCLE_TIME_IN_MILLIS$; ...@@ -29,6 +30,8 @@ const int cycle_time = $CYCLE_TIME_IN_MILLIS$;
$SENSOR_VARIABLES$ $SENSOR_VARIABLES$
$AUXILIARY_FUNCTIONS$
static void worker() { static void worker() {
step++; step++;
$WORKER_CODE$ $WORKER_CODE$
......
UltraSonicTransformation.java d4f9f72befdd6f8d89532826f761f59e6808f120 YELLOW
/*-------------------------------------------------------------------------+
| Copyright 2018 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.generator.transform.brick;
import org.fortiss.af3.platform.raspberry.generator.executable.brick.UltraSonicSensorExecutable;
import org.fortiss.af3.platform.raspberry.generator.transform.RasPiGeneratorTransformationBase;
import org.fortiss.af3.platform.raspberry.model.brick.UltraSonicSensor;
import org.fortiss.af3.platform.raspberry.model.gamepad.Button1;
/** Transformation for {@link Button1}. */
public class UltraSonicTransformation extends RasPiGeneratorTransformationBase {
/** Constructor. */
public UltraSonicTransformation() {
super(UltraSonicSensor.class, UltraSonicSensorExecutable.class);
}
}
Source diff could not be displayed: it is too large. Options to address this: view the blob.
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