From 910e46950103d1322f3b7aa65a16b2a6aa1f42f2 Mon Sep 17 00:00:00 2001 From: Florian Hoelzl <hoelzl@fortiss.org> Date: Fri, 25 May 2018 13:32:13 +0200 Subject: [PATCH] YELLOW. Signed-off-by: Florian Hoelzl <hoelzl@fortiss.org> --- org.fortiss.af3.platform.raspberry/plugin.xml | 26 ++ .../raspberry/generator/executable/.ratings | 5 +- .../executable/ConsoleOutputExecutable.java | 60 +++++ .../executable/PWMActuatorExecutable.java | 27 +- .../executable/RaspberryPIExecutable.java | 44 ++- .../generator/executable/framework/.ratings | 5 +- .../framework/IRasPiHeaderExecutable.java | 31 +++ .../IRasPiLibraryBasedExecutable.java | 31 +++ .../IRasPiSourceBasedExecutable.java | 31 +++ .../ISingletonInitializableExecutable.java | 7 +- .../generator/executable/gamepad/.ratings | 27 +- .../executable/gamepad/Button1Executable.java | 30 +-- .../executable/gamepad/Button2Executable.java | 27 +- .../executable/gamepad/Button3Executable.java | 26 +- .../executable/gamepad/Button4Executable.java | 28 +- .../gamepad/ButtonExecutableBase.java | 46 ++++ .../gamepad/ButtonL1Executable.java | 26 +- .../gamepad/ButtonL2Executable.java | 26 +- .../gamepad/ButtonR1Executable.java | 26 +- .../gamepad/ButtonR2Executable.java | 26 +- .../gamepad/GamepadExecutableBase.java | 55 ++++ .../gamepad/Left_StickXExecutable.java | 26 +- .../gamepad/Left_StickYExecutable.java | 26 +- .../gamepad/Right_StickXExecutable.java | 26 +- .../gamepad/Right_StickYExecutable.java | 26 +- .../gamepad/StickExecutableBase.java | 46 ++++ .../generator/executable/library/.ratings | 2 + .../library/BrickLibraryExecutableBase.java | 50 ++++ .../library/PiHALLibraryExecutableBase.java | 50 ++++ .../raspberry/generator/templates/.ratings | 2 +- .../generator/templates/RasPiCTemplates.java | 4 +- .../raspberry/generator/transform/.ratings | 1 + .../ConsoleOutputTransformation.java | 27 ++ .../model/SCA-SingleUnit-Test.af3_23 | 253 ++++++++++++++++++ 34 files changed, 826 insertions(+), 323 deletions(-) create mode 100644 org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/ConsoleOutputExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/IRasPiHeaderExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/IRasPiLibraryBasedExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/IRasPiSourceBasedExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonExecutableBase.java create mode 100644 org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/GamepadExecutableBase.java create mode 100644 org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/StickExecutableBase.java create mode 100644 org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/library/.ratings create mode 100644 org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/library/BrickLibraryExecutableBase.java create mode 100644 org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/library/PiHALLibraryExecutableBase.java create mode 100644 org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/transform/ConsoleOutputTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/test-data/model/SCA-SingleUnit-Test.af3_23 diff --git a/org.fortiss.af3.platform.raspberry/plugin.xml b/org.fortiss.af3.platform.raspberry/plugin.xml index 62127ce5..1fbf75e3 100644 --- a/org.fortiss.af3.platform.raspberry/plugin.xml +++ b/org.fortiss.af3.platform.raspberry/plugin.xml @@ -156,6 +156,32 @@ </objectClass> </target> </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.ConsoleOutputTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.ConsoleOutput"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.ConsoleOutputExecutable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.PWMActuatorTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.ActuatorPWM"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.PWMActuatorExecutable"> + </objectClass> + </target> + </transformationProvider> <transformationProvider transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.gamepad.Button1Transformation"> <source> diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/.ratings b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/.ratings index 44e3570d..f797ad8e 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/.ratings +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/.ratings @@ -1,8 +1,9 @@ CanBusExecutable.java a6d7a7767a1eae9770007e98115ead912f8a6e47 RED CanConnectorExecutable.java ed13a0d5b71eae473ddec911cb572780660c85a4 RED CanTransmissionCatalog.java ec4637eda80234429a9f382a37713588a0fbb83a RED +ConsoleOutputExecutable.java 5b8c50f2236ad49958a0a0b599a7e60265a6fc06 YELLOW HeaderCopyGenerator.java 18239a3adae35256e32dad19df9d8f38acbf7e66 RED MultiUnitMainGenerator.java 458754b89c2d79db3fee08baa444424772e40fb7 RED -PWMActuatorExecutable.java 7f408032787fc45e6e8c0ecb919cc80f6bcbcdc7 RED -RaspberryPIExecutable.java 3bfe08becb7e7ca9f056ce44188cc310a99ffa44 RED +PWMActuatorExecutable.java ff4ab2e9f29af55e2564338b50533b09f86d6224 YELLOW +RaspberryPIExecutable.java fd83311332ba0ad5d2cc2f09d406b5b0d2ee6668 RED SingleUnitMainGenerator.java e1df0d82804fd0622b97ecde827844da30370e14 RED diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/ConsoleOutputExecutable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/ConsoleOutputExecutable.java new file mode 100644 index 00000000..5b8c50f2 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/ConsoleOutputExecutable.java @@ -0,0 +1,60 @@ +/*-------------------------------------------------------------------------+ +| 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.executable; + +import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.funcCall; +import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.stringConst; + +import org.fortiss.af3.component.model.OutputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.expression.model.terms.StringConst; +import org.fortiss.af3.expression.model.types.TDouble; +import org.fortiss.af3.platform.language.executable.ExecutableBase; +import org.fortiss.af3.platform.language.executable.IWritableExecutableWithNoValSupport; +import org.fortiss.af3.platform.raspberry.model.ConsoleOutput; +import org.fortiss.af3.project.model.typesystem.IType; + +/** Executable for {@link ConsoleOutput}. */ +public class ConsoleOutputExecutable extends ExecutableBase<ConsoleOutput> implements + IWritableExecutableWithNoValSupport { + /** Constructor. */ + public ConsoleOutputExecutable(ConsoleOutput modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueWriteAccessor(OutputPort logicalSignal, IExpressionTerm value) { + String typeFormat = getTypeFormat(logicalSignal.getVariableType()); + StringConst format = stringConst(logicalSignal.getName() + " = " + typeFormat + "\n"); + return funcCall("printf", format, value); + } + + /** Returns the C format string for the given type. */ + private String getTypeFormat(IType type) { + if(type instanceof TDouble) { + return "%f"; + } + return "%i"; + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValWriteAccessor(OutputPort logicalSignal) { + StringConst format = stringConst(logicalSignal.getName() + " = NoVal"); + return funcCall("printf", format); + } +} diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/PWMActuatorExecutable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/PWMActuatorExecutable.java index 7f408032..ff4ab2e9 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/PWMActuatorExecutable.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/PWMActuatorExecutable.java @@ -17,42 +17,39 @@ package org.fortiss.af3.platform.raspberry.generator.executable; import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.funcCall; import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.intConst; +import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.stringConst; import org.fortiss.af3.component.model.OutputPort; import org.fortiss.af3.expression.model.terms.IExpressionTerm; -import org.fortiss.af3.platform.language.executable.TransmitterExecutableBase; +import org.fortiss.af3.platform.language.executable.IInitializableExecutable; +import org.fortiss.af3.platform.language.executable.ITerminatableExecutable; +import org.fortiss.af3.platform.language.executable.IWritableExecutable; +import org.fortiss.af3.platform.raspberry.generator.executable.library.PiHALLibraryExecutableBase; import org.fortiss.af3.platform.raspberry.model.ActuatorPWM; /** Executable for {@link ActuatorPWM}. */ -public class PWMActuatorExecutable extends TransmitterExecutableBase<ActuatorPWM> { - +public class PWMActuatorExecutable extends PiHALLibraryExecutableBase<ActuatorPWM> implements + IInitializableExecutable, IWritableExecutable, ITerminatableExecutable { /** Constructor. */ public PWMActuatorExecutable(ActuatorPWM modelElement) { super(modelElement); } /** {@inheritDoc} */ + @Override public IExpressionTerm getInitialization() { - return funcCall("pwm_init", intConst(getPWMChannelFromModelElement(modelElement))); - } - - /** {@inheritDoc} */ - public IExpressionTerm getNoValWriteAccessor(OutputPort logicalSignal) { - return funcCall("pwm_set_noval", intConst(getPWMChannelFromModelElement(modelElement))); + return funcCall("temp_actuator_initialize", stringConst("/dev/ttyACM0")); } /** {@inheritDoc} */ + @Override public IExpressionTerm getTermination() { - return funcCall("pwm_term", intConst(getPWMChannelFromModelElement(modelElement))); + return funcCall("temp_actuator_terminate"); } /** {@inheritDoc} */ @Override public IExpressionTerm getValueWriteAccessor(OutputPort logicalSignal, IExpressionTerm value) { - return funcCall("pwm_write", intConst(getPWMChannelFromModelElement(modelElement)), value); - } - - private int getPWMChannelFromModelElement(ActuatorPWM modelElement) { - return modelElement.getChannelID(); + return funcCall("temp_actuator_set_target", intConst(modelElement.getChannelID()), value); } } diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPIExecutable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPIExecutable.java index 3bfe08be..fd833113 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPIExecutable.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPIExecutable.java @@ -18,7 +18,6 @@ package org.fortiss.af3.platform.raspberry.generator.executable; 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.generator.executable.HeaderCopyGenerator.copyHeaderFiles; import static org.fortiss.af3.platform.raspberry.generator.templates.RasPiCTemplates.getConfigureFile; import static org.fortiss.af3.platform.raspberry.generator.templates.RasPiCTemplates.getEclipseProjectFile; @@ -95,9 +94,7 @@ public class RaspberryPIExecutable extends ExecutionUnitExecutableBase<Raspberry List<Pair<PlatformConnectorUnit, Port>> deployedPorts, ITransformationContext context) { this.context = context; findDeploymentAndLookForCanTransmissionCatalog(); - // create the result package - generatorResult = createCSourcePackage(); - generatorResult.setBaseLocation(name); + createGeneratorResultSourcePackage(name); try { addEclipseCProjectFiles(); addConfigureAndMakedefsFiles(); @@ -112,6 +109,21 @@ public class RaspberryPIExecutable extends ExecutionUnitExecutableBase<Raspberry return generatorResult; } + /** Initializes the generator result source package. */ + private void createGeneratorResultSourcePackage(String name) { + // create the result package + generatorResult = createCSourcePackage(); + generatorResult.setBaseLocation(name); + CSourcePackage incLib = + AF3GeneratorCommonLanguagesCFactory.eINSTANCE.createCSourcePackage(); + incLib.setBaseLocation(INC_LIB_SUB_PACKAGE_NAME); + generatorResult.getSubPackages().add(incLib); + + CSourcePackage lib = AF3GeneratorCommonLanguagesCFactory.eINSTANCE.createCSourcePackage(); + lib.setBaseLocation(LIB_SUB_PACKAGE_NAME); + generatorResult.getSubPackages().add(lib); + } + /** Adds the code for the deployed logical components. */ private void addLogicalComponentCode(List<Pair<ExecutionUnit, Component>> deployedComponents) throws ChainTransformationFailedException { @@ -174,7 +186,8 @@ public class RaspberryPIExecutable extends ExecutionUnitExecutableBase<Raspberry srcGenPack.addUnit(mg.createMultiUnitMain()); } else { SingleUnitMainGenerator mg = - new SingleUnitMainGenerator(modelElement, deployedComponents, deployedPorts, context); + new SingleUnitMainGenerator(modelElement, deployedComponents, deployedPorts, + context); srcGenPack.addUnit(mg.createSingleUnitMain()); } } @@ -187,26 +200,7 @@ public class RaspberryPIExecutable extends ExecutionUnitExecutableBase<Raspberry /** Adds the library code need by the deployment code generator. */ private void addStaticLibrariesAndCode() throws Exception { - CSourcePackage srcLib = - AF3GeneratorCommonLanguagesCFactory.eINSTANCE.createCSourcePackage(); - srcLib.setBaseLocation(SRC_LIB_SUB_PACKAGE_NAME); - generatorResult.getSubPackages().add(srcLib); - srcLib.addUnit(createByteContentUnitForPluginFileInRCP( - AF3PlatformRaspberryActivator.PLUGIN_ID, "code-gen-hal/src", "data.c", false)); - - CSourcePackage incLib = - AF3GeneratorCommonLanguagesCFactory.eINSTANCE.createCSourcePackage(); - incLib.setBaseLocation(INC_LIB_SUB_PACKAGE_NAME); - generatorResult.getSubPackages().add(incLib); - - CSourcePackage lib = AF3GeneratorCommonLanguagesCFactory.eINSTANCE.createCSourcePackage(); - lib.setBaseLocation(LIB_SUB_PACKAGE_NAME); - generatorResult.getSubPackages().add(lib); - lib.addUnit(createByteContentUnitForPluginFileInRCP( - AF3PlatformRaspberryActivator.PLUGIN_ID, "code-gen-hal/lib", "libbrick.a", false)); - lib.addUnit(createByteContentUnitForPluginFileInRCP( - AF3PlatformRaspberryActivator.PLUGIN_ID, "code-gen-hal/lib", "libaf3pihal.a", false)); - copyHeaderFiles(incLib); + copyHeaderFiles(null); } /** Adds auxiliary files for Eclipse C project. */ diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/.ratings b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/.ratings index e2d40397..9e391e52 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/.ratings +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/.ratings @@ -1 +1,4 @@ -ISingletonInitializableExecutable.java 4c423c2595dbaac444bdebc616a3d859b9056488 YELLOW +IRasPiHeaderExecutable.java f14b5714e7b982e097f6ac6e95eb91223a30d048 YELLOW +IRasPiLibraryBasedExecutable.java cf3548f22185e666fdcf6d4658b783734c0e5e8e YELLOW +IRasPiSourceBasedExecutable.java 79646213964346ace17013f5c8df5de13dafb1f0 YELLOW +ISingletonInitializableExecutable.java 64e05ca55f07855b4b241ee48810fbe3e9d6ad22 YELLOW diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/IRasPiHeaderExecutable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/IRasPiHeaderExecutable.java new file mode 100644 index 00000000..f14b5714 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/IRasPiHeaderExecutable.java @@ -0,0 +1,31 @@ +/*-------------------------------------------------------------------------+ +| 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.executable.framework; + +import org.fortiss.af3.generator.common.model.source.ByteContentUnit; + +/** + * Interface for executables, which require a header file to be included. + * + * @author hoelzl + */ +public interface IRasPiHeaderExecutable { + /** Returns the name of the header file required by this executable. */ + String getHeaderFileName(); + + /** Returns the header file as {@link ByteContentUnit} binary. */ + ByteContentUnit getHeaderFileContent(); +} diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/IRasPiLibraryBasedExecutable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/IRasPiLibraryBasedExecutable.java new file mode 100644 index 00000000..cf3548f2 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/IRasPiLibraryBasedExecutable.java @@ -0,0 +1,31 @@ +/*-------------------------------------------------------------------------+ +| 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.executable.framework; + +import org.fortiss.af3.generator.common.model.source.ByteContentUnit; + +/** + * Interface for executables, which require a static library to be included. + * + * @author hoelzl + */ +public interface IRasPiLibraryBasedExecutable { + /** Returns the name of the library required by this executable. */ + String getLibraryFileName(); + + /** Returns the library as {@link ByteContentUnit} binary. */ + ByteContentUnit getLibraryFileContent(); +} diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/IRasPiSourceBasedExecutable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/IRasPiSourceBasedExecutable.java new file mode 100644 index 00000000..79646213 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/IRasPiSourceBasedExecutable.java @@ -0,0 +1,31 @@ +/*-------------------------------------------------------------------------+ +| 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.executable.framework; + +import org.fortiss.af3.generator.common.model.source.ByteContentUnit; + +/** + * Interface for executables, which require a source file to be included. + * + * @author hoelzl + */ +public interface IRasPiSourceBasedExecutable { + /** Returns the name of the source file required by this executable. */ + String getSourceFileName(); + + /** Returns the source file content as {@link ByteContentUnit}. */ + ByteContentUnit getSourceFileContent(); +} diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/ISingletonInitializableExecutable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/ISingletonInitializableExecutable.java index 4c423c25..64e05ca5 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/ISingletonInitializableExecutable.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/framework/ISingletonInitializableExecutable.java @@ -20,11 +20,12 @@ import org.fortiss.af3.platform.language.executable.IInitializableExecutable; /** * Interface implemented by platform-specific executables, which need * initialization during system start-up. In contrast to {@link IInitializableExecutable}, - * if there are more than one actuator or sensor with the same initialization term, this - * term is only included once in the generated code. + * if there are more than one actuator or sensor with the singleton identifier, the + * initialization is only included once in the generated code. * * @author hoelzl */ public interface ISingletonInitializableExecutable extends IInitializableExecutable { - // marker interface + /** Returns the singleton identifier. */ + String getSingletonInitializationIdentifier(); } diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/.ratings b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/.ratings index a60f5ff4..b032c455 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/.ratings +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/.ratings @@ -1,12 +1,15 @@ -Button1Executable.java 24ccb4a8b5c2abf4fbe09b16c97aa1e6959b2b78 RED -Button2Executable.java 1619d2c2c4e0018d7e1855488c8157dde8f9aca6 RED -Button3Executable.java cd9615e4b49e39395235e2aae41d0a663cd00dad RED -Button4Executable.java 55ce16f9c89e8456143bf5ae2105d8ebd0d7818a RED -ButtonL1Executable.java 11e985bfca3711a9fee53f53919b2dd580431025 RED -ButtonL2Executable.java e4f01bedf710a24638e3fd9e631f1dd07bd5994c RED -ButtonR1Executable.java ff808449dedeb01c0e097bee9d70cca79178dd6f RED -ButtonR2Executable.java 3c5892adbaadbb4e526384a4403c7c83af8e4006 RED -Left_StickXExecutable.java 5ee19c799ac427a30a5132d8ee56813a619a318b RED -Left_StickYExecutable.java 72072552129629a3c94d689503e2c5949918d542 RED -Right_StickXExecutable.java be3ca2771b669c0ac06cf9cb0e73a539fadddd01 RED -Right_StickYExecutable.java 54ab05658e14ce42f90a2ab60ff64931d5083811 RED +Button1Executable.java 4419314d71af50239cf6933a83a0f652614cf368 YELLOW +Button2Executable.java 3af03ceea3aa09178fe88fe630c94282de0b72f2 YELLOW +Button3Executable.java 964fbe4e0b5282ab617c4be2bed31afa8b4f394f YELLOW +Button4Executable.java 53db1cce9e3dfface4027f883586bf90638cd4ff YELLOW +ButtonExecutableBase.java 0b7b23652e94f2bf2544b1cba79a298e53d458e7 YELLOW +ButtonL1Executable.java ab68cddae1d323ff0ecd7956133c44d1ef0f9168 YELLOW +ButtonL2Executable.java 336b9d8d26a682b701f7a2ca078369c9cc621fbb YELLOW +ButtonR1Executable.java 700ef701ed77a0d3f8141166fe647ac5cd4ad570 YELLOW +ButtonR2Executable.java 9b4acdc37505f41c60d8216c92bcbd3f43a2ccec YELLOW +GamepadExecutableBase.java 520499696335e537bfb2197fa53afcdacb41efcf YELLOW +Left_StickXExecutable.java c3e7f28f44fa27bd79e14ed7e60f44be2dc5a9ab YELLOW +Left_StickYExecutable.java f81cc1e3124eb712507825bc54e7d0f633fde640 YELLOW +Right_StickXExecutable.java ade165c88d0c6758efa167e5ba445eff87a0fd79 YELLOW +Right_StickYExecutable.java 891ea877d8c3f4bab6072a02b17bb92a6caa055d YELLOW +StickExecutableBase.java 01fc6a6617fb6631c105933127de59be59f7915f YELLOW diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button1Executable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button1Executable.java index 24ccb4a8..4419314d 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button1Executable.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button1Executable.java @@ -15,38 +15,18 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.platform.raspberry.generator.executable.gamepad; -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.language.executable.ReceiverExecutableBase; import org.fortiss.af3.platform.raspberry.model.gamepad.Button1; -/** Executable for {@link Button1}. */ -public class Button1Executable extends ReceiverExecutableBase<Button1> { - +/** Executable for gamepad {@link Button1}. */ +public class Button1Executable extends ButtonExecutableBase<Button1> { /** Constructor. */ public Button1Executable(Button1 modelElement) { super(modelElement); } /** {@inheritDoc} */ - public IExpressionTerm getInitialization() { - return funcCall("gp_init"); - } - - /** {@inheritDoc} */ - public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { - return funcCall("gp_btn1_is_noval"); - } - - /** {@inheritDoc} */ - public IExpressionTerm getTermination() { - return funcCall("gp_term"); - } - - /** {@inheritDoc} */ - public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { - return funcCall("gp_btn1_read"); + @Override + protected String getButtonIdentifier() { + return "GAMEPAD_BUTTON_1"; } } diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button2Executable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button2Executable.java index 1619d2c2..3af03cee 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button2Executable.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button2Executable.java @@ -15,15 +15,10 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.platform.raspberry.generator.executable.gamepad; -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.language.executable.ReceiverExecutableBase; import org.fortiss.af3.platform.raspberry.model.gamepad.Button2; /** Executable for {@link Button2}. */ -public class Button2Executable extends ReceiverExecutableBase<Button2> { +public class Button2Executable extends ButtonExecutableBase<Button2> { /** Constructor. */ public Button2Executable(Button2 modelElement) { @@ -31,22 +26,8 @@ public class Button2Executable extends ReceiverExecutableBase<Button2> { } /** {@inheritDoc} */ - public IExpressionTerm getInitialization() { - return funcCall("gp_init"); - } - - /** {@inheritDoc} */ - public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { - return funcCall("gp_btn2_is_noval"); - } - - /** {@inheritDoc} */ - public IExpressionTerm getTermination() { - return funcCall("gp_term"); - } - - /** {@inheritDoc} */ - public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { - return funcCall("gp_btn2_read"); + @Override + protected String getButtonIdentifier() { + return "GAMEPAD_BUTTON_2"; } } diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button3Executable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button3Executable.java index cd9615e4..964fbe4e 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button3Executable.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button3Executable.java @@ -15,34 +15,18 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.platform.raspberry.generator.executable.gamepad; -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.language.executable.ReceiverExecutableBase; import org.fortiss.af3.platform.raspberry.model.gamepad.Button3; /** Executable for {@link Button3}. */ -public class Button3Executable extends ReceiverExecutableBase<Button3> { - +public class Button3Executable extends ButtonExecutableBase<Button3> { /** Constructor. */ public Button3Executable(Button3 modelElement) { super(modelElement); } - public IExpressionTerm getInitialization() { - return funcCall("gp_init"); - } - - public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { - return funcCall("gp_btn3_is_noval"); - } - - public IExpressionTerm getTermination() { - return funcCall("gp_term"); - } - - public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { - return funcCall("gp_btn3_read"); + /** {@inheritDoc} */ + @Override + protected String getButtonIdentifier() { + return "GAMEPAD_BUTTON_3"; } } diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button4Executable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button4Executable.java index 55ce16f9..53db1cce 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button4Executable.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button4Executable.java @@ -15,38 +15,18 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.platform.raspberry.generator.executable.gamepad; -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.language.executable.ReceiverExecutableBase; import org.fortiss.af3.platform.raspberry.model.gamepad.Button4; /** Executable for {@link Button4}. */ -public class Button4Executable extends ReceiverExecutableBase<Button4> { - +public class Button4Executable extends ButtonExecutableBase<Button4> { /** Constructor. */ public Button4Executable(Button4 modelElement) { super(modelElement); } /** {@inheritDoc} */ - public IExpressionTerm getInitialization() { - return funcCall("gp_init"); - } - - /** {@inheritDoc} */ - public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { - return funcCall("gp_btn4_is_noval"); - } - - /** {@inheritDoc} */ - public IExpressionTerm getTermination() { - return funcCall("gp_term"); - } - - /** {@inheritDoc} */ - public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { - return funcCall("gp_btn4_read"); + @Override + protected String getButtonIdentifier() { + return "GAMEPAD_BUTTON_4"; } } diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonExecutableBase.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonExecutableBase.java new file mode 100644 index 00000000..0b7b2365 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonExecutableBase.java @@ -0,0 +1,46 @@ +/*-------------------------------------------------------------------------+ +| 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.executable.gamepad; + +import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.funcCall; +import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.rawString; + +import org.eclipse.emf.ecore.EObject; +import org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.language.executable.IReadableExecutable; + +/** + * Base class for executables reading gamepad buttons. + * + * @author hoelzl + */ +public abstract class ButtonExecutableBase<T extends EObject> extends GamepadExecutableBase<T> + implements IReadableExecutable { + /** Constructor. */ + public ButtonExecutableBase(T modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public final IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("gamepad_get_button_state", rawString(getButtonIdentifier())); + } + + /** Returns the button identifier as defined in {@code gamepad.h}. */ + protected abstract String getButtonIdentifier(); +} diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL1Executable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL1Executable.java index 11e985bf..ab68cdda 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL1Executable.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL1Executable.java @@ -15,34 +15,18 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.platform.raspberry.generator.executable.gamepad; -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.language.executable.ReceiverExecutableBase; import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonL1; /** Executable for {@link ButtonL1}. */ -public class ButtonL1Executable extends ReceiverExecutableBase<ButtonL1> { - +public class ButtonL1Executable extends ButtonExecutableBase<ButtonL1> { /** Constructor. */ public ButtonL1Executable(ButtonL1 modelElement) { super(modelElement); } - public IExpressionTerm getInitialization() { - return funcCall("gp_init"); - } - - public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { - return funcCall("gp_btnL1_is_noval"); - } - - public IExpressionTerm getTermination() { - return funcCall("gp_term"); - } - - public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { - return funcCall("gp_btnL1_read"); + /** {@inheritDoc} */ + @Override + protected String getButtonIdentifier() { + return "GAMEPAD_BUTTON_L1"; } } diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL2Executable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL2Executable.java index e4f01bed..336b9d8d 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL2Executable.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL2Executable.java @@ -15,34 +15,18 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.platform.raspberry.generator.executable.gamepad; -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.language.executable.ReceiverExecutableBase; import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonL2; /** Executable for {@link ButtonL2}. */ -public class ButtonL2Executable extends ReceiverExecutableBase<ButtonL2> { - +public class ButtonL2Executable extends ButtonExecutableBase<ButtonL2> { /** Constructor. */ public ButtonL2Executable(ButtonL2 modelElement) { super(modelElement); } - public IExpressionTerm getInitialization() { - return funcCall("gp_init"); - } - - public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { - return funcCall("gp_btnL2_is_noval"); - } - - public IExpressionTerm getTermination() { - return funcCall("gp_term"); - } - - public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { - return funcCall("gp_btnL2_read"); + /** {@inheritDoc} */ + @Override + protected String getButtonIdentifier() { + return "GAMEPAD_BUTTON_L2"; } } diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR1Executable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR1Executable.java index ff808449..700ef701 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR1Executable.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR1Executable.java @@ -15,34 +15,18 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.platform.raspberry.generator.executable.gamepad; -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.language.executable.ReceiverExecutableBase; import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonR1; /** Executable for {@link ButtonR1}. */ -public class ButtonR1Executable extends ReceiverExecutableBase<ButtonR1> { - +public class ButtonR1Executable extends ButtonExecutableBase<ButtonR1> { /** Constructor. */ public ButtonR1Executable(ButtonR1 modelElement) { super(modelElement); } - public IExpressionTerm getInitialization() { - return funcCall("gp_init"); - } - - public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { - return funcCall("gp_btnR1_is_noval"); - } - - public IExpressionTerm getTermination() { - return funcCall("gp_term"); - } - - public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { - return funcCall("gp_btnR1_read"); + /** {@inheritDoc} */ + @Override + protected String getButtonIdentifier() { + return "GAMEPAD_BUTTON_R1"; } } diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR2Executable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR2Executable.java index 3c5892ad..9b4acdc3 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR2Executable.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR2Executable.java @@ -15,34 +15,18 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.platform.raspberry.generator.executable.gamepad; -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.language.executable.ReceiverExecutableBase; import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonR2; /** Executable for {@link ButtonR2}. */ -public class ButtonR2Executable extends ReceiverExecutableBase<ButtonR2> { - +public class ButtonR2Executable extends ButtonExecutableBase<ButtonR2> { /** Constructor. */ public ButtonR2Executable(ButtonR2 modelElement) { super(modelElement); } - public IExpressionTerm getInitialization() { - return funcCall("gp_init"); - } - - public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { - return funcCall("gp_btnR2_is_noval"); - } - - public IExpressionTerm getTermination() { - return funcCall("gp_term"); - } - - public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { - return funcCall("gp_btnR2_read"); + /** {@inheritDoc} */ + @Override + protected String getButtonIdentifier() { + return "GAMEPAD_BUTTON_R2"; } } diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/GamepadExecutableBase.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/GamepadExecutableBase.java new file mode 100644 index 00000000..52049969 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/GamepadExecutableBase.java @@ -0,0 +1,55 @@ +/*-------------------------------------------------------------------------+ +| 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.executable.gamepad; + +import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.rawString; + +import org.eclipse.emf.ecore.EObject; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.raspberry.generator.executable.framework.ISingletonInitializableExecutable; +import org.fortiss.af3.platform.raspberry.generator.executable.library.PiHALLibraryExecutableBase; +import org.fortiss.af3.platform.raspberry.model.gamepad.GamepadPackage; + +/** + * Base class for all executables of the gamepad input sensors. + * + * @author hoelzl + */ +abstract class GamepadExecutableBase<T extends EObject> extends PiHALLibraryExecutableBase<T> + implements ISingletonInitializableExecutable { + /** Constructor. */ + public GamepadExecutableBase(T modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public final IExpressionTerm getInitialization() { + return rawString("gamepad_configuration_t* gamepad_config = malloc(sizeof(gamepad_configuration_t));\n" + + "gamepad_config->device_id = \"/dev/input/js0\";\n" + + "gamepad_config->waiting_sleep_in_micros = 250;\n" + + "gamepad_config->axis_callback = NULL;\n" + + "gamepad_config->button_callback = NULL;" + + "gamepad_initialize(gamepad_config);\n\n"); + } + + /** {@inheritDoc} */ + @Override + public final String getSingletonInitializationIdentifier() { + // use EMF package as singleton identifier + return GamepadPackage.eNS_URI; + } +} diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickXExecutable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickXExecutable.java index 5ee19c79..c3e7f28f 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickXExecutable.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickXExecutable.java @@ -15,34 +15,18 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.platform.raspberry.generator.executable.gamepad; -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.language.executable.ReceiverExecutableBase; import org.fortiss.af3.platform.raspberry.model.gamepad.Left_StickX_Position; /** Executable for {@link Left_StickX_Position}. */ -public class Left_StickXExecutable extends ReceiverExecutableBase<Left_StickX_Position> { - +public class Left_StickXExecutable extends StickExecutableBase<Left_StickX_Position> { /** Constructor. */ public Left_StickXExecutable(Left_StickX_Position modelElement) { super(modelElement); } - public IExpressionTerm getInitialization() { - return funcCall("gp_init"); - } - - public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { - return funcCall("gp_btnLX_is_noval"); - } - - public IExpressionTerm getTermination() { - return funcCall("gp_term"); - } - - public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { - return funcCall("gp_btnLX_read"); + /** {@inheritDoc} */ + @Override + protected String getAxisIdentifier() { + return "GAMEPAD_AXIS_LEFT_STICK_HORIZONTAL"; } } diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickYExecutable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickYExecutable.java index 72072552..f81cc1e3 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickYExecutable.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickYExecutable.java @@ -15,34 +15,18 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.platform.raspberry.generator.executable.gamepad; -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.language.executable.ReceiverExecutableBase; import org.fortiss.af3.platform.raspberry.model.gamepad.Left_StickY_Position; /** Executable for {@link Left_StickY_Position}. */ -public class Left_StickYExecutable extends ReceiverExecutableBase<Left_StickY_Position> { - +public class Left_StickYExecutable extends StickExecutableBase<Left_StickY_Position> { /** Constructor. */ public Left_StickYExecutable(Left_StickY_Position modelElement) { super(modelElement); } - public IExpressionTerm getInitialization() { - return funcCall("gp_init"); - } - - public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { - return funcCall("gp_btnLY_is_noval"); - } - - public IExpressionTerm getTermination() { - return funcCall("gp_term"); - } - - public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { - return funcCall("gp_btnLY_read"); + /** {@inheritDoc} */ + @Override + protected String getAxisIdentifier() { + return "GAMEPAD_AXIS_LEFT_STICK_VERTICAL"; } } diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickXExecutable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickXExecutable.java index be3ca277..ade165c8 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickXExecutable.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickXExecutable.java @@ -15,34 +15,18 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.platform.raspberry.generator.executable.gamepad; -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.language.executable.ReceiverExecutableBase; import org.fortiss.af3.platform.raspberry.model.gamepad.Right_StickX_Position; /** Executable for {@link Right_StickX_Position}. */ -public class Right_StickXExecutable extends ReceiverExecutableBase<Right_StickX_Position> { - +public class Right_StickXExecutable extends StickExecutableBase<Right_StickX_Position> { /** Constructor. */ public Right_StickXExecutable(Right_StickX_Position modelElement) { super(modelElement); } - public IExpressionTerm getInitialization() { - return funcCall("gp_init"); - } - - public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { - return funcCall("gp_btnRX_is_noval"); - } - - public IExpressionTerm getTermination() { - return funcCall("gp_term"); - } - - public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { - return funcCall("gp_btnRX_read"); + /** {@inheritDoc} */ + @Override + protected String getAxisIdentifier() { + return "GAMEPAD_AXIS_RIGHT_STICK_HORIZONTAL"; } } diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickYExecutable.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickYExecutable.java index 54ab0565..891ea877 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickYExecutable.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickYExecutable.java @@ -15,34 +15,18 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.platform.raspberry.generator.executable.gamepad; -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.language.executable.ReceiverExecutableBase; import org.fortiss.af3.platform.raspberry.model.gamepad.Right_StickY_Position; /** Executable for {@link Right_StickY_Position}. */ -public class Right_StickYExecutable extends ReceiverExecutableBase<Right_StickY_Position> { - +public class Right_StickYExecutable extends StickExecutableBase<Right_StickY_Position> { /** Constructor. */ public Right_StickYExecutable(Right_StickY_Position modelElement) { super(modelElement); } - public IExpressionTerm getInitialization() { - return funcCall("gp_init"); - } - - public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { - return funcCall("gp_btnRY_is_noval"); - } - - public IExpressionTerm getTermination() { - return funcCall("gp_term"); - } - - public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { - return funcCall("gp_btnRY_read"); + /** {@inheritDoc} */ + @Override + protected String getAxisIdentifier() { + return "GAMEPAD_AXIS_RIGHT_STICK_VERTICAL"; } } diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/StickExecutableBase.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/StickExecutableBase.java new file mode 100644 index 00000000..01fc6a66 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/StickExecutableBase.java @@ -0,0 +1,46 @@ +/*-------------------------------------------------------------------------+ +| 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.executable.gamepad; + +import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.funcCall; +import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.rawString; + +import org.eclipse.emf.ecore.EObject; +import org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.language.executable.IReadableExecutable; + +/** + * Base class for executables reading gamepad sticks. + * + * @author hoelzl + */ +public abstract class StickExecutableBase<T extends EObject> extends GamepadExecutableBase<T> + implements IReadableExecutable { + /** Constructor. */ + public StickExecutableBase(T modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public final IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("gamepad_get_axis_position", rawString(getAxisIdentifier())); + } + + /** Returns the axis identifier as defined in {@code gamepad.h}. */ + protected abstract String getAxisIdentifier(); +} diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/library/.ratings b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/library/.ratings new file mode 100644 index 00000000..71b633e4 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/library/.ratings @@ -0,0 +1,2 @@ +BrickLibraryExecutableBase.java 797162a1dbb8b18c439cd2a3eb00166053fd8834 YELLOW +PiHALLibraryExecutableBase.java be4fe458679bd8fdca4c727b3380911a0f1a3e41 YELLOW diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/library/BrickLibraryExecutableBase.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/library/BrickLibraryExecutableBase.java new file mode 100644 index 00000000..797162a1 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/library/BrickLibraryExecutableBase.java @@ -0,0 +1,50 @@ +/*-------------------------------------------------------------------------+ +| 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.executable.library; + +import static org.fortiss.af3.generator.common.utils.SourceModelElementFactory.createByteContentUnitForPluginFileInRCP; + +import org.eclipse.emf.ecore.EObject; +import org.fortiss.af3.generator.common.model.source.ByteContentUnit; +import org.fortiss.af3.platform.language.executable.ExecutableBase; +import org.fortiss.af3.platform.raspberry.AF3PlatformRaspberryActivator; +import org.fortiss.af3.platform.raspberry.generator.executable.framework.IRasPiLibraryBasedExecutable; + +/** + * Base class for executables using the AF3 Pi HAL library. + * + * @author hoelzl + */ +public abstract class BrickLibraryExecutableBase<T extends EObject> extends ExecutableBase<T> + implements IRasPiLibraryBasedExecutable { + /** Constructor. */ + public BrickLibraryExecutableBase(T modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public final String getLibraryFileName() { + return "libbrick.a"; + } + + /** {@inheritDoc} */ + @Override + public final ByteContentUnit getLibraryFileContent() { + return createByteContentUnitForPluginFileInRCP(AF3PlatformRaspberryActivator.PLUGIN_ID, + "code-gen-hal/lib", "libbrick.a", false); + } +} diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/library/PiHALLibraryExecutableBase.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/library/PiHALLibraryExecutableBase.java new file mode 100644 index 00000000..be4fe458 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/executable/library/PiHALLibraryExecutableBase.java @@ -0,0 +1,50 @@ +/*-------------------------------------------------------------------------+ +| 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.executable.library; + +import static org.fortiss.af3.generator.common.utils.SourceModelElementFactory.createByteContentUnitForPluginFileInRCP; + +import org.eclipse.emf.ecore.EObject; +import org.fortiss.af3.generator.common.model.source.ByteContentUnit; +import org.fortiss.af3.platform.language.executable.ExecutableBase; +import org.fortiss.af3.platform.raspberry.AF3PlatformRaspberryActivator; +import org.fortiss.af3.platform.raspberry.generator.executable.framework.IRasPiLibraryBasedExecutable; + +/** + * Base class for executables using the AF3 Pi HAL library. + * + * @author hoelzl + */ +public abstract class PiHALLibraryExecutableBase<T extends EObject> extends ExecutableBase<T> + implements IRasPiLibraryBasedExecutable { + /** Constructor. */ + public PiHALLibraryExecutableBase(T modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public final String getLibraryFileName() { + return "libaf3pihal.a"; + } + + /** {@inheritDoc} */ + @Override + public final ByteContentUnit getLibraryFileContent() { + return createByteContentUnitForPluginFileInRCP(AF3PlatformRaspberryActivator.PLUGIN_ID, + "code-gen-hal/lib", "libaf3pihal.a", false); + } +} diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/templates/.ratings b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/templates/.ratings index 4726ce70..9f890542 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/templates/.ratings +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/templates/.ratings @@ -1 +1 @@ -RasPiCTemplates.java 3667e3e66b2f5219148ac8ef7f1be5e75bfbe92f RED +RasPiCTemplates.java d9eeaef85fefbd705275be87b2be5aaa5f78c6f7 YELLOW diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/templates/RasPiCTemplates.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/templates/RasPiCTemplates.java index 3667e3e6..d9eeaef8 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/templates/RasPiCTemplates.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/templates/RasPiCTemplates.java @@ -74,9 +74,7 @@ public final class RasPiCTemplates { public static AbstractUnit getEclipseProjectFile(String projectName) { StringTemplate template = makeTemplate("ProjectFile.stg", "ProjectFile"); template.setAttribute("PROJECT_NAME", projectName); - StaticContentSourceUnit unit = - createStaticContentSourceUnit(".project", template.toString(), false); - return unit; + return createStaticContentSourceUnit(".project", template.toString(), false); } /** Returns the 'configure' file used to create a Makefile. */ diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/transform/.ratings b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/transform/.ratings index 7c81becd..5d000c84 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/transform/.ratings +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/transform/.ratings @@ -2,6 +2,7 @@ CanBusTransformation.java 8b4877996d3f9c1a4ddffd773595e8ea3e6fd3a2 YELLOW CanBusTransmissionCatalogTransformation.java 1d1f72d107a59ddaefac42e38cdfa236f688eebc YELLOW CanConnectorTransformation.java b149be82c792838b56e3c2741732e69599f25523 YELLOW CanConnectorTransmissionCatalogTransformation.java fa822114b375a2efdfa72c9c461099947519418d YELLOW +ConsoleOutputTransformation.java 28597bfe24ee3c54df8248013ca599f06344790d YELLOW PWMActuatorTransformation.java 4bafff7e72aec8a86af540fd4db88c6eafb75341 YELLOW RasPiGeneratorTransformationBase.java dc2bd2ae0d0759234dc4ce7621034c888285b0df YELLOW RaspberryPITransformation.java 6f12165d10e1e2d3b0f8ac6ffe19603cfcfacd4a YELLOW diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/transform/ConsoleOutputTransformation.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/transform/ConsoleOutputTransformation.java new file mode 100644 index 00000000..28597bfe --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/transform/ConsoleOutputTransformation.java @@ -0,0 +1,27 @@ +/*-------------------------------------------------------------------------+ +| 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; + +import org.fortiss.af3.platform.raspberry.generator.executable.ConsoleOutputExecutable; +import org.fortiss.af3.platform.raspberry.model.ConsoleOutput; + +/** Transformation for {@link ConsoleOutput}. */ +public class ConsoleOutputTransformation extends RasPiGeneratorTransformationBase { + /** Constructor. */ + public ConsoleOutputTransformation() { + super(ConsoleOutput.class, ConsoleOutputExecutable.class); + } +} diff --git a/org.fortiss.af3.platform.raspberry/test-data/model/SCA-SingleUnit-Test.af3_23 b/org.fortiss.af3.platform.raspberry/test-data/model/SCA-SingleUnit-Test.af3_23 new file mode 100644 index 00000000..df523200 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/test-data/model/SCA-SingleUnit-Test.af3_23 @@ -0,0 +1,253 @@ +<?xml version="1.0" encoding="UTF-8"?> +<org-fortiss-af3-project:FileProject xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:org-fortiss-af3-component="http://www.fortiss.org/af3/component" xmlns:org-fortiss-af3-component-annotation="http://www.fortiss.org/af3/component/annotation" xmlns:org-fortiss-af3-component-behavior-code="http://www.fortiss.org/af3/component/behavior/code" xmlns:org-fortiss-af3-deployment="http://www.fortiss.org/af3/deployment" xmlns:org-fortiss-af3-expression="http://www.fortiss.org/af3/expression" xmlns:org-fortiss-af3-expression-definitions="http://www.fortiss.org/af3/expression/definitions" xmlns:org-fortiss-af3-expression-terms="http://www.fortiss.org/af3/expression/terms" xmlns:org-fortiss-af3-expression-terms-imperative="http://www.fortiss.org/af3/expression/terms/imperative" xmlns:org-fortiss-af3-expression-types="http://www.fortiss.org/af3/expression/types" xmlns:org-fortiss-af3-platform="http://www.fortiss.org/af3/platform" xmlns:org-fortiss-af3-platform-annotation="http://www.fortiss.org/af3/platform/annotation" xmlns:org-fortiss-af3-platform-raspberry="http://www.fortiss.org/af3/platform/raspberry" xmlns:org-fortiss-af3-platform-raspberry-gamepad="http://www.fortiss.org/af3/platform/raspberry/gamepad" xmlns:org-fortiss-af3-project="http://www.fortiss.org/af3/project" xmlns:org-fortiss-af3-project-configuration="http://www.fortiss.org/af3/project/configuration" xmlns:org-fortiss-af3-project-development="http://www.fortiss.org/af3/project/development" xmlns:org-fortiss-af3-project-execution="http://www.fortiss.org/af3/project/execution" xmlns:org-fortiss-af3-safety-annotation="http://www.fortiss.org/af3/safety/annotation" xmlns:org-fortiss-af3-timing-annotation="http://www.fortiss.org/af3/timing/annotation" xmlns:org-fortiss-tooling-base-model-layout="http://www.fortiss.org/tooling/base/model/layout" xmi:id="172" id="172" name="SCA-Single Unit Test" af3Version="2.11.0.qualifier"> + <rootElements xsi:type="org-fortiss-af3-project:ProjectConfiguration" xmi:id="1" id="1"> + <configurationElements xsi:type="org-fortiss-af3-project-configuration:TypeSystemConfiguration" xmi:id="2" id="2"> + <typesystem xsi:type="org-fortiss-af3-expression:MicroTypeSystem"/> + </configurationElements> + <configurationElements xsi:type="org-fortiss-af3-project-configuration:DevelopmentProcessConfiguration" xmi:id="3" id="3"> + <development xsi:type="org-fortiss-af3-project-development:ConstraintBasedDevelopmentProcess" currentObjective="4" constraintInstanceContainer="3"> + <configurations xmi:id="4" id="4" name="Default configuration"/> + </development> + </configurationElements> + </rootElements> + <rootElements xsi:type="org-fortiss-af3-expression:DataDictionary" xmi:id="5" id="5"> + <typeDefinitions xsi:type="org-fortiss-af3-expression-definitions:Enumeration" xmi:id="46" id="46" name="MyEnum"> + <members xmi:id="47" id="47" name="First"/> + <members xmi:id="48" id="48" name="Second"/> + </typeDefinitions> + </rootElements> + <rootElements xsi:type="org-fortiss-af3-component:ComponentArchitecture" xmi:id="6" id="6" name="Component Architecture" referencedBy="//@rootElements.5/@componentArchitectureReference"> + <containedElements xsi:type="org-fortiss-af3-component:Component" xmi:id="7" id="7" name="SCATest" comment=""> + <containedElements xsi:type="org-fortiss-af3-component:Component" xmi:id="12" id="12" name="Gamepad_Input" comment=""> + <specifications xsi:type="org-fortiss-af3-component:CausalityComponentSpecification" xmi:id="13" id="13" stronglyCausal="true"/> + <specifications xsi:type="org-fortiss-af3-component:VerifBehaviourComponentSpecification" xmi:id="14" id="14"/> + <specifications xsi:type="org-fortiss-af3-safety-annotation:SafetyIntegrityLevel" xmi:id="15" id="15"/> + <specifications xsi:type="org-fortiss-af3-component-annotation:MemoryRequirement" xmi:id="16" id="16"/> + <specifications xsi:type="org-fortiss-af3-component-behavior-code:CodeSpecification" xmi:id="60" id="60"> + <body> + <statements xsi:type="org-fortiss-af3-expression-terms-imperative:IfThenElse"> + <guard xsi:type="org-fortiss-af3-expression-terms:FunctionCall"> + <function xsi:type="org-fortiss-af3-expression-terms:PredefinedFunction" operator="GreaterThan"/> + <arguments xsi:type="org-fortiss-af3-expression-terms:Var" identifier="Button_1"/> + <arguments xsi:type="org-fortiss-af3-expression-terms:IntConst"/> + </guard> + <thenBlock> + <statements xsi:type="org-fortiss-af3-expression-terms-imperative:Assignment"> + <variable identifier="sensorInput"/> + <value xsi:type="org-fortiss-af3-expression-terms:IntConst" value="1"/> + </statements> + </thenBlock> + <elseBlock> + <statements xsi:type="org-fortiss-af3-expression-terms-imperative:Assignment"> + <variable identifier="sensorInput"/> + <value xsi:type="org-fortiss-af3-expression-terms:IntConst"/> + </statements> + </elseBlock> + </statements> + <statements xsi:type="org-fortiss-af3-expression-terms-imperative:Return"/> + </body> + </specifications> + <connectors xsi:type="org-fortiss-af3-component:OutputPort" xmi:id="36" id="36" name="sensorInput" comment="" outgoing="40"> + <specifications xsi:type="org-fortiss-af3-component:PortSpecification" xmi:id="37" id="37"> + <type xsi:type="org-fortiss-af3-expression-types:TInt" lowerBound="0"/> + <initialValue xsi:type="org-fortiss-af3-expression-terms:IntConst"/> + </specifications> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:OffsetOrientation" key="coffsetorient" offset="24" orientation="EAST"/> + </connectors> + <connectors xsi:type="org-fortiss-af3-component:InputPort" xmi:id="41" id="41" name="Button_1" comment=""> + <specifications xsi:type="org-fortiss-af3-component:PortSpecification" xmi:id="42" id="42" NoValAllowed="false"> + <type xsi:type="org-fortiss-af3-expression-types:TInt" lowerBound="0" upperBound="1"/> + <initialValue xsi:type="org-fortiss-af3-expression-terms:DefinedConst" value="NoVal"/> + </specifications> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:OffsetOrientation" key="coffsetorient" offset="24" orientation="WEST"/> + </connectors> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos" x="24" y="144"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="217" height="121"/> + </containedElements> + <containedElements xsi:type="org-fortiss-af3-component:Component" xmi:id="22" id="22" name="Coordinator" comment=""> + <specifications xsi:type="org-fortiss-af3-component:CausalityComponentSpecification" xmi:id="23" id="23" stronglyCausal="true"/> + <specifications xsi:type="org-fortiss-af3-component:VerifBehaviourComponentSpecification" xmi:id="24" id="24"/> + <specifications xsi:type="org-fortiss-af3-safety-annotation:SafetyIntegrityLevel" xmi:id="25" id="25"/> + <specifications xsi:type="org-fortiss-af3-component-annotation:MemoryRequirement" xmi:id="26" id="26"/> + <specifications xsi:type="org-fortiss-af3-component-behavior-code:CodeSpecification" xmi:id="61" id="61"> + <body> + <statements xsi:type="org-fortiss-af3-expression-terms-imperative:IfThenElse"> + <guard xsi:type="org-fortiss-af3-expression-terms:FunctionCall"> + <function xsi:type="org-fortiss-af3-expression-terms:PredefinedFunction" operator="Equal"/> + <arguments xsi:type="org-fortiss-af3-expression-terms:Var" identifier="sensorInput"/> + <arguments xsi:type="org-fortiss-af3-expression-terms:IntConst"/> + </guard> + <thenBlock> + <statements xsi:type="org-fortiss-af3-expression-terms-imperative:Assignment"> + <variable identifier="actuatorOutput"/> + <value xsi:type="org-fortiss-af3-expression-terms:IntConst" value="6000"/> + </statements> + </thenBlock> + <elseBlock> + <statements xsi:type="org-fortiss-af3-expression-terms-imperative:Assignment"> + <variable identifier="actuatorOutput"/> + <value xsi:type="org-fortiss-af3-expression-terms:IntConst"/> + </statements> + </elseBlock> + </statements> + <statements xsi:type="org-fortiss-af3-expression-terms-imperative:Return"/> + </body> + </specifications> + <connectors xsi:type="org-fortiss-af3-component:InputPort" xmi:id="38" id="38" name="sensorInput" comment="" incoming="40"> + <specifications xsi:type="org-fortiss-af3-component:PortSpecification" xmi:id="39" id="39"> + <type xsi:type="org-fortiss-af3-expression-types:TInt" lowerBound="0"/> + <initialValue xsi:type="org-fortiss-af3-expression-terms:IntConst"/> + </specifications> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:OffsetOrientation" key="coffsetorient" offset="24" orientation="WEST"/> + </connectors> + <connectors xsi:type="org-fortiss-af3-component:OutputPort" xmi:id="53" id="53" name="actuatorOutput" comment="" outgoing="57"> + <specifications xsi:type="org-fortiss-af3-component:PortSpecification" xmi:id="54" id="54"> + <type xsi:type="org-fortiss-af3-expression-types:TInt" lowerBound="0" upperBound="6000"/> + <initialValue xsi:type="org-fortiss-af3-expression-terms:DefinedConst" value="NoVal"/> + </specifications> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:OffsetOrientation" key="coffsetorient" offset="24" orientation="EAST"/> + </connectors> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos" x="420" y="144"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="217" height="121"/> + </containedElements> + <containedElements xsi:type="org-fortiss-af3-component:Component" xmi:id="27" id="27" name="PWM Output" comment=""> + <specifications xsi:type="org-fortiss-af3-component:CausalityComponentSpecification" xmi:id="28" id="28" stronglyCausal="true"/> + <specifications xsi:type="org-fortiss-af3-component:VerifBehaviourComponentSpecification" xmi:id="29" id="29"/> + <specifications xsi:type="org-fortiss-af3-safety-annotation:SafetyIntegrityLevel" xmi:id="30" id="30"/> + <specifications xsi:type="org-fortiss-af3-component-annotation:MemoryRequirement" xmi:id="31" id="31"/> + <specifications xsi:type="org-fortiss-af3-component-behavior-code:CodeSpecification" xmi:id="62" id="62"> + <body> + <statements xsi:type="org-fortiss-af3-expression-terms-imperative:Assignment"> + <variable identifier="PWM"/> + <value xsi:type="org-fortiss-af3-expression-terms:Var" identifier="actuatorOutput"/> + </statements> + <statements xsi:type="org-fortiss-af3-expression-terms-imperative:Return"/> + </body> + </specifications> + <connectors xsi:type="org-fortiss-af3-component:InputPort" xmi:id="55" id="55" name="actuatorOutput" comment="" incoming="57"> + <specifications xsi:type="org-fortiss-af3-component:PortSpecification" xmi:id="56" id="56"> + <type xsi:type="org-fortiss-af3-expression-types:TInt" lowerBound="0" upperBound="6000"/> + <initialValue xsi:type="org-fortiss-af3-expression-terms:DefinedConst" value="NoVal"/> + </specifications> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:OffsetOrientation" key="coffsetorient" offset="24" orientation="WEST"/> + </connectors> + <connectors xsi:type="org-fortiss-af3-component:OutputPort" xmi:id="58" id="58" name="PWM" comment=""> + <specifications xsi:type="org-fortiss-af3-component:PortSpecification" xmi:id="59" id="59" NoValAllowed="false"> + <type xsi:type="org-fortiss-af3-expression-types:TInt" lowerBound="0" upperBound="6000"/> + <initialValue xsi:type="org-fortiss-af3-expression-terms:DefinedConst" value="NoVal"/> + </specifications> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:OffsetOrientation" key="coffsetorient" offset="24" orientation="EAST"/> + </connectors> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos" x="912" y="144"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="217" height="121"/> + </containedElements> + <specifications xsi:type="org-fortiss-af3-component:CausalityComponentSpecification" xmi:id="8" id="8"/> + <specifications xsi:type="org-fortiss-af3-component:VerifBehaviourComponentSpecification" xmi:id="9" id="9"/> + <specifications xsi:type="org-fortiss-af3-safety-annotation:SafetyIntegrityLevel" xmi:id="43" id="43"/> + <specifications xsi:type="org-fortiss-af3-component-annotation:MemoryRequirement" xmi:id="44" id="44"/> + <connections xsi:type="org-fortiss-af3-component:Channel" xmi:id="40" id="40" name="sensorInput" comment="" source="36" target="38"> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Points" key="points"/> + </connections> + <connections xsi:type="org-fortiss-af3-component:Channel" xmi:id="57" id="57" name="actuatorOutput" comment="" source="53" target="55"> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Points" key="points"/> + </connections> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="216" height="72"/> + </containedElements> + <specifications xsi:type="org-fortiss-af3-safety-annotation:SafetyIntegrityLevel" xmi:id="45" id="45"/> + </rootElements> + <rootElements xsi:type="org-fortiss-af3-project-execution:ExecutionConfigurationStore" xmi:id="114" id="114"> + <configurations xmi:id="115" id="115" name="Execonf" comment="" idReference="11"/> + <configurations xmi:id="182" id="182" name="Deployment" comment="" idReference="171"/> + </rootElements> + <rootElements xsi:type="org-fortiss-af3-platform:PlatformArchitecture" xmi:id="116" id="116" name="Platform Architecture" comment="" referencedBy="//@rootElements.5/@platformArchitectureReference"> + <containedElements xsi:type="org-fortiss-af3-platform-raspberry:RaspberryPi" xmi:id="117" id="117" name="SCAUnit" canCoordinationID="250" ipAddress="192.168.21.241" cycleTime="100"> + <specifications xsi:type="org-fortiss-af3-platform-annotation:PowerConsumption" xmi:id="118" id="118"/> + <specifications xsi:type="org-fortiss-af3-platform-annotation:HardwareCost" xmi:id="119" id="119"/> + <specifications xsi:type="org-fortiss-af3-platform-annotation:MemoryPerNode" xmi:id="120" id="120"/> + <specifications xsi:type="org-fortiss-af3-safety-annotation:SafetyIntegrityLevel" xmi:id="121" id="121"/> + <connectors xsi:type="org-fortiss-af3-platform-raspberry-gamepad:Button1" xmi:id="146" id="146" name="Button1_Triangle"> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:OffsetOrientation" key="coffsetorient" offset="36" orientation="WEST"/> + </connectors> + <connectors xsi:type="org-fortiss-af3-platform-raspberry:ActuatorPWM" xmi:id="170" id="170" name="PWM"> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:OffsetOrientation" key="coffsetorient" offset="36" orientation="EAST"/> + </connectors> + <connectors xsi:type="org-fortiss-af3-platform-raspberry:ConsoleOutput" xmi:id="183" id="183" name="Console"> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:OffsetOrientation" key="coffsetorient" offset="60" orientation="EAST"/> + </connectors> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos" x="84" y="72"/> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="241" height="277"/> + </containedElements> + <specifications xsi:type="org-fortiss-af3-safety-annotation:SafetyIntegrityLevel" xmi:id="127" id="127"/> + </rootElements> + <rootElements xsi:type="org-fortiss-af3-deployment:Deployment" xmi:id="171" id="171" name="Deployment"> + <componentArchitectureReference reference="6"/> + <platformArchitectureReference reference="116"/> + <componentAllocations xmi:id="173" id="173" component="12" executionUnit="117"> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Points" key="points"/> + </componentAllocations> + <componentAllocations xmi:id="174" id="174" component="22" executionUnit="117"> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Points" key="points"/> + </componentAllocations> + <componentAllocations xmi:id="175" id="175" component="27" executionUnit="117"> + <layoutData xsi:type="org-fortiss-tooling-base-model-layout:Points" key="points"/> + </componentAllocations> + <portAllocations xsi:type="org-fortiss-af3-deployment:InputPortAllocation" inputPort="41" receiver="146"/> + <portAllocations xsi:type="org-fortiss-af3-deployment:OutputPortAllocation" outputPort="58" transmitter="170"/> + <portAllocations xsi:type="org-fortiss-af3-deployment:OutputPortAllocation" outputPort="53" transmitter="183"/> + <deploymentParameterMap> + <key/> + <value xmi:id="176" id="176" component="12" executionUnit="117"> + <specifications xsi:type="org-fortiss-af3-timing-annotation:Wcet" xmi:id="177" id="177"/> + </value> + </deploymentParameterMap> + <deploymentParameterMap> + <key/> + <value xmi:id="178" id="178" component="22" executionUnit="117"> + <specifications xsi:type="org-fortiss-af3-timing-annotation:Wcet" xmi:id="179" id="179"/> + </value> + </deploymentParameterMap> + <deploymentParameterMap> + <key/> + <value xmi:id="180" id="180" component="27" executionUnit="117"> + <specifications xsi:type="org-fortiss-af3-timing-annotation:Wcet" xmi:id="181" id="181"/> + </value> + </deploymentParameterMap> + </rootElements> +</org-fortiss-af3-project:FileProject> -- GitLab