From 37d70f35e26a0997a29caa8ec1d9a44f9a69fa92 Mon Sep 17 00:00:00 2001 From: Florian Hoelzl <hoelzl@fortiss.org> Date: Fri, 6 Oct 2017 12:33:18 +0000 Subject: [PATCH] Created tag for rapsberry rover code at end of first lab course. --- .../tags/end-of-first-course/.classpath | 8 + .../tags/end-of-first-course/.project | 38 ++ .../end-of-first-course/META-INF/MANIFEST.MF | 29 ++ .../end-of-first-course/buckminster.cspex | 24 + .../tags/end-of-first-course/build.properties | 13 + .../tags/end-of-first-course/lib/Makedefs | 47 ++ .../lib/inc-gen/data_dictionary.h | 55 +++ .../lib/inc/CanConnector.h | 46 ++ .../tags/end-of-first-course/lib/inc/GPIO.h | 27 ++ .../end-of-first-course/lib/inc/Gamepad.h | 91 ++++ .../tags/end-of-first-course/lib/inc/IMU.h | 0 .../lib/inc/LaserRangeFinder.h | 20 + .../lib/inc/LaserScanner.h | 0 .../tags/end-of-first-course/lib/inc/PWM.h | 39 ++ .../tags/end-of-first-course/lib/inc/io.h | 25 + .../lib/inc/libcansocket.h | 43 ++ .../end-of-first-course/lib/inc/libmaestro.h | 12 + .../end-of-first-course/lib/inc/libuart.h | 35 ++ .../lib/src-gen/data_dictionary.c | 170 +++++++ .../lib/src/CanConnector.c | 84 ++++ .../tags/end-of-first-course/lib/src/GPIO.c | 56 +++ .../end-of-first-course/lib/src/Gamepad.c | 276 +++++++++++ .../tags/end-of-first-course/lib/src/IMU.c | 0 .../lib/src/LaserRangeFinder.c | 102 +++++ .../lib/src/LaserScanner.c | 0 .../tags/end-of-first-course/lib/src/PWM.c | 87 ++++ .../tags/end-of-first-course/lib/src/io.c | 45 ++ .../lib/src/libcansocket.c | 56 +++ .../end-of-first-course/lib/src/libmaestro.c | 36 ++ .../end-of-first-course/lib/src/libuart.c | 119 +++++ .../tags/end-of-first-course/lib/src/main.c | 51 +++ .../model/generate-ecore.xml | 28 ++ .../end-of-first-course/model/raspberry.ecore | 39 ++ .../model/raspberry.genmodel | 45 ++ .../end-of-first-course/plugin.properties | 7 + .../tags/end-of-first-course/plugin.xml | 433 ++++++++++++++++++ .../tags/end-of-first-course/pom.xml | 21 + .../AF3PlatformRaspberryActivator.java | 40 ++ .../PWMChannelNumberValueProvider.java | 48 ++ .../raspberry/compose/CanBusCompositor.java | 51 +++ .../compose/CanToRaspberryCompositor.java | 99 ++++ .../compose/RaspberryPiCompositor.java | 79 ++++ .../compose/RaspberryToCanCompositor.java | 99 ++++ .../executable/CanBusExecutable.java | 55 +++ .../executable/CanConnectorExecutable.java | 115 +++++ .../executable/CanTransmissionCatalog.java | 55 +++ .../generator/executable/GPIExecutable.java | 73 +++ .../generator/executable/GPOExecutable.java | 73 +++ .../executable/GamepadSensorExecutable.java | 64 +++ .../executable/IMUSensorExecutable.java | 64 +++ .../LaserRangeFinderSensorExecutable.java | 66 +++ .../LaserScannerSensorExecutable.java | 64 +++ .../executable/PWMActuatorExecutable.java | 73 +++ .../executable/RaspberryPIExecutable.java | 207 +++++++++ .../executable/WheelEncoderExecutable.java | 39 ++ .../executable/gamepad/Button1Executable.java | 66 +++ .../executable/gamepad/Button2Executable.java | 66 +++ .../executable/gamepad/Button3Executable.java | 66 +++ .../executable/gamepad/Button4Executable.java | 66 +++ .../gamepad/ButtonL1Executable.java | 66 +++ .../gamepad/ButtonL2Executable.java | 66 +++ .../gamepad/ButtonR1Executable.java | 66 +++ .../gamepad/ButtonR2Executable.java | 66 +++ .../gamepad/Left_StickXExecutable.java | 66 +++ .../gamepad/Left_StickYExecutable.java | 66 +++ .../gamepad/Right_StickXExecutable.java | 66 +++ .../gamepad/Right_StickYExecutable.java | 66 +++ .../transform/CanBusTransformation.java | 60 +++ ...nBusTransmissionCatalogTransformation.java | 61 +++ .../transform/CanConnectorTransformation.java | 60 +++ ...ctorTransmissionCatalogTransformation.java | 61 +++ .../transform/GPITransformation.java | 60 +++ .../transform/GPOTransformation.java | 60 +++ .../GamepadSensorTransformation.java | 59 +++ .../transform/IMUSensorTransformation.java | 60 +++ .../LaserRangeFinderSensorTransformation.java | 60 +++ .../LaserScannerSensorTransformation.java | 60 +++ .../transform/PWMActuatorTransformation.java | 60 +++ .../transform/RaspberryPITransformation.java | 60 +++ .../transform/WheelEncoderTransformation.java | 61 +++ .../gamepad/Button1Transformation.java | 60 +++ .../gamepad/Button2Transformation.java | 60 +++ .../gamepad/Button3Transformation.java | 60 +++ .../gamepad/Button4Transformation.java | 60 +++ .../gamepad/ButtonL1Transformation.java | 60 +++ .../gamepad/ButtonL2Transformation.java | 60 +++ .../gamepad/ButtonR1Transformation.java | 60 +++ .../gamepad/ButtonR2Transformation.java | 60 +++ .../gamepad/Left_StickXTransformation.java | 61 +++ .../gamepad/Left_StickYTransformation.java | 61 +++ .../gamepad/Right_StickXTransformation.java | 61 +++ .../gamepad/Right_StickYTransformation.java | 61 +++ .../util/RaspberryModelElementFactory.java | 261 +++++++++++ 93 files changed, 6130 insertions(+) create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/.classpath create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/.project create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/META-INF/MANIFEST.MF create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/buckminster.cspex create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/build.properties create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/Makedefs create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc-gen/data_dictionary.h create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/CanConnector.h create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/GPIO.h create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/Gamepad.h create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/IMU.h create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/LaserRangeFinder.h create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/LaserScanner.h create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/PWM.h create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/io.h create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/libcansocket.h create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/libmaestro.h create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/libuart.h create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src-gen/data_dictionary.c create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/CanConnector.c create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/GPIO.c create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/Gamepad.c create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/IMU.c create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/LaserRangeFinder.c create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/LaserScanner.c create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/PWM.c create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/io.c create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/libcansocket.c create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/libmaestro.c create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/libuart.c create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/main.c create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/model/generate-ecore.xml create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/model/raspberry.ecore create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/model/raspberry.genmodel create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/plugin.properties create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/plugin.xml create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/pom.xml create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/AF3PlatformRaspberryActivator.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/annotation/PWMChannelNumberValueProvider.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/CanBusCompositor.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/CanToRaspberryCompositor.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/RaspberryPiCompositor.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/RaspberryToCanCompositor.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/CanBusExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/CanConnectorExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/CanTransmissionCatalog.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/GPIExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/GPOExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/GamepadSensorExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/IMUSensorExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/LaserRangeFinderSensorExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/LaserScannerSensorExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/PWMActuatorExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPIExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/WheelEncoderExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button1Executable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button2Executable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button3Executable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button4Executable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL1Executable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL2Executable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR1Executable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR2Executable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickXExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickYExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickXExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickYExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanBusTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanBusTransmissionCatalogTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanConnectorTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanConnectorTransmissionCatalogTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/GPITransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/GPOTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/GamepadSensorTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/IMUSensorTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/LaserRangeFinderSensorTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/LaserScannerSensorTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/PWMActuatorTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/RaspberryPITransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/WheelEncoderTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button1Transformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button2Transformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button3Transformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button4Transformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonL1Transformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonL2Transformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonR1Transformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonR2Transformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Left_StickXTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Left_StickYTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Right_StickXTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Right_StickYTransformation.java create mode 100644 org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/util/RaspberryModelElementFactory.java diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/.classpath b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/.classpath new file mode 100644 index 00000000..f440d5cd --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/.classpath @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="generated-src"/> + <classpathentry kind="output" path="build"/> +</classpath> diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/.project b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/.project new file mode 100644 index 00000000..896d6e89 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/.project @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.fortiss.af3.platform.raspberry</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.fortiss.ide.dev_tools.emf.builder.EcoreBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.fortiss.ide.dev_tools.warnings.RemoveWarningsBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/META-INF/MANIFEST.MF b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/META-INF/MANIFEST.MF new file mode 100644 index 00000000..0b3651d7 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/META-INF/MANIFEST.MF @@ -0,0 +1,29 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Fortiss AF3 Platform Raspberry +Bundle-SymbolicName: org.fortiss.af3.platform.raspberry;singleton:=true +Bundle-Version: 2.9.0.qualifier +Bundle-ClassPath: . +Bundle-Vendor: fortiss GmbH +Bundle-Localization: plugin +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Export-Package: org.fortiss.af3.platform.raspberry.model, + org.fortiss.af3.platform.raspberry.model.gamepad, + org.fortiss.af3.platform.raspberry.model.gamepad.impl, + org.fortiss.af3.platform.raspberry.model.gamepad.util, + org.fortiss.af3.platform.raspberry.model.impl, + org.fortiss.af3.platform.raspberry.model.util, + org.fortiss.af3.platform.raspberry.util +Bundle-ActivationPolicy: lazy +Bundle-Activator: org.fortiss.af3.platform.raspberry.AF3PlatformRaspberryActivator +Require-Bundle: org.fortiss.af3.project, + org.fortiss.tooling.kernel;visibility:=reexport, + org.eclipse.core.runtime, + org.eclipse.emf.ecore;visibility:=reexport, + org.fortiss.tooling.base;visibility:=reexport, + org.fortiss.af3.platform;bundle-version="2.5.0";visibility:=reexport, + org.fortiss.tooling.base.ui;bundle-version="2.11.0", + org.fortiss.af3.generator.common +Import-Package: org.fortiss.af3.deployment.generator, + org.fortiss.af3.platform.model + diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/buckminster.cspex b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/buckminster.cspex new file mode 100644 index 00000000..6f45c454 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/buckminster.cspex @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<cspecExtension + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:bc="http://www.eclipse.org/buckminster/Common-1.0" + xmlns="http://www.eclipse.org/buckminster/CSpec-1.0"> + <actions> + <!-- Place your Actions here --> + <public name="generate-ecore" actor="jdt.ant" always="true"> + <actorProperties> + <property key="buildFile" value="model/generate-ecore.xml" /> + <property key="targets" value="generate-ecore"/> + </actorProperties> + <products> + <path path="generated-src" /> + </products> + </public> + </actions> + <alterGroups> + <!-- Place your Group alterations here --> + <public name="eclipse.build.source"> + <attribute name="generate-ecore"/> + </public> + </alterGroups> +</cspecExtension> diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/build.properties b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/build.properties new file mode 100644 index 00000000..f47685fe --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/build.properties @@ -0,0 +1,13 @@ +# <copyright> +# </copyright> +# +# $Id$ + +bin.includes = .,\ + model/,\ + META-INF/,\ + plugin.xml,\ + plugin.properties +source.. = src/,\ + generated-src/ +output.. = build/ diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/Makedefs b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/Makedefs new file mode 100644 index 00000000..30b33f53 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/Makedefs @@ -0,0 +1,47 @@ +# The default application name. +ifndef APPL + APPL=my_app +endif + +# The default build path. +ifndef BPATH + BPATH=build +endif + +# The compiler. +ifndef CROSSCC + CROSSCC=gcc +endif + +# The linker. +ifndef CROSSLD + CROSSLD=gcc +endif + +# The flags which are passed to the compiler and the linker. +CCFLAGS+=-std=gnu99 -Wall -pthread -lwiringPi -pedantic -c ${patsubst %,-I%,${subst :, ,${IPATH}}} +LDFLAGS+=-std=gnu99 -Wall -pthread -lpthread -lwiringPi -pedantic + +# The default rules, i.e. the entry point. +all: ${BPATH} +all: ${BPATH}/${APPL}.run + +# The target to clean the build directory. +clean: + @echo "cleaning up path '${BPATH}' ..." + @rm -rf ${BPATH} + +# The rule for creating the build directory. +${BPATH}: + @echo "creating path '${BPATH}' ..." + @mkdir ${BPATH} + +# The rule for building an object file from the corresponding C source file. +${BPATH}/%.o: %.c + @echo "compiling file '${<}' ..." + @${CROSSCC} ${CCFLAGS} -o ${@} ${<} + +# The rule for linking an application. +${BPATH}/%.run: + @echo "linking application '${@}' ..." + @${CROSSLD} ${LDFLAGS} -o ${@} $(filter %.o %.a, ${^}) \ No newline at end of file diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc-gen/data_dictionary.h b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc-gen/data_dictionary.h new file mode 100644 index 00000000..b9570e11 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc-gen/data_dictionary.h @@ -0,0 +1,55 @@ +/* generated by AutoFOCUS 3 (2.11.0) on Tue May 16 17:42:09 CEST 2017 */ +#ifndef __HEADER_data_dictionary_h +#define __HEADER_data_dictionary_h +#if defined(__cplusplus) +typedef bool GEN_TYPE_boolean; +#else +typedef enum Enum_TYPE_boolean { + false = 0, true = 1 +} GEN_TYPE_boolean; +#endif + +typedef int GEN_TYPE_int; + +typedef double GEN_TYPE_double; + +/*extern GEN_TYPE_double abs(GEN_TYPE_double _V); + +extern GEN_TYPE_double arctan(GEN_TYPE_double _V); + +extern GEN_TYPE_double cos(GEN_TYPE_double _V); + +extern GEN_TYPE_double cot(GEN_TYPE_double _V); + +extern GEN_TYPE_double e(); + +extern GEN_TYPE_double exp(GEN_TYPE_double _V); + +extern GEN_TYPE_double ln(GEN_TYPE_double _V); + +extern GEN_TYPE_double pi(); + +extern GEN_TYPE_double sgn(GEN_TYPE_double _V); + +extern GEN_TYPE_double sin(GEN_TYPE_double _V); + +extern GEN_TYPE_double sqrt(GEN_TYPE_double _V); + +extern GEN_TYPE_double tan(GEN_TYPE_double _V); + +extern GEN_TYPE_double _sqrt(GEN_TYPE_double _X,GEN_TYPE_double _V); + +extern GEN_TYPE_double pow(GEN_TYPE_double _V,GEN_TYPE_double _N); + +extern GEN_TYPE_double factorial(GEN_TYPE_double _V); + +extern GEN_TYPE_double min(GEN_TYPE_double _a,GEN_TYPE_double _b); + +extern GEN_TYPE_double max(GEN_TYPE_double _a,GEN_TYPE_double _b); + +extern GEN_TYPE_double rad2deg(GEN_TYPE_double _A); + +extern GEN_TYPE_double deg2rad(GEN_TYPE_double _A);*/ + +#endif // __HEADER_data_dictionary_h + diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/CanConnector.h b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/CanConnector.h new file mode 100644 index 00000000..a75fa33e --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/CanConnector.h @@ -0,0 +1,46 @@ +#ifndef __CANCONNECTOR_H +#define __CANCONNECTOR_H + +#include <stdio.h> + +#include "inc/libcansocket.h" +#include "inc-gen/data_dictionary.h" + +// types +typedef const char* CAN_MSG_T; +typedef unsigned long CAN_CLK_T; + +// constants +extern const char* CAN_DEVICE_NAME; + +// send and receive +void can_send(); +void can_send_clock(CAN_CLK_T counter); +void can_receive(); +CAN_CLK_T can_receive_clock(); + +// init, terminate, prepare +void can_init(); +void can_term(); + +void prepare_input_CanConnector(); +void finish_input_CanConnector(); + +void prepare_output_CanConnector(); +void finish_output_CanConnector(); + +// noval +GEN_TYPE_boolean can_is_noval(CAN_MSG_T msg); +GEN_TYPE_boolean can_set_noval(CAN_MSG_T msg); + +// readers +GEN_TYPE_boolean can_read_bool(CAN_MSG_T msg); +GEN_TYPE_double can_read_double(CAN_MSG_T msg); +GEN_TYPE_int can_read_int(CAN_MSG_T pomsgrt); + +// writers +void can_write_bool(CAN_MSG_T msg, GEN_TYPE_boolean value); +void can_write_double(CAN_MSG_T msg, GEN_TYPE_double value); +void can_write_int(CAN_MSG_T msg, GEN_TYPE_int value); + +#endif // __CANCONNECTOR_H diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/GPIO.h b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/GPIO.h new file mode 100644 index 00000000..b725758a --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/GPIO.h @@ -0,0 +1,27 @@ +#ifndef __GPIO_H +#define __GPIO_H + +#include <stdio.h> +#include <wiringPi.h> +#include "inc-gen/data_dictionary.h" + +// types +typedef int GPIO_PIN_T; + +// init, term +void gpio_init(GPIO_PIN_T pin); +void gpio_init_in(GPIO_PIN_T pin); +void gpio_init_out(GPIO_PIN_T pin); +void gpio_term(GPIO_PIN_T pin); + +// noval +GEN_TYPE_boolean gpio_is_noval(GPIO_PIN_T pin); +void gpio_set_noval(GPIO_PIN_T pin); + +// readers +GEN_TYPE_boolean gpio_read(GPIO_PIN_T pin); + +// writers +void gpio_write(GPIO_PIN_T pin, GEN_TYPE_boolean value); + +#endif // __GPIO_H diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/Gamepad.h b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/Gamepad.h new file mode 100644 index 00000000..0e818c4d --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/Gamepad.h @@ -0,0 +1,91 @@ +#ifndef __GAMEPAD_H +#define __GAMEPAD_H + +#include <stdio.h> +#include <stdlib.h> +#include <inttypes.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> +#include <unistd.h> + +#include "inc-gen/data_dictionary.h" + +// constants +#define JS_EVENT_BUTTON 0x01 +#define JS_EVENT_AXIS 0x02 +#define JS_EVENT_INIT 0x80 + +extern const char* GP_DEVICE_NAME; + +// types etc +union input_events { + struct input_btns { + int16_t js1_lr; // LX + int16_t js1_ud; // LY + int16_t js2_lr; // RX + int16_t js2_ud; // RY + int16_t gp_lr; // GPX + int16_t gp_ud; // GPY + int16_t bt_tri; // BTN1 + int16_t bt_cir; // BTN2 + int16_t bt_x; // BTN3 + int16_t bt_sqr; // BTN4 + int16_t bt_l1; // L1 + int16_t bt_r1; // R1 + int16_t bt_l2; // L2 + int16_t bt_r2; // R2 + int16_t bt_sel; // SELECT + int16_t bt_strt;// START + int16_t js1_bt; // LCLICK + int16_t js2_bt; // RCLICK + } btns; + int16_t inps[18]; +}; + +struct js_event { + uint32_t time; // event time stamp in millisecons + int16_t value; // value + uint8_t type; // event type + uint8_t number; // axis/button number +}; + +extern volatile union input_events ie; + +// worker +void* gp_worker(void* pt_args); + +// init, term +void gp_init(); +void gp_term(); + +// readers +GEN_TYPE_boolean gp_btn1_read(); +GEN_TYPE_boolean gp_btn2_read(); +GEN_TYPE_boolean gp_btn3_read(); +GEN_TYPE_boolean gp_btn4_read(); +GEN_TYPE_boolean gp_btnL1_read(); +GEN_TYPE_boolean gp_btnL2_read(); +GEN_TYPE_boolean gp_btnR1_read(); +GEN_TYPE_boolean gp_btnR2_read(); +GEN_TYPE_double gp_btnLX_read(); +GEN_TYPE_double gp_btnLY_read(); +GEN_TYPE_double gp_btnRX_read(); +GEN_TYPE_double gp_btnRY_read(); + +// noval +GEN_TYPE_boolean gp_btn1_is_noval(); +GEN_TYPE_boolean gp_btn2_is_noval(); +GEN_TYPE_boolean gp_btn3_is_noval(); +GEN_TYPE_boolean gp_btn4_is_noval(); +GEN_TYPE_boolean gp_btnL1_is_noval(); +GEN_TYPE_boolean gp_btnL2_is_noval(); +GEN_TYPE_boolean gp_btnR1_is_noval(); +GEN_TYPE_boolean gp_btnR2_is_noval(); +GEN_TYPE_boolean gp_btnLX_is_noval(); +GEN_TYPE_boolean gp_btnLY_is_noval(); +GEN_TYPE_boolean gp_btnRX_is_noval(); +GEN_TYPE_boolean gp_btnRY_is_noval(); + +#endif // __GAMEPAD_H diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/IMU.h b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/IMU.h new file mode 100644 index 00000000..e69de29b diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/LaserRangeFinder.h b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/LaserRangeFinder.h new file mode 100644 index 00000000..75cab869 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/LaserRangeFinder.h @@ -0,0 +1,20 @@ +#ifndef __LASERRANGEFINDER_H +#define __LASERRANGEFINDER_H + +#include <stdlib.h> + +#include "inc-gen/data_dictionary.h" +#include "inc/libuart.h" + +// constants +const char* LRF_DEVICE_NAME; + +// init, terminate +void lrf_init(); +void lrf_term(); + +// getters +GEN_TYPE_boolean lrf_is_noval(); +GEN_TYPE_int lrf_read(); + +#endif // __LASERRANGEFINDER_H diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/LaserScanner.h b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/LaserScanner.h new file mode 100644 index 00000000..e69de29b diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/PWM.h b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/PWM.h new file mode 100644 index 00000000..8b72ff55 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/PWM.h @@ -0,0 +1,39 @@ +#ifndef __PWM_H +#define __PWM_H + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <termios.h> +#include <fcntl.h> +#include <sys/stat.h> + +#include "inc-gen/data_dictionary.h" +#include "inc/libmaestro.h" + +// macros +// 6072 is the value for 0, max. value to motor is currently 7572 +// from AF3 you get a max. speed value in mm/s : 1471 +// Hence, add the constant 6072 and map values -1471-1471 to -1500-1500 +#define PWM_ADJUST_VALUE(x) (6072 + 1500 * x /1471) + +// types +typedef unsigned char PWM_CHANNEL_T; + +// constants +extern const int PWM_SLEEP_TIME; +extern const char* PWM_DEVICE_NAME; +extern const size_t PWM_MAX_NO_CHANNELS; + +// worker +void* pwm_worker(void* pt_args); + +// init, term +void pwm_init(PWM_CHANNEL_T channel); +void pwm_term(PWM_CHANNEL_T channel); + +// writers +void pwm_write(PWM_CHANNEL_T channel, GEN_TYPE_int value); +void pwm_set_noval(PWM_CHANNEL_T channel); + +#endif // __PWM_H diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/io.h b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/io.h new file mode 100644 index 00000000..12856441 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/io.h @@ -0,0 +1,25 @@ +#ifndef __IO_H +#define __IO_H + +#include "inc-gen/data_dictionary.h" + +// init, terminate +void init_left_stick(); +void term_left_stick(); + +void init_right_stick(); +void term_right_stick(); + +// NOVAL +GEN_TYPE_boolean is_noval_left_stick(); +GEN_TYPE_boolean is_noval_right_stick(); + +// readers +GEN_TYPE_double read_left_stick(); +GEN_TYPE_double read_right_stick(); + +// writers +void write_left_stick(GEN_TYPE_double value); +void write_right_stick(GEN_TYPE_double value); + +#endif // __IO_H diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/libcansocket.h b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/libcansocket.h new file mode 100644 index 00000000..a791bad0 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/libcansocket.h @@ -0,0 +1,43 @@ +#ifndef __LIBCANSOCKET_H +#define __LIBCANSOCKET_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include <net/if.h> +#include <sys/ioctl.h> + +#include <linux/can.h> +#include <linux/can/raw.h> + +#define SR_ERR -1 + +struct can_socket { + int s; + struct sockaddr_can addr; + struct ifreq ifr; +}; + +/** + * Opens a can socket on the given interface + */ +struct can_socket* can_socket_open(const char *if_name); + +/** + * Closes a given socket + */ +void can_socket_close(struct can_socket* sock); + +/** + * Sends a can frame on the specified socket + */ +ssize_t can_socket_send(struct can_socket* sock, struct can_frame* frame); + +/** + * + */ +ssize_t can_socket_receive(struct can_socket* sock, struct can_frame* frame); + +#endif // __LIBCANSOCKET_H diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/libmaestro.h b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/libmaestro.h new file mode 100644 index 00000000..22f83e05 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/libmaestro.h @@ -0,0 +1,12 @@ +#ifndef __LIBMAESTRO_H +#define __LIBMAESTRO_H + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <termios.h> + +int maestroRead(int fd, unsigned char channel); +int maestroWrite(int fd, unsigned char channel, unsigned short target); + +#endif // __LIBMAESTRO_H diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/libuart.h b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/libuart.h new file mode 100644 index 00000000..2861d5aa --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/inc/libuart.h @@ -0,0 +1,35 @@ +/** + * @file uart.h + * @author Bianca Forkel + */ + +#ifndef MBSE_UART_H +#define MBSE_UART_H + +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <fcntl.h> +#include <termios.h> +#include <errno.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/select.h> + +extern int uart_filestream; + +char port[13]; + +int uart_setup(const char*); + +int uart_send_byte(char, int); + +int uart_send_string(char*, int, int); + +int uart_receive(char*, int, int); + +void uart_close(); + +void uart_flush(); + +#endif diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src-gen/data_dictionary.c b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src-gen/data_dictionary.c new file mode 100644 index 00000000..1d778b9d --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src-gen/data_dictionary.c @@ -0,0 +1,170 @@ +/* generated by AutoFOCUS 3 (2.11.0) on Tue May 16 17:42:09 CEST 2017 */ +#include "inc-gen/data_dictionary.h" + +/*GEN_TYPE_double abs(GEN_TYPE_double _V){ + return _V * sgn(_V); +} + +GEN_TYPE_double arctan(GEN_TYPE_double _V){ + if (abs(_V) <= 1.0) { + return _V / (1 + (0.28 * _V) * _V); + } + else { + if (_V > 1) { + return pi() / 2.0 - _V / (_V * _V + 0.28); + } + else { + return -(pi() / 2.0) - _V / (_V * _V + 0.28); + } + } +} + +GEN_TYPE_double cos(GEN_TYPE_double _V){ + return sin((_V + pi() / 2.0)); +} + +GEN_TYPE_double cot(GEN_TYPE_double _V){ + return cos(_V) / sin(_V); +} + +GEN_TYPE_double e(){ + return 2.718281828459; +} + +GEN_TYPE_double exp(GEN_TYPE_double _V){ + return ((((1 + _V) + (_V * _V) / 2) + ((_V * _V) * _V) / 6) + (((_V * _V) * _V) * _V) / 24) + ((((_V * _V) * _V) * _V) * _V) / 120; +} + +GEN_TYPE_double ln(GEN_TYPE_double _V){ + if (_V <= 0) { + return 0; + } + else { + return ((((_V - 1.0) - ((_V - 1.0) * (_V - 1.0)) / 2.0) + (((_V - 1) * (_V - 1)) * (_V - 1)) / 3.0) - ((((_V - 1) * (_V - 1)) * (_V - 1)) * (_V - 1)) / 4.0) + (((((_V - 1) * (_V - 1)) * (_V - 1)) * (_V - 1)) * (_V - 1)) / 5.0; + } +} + +GEN_TYPE_double pi(){ + return 3.14159265; +} + +GEN_TYPE_double sgn(GEN_TYPE_double _V){ + if (_V < 0) { + return -1; + } + else { + if (_V == 0) { + return 0; + } + else { + return 1; + } + } +} + +GEN_TYPE_double sin(GEN_TYPE_double _V){ + if (_V % (2 * pi()) < 0) { + return -sin((-_V)); + } + else { + if (_V % (2 * pi()) > pi()) { + return -sin((_V % (2 * pi()) - pi())); + } + else { + if (_V % (2 * pi()) < 0) { + if (1.27323954 * (_V % (2 * pi())) + (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi())) < 0) { + return 0.225 * ((1.27323954 * (_V % (2 * pi())) + (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi()))) * -(1.27323954 * (_V % (2 * pi())) + (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi()))) - (1.27323954 * (_V % (2 * pi())) + (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi())))) + (1.27323954 * (_V % (2 * pi())) + (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi()))); + } + else { + return 0.225 * ((1.27323954 * (_V % (2 * pi())) + (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi()))) * (1.27323954 * (_V % (2 * pi())) + (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi()))) - (1.27323954 * (_V % (2 * pi())) + (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi())))) + (1.27323954 * (_V % (2 * pi())) + (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi()))); + } + } + else { + if (1.27323954 * (_V % (2 * pi())) - (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi())) < 0) { + return 0.225 * ((1.27323954 * (_V % (2 * pi())) - (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi()))) * -(1.27323954 * (_V % (2 * pi())) - (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi()))) - (1.27323954 * (_V % (2 * pi())) - (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi())))) + (1.27323954 * (_V % (2 * pi())) - (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi()))); + } + else { + return 0.225 * ((1.27323954 * (_V % (2 * pi())) - (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi()))) * (1.27323954 * (_V % (2 * pi())) - (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi()))) - (1.27323954 * (_V % (2 * pi())) - (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi())))) + (1.27323954 * (_V % (2 * pi())) - (0.405284735 * (_V % (2 * pi()))) * (_V % (2 * pi()))); + } + } + } + } +} + +GEN_TYPE_double sqrt(GEN_TYPE_double _V){ + if (_V <= 0) { + return 0; + } + else { + return _sqrt(_V, _sqrt(_V, _sqrt(_V, _sqrt(_V, _sqrt(_V, _sqrt(_V, _sqrt(_V, _sqrt(_V, _sqrt(_V, _sqrt(_V, ((_V + 1.0) / 2.0))))))))))); + } +} + +GEN_TYPE_double tan(GEN_TYPE_double _V){ + return sin(_V) / cos(_V); +} + +GEN_TYPE_double _sqrt(GEN_TYPE_double _X,GEN_TYPE_double _V){ + return 0.5 * (_V + _X / _V); +} + +GEN_TYPE_double pow(GEN_TYPE_double _V,GEN_TYPE_double _N){ + if (_N == 0) { + return 1; + } + else { + if (_N < 0) { + if (_V == 0) { + return 0; + } + else { + return 1.0 / pow(_V, (-_N)); + } + } + else { + if (_N == 1) { + return _V; + } + else { + return _V * pow(_V, (_N - 1)); + } + } + } +} + +GEN_TYPE_double factorial(GEN_TYPE_double _V){ + if (_V % 1 != 0) { + return factorial((_V - _V % 1)); + } + else { + if (_V == 0 || _V == 1) { + return 1; + } + else { + return factorial((_V - 1)) * _V; + } + } +} + +GEN_TYPE_double min(GEN_TYPE_double _a,GEN_TYPE_double _b){ + if (_a < _b) { + return _a; + } + return _b; +} + +GEN_TYPE_double max(GEN_TYPE_double _a,GEN_TYPE_double _b){ + if (_a > _b) { + return _a; + } + return _b; +} + +GEN_TYPE_double rad2deg(GEN_TYPE_double _A){ + return (_A / pi()) * 180.0; +} + +GEN_TYPE_double deg2rad(GEN_TYPE_double _A){ + return (_A / 180.0) * pi(); +}*/ + diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/CanConnector.c b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/CanConnector.c new file mode 100644 index 00000000..196072d4 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/CanConnector.c @@ -0,0 +1,84 @@ + +#include "inc/CanConnector.h" + +// constants +const char* CAN_DEVICE_NAME = "can0"; + +// variables +struct can_socket* can_sock; + +// send and receive +void can_send() { + // TODO send and empty buffer +} + +void can_send_clock(CAN_CLK_T counter) { + // TODO send clock message with clock counter +} + +void can_receive() { + // TODO fill buffer +} + +CAN_CLK_T can_receive_clock() { + // TODO receive clock message and return clock counter +} + +// init, terminate +void can_init() { + printf("initializing CAN\n"); + + can_sock = can_socket_open(CAN_DEVICE_NAME); + + // TODO init buffers +} + +void can_term() { + printf("terminating CAN\n"); + + can_socket_close(can_sock); +} + +void prepare_input_CanConnector() {} + +void finish_input_CanConnector() {} + +void prepare_output_CanConnector() {} + +void finish_output_CanConnector() {} + +// noval +GEN_TYPE_boolean can_is_noval(CAN_MSG_T msg) { + return false; +} + +GEN_TYPE_boolean can_set_noval(CAN_MSG_T msg) { + return false; +} + +// readers +GEN_TYPE_boolean can_read_bool(CAN_MSG_T msg) { + return false; // TODO +} + +GEN_TYPE_double can_read_double(CAN_MSG_T msg) { + return 0.0; // TODO +} + +GEN_TYPE_int can_read_int(CAN_MSG_T msg) { + return 0; // TODO +} + +// writers +void can_write_bool(CAN_MSG_T msg, GEN_TYPE_boolean value) { + // TODO +} + +void can_write_double(CAN_MSG_T msg, GEN_TYPE_double value) { + // TODO +} + +void can_write_int(CAN_MSG_T msg, GEN_TYPE_int value) { + // TODO +} + diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/GPIO.c b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/GPIO.c new file mode 100644 index 00000000..35593258 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/GPIO.c @@ -0,0 +1,56 @@ +#include "inc/GPIO.h" + +// init, term +GEN_TYPE_boolean gpio_initialized = false; +GEN_TYPE_boolean gpio_terminated = false; + +void gpio_init(GPIO_PIN_T pin) { + // important, since all pins are accessing the same method + if(gpio_initialized) return; + + if(wiringPiSetup() == -1) { + perror("cannot setup wiring pi\n"); + return; + } + + gpio_initialized = true; +} + +void gpio_init_in(GPIO_PIN_T pin) { + gpio_init(pin); + + pinMode(pin, INPUT); +} + +void gpio_init_out(GPIO_PIN_T pin) { + gpio_init(pin); + + pinMode(pin, OUTPUT); +} + +void gpio_term(GPIO_PIN_T pin) { + // important, since all pins are accessing the same method + if(gpio_terminated) return; + + gpio_terminated = false; +} + +// noval +GEN_TYPE_boolean gpio_is_noval(GPIO_PIN_T pin) { + return false; +} + +void gpio_set_noval(GPIO_PIN_T pin) { + // do nothing +} + +// readers +GEN_TYPE_boolean gpio_read(GPIO_PIN_T pin) { + return digitalRead(pin); +} + +// writers +void gpio_write(GPIO_PIN_T pin, GEN_TYPE_boolean value) { + digitalWrite(pin, value); +} + diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/Gamepad.c b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/Gamepad.c new file mode 100644 index 00000000..c3134d4f --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/Gamepad.c @@ -0,0 +1,276 @@ + +#include "inc/Gamepad.h" + +// constants +const char* GP_DEVICE_NAME = "/dev/input/js0"; + +// variables +volatile union input_events ie; // stores the button values + +// worker +GEN_TYPE_boolean gp_is_running = true; + +void* gp_worker(void* pt_args) { + int fd; + fd = open(GP_DEVICE_NAME, O_RDONLY); + + if(fd <= 0) { + perror("Error while connecting to gamepad device. Aborting"); + return NULL; + } + + struct timeval timeout; + struct js_event jse; + fd_set read_fds, write_fds, except_fds; + + // loop until terminated... + while(gp_is_running) { + FD_ZERO(&read_fds); + FD_ZERO(&write_fds); + FD_ZERO(&except_fds); + FD_SET(fd, &read_fds); + + timeout.tv_sec = 0; + timeout.tv_usec = 25000; + + if (select(fd + 1, &read_fds, &write_fds, &except_fds, &timeout) == 1) { + if(read(fd,&jse,sizeof(jse)) == sizeof(jse)) { + jse.type &= ~JS_EVENT_INIT; + + if(jse.type == JS_EVENT_AXIS) { + ie.inps[jse.number] = jse.value; + + #ifdef DEBUG + printf("Axis %d %d\n", jse.number, jse.value); + #endif // DEBUG + } + + if(jse.type == JS_EVENT_BUTTON) { + ie.inps[jse.number + 6] = jse.value; + + #ifdef DEBUG + printf("Button %d %d\n",jse.number, jse.value); + #endif // DEBUG + } + } + } + } + + close(fd); + + return NULL; +} + +// init, term +GEN_TYPE_boolean gp_initialized = false; +GEN_TYPE_boolean gp_terminated = false; + +void gp_init() { + // important, since all btns are accessing the same method + if(gp_initialized) return; + + // Initialize Joystick Inputs to 0 + ie.btns.js1_ud = 0; + ie.btns.js2_lr = 0; + ie.btns.js2_ud = 0; + + // Initialize Button inputs to NoVal + ie.btns.bt_tri = 2; + ie.btns.bt_cir = 2; + ie.btns.bt_x = 2; + ie.btns.bt_sqr = 2; + ie.btns.bt_l1 = 2; + ie.btns.bt_l2 = 2; + ie.btns.bt_r1 = 2; + ie.btns.bt_r2 = 2; + + gp_initialized = true; +} + +void gp_term() { + // important, since all btns are accessing the same method + if(gp_terminated) return; + + gp_terminated = false; + gp_is_running = false; +} + +// readers: Return button values (1 is true, 0 is false, 2 is NoVal) +// important: Reset button values to NoVal after reading +GEN_TYPE_boolean gp_btn1_read() { + if (ie.btns.bt_tri == 1) + { + ie.btns.bt_tri = 2; + return 1; + } + else + { + ie.btns.bt_tri = 2; + return 0; + } +} + +GEN_TYPE_boolean gp_btn2_read() { + if (ie.btns.bt_cir == 1) + { + ie.btns.bt_cir = 2; + return 1; + } + else + { + ie.btns.bt_cir = 2; + return 0; + } +} + +GEN_TYPE_boolean gp_btn3_read() { + if (ie.btns.bt_x == 1) + { + ie.btns.bt_x = 2; + return 1; + } + else + { + ie.btns.bt_x = 2; + return 0; + } +} + +GEN_TYPE_boolean gp_btn4_read() { + if (ie.btns.bt_sqr == 1) + { + ie.btns.bt_sqr = 2; + return 1; + } + else + { + ie.btns.bt_sqr = 2; + return 0; + } +} + +GEN_TYPE_boolean gp_btnL1_read() { + if (ie.btns.bt_l1 == 1) + { + ie.btns.bt_l1 = 2; + return 1; + } + else + { + ie.btns.bt_l1 = 2; + return 0; + } +} + +GEN_TYPE_boolean gp_btnL2_read() { + if (ie.btns.bt_l2 == 1) + { + ie.btns.bt_l2 = 2; + return 1; + } + else + { + ie.btns.bt_l2 = 2; + return 0; + } +} + +GEN_TYPE_boolean gp_btnR1_read() { + if (ie.btns.bt_r1 == 1) + { + ie.btns.bt_r1 = 2; + return 1; + } + else + { + ie.btns.bt_r1 = 2; + return 0; + } +} + +GEN_TYPE_boolean gp_btnR2_read() { + if (ie.btns.bt_r2 == 1) + { + ie.btns.bt_r2 = 2; + return 1; + } + else + { + ie.btns.bt_r2 = 2; + return 0; + } +} + +GEN_TYPE_double gp_btnLX_read() { + return ie.btns.js1_lr; +} + +GEN_TYPE_double gp_btnLY_read() { + return -ie.btns.js1_ud; +} + +GEN_TYPE_double gp_btnRX_read() { + return ie.btns.js2_lr; +} + +GEN_TYPE_double gp_btnRY_read() { + return -ie.btns.js2_ud; +} + +// noval +GEN_TYPE_boolean gp_btn1_is_noval() { + if (ie.btns.bt_tri == 2) return 1; + return 0; +} + +GEN_TYPE_boolean gp_btn2_is_noval() { + if (ie.btns.bt_cir == 2) return 1; + return 0; +} + +GEN_TYPE_boolean gp_btn3_is_noval() { + if (ie.btns.bt_x == 2) return 1; + return 0; +} + +GEN_TYPE_boolean gp_btn4_is_noval() { + if (ie.btns.bt_sqr == 2) return 1; + return 0; +} + +GEN_TYPE_boolean gp_btnL1_is_noval() { + if (ie.btns.bt_l1 == 2) return 1; + return 0; +} + +GEN_TYPE_boolean gp_btnL2_is_noval() { + if (ie.btns.bt_l2 == 2) return 1; + return 0; +} + +GEN_TYPE_boolean gp_btnR1_is_noval() { + if (ie.btns.bt_r1 == 2) return 1; + return 0; +} + +GEN_TYPE_boolean gp_btnR2_is_noval() { + if (ie.btns.bt_r2 == 2) return 1; + return 0; +} + +GEN_TYPE_boolean gp_btnLX_is_noval() { + return false; +} + +GEN_TYPE_boolean gp_btnLY_is_noval() { + return false; +} + +GEN_TYPE_boolean gp_btnRX_is_noval() { + return false; +} + +GEN_TYPE_boolean gp_btnRY_is_noval() { + return false; +} + diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/IMU.c b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/IMU.c new file mode 100644 index 00000000..e69de29b diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/LaserRangeFinder.c b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/LaserRangeFinder.c new file mode 100644 index 00000000..6a73d303 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/LaserRangeFinder.c @@ -0,0 +1,102 @@ + +#include "inc/LaserRangeFinder.h" + +int timeout; + +/** Initialize the laser range finder. */ +void lrf_init() { + timeout = 0; + + char port[100]; + FILE* fp = popen("ls -d /dev/serial/by-id/* | grep \"Arduino_Micro\" | tr -d \"\n\"", "r"); + fgets(port, sizeof(port), fp); + + + printf("lrf port=%s\n", port); + pclose(fp); + + uart_setup(port); +} + +/** Terminate the session. */ +void lrf_term() { + uart_close(); +} + +/** Checking for noVal. */ +GEN_TYPE_boolean lrf_is_noval() { + return false; +} + +/** Get one distance measurement from the laser range finder. */ +GEN_TYPE_int lrf_read() { + + if(timeout>1000) + lrf_init(); + + if (uart_filestream == -1) { + timeout++; + printf("-1: no filestream\n"); + return -1; + } + + //empty buffer + uart_flush(); + + //initialize arrays + int sizeB = 10; + int sizeV = 4; + + int i; + char bytes[sizeB]; + for (i = 0; i < sizeB; i++) { + bytes[i] = 0; + } + int n_read = 0; + + char value[sizeV]; + for (i = 0; i < sizeV; i++) { + value[i] = 0; + } + + int n = 0; + int d; + + //receive values + while (1) { + n_read = uart_receive(bytes, sizeB, 0); + + if(n_read <= 0) { + timeout++; + printf("-1: n_read=%d\n",n_read); + return -1; + } + + for (i = 0; i < n_read; i++) { + if (bytes[i] != 0xd && bytes[i] != 0xa) { + if(n < sizeV) + value[n++] = bytes[i]; + else { + timeout++; + printf("-1: too many bytes\n"); + return -1; + } + } else { + d = atoi(value); + if (d == 0) { + timeout++; + printf("-1: zero value\n"); + return -1; + } else if(d == 1061) { //strange behaviour of one lrf + printf("-1: 1061\n"); + return -1; + } + else { + printf("%d\n", d); + timeout = 0; + return d; + } + } + } + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/LaserScanner.c b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/LaserScanner.c new file mode 100644 index 00000000..e69de29b diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/PWM.c b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/PWM.c new file mode 100644 index 00000000..d50d6985 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/PWM.c @@ -0,0 +1,87 @@ +#include "inc/PWM.h" + +// constants +const int PWM_SLEEP_TIME = 50000; +const char* PWM_DEVICE_NAME = "/dev/ttyACM0"; +const size_t PWM_MAX_NO_CHANNELS = 4; + +// worker +GEN_TYPE_boolean pwm_is_running = true; + +GEN_TYPE_int* pwm_channel_values; +GEN_TYPE_boolean* pwm_channel_enabled; + +void pwm_send(int fd) { + size_t i; + + for(i = 0; i < PWM_MAX_NO_CHANNELS; i++) { + if(pwm_channel_enabled[i]) { + maestroWrite(fd, i, pwm_channel_values[i]); + } + } +} + +void* pwm_worker(void* pt_args) { + int fd = open(PWM_DEVICE_NAME, O_RDWR | O_NOCTTY); + + if (fd == -1) { + perror("Error while connecting to pwm device"); + return NULL; + } + + struct termios options; + tcgetattr(fd, &options); + options.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); + options.c_oflag &= ~(ONLCR | OCRNL); + tcsetattr(fd, TCSANOW, &options); + + while(pwm_is_running) { + pwm_send(fd); + usleep(PWM_SLEEP_TIME); + } + + close(fd); + + return NULL; +} + +// init, term +GEN_TYPE_boolean pwm_initialized = false; +GEN_TYPE_boolean pwm_terminated = false; + +void pwm_init(PWM_CHANNEL_T channel) { + // important, since all pwms are accessing the same method + if(!pwm_initialized) { + pwm_channel_values = calloc(sizeof(GEN_TYPE_int), PWM_MAX_NO_CHANNELS); + pwm_channel_enabled = calloc(sizeof(GEN_TYPE_boolean), PWM_MAX_NO_CHANNELS); + + // start a pwm thread + //pthread_t pt_pwm; + //pthread_create(&pt_pwm, NULL, pwm_worker, NULL); + + pwm_initialized = true; + } + + pwm_channel_enabled[channel] = true; +} + +void pwm_term(PWM_CHANNEL_T channel) { + // important, since all pwms are accessing the same method + if(pwm_terminated) return; + + free(pwm_channel_values); + free(pwm_channel_enabled); + + pwm_is_running = false; + pwm_terminated = true; +} + +// writers +void pwm_write(PWM_CHANNEL_T channel, GEN_TYPE_int value) { + pwm_channel_values[channel] = PWM_ADJUST_VALUE(value); +} + +void pwm_set_noval(PWM_CHANNEL_T channel) { + // do nothing, not used +} + diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/io.c b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/io.c new file mode 100644 index 00000000..0e446a06 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/io.c @@ -0,0 +1,45 @@ +#include "inc/io.h" + +// init, terminate +void init_left_stick() { + +} + +void term_left_stick() { + +} + +void init_right_stick() { + +} + +void term_right_stick() { + +} + +// NOVAL +GEN_TYPE_boolean is_noval_left_stick() { + return false; +} + +GEN_TYPE_boolean is_noval_right_stick() { + return false; +} + +// readers +GEN_TYPE_double read_left_stick() { + return 0.0; +} + +GEN_TYPE_double read_right_stick() { + return 0.0; +} + +// writers +void write_left_stick(GEN_TYPE_double value) { + +} + +void write_right_stick(GEN_TYPE_double value) { + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/libcansocket.c b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/libcansocket.c new file mode 100644 index 00000000..b57cc6e8 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/libcansocket.c @@ -0,0 +1,56 @@ +#include "inc/libcansocket.h" + +struct can_socket* can_socket_open(const char *if_name) { + struct can_socket* sock = malloc(sizeof(struct can_socket)); + + /* open socket */ + if ((sock->s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) { + perror("socket"); + return NULL; + } + + sock->addr.can_family = AF_CAN; + + /* map if name to interface index -> will fail if interface does not exist */ + strcpy(sock->ifr.ifr_name, if_name); + if (ioctl(sock->s, SIOCGIFINDEX, &sock->ifr) < 0) { + perror("SIOCGIFINDEX"); + return NULL; + } + sock->addr.can_ifindex = sock->ifr.ifr_ifindex; + + /* bind socket to interface -> will fail if interface is not up */ + if (bind(sock->s, (struct sockaddr *)&sock->addr, sizeof(sock->addr)) < 0) { + perror("bind"); + return NULL; + } + + return sock; +} + +void can_socket_close(struct can_socket* sock) { + close(sock->s); +} + +ssize_t can_socket_send(struct can_socket* sock, struct can_frame* frame) { + ssize_t nbytes; + + /* send frame */ + if ((nbytes = write(sock->s, &frame, sizeof(*frame))) != sizeof(*frame)) { + perror("write"); + return SR_ERR; + } + + return nbytes; +} + +ssize_t can_socket_receive(struct can_socket* sock, struct can_frame* frame) { + ssize_t nbytes; + + if ((nbytes = read(sock->s, frame, sizeof(struct can_frame))) != sizeof(*frame)) { + perror("read"); + return SR_ERR; + } + + return nbytes; +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/libmaestro.c b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/libmaestro.c new file mode 100644 index 00000000..356d5692 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/libmaestro.c @@ -0,0 +1,36 @@ +#include "inc/libmaestro.h" + +// read from channel given a file descriptor +int maestroRead(int fd, unsigned char channel) { + unsigned char command[] = {0x90, channel}; + + if(write(fd, command, sizeof(command)) == -1) + { + perror("error writing"); + return -1; + } + + unsigned char response[2]; + + if(read(fd,response,2) != 2) + { + perror("Error reading from maestro"); + return -1; + } + + return response[0] + 256*response[1]; +} + +// write target to a channel given a file descriptor +// the units of 'target' are quarter-microseconds +int maestroWrite(int fd, unsigned char channel, unsigned short target) { + unsigned char command[] = {0x84, channel, (target & 0x7F), (target >> 7 & 0x7F)}; + + if (write(fd, command, sizeof(command)) == -1) + { + perror("Error writing to maestro"); + return -1; + } + + return 0; +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/libuart.c b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/libuart.c new file mode 100644 index 00000000..ca027e83 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/libuart.c @@ -0,0 +1,119 @@ +/** + * @file uart.c + * @author Bianca Forkel + */ + +#include "inc/libuart.h" + +int uart_filestream = -1; + +/** Initializing the UART connection. */ +int uart_setup(const char *porta) { + strcpy(port, porta); + uart_filestream = open(port, O_RDWR | O_NOCTTY | O_NDELAY); + if (uart_filestream < 0) { + fprintf(stderr, "[%s] Error opening port: %s\n", port, strerror(errno)); + } + + struct termios tty; + memset(&tty, 0, sizeof tty); + if (tcgetattr(uart_filestream, &tty) != 0) { + fprintf(stderr, "[%s] Error from tcgetattr: %s\n", port, strerror(errno)); + } + + // Baud Rate + cfsetospeed(&tty, (speed_t) B115200); + cfsetispeed(&tty, (speed_t) B115200); + + // TTY settings: 8N1 + tty.c_cflag &= ~PARENB; //no parity + tty.c_cflag &= ~CSTOPB; // 1 stop bit + tty.c_cflag &= ~CSIZE; + tty.c_cflag |= CS8; // 8 data bits + + tty.c_cflag &= ~CRTSCTS; + tty.c_cc[VMIN] = 1; + tty.c_cc[VTIME] = 5; + tty.c_cflag |= CREAD | CLOCAL; + + cfmakeraw(&tty); + + uart_flush(); + + if (tcsetattr(uart_filestream, TCSANOW, &tty) != 0) { + fprintf(stderr, "[%s] Error from tcsetattr: %s\n", port, strerror(errno)); + } + return uart_filestream; +} + +/** Sending one byte via UART. */ +int uart_send_byte(char data, int printt) { + if (uart_filestream != -1) { + int n_written = 0; + n_written = write(uart_filestream, &data, 1); + if (n_written < 0) { + if (printt) + fprintf(stderr, "[%s] Error sending byte: %s\n", port, strerror(errno)); + } else { + if (printt) + printf("[%s] Sent byte %#02x\n", port, data); + return 0; + } + } + return -1; +} + +/** Receive from the UART stream. */ +int uart_receive(char *c, int bufLen, int printt) { + fd_set set; + struct timeval timeout; + int rv; + int n_read = -1; + + if (uart_filestream != -1) { + FD_ZERO(&set); + FD_SET(uart_filestream, &set); + + timeout.tv_sec = 0; + timeout.tv_usec = 10000; + + rv = select(uart_filestream + 1, &set, NULL, NULL, &timeout); + if (rv == -1) { + if (printt) + perror("select"); + } else if (rv == 0) { + if (printt) + perror("timeout"); + } else { + n_read = read(uart_filestream, (void *) c, bufLen); + } + + if (n_read < 0) { + if (printt) + fprintf(stderr, "[%s] Error receiving byte: %s\n", port, strerror(errno)); + n_read = 0; + } else if (n_read == 0) { + if (printt) + printf("[%s] No data to receive \n", port); + } else { + if (printt) { + printf("[%s] %i Bytes received: 0x", port, n_read); + int i; + for (i = 0; i < n_read; i++) + printf("%02x", c[i]); + printf("\n"); + } + } + } + return n_read; +} + +/** Close the UART connection. */ +void uart_close() { + close(uart_filestream); +} + +/** Flush the UART buffer. */ +void uart_flush() { + tcflush(uart_filestream, TCIFLUSH); +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/main.c b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/main.c new file mode 100644 index 00000000..60b55265 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/lib/src/main.c @@ -0,0 +1,51 @@ +/* + * The main function and everything related to starting the application + */ + +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <pthread.h> + +#include "inc-gen/system.h" +#include "inc/CanConnector.h" +#include "inc/Gamepad.h" +#include "inc/PWM.h" + +#define PARAM_MAXCMP 5 +#define PARAM_MASTER "master" +#define PARAM_SLAVE "slave" + +int main(int argc, char* argv[]) { + // init the system + initialize_system(); + + // start a gamepad thread + pthread_t pt_gamepad; + pthread_create(&pt_gamepad, NULL, gp_worker, NULL); + + // start a pwm thread + pthread_t pt_pwm; + pthread_create(&pt_pwm, NULL, pwm_worker, NULL); + + // MASTER MODE (master as parameter) + if(argc >= 2 && strncmp(argv[1], PARAM_MASTER, PARAM_MAXCMP) == 0) { + // TODO do master stuff + } + + // SLAVE MODE (slave as parameter) + else if(argc >= 2 && strncmp(argv[1], PARAM_SLAVE, PARAM_MAXCMP) == 0) { + // TODO do slave stuff + } + + // DEFAULT MODE (no parameter) + else { + // run endlessly + while(1) { + run_system(); + usleep(1000); + } + } + + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/model/generate-ecore.xml b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/model/generate-ecore.xml new file mode 100644 index 00000000..20bba821 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/model/generate-ecore.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<project name="org.fortiss.af3.platform.raspberry" default="generate-ecore" basedir=".."> + + <property name="model.name" value="raspberry" /> + <property name="model.project" value="org.fortiss.af3.platform.raspberry" /> + + <!-- Classpath Definition --> + <buckminster.valuepath id="project.classpath" value="${fs:project.classpath}" /> + <path id="classpath"> + <path refid="project.classpath"/> + + <!-- add src to the classpath as only the bin directory is in the classpath + and some resources such as the workflow or properties file might not yet + have been copied to the bin directory --> + <pathelement location="src"/> + </path> + + <!-- Generation Tasks --> + <target name="generate-ecore"> + <emf.Ecore2Javaw + model="model/${model.name}.ecore" + genModel="model/${model.name}.genmodel" + modelProject="/${model.project}" + modelProjectFragmentPath="generated-src" + reconcileGenModel="reload"> + </emf.Ecore2Javaw> + </target> +</project> \ No newline at end of file diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/model/raspberry.ecore b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/model/raspberry.ecore new file mode 100644 index 00000000..7dbfc2b5 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/model/raspberry.ecore @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="model" nsURI="http://www.fortiss.org/af3/platform/raspberry" + nsPrefix="org-fortiss-af3-platform-raspberry"> + <eClassifiers xsi:type="ecore:EClass" name="RaspberryPi" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericExecutionUnit"/> + <eClassifiers xsi:type="ecore:EClass" name="CanBus" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericTransmissionUnit"/> + <eClassifiers xsi:type="ecore:EClass" name="CanConnector" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericTransceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="SensorConnector" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="ActuatorConnector" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericTransmitter"/> + <eClassifiers xsi:type="ecore:EClass" name="SensorGamepad" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="SensorIMU" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="SensorLaserRangeFinder" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="SensorLaserScanner" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="ActuatorPWM" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericTransmitter"/> + <eClassifiers xsi:type="ecore:EClass" name="GPI" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="GPO" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericTransmitter"/> + <eClassifiers xsi:type="ecore:EClass" name="WheelEncoder" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eSubpackages name="gamepad" nsURI="http://www.fortiss.org/af3/platform/raspberry/gamepad" + nsPrefix="org-fortiss-af3-platform-raspberry-gamepad"> + <eClassifiers xsi:type="ecore:EClass" name="Button1" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="Button2" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="Button3" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="Button4" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="ButtonL1" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="ButtonR2" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="ButtonL2" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="ButtonR1" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="Left_StickX_Position" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="Left_StickY_Position" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="Right_StickX_Position" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + <eClassifiers xsi:type="ecore:EClass" name="Right_StickY_Position" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//generic/GenericReceiver"/> + </eSubpackages> + <eSubpackages name="annotation" nsURI="http://www.fortiss.org/af3/platform/raspberry/annotation" + nsPrefix="org-fortiss-af3-platform-raspberry-annotation"> + <eClassifiers xsi:type="ecore:EClass" name="Channel" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IAnnotatedSpecification platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IHiddenSpecification"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="channel" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> + </eClassifiers> + </eSubpackages> +</ecore:EPackage> diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/model/raspberry.genmodel b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/model/raspberry.genmodel new file mode 100644 index 00000000..156f41bf --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/model/raspberry.genmodel @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" + xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.fortiss.af3.platform.raspberry/generated-src" + modelPluginID="org.fortiss.af3.platform.raspberry" modelName="Raspberry" importerID="org.eclipse.emf.importer.ecore" + containmentProxies="true" arrayAccessors="true" complianceLevel="7.0" copyrightFields="false" + usedGenPackages="platform:/resource/org.fortiss.tooling.base/model/base.genmodel#//model platform:/resource/org.fortiss.af3.platform/model/platform.genmodel#//model platform:/resource/org.fortiss.tooling.kernel/model/kernel.genmodel#//model"> + <foreignModel>raspberry.ecore</foreignModel> + <genPackages prefix="Model" basePackage="org.fortiss.af3.platform.raspberry" disposableProviderFactory="true" + ecorePackage="raspberry.ecore#/"> + <genClasses ecoreClass="raspberry.ecore#//RaspberryPi"/> + <genClasses ecoreClass="raspberry.ecore#//CanBus"/> + <genClasses ecoreClass="raspberry.ecore#//CanConnector"/> + <genClasses ecoreClass="raspberry.ecore#//SensorConnector"/> + <genClasses ecoreClass="raspberry.ecore#//ActuatorConnector"/> + <genClasses ecoreClass="raspberry.ecore#//SensorGamepad"/> + <genClasses ecoreClass="raspberry.ecore#//SensorIMU"/> + <genClasses ecoreClass="raspberry.ecore#//SensorLaserRangeFinder"/> + <genClasses ecoreClass="raspberry.ecore#//SensorLaserScanner"/> + <genClasses ecoreClass="raspberry.ecore#//ActuatorPWM"/> + <genClasses ecoreClass="raspberry.ecore#//GPI"/> + <genClasses ecoreClass="raspberry.ecore#//GPO"/> + <genClasses ecoreClass="raspberry.ecore#//WheelEncoder"/> + <nestedGenPackages prefix="Gamepad" basePackage="org.fortiss.af3.platform.raspberry.model" + disposableProviderFactory="true" ecorePackage="raspberry.ecore#//gamepad"> + <genClasses ecoreClass="raspberry.ecore#//gamepad/Button1"/> + <genClasses ecoreClass="raspberry.ecore#//gamepad/Button2"/> + <genClasses ecoreClass="raspberry.ecore#//gamepad/Button3"/> + <genClasses ecoreClass="raspberry.ecore#//gamepad/Button4"/> + <genClasses ecoreClass="raspberry.ecore#//gamepad/ButtonL1"/> + <genClasses ecoreClass="raspberry.ecore#//gamepad/ButtonR2"/> + <genClasses ecoreClass="raspberry.ecore#//gamepad/ButtonL2"/> + <genClasses ecoreClass="raspberry.ecore#//gamepad/ButtonR1"/> + <genClasses ecoreClass="raspberry.ecore#//gamepad/Left_StickX_Position"/> + <genClasses ecoreClass="raspberry.ecore#//gamepad/Left_StickY_Position"/> + <genClasses ecoreClass="raspberry.ecore#//gamepad/Right_StickX_Position"/> + <genClasses ecoreClass="raspberry.ecore#//gamepad/Right_StickY_Position"/> + </nestedGenPackages> + <nestedGenPackages prefix="Annotation" basePackage="org.fortiss.af3.platform.raspberry.model" + disposableProviderFactory="true" ecorePackage="raspberry.ecore#//annotation"> + <genClasses ecoreClass="raspberry.ecore#//annotation/Channel"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute raspberry.ecore#//annotation/Channel/channel"/> + </genClasses> + </nestedGenPackages> + </genPackages> +</genmodel:GenModel> diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/plugin.properties b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/plugin.properties new file mode 100644 index 00000000..92e4eb1a --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/plugin.properties @@ -0,0 +1,7 @@ +# <copyright> +# </copyright> +# +# $Id$ + +pluginName = Fortiss AF3 Base Project +providerName = fortiss GmbH diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/plugin.xml b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/plugin.xml new file mode 100644 index 00000000..397e4f32 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/plugin.xml @@ -0,0 +1,433 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.0"?> + +<!-- + <copyright> + </copyright> + + $Id$ +--> + +<plugin> + + <extension point="org.eclipse.emf.ecore.generated_package"> + <!-- @generated raspberry --> + <package + uri="http://www.fortiss.org/af3/platform/raspberry" + class="org.fortiss.af3.platform.raspberry.model.ModelPackage" + genModel="model/raspberry.genmodel"/> + </extension> + + <extension point="org.eclipse.emf.ecore.generated_package"> + <!-- @generated raspberry --> + <package + uri="http://www.fortiss.org/af3/platform/raspberry/gamepad" + class="org.fortiss.af3.platform.raspberry.model.gamepad.GamepadPackage" + genModel="model/raspberry.genmodel"/> + </extension> + + <extension point="org.eclipse.emf.ecore.generated_package"> + <!-- @generated raspberry --> + <package + uri="http://www.fortiss.org/af3/platform/raspberry/annotation" + class="org.fortiss.af3.platform.raspberry.model.annotation.AnnotationPackage" + genModel="model/raspberry.genmodel"/> + </extension> + <extension + point="org.fortiss.tooling.kernel.modelElementCompositor"> + <modelElementCompositor + compositor="org.fortiss.af3.platform.raspberry.compose.RaspberryPiCompositor"> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.RaspberryPi"> + </modelElementClass> + </modelElementCompositor> + <modelElementCompositor + compositor="org.fortiss.af3.platform.raspberry.compose.CanBusCompositor"> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.CanBus"> + </modelElementClass> + </modelElementCompositor> + </extension> + <extension + point="org.fortiss.tooling.kernel.modelConnectionCompositor"> + <modelConnectionCompositor + modelConnectionCompositor="org.fortiss.af3.platform.raspberry.compose.RaspberryToCanCompositor"> + <source> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.CanConnector"> + </modelElementClass> + </source> + <target> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.CanConnector"> + </modelElementClass> + </target> + </modelConnectionCompositor> + <modelConnectionCompositor + modelConnectionCompositor="org.fortiss.af3.platform.raspberry.compose.CanToRaspberryCompositor"> + <source> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.CanConnector"> + </modelElementClass> + </source> + <target> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.CanConnector"> + </modelElementClass> + </target> + </modelConnectionCompositor> + </extension> + <extension + point="org.fortiss.tooling.kernel.transformationProvider"> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.RaspberryPITransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.RaspberryPi"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.RaspberryPIExecutable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.CanConnectorTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.CanConnector"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.CanConnectorExecutable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.IMUSensorTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.SensorIMU"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.IMUSensorExecutable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.LaserRangeFinderSensorTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.SensorLaserRangeFinder"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.LaserRangeFinderSensorExecutable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.LaserScannerSensorTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.SensorLaserScanner"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.LaserScannerSensorExecutable"> + </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.CanBusTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.CanBus"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.CanBusExecutable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.GamepadSensorTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.SensorGamepad"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.GamepadSensorExecutable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.CanBusTransmissionCatalogTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.CanBus"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.CanTransmissionCatalog"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.CanConnectorTransmissionCatalogTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.CanConnector"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.CanTransmissionCatalog"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.GPITransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.GPI"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.GPIExecutable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.GPOTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.GPO"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.GPOExecutable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.gamepad.Button1Transformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.gamepad.Button1"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Button1Executable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.gamepad.Button2Transformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.gamepad.Button2"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Button2Executable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.gamepad.Button3Transformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.gamepad.Button3"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Button3Executable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.gamepad.Button4Transformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.gamepad.Button4"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Button4Executable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.gamepad.ButtonL1Transformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.gamepad.ButtonL1"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.gamepad.ButtonL1Executable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.gamepad.ButtonL2Transformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.gamepad.ButtonL2"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.gamepad.ButtonL2Executable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.gamepad.ButtonR1Transformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.gamepad.ButtonR1"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.gamepad.ButtonR1Executable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.gamepad.ButtonR2Transformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.gamepad.ButtonR2"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.gamepad.ButtonR2Executable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.gamepad.Left_StickXTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.gamepad.Left_StickX_Position"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Left_StickXExecutable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.gamepad.Left_StickYTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.gamepad.Left_StickY_Position"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Left_StickYExecutable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.gamepad.Right_StickXTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.gamepad.Right_StickX_Position"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Right_StickXExecutable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.gamepad.Right_StickYTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.gamepad.Right_StickY_Position"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Right_StickYExecutable"> + </objectClass> + </target> + </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.WheelEncoderTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.WheelEncoder"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.WheelEncoderExecutable"> + </objectClass> + </target> + </transformationProvider> + </extension> + <extension + point="org.fortiss.tooling.base.annotation"> + <annotation + binding="org.fortiss.af3.platform.annotation.valueprovider.GPIOPinNumberValueProvider"> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.GPI"> + </modelElementClass> + </annotation> + <annotation + binding="org.fortiss.af3.platform.annotation.valueprovider.GPIOPinNumberValueProvider"> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.GPO"> + </modelElementClass> + </annotation> + <annotation + binding="org.fortiss.af3.platform.raspberry.annotation.PWMChannelNumberValueProvider"> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.ActuatorPWM"> + </modelElementClass> + </annotation> + </extension> + + + + +</plugin> diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/pom.xml b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/pom.xml new file mode 100644 index 00000000..3622f7b7 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/pom.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + $Id$ + @version $Rev$ + @ConQAT.Rating RED Hash: E1674C4A6DD3CBC4A7B7E85232D9695F +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.fortiss.af3</groupId> + <artifactId>org.fortiss.af3.platform.raspberry</artifactId> + <packaging>eclipse-plugin</packaging> + + <parent> + <groupId>org.fortiss.std.pom</groupId> + <artifactId>std-parent-pom-indigo</artifactId> + <version>1.0</version> + <relativePath>../fortiss-std-env/maven-build/pom.xml</relativePath> + </parent> + + <version>2.9.0-SNAPSHOT</version> +</project> \ No newline at end of file diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/AF3PlatformRaspberryActivator.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/AF3PlatformRaspberryActivator.java new file mode 100644 index 00000000..8a4cd244 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/AF3PlatformRaspberryActivator.java @@ -0,0 +1,40 @@ +package org.fortiss.af3.platform.raspberry; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle. + */ +public class AF3PlatformRaspberryActivator extends Plugin { + + /** The plug-in ID. */ + public static final String PLUGIN_ID = AF3PlatformRaspberryActivator.class.getPackage().getName(); //$NON-NLS-1$ + + /** The shared instance. */ + private static AF3PlatformRaspberryActivator plugin; + + /** Constructor. */ + public AF3PlatformRaspberryActivator() { + // do nothing + } + + /** {@inheritDoc} */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /** {@inheritDoc} */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** Returns the shared instance. */ + public static AF3PlatformRaspberryActivator getDefault() { + return plugin; + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/annotation/PWMChannelNumberValueProvider.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/annotation/PWMChannelNumberValueProvider.java new file mode 100644 index 00000000..13abd5eb --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/annotation/PWMChannelNumberValueProvider.java @@ -0,0 +1,48 @@ +/*--------------------------------------------------------------------------+ +$Id: GPIOPinNumberValueProvider.java 15846 2016-02-02 09:14:08Z zverlov $ +| | +| Copyright 2015 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.annotation; + +import org.fortiss.af3.platform.model.Transceiver; +import org.fortiss.af3.platform.raspberry.model.annotation.AnnotationPackage; +import org.fortiss.af3.platform.raspberry.model.annotation.Channel; +import org.fortiss.tooling.base.annotation.valueprovider.EStructuralFeatureValueProviderBase; +import org.fortiss.tooling.base.annotation.valueprovider.IAnnotationValueProvider; + +/** + * {@link IAnnotationValueProvider} that allows to annotate a Pin Number of a GPIO + * {@link Transceiver} used in PikeOS Platform. + * + * @author chaudhary + * @author $Author: zverlov $ + * @version $Rev: 15846 $ + * @ConQAT.Rating GREEN Hash: C69EECC82FF9912335C19FC6A5CD6996 + */ + +public class PWMChannelNumberValueProvider extends EStructuralFeatureValueProviderBase<Channel> { + + /** Constructor. */ + public PWMChannelNumberValueProvider() { + super(AnnotationPackage.Literals.CHANNEL, AnnotationPackage.Literals.CHANNEL__CHANNEL); + } + + /** {@inheritDoc} */ + @Override + public String getAnnotationName(Channel specification) { + return "PWM Channel"; + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/CanBusCompositor.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/CanBusCompositor.java new file mode 100644 index 00000000..1a3e29f9 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/CanBusCompositor.java @@ -0,0 +1,51 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.compose; + +import static org.conqat.lib.commons.reflect.ReflectionUtils.isInstanceOfAny; + +import org.eclipse.emf.ecore.EObject; +import org.fortiss.af3.platform.compose.PlatformArchitectureElementCompositorBase; +import org.fortiss.af3.platform.model.IPlatformArchitectureElement; +import org.fortiss.af3.platform.raspberry.model.CanBus; +import org.fortiss.af3.platform.raspberry.model.CanConnector; + +/** + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class CanBusCompositor extends + PlatformArchitectureElementCompositorBase<IPlatformArchitectureElement> { + + /** {@inheritDoc} */ + @Override + protected boolean isCorrectElementClass(IPlatformArchitectureElement container, + EObject contained) { + final boolean instanceOfAny = isInstanceOfAny(contained, CanConnector.class); + if(container != null) { + final boolean instanceOfAny2 = isInstanceOfAny(container, CanBus.class); + return instanceOfAny2 && + instanceOfAny; + } + return instanceOfAny; + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/CanToRaspberryCompositor.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/CanToRaspberryCompositor.java new file mode 100644 index 00000000..ef580fef --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/CanToRaspberryCompositor.java @@ -0,0 +1,99 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.compose; + +import static org.fortiss.af3.platform.utils.PlatformModelElementFactory.createTransmissionConnection; + +import org.eclipse.emf.ecore.EObject; +import org.fortiss.af3.platform.model.TransmissionConnection; +import org.fortiss.af3.platform.raspberry.model.CanBus; +import org.fortiss.af3.platform.raspberry.model.CanConnector; +import org.fortiss.af3.platform.raspberry.model.RaspberryPi; +import org.fortiss.tooling.base.model.element.IHierarchicElement; +import org.fortiss.tooling.kernel.extension.IConnectionCompositor; +import org.fortiss.tooling.kernel.extension.data.IConnectionCompositionContext; + +/** + * Connection compositor for {@link RaspberryPi} to {@link CanBus} connections. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class CanToRaspberryCompositor implements + IConnectionCompositor<IHierarchicElement, CanConnector, CanConnector> { + + /** {@inheritDoc} */ + @Override + public boolean canConnect(CanConnector source, CanConnector target, IHierarchicElement parent, + IConnectionCompositionContext context) { + if(source.getOwner() instanceof CanBus && target.getOwner() instanceof RaspberryPi) { + return source.getOutgoing().isEmpty(); + } + return false; + } + + /** {@inheritDoc} */ + @Override + public boolean connect(CanConnector source, CanConnector target, IHierarchicElement parent, + IConnectionCompositionContext context) { + createTransmissionConnection(parent, source, target); + return true; + } + + /** {@inheritDoc} */ + @Override + public boolean canReconnect(EObject connection, CanConnector source, CanConnector target, + IConnectionCompositionContext context) { + // TODO Auto-generated method stub + return false; + } + + /** {@inheritDoc} */ + @Override + public boolean reconnect(EObject connection, CanConnector source, CanConnector target, + IConnectionCompositionContext context) { + // TODO Auto-generated method stub + return false; + } + + /** {@inheritDoc} */ + @Override + public boolean canDisconnect(EObject connection) { + if(connection instanceof TransmissionConnection) { + TransmissionConnection c = (TransmissionConnection)connection; + return c.getSource() instanceof CanConnector && c.getTarget() instanceof CanConnector; + } + return false; + } + + /** {@inheritDoc} */ + @Override + public boolean disconnect(EObject connection) { + if(connection instanceof TransmissionConnection) { + TransmissionConnection tcon = ((TransmissionConnection)connection); + tcon.setOwner(null); + tcon.setSource(null); + tcon.setTarget(null); + return true; + } + return false; + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/RaspberryPiCompositor.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/RaspberryPiCompositor.java new file mode 100644 index 00000000..7a6d8b6e --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/RaspberryPiCompositor.java @@ -0,0 +1,79 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.compose; + +import static org.conqat.lib.commons.reflect.ReflectionUtils.isInstanceOfAny; + +import org.eclipse.emf.ecore.EObject; +import org.fortiss.af3.platform.compose.PlatformArchitectureElementCompositorBase; +import org.fortiss.af3.platform.model.IPlatformArchitectureElement; +import org.fortiss.af3.platform.raspberry.model.ActuatorConnector; +import org.fortiss.af3.platform.raspberry.model.ActuatorPWM; +import org.fortiss.af3.platform.raspberry.model.CanConnector; +import org.fortiss.af3.platform.raspberry.model.GPI; +import org.fortiss.af3.platform.raspberry.model.GPO; +import org.fortiss.af3.platform.raspberry.model.RaspberryPi; +import org.fortiss.af3.platform.raspberry.model.SensorConnector; +import org.fortiss.af3.platform.raspberry.model.SensorIMU; +import org.fortiss.af3.platform.raspberry.model.SensorLaserRangeFinder; +import org.fortiss.af3.platform.raspberry.model.SensorLaserScanner; +import org.fortiss.af3.platform.raspberry.model.WheelEncoder; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button1; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button2; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button3; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button4; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonL1; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonL2; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonR1; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonR2; +import org.fortiss.af3.platform.raspberry.model.gamepad.Left_StickX_Position; +import org.fortiss.af3.platform.raspberry.model.gamepad.Left_StickY_Position; +import org.fortiss.af3.platform.raspberry.model.gamepad.Right_StickX_Position; +import org.fortiss.af3.platform.raspberry.model.gamepad.Right_StickY_Position; + +/** + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class RaspberryPiCompositor extends + PlatformArchitectureElementCompositorBase<IPlatformArchitectureElement> { + + /** {@inheritDoc} */ + @Override + protected boolean isCorrectElementClass(IPlatformArchitectureElement container, + EObject contained) { + + final boolean instanceOfAny2 = + isInstanceOfAny(contained, CanConnector.class, SensorConnector.class, + ActuatorConnector.class, ActuatorPWM.class, SensorLaserRangeFinder.class, + SensorLaserScanner.class, SensorIMU.class, GPI.class, GPO.class, + Button1.class, Button2.class, Button3.class, Button4.class, ButtonL1.class, + ButtonL2.class, ButtonR1.class, ButtonR2.class, Left_StickX_Position.class, + Left_StickY_Position.class, Right_StickX_Position.class, + Right_StickY_Position.class, WheelEncoder.class); + if(container != null) { + final boolean instanceOfAny = isInstanceOfAny(container, RaspberryPi.class); + return instanceOfAny && instanceOfAny2; + } + return instanceOfAny2; + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/RaspberryToCanCompositor.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/RaspberryToCanCompositor.java new file mode 100644 index 00000000..7c18a6de --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/compose/RaspberryToCanCompositor.java @@ -0,0 +1,99 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.compose; + +import static org.fortiss.af3.platform.utils.PlatformModelElementFactory.createTransmissionConnection; + +import org.eclipse.emf.ecore.EObject; +import org.fortiss.af3.platform.model.TransmissionConnection; +import org.fortiss.af3.platform.raspberry.model.CanBus; +import org.fortiss.af3.platform.raspberry.model.CanConnector; +import org.fortiss.af3.platform.raspberry.model.RaspberryPi; +import org.fortiss.tooling.base.model.element.IHierarchicElement; +import org.fortiss.tooling.kernel.extension.IConnectionCompositor; +import org.fortiss.tooling.kernel.extension.data.IConnectionCompositionContext; + +/** + * Connection compositor for {@link RaspberryPi} to {@link CanBus} connections. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class RaspberryToCanCompositor implements + IConnectionCompositor<IHierarchicElement, CanConnector, CanConnector> { + + /** {@inheritDoc} */ + @Override + public boolean canConnect(CanConnector source, CanConnector target, IHierarchicElement parent, + IConnectionCompositionContext context) { + if(source.getOwner() instanceof RaspberryPi && target.getOwner() instanceof CanBus) { + return source.getOutgoing().isEmpty(); + } + return false; + } + + /** {@inheritDoc} */ + @Override + public boolean connect(CanConnector source, CanConnector target, IHierarchicElement parent, + IConnectionCompositionContext context) { + createTransmissionConnection(parent, source, target); + return true; + } + + /** {@inheritDoc} */ + @Override + public boolean canReconnect(EObject connection, CanConnector source, CanConnector target, + IConnectionCompositionContext context) { + // TODO Auto-generated method stub + return false; + } + + /** {@inheritDoc} */ + @Override + public boolean reconnect(EObject connection, CanConnector source, CanConnector target, + IConnectionCompositionContext context) { + // TODO Auto-generated method stub + return false; + } + + /** {@inheritDoc} */ + @Override + public boolean canDisconnect(EObject connection) { + if(connection instanceof TransmissionConnection) { + TransmissionConnection c = (TransmissionConnection)connection; + return c.getSource() instanceof CanConnector && c.getTarget() instanceof CanConnector; + } + return false; + } + + /** {@inheritDoc} */ + @Override + public boolean disconnect(EObject connection) { + if(connection instanceof TransmissionConnection) { + TransmissionConnection tcon = ((TransmissionConnection)connection); + tcon.setOwner(null); + tcon.setSource(null); + tcon.setTarget(null); + return true; + } + return false; + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/CanBusExecutable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/CanBusExecutable.java new file mode 100644 index 00000000..d8f0d797 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/CanBusExecutable.java @@ -0,0 +1,55 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 java.util.List; +import java.util.Map; + +import org.fortiss.af3.component.model.Component; +import org.fortiss.af3.component.model.Port; +import org.fortiss.af3.generator.common.model.source.SourcePackage; +import org.fortiss.af3.platform.language.executable.TransmissionUnitExecutableBase; +import org.fortiss.af3.platform.model.ExecutionUnit; +import org.fortiss.af3.platform.model.TransmissionUnit; +import org.fortiss.af3.platform.raspberry.model.CanBus; + +/** + * Executable for {@link CanBus}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class CanBusExecutable extends TransmissionUnitExecutableBase<TransmissionUnit> { + + /** Constructor. */ + public CanBusExecutable(TransmissionUnit modelElement) { + super(modelElement); + // no functionality as of now + } + + /** {@inheritDoc} */ + @Override + public void createAllFiles(SourcePackage pack, Map<ExecutionUnit, List<Port>> euPortsPair, + Map<ExecutionUnit, List<Component>> euComponentList, Component topComponent, + int deploymentID) { + // no functionality as of now + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/CanConnectorExecutable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/CanConnectorExecutable.java new file mode 100644 index 00000000..b69b60a7 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/CanConnectorExecutable.java @@ -0,0 +1,115 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.rawString; + +import org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.component.model.OutputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.expression.model.terms.RawString; +import org.fortiss.af3.expression.model.types.TBool; +import org.fortiss.af3.expression.model.types.TDouble; +import org.fortiss.af3.expression.model.types.TInt; +import org.fortiss.af3.platform.generic.generator.executable.GenericTransceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericTransceiver; +import org.fortiss.af3.platform.raspberry.model.CanConnector; + +/** + * Executable for {@link CanConnector}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class CanConnectorExecutable extends GenericTransceiverExecutable { + + /** Constructor. */ + public CanConnectorExecutable(GenericTransceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + // init CAN bus on the given interface + return funcCall("can_init"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + // check for NOVAL on the given signal port + return funcCall("can_is_noval", literalString(logicalSignal.getName())); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValWriteAccessor(OutputPort logicalSignal) { + // set NOVAL on the given signal port + return funcCall("can_set_noval", literalString(logicalSignal.getName())); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + // terminate the bus on the given interface + return funcCall("can_term"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + // read the value on the given signal port depending on the variable type + if(logicalSignal.getVariableType() instanceof TBool) { + return funcCall("can_read_bool", literalString(logicalSignal.getName())); + } else if(logicalSignal.getVariableType() instanceof TDouble) { + return funcCall("can_read_double", literalString(logicalSignal.getName())); + } else if(logicalSignal.getVariableType() instanceof TInt) { + return funcCall("can_read_int", literalString(logicalSignal.getName())); + } else { + throw new RuntimeException("unknown data type: " + + logicalSignal.getVariableType().getTypeClassName()); + } + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueWriteAccessor(OutputPort logicalSignal, IExpressionTerm value) { + // write the value on the given signal port depending on the variable type + if(logicalSignal.getVariableType() instanceof TBool) { + return funcCall("can_write_bool", literalString(logicalSignal.getName()), value); + } else if(logicalSignal.getVariableType() instanceof TDouble) { + return funcCall("can_write_double", literalString(logicalSignal.getName()), value); + } else if(logicalSignal.getVariableType() instanceof TInt) { + return funcCall("can_write_int", literalString(logicalSignal.getName()), value); + } else { + throw new RuntimeException("unknown data type: " + + logicalSignal.getVariableType().getTypeClassName()); + } + } + + /** + * builds a constant literal C string including double quotes + */ + private RawString literalString(String str) { + return rawString("\"" + str + "\""); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/CanTransmissionCatalog.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/CanTransmissionCatalog.java new file mode 100644 index 00000000..8f3a64fd --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/CanTransmissionCatalog.java @@ -0,0 +1,55 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 java.util.ArrayList; +import java.util.List; + +import org.fortiss.af3.deployment.generator.DeploymentExecutableTransformationContext; +import org.fortiss.af3.deployment.generator.Transmission; +import org.fortiss.af3.deployment.generator.TransmissionCatalog; +import org.fortiss.af3.generator.common.model.c.CSourcePackage; + +/** + * Can Transmission Catalog + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class CanTransmissionCatalog extends TransmissionCatalog { + + /** Stores the transmissions contained in this catalog. */ + private final List<Transmission> transmissions = new ArrayList<Transmission>(); + + /** Adds the given transmission to the catalog. */ + @Override + public void addTransmission(Transmission transmission) { + transmissions.add(transmission); + } + + /** + * Here the one can create additional SourcePackages which are common for all ECUs. + * It won't be used in the current release. + */ + @Override + public CSourcePackage getSourcePackage(DeploymentExecutableTransformationContext ctx) { + return null; + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/GPIExecutable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/GPIExecutable.java new file mode 100644 index 00000000..5d6b311d --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/GPIExecutable.java @@ -0,0 +1,73 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.intConst; + +import org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.annotation.GPIOPin; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.GPI; +import org.fortiss.tooling.base.utils.AnnotationUtils; + +/** + * Executable for {@link GPI}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class GPIExecutable extends GenericReceiverExecutable { + + /** Constructor. */ + public GPIExecutable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("gpio_init_in", intConst(getPinFromModelElement(modelElement))); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return funcCall("gpio_is_noval", intConst(getPinFromModelElement(modelElement))); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("gpio_term", intConst(getPinFromModelElement(modelElement))); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("gpio_read", intConst(getPinFromModelElement(modelElement))); + } + + private static int getPinFromModelElement(GenericReceiver modelElement) { + return AnnotationUtils.getAnnotation(modelElement, GPIOPin.class).getPinNumber(); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/GPOExecutable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/GPOExecutable.java new file mode 100644 index 00000000..a64a68c0 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/GPOExecutable.java @@ -0,0 +1,73 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.intConst; + +import org.fortiss.af3.component.model.OutputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericTransmitterExecutable; +import org.fortiss.af3.platform.model.annotation.GPIOPin; +import org.fortiss.af3.platform.model.generic.GenericTransmitter; +import org.fortiss.af3.platform.raspberry.model.GPO; +import org.fortiss.tooling.base.utils.AnnotationUtils; + +/** + * Executable for {@link GPO}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class GPOExecutable extends GenericTransmitterExecutable { + + /** Constructor. */ + public GPOExecutable(GenericTransmitter modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("gpio_init_out", intConst(getPinFromModelElement(modelElement))); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValWriteAccessor(OutputPort logicalSignal) { + return funcCall("gpio_set_noval", intConst(getPinFromModelElement(modelElement))); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("gpio_term", intConst(getPinFromModelElement(modelElement))); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueWriteAccessor(OutputPort logicalSignal, IExpressionTerm value) { + return funcCall("gpio_write", intConst(getPinFromModelElement(modelElement)), value); + } + + private static int getPinFromModelElement(GenericTransmitter modelElement) { + return AnnotationUtils.getAnnotation(modelElement, GPIOPin.class).getPinNumber(); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/GamepadSensorExecutable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/GamepadSensorExecutable.java new file mode 100644 index 00000000..f335e8ec --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/GamepadSensorExecutable.java @@ -0,0 +1,64 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.SensorIMU; + +/** + * Executable for {@link SensorIMU}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class GamepadSensorExecutable extends GenericReceiverExecutable { + + /** Constructor. */ + public GamepadSensorExecutable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return super.getInitialization(); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return super.getNoValGuardAccessor(logicalSignal); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return super.getTermination(); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return super.getValueReadAccessor(logicalSignal); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/IMUSensorExecutable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/IMUSensorExecutable.java new file mode 100644 index 00000000..bec3e38f --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/IMUSensorExecutable.java @@ -0,0 +1,64 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.SensorIMU; + +/** + * Executable for {@link SensorIMU}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class IMUSensorExecutable extends GenericReceiverExecutable { + + /** Constructor. */ + public IMUSensorExecutable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return super.getInitialization(); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return super.getNoValGuardAccessor(logicalSignal); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return super.getTermination(); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return super.getValueReadAccessor(logicalSignal); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/LaserRangeFinderSensorExecutable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/LaserRangeFinderSensorExecutable.java new file mode 100644 index 00000000..6fa57e26 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/LaserRangeFinderSensorExecutable.java @@ -0,0 +1,66 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.SensorLaserRangeFinder; + +/** + * Executable for {@link SensorLaserRangeFinder}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class LaserRangeFinderSensorExecutable extends GenericReceiverExecutable { + + /** Constructor. */ + public LaserRangeFinderSensorExecutable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("lrf_init"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return funcCall("lrf_is_noval"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("lrf_term"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("lrf_read"); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/LaserScannerSensorExecutable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/LaserScannerSensorExecutable.java new file mode 100644 index 00000000..5c64931b --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/LaserScannerSensorExecutable.java @@ -0,0 +1,64 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.SensorLaserScanner; + +/** + * Executable for {@link SensorLaserScanner}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class LaserScannerSensorExecutable extends GenericReceiverExecutable { + + /** Constructor. */ + public LaserScannerSensorExecutable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return super.getInitialization(); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return super.getNoValGuardAccessor(logicalSignal); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return super.getTermination(); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return super.getValueReadAccessor(logicalSignal); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/PWMActuatorExecutable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/PWMActuatorExecutable.java new file mode 100644 index 00000000..34c1cb46 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/PWMActuatorExecutable.java @@ -0,0 +1,73 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.intConst; + +import org.fortiss.af3.component.model.OutputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericTransmitterExecutable; +import org.fortiss.af3.platform.model.generic.GenericTransmitter; +import org.fortiss.af3.platform.raspberry.model.ActuatorPWM; +import org.fortiss.af3.platform.raspberry.model.annotation.Channel; +import org.fortiss.tooling.base.utils.AnnotationUtils; + +/** + * Executable for {@link ActuatorPWM}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class PWMActuatorExecutable extends GenericTransmitterExecutable { + + /** Constructor. */ + public PWMActuatorExecutable(GenericTransmitter modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("pwm_init", intConst(getPWMChannelFromModelElement(modelElement))); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValWriteAccessor(OutputPort logicalSignal) { + return funcCall("pwm_set_noval", intConst(getPWMChannelFromModelElement(modelElement))); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("pwm_term", intConst(getPWMChannelFromModelElement(modelElement))); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueWriteAccessor(OutputPort logicalSignal, IExpressionTerm value) { + return funcCall("pwm_write", intConst(getPWMChannelFromModelElement(modelElement)), value); + } + + private int getPWMChannelFromModelElement(GenericTransmitter modelElement) { + return AnnotationUtils.getAnnotation(modelElement, Channel.class).getChannel(); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPIExecutable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPIExecutable.java new file mode 100644 index 00000000..920e0922 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPIExecutable.java @@ -0,0 +1,207 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.generator.common.utils.CLanguageModelElementFacade.addUserHeaderInclude; +import static org.fortiss.af3.generator.common.utils.SourceModelElementFactory.createByteContentUnitForPluginFile; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Set; + +import org.conqat.lib.commons.collections.Pair; +import org.fortiss.af3.component.model.Component; +import org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.component.model.OutputPort; +import org.fortiss.af3.component.model.Port; +import org.fortiss.af3.component.model.generator.ComponentFunction; +import org.fortiss.af3.component.model.generator.LocalFunction; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.expression.model.terms.imperative.IStatementTerm; +import org.fortiss.af3.generator.common.model.c.CSourcePackage; +import org.fortiss.af3.generator.common.model.source.SourceUnit; +import org.fortiss.af3.platform.generic.generator.executable.GenericExecutionUnitExecutable; +import org.fortiss.af3.platform.language.executable.IInitializableExecutable; +import org.fortiss.af3.platform.language.executable.IReadableExecutable; +import org.fortiss.af3.platform.language.executable.ITerminatableExecutable; +import org.fortiss.af3.platform.language.executable.IWritableExecutable; +import org.fortiss.af3.platform.model.ExecutionUnit; +import org.fortiss.af3.platform.model.PlatformConnectorUnit; +import org.fortiss.af3.platform.model.generic.GenericTransceiver; +import org.fortiss.af3.platform.raspberry.AF3PlatformRaspberryActivator; +import org.fortiss.af3.platform.raspberry.model.RaspberryPi; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * {@link IInitializableExecutable} and {@link ITerminatableExecutable} for the {@link RaspberryPi} + * platform. + * + * + * @author eder + * @author $Author: eder $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class RaspberryPIExecutable extends GenericExecutionUnitExecutable { + + private static final String SRC_LIB_SUB_PACKAGE_NAME = "src-lib"; + private static final String INC_LIB_SUB_PACKAGE_NAME = "inc-lib"; + + /** Constructor. */ + public RaspberryPIExecutable(ExecutionUnit modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + protected CSourcePackage createExecutionUnitSourcePackage(String name, + List<Pair<ExecutionUnit, Component>> deployedComponents, + List<Pair<PlatformConnectorUnit, Port>> deployedPorts, ITransformationContext context) { + + CSourcePackage pkg = + super.createExecutionUnitSourcePackage(name, deployedComponents, deployedPorts, + context); + + // get system.h to add references to self-defined inc files + SourceUnit system = pkg.getSrcGenPackage().findSourceUnitByName("system.c"); + + // Add source/header files here to be copied into the deployment directory + try { + /** COMPONENTS **/ + + addFile(pkg, "src/main.c"); + + // reference is added by GenericExecutableBase -> only add file + addFile(pkg, "inc/io.h"); + addFile(pkg, "src/io.c"); + + // add all components including references + addFilesWithReference(pkg, system, "CanConnector"); + addFilesWithReference(pkg, system, "Gamepad"); + addFilesWithReference(pkg, system, "GPIO"); + addFilesWithReference(pkg, system, "IMU"); + addFilesWithReference(pkg, system, "LaserRangeFinder"); + addFilesWithReference(pkg, system, "LaserScanner"); + addFilesWithReference(pkg, system, "PWM"); + + /** LIBRARIES **/ + + // add UART lib + addFile(pkg, "inc/libuart.h"); + addFile(pkg, "src/libuart.c"); + addFile(pkg, "inc/libmaestro.h"); + addFile(pkg, "src/libmaestro.c"); + addFile(pkg, "inc/libcansocket.h"); + addFile(pkg, "src/libcansocket.c"); + + /** FIXES AND PATCHES **/ + + // overwrite data_dictionary, the new one has all functions + // required for the simulation commented out so there are no + // conflicts + addFile(pkg, "inc-gen/data_dictionary.h"); + addFile(pkg, "src-gen/data_dictionary.c"); + + // overwrite Makedefs, the new one uses -std=gnu99 instead of -std=c99 + // so libuart compiles properly + addFile(pkg, "Makedefs"); + + } catch(IOException | URISyntaxException e) { + throw new RuntimeException("could not add header and source files from lib", e); + } + + return pkg; + } + + private static void addFilesWithReference(CSourcePackage pkg, SourceUnit source, + String fileWithoutExtension) throws IOException, URISyntaxException { + addFile(pkg, "src/" + fileWithoutExtension + ".c"); + addFile(pkg, "inc/" + fileWithoutExtension + ".h"); + addSystemCReference(source, fileWithoutExtension); + } + + private static void addFile(CSourcePackage pkg, String file) throws IOException, + URISyntaxException { + pkg.addUnit(createByteContentUnitForPluginFile(AF3PlatformRaspberryActivator.PLUGIN_ID, + "lib", file, false)); + } + + private static void addSystemCReference(SourceUnit source, String reference) { + addUserHeaderInclude(source, reference); + } + + /** {@inheritDoc} */ + @Override + protected ComponentFunction createInitializeFunction( + List<Pair<ExecutionUnit, Component>> deployedComponents, + Set<PlatformConnectorUnit> usedUnits) { + return super.createInitializeFunction(deployedComponents, usedUnits); + } + + /** {@inheritDoc} */ + @Override + protected void + createReadAccess(IReadableExecutable exec, InputPort p, List<IStatementTerm> body) { + super.createReadAccess(exec, p, body); + } + + /** {@inheritDoc} */ + @Override + protected LocalFunction createReadInputFunction( + List<Pair<PlatformConnectorUnit, Port>> deployedPorts, + Set<GenericTransceiver> usedTransceivers) { + return super.createReadInputFunction(deployedPorts, usedTransceivers); + } + + /** {@inheritDoc} */ + @Override + protected ComponentFunction createStepFunction( + List<Pair<ExecutionUnit, Component>> deployedComponents, + List<Pair<PlatformConnectorUnit, Port>> deployedPorts, + Set<GenericTransceiver> usedTransceivers) { + return super.createStepFunction(deployedComponents, deployedPorts, usedTransceivers); + } + + /** {@inheritDoc} */ + @Override + protected LocalFunction createTerminationFunction(Set<PlatformConnectorUnit> usedUnits) { + return super.createTerminationFunction(usedUnits); + } + + /** {@inheritDoc} */ + @Override + protected void createWriteAccess(IWritableExecutable exec, OutputPort p, + List<IStatementTerm> body) { + super.createWriteAccess(exec, p, body); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("init_raspberryPI_ecu"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("term_raspberryPI_ecu"); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/WheelEncoderExecutable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/WheelEncoderExecutable.java new file mode 100644 index 00000000..5da6e0d0 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/WheelEncoderExecutable.java @@ -0,0 +1,39 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.raspberry.model.SensorLaserRangeFinder; +import org.fortiss.af3.platform.raspberry.model.WheelEncoder; + +/** + * Executable for {@link SensorLaserRangeFinder}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class WheelEncoderExecutable extends GenericReceiverExecutable { + + /** Constructor. */ + public WheelEncoderExecutable(WheelEncoder modelElement) { + super(modelElement); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button1Executable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button1Executable.java new file mode 100644 index 00000000..bb216285 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button1Executable.java @@ -0,0 +1,66 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button1; + +/** + * Executable for {@link Button1}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Button1Executable extends GenericReceiverExecutable { + + /** Constructor. */ + public Button1Executable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("gp_init"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return funcCall("gp_btn1_is_noval"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("gp_term"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("gp_btn1_read"); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button2Executable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button2Executable.java new file mode 100644 index 00000000..4926a0a5 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button2Executable.java @@ -0,0 +1,66 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button2; + +/** + * Executable for {@link Button2}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Button2Executable extends GenericReceiverExecutable { + + /** Constructor. */ + public Button2Executable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("gp_init"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return funcCall("gp_btn2_is_noval"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("gp_term"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("gp_btn2_read"); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button3Executable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button3Executable.java new file mode 100644 index 00000000..75c8149e --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button3Executable.java @@ -0,0 +1,66 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button3; + +/** + * Executable for {@link Button3}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Button3Executable extends GenericReceiverExecutable { + + /** Constructor. */ + public Button3Executable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("gp_init"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return funcCall("gp_btn3_is_noval"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("gp_term"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("gp_btn3_read"); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button4Executable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button4Executable.java new file mode 100644 index 00000000..b8f99e8c --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Button4Executable.java @@ -0,0 +1,66 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button4; + +/** + * Executable for {@link Button4}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Button4Executable extends GenericReceiverExecutable { + + /** Constructor. */ + public Button4Executable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("gp_init"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return funcCall("gp_btn4_is_noval"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("gp_term"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("gp_btn4_read"); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL1Executable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL1Executable.java new file mode 100644 index 00000000..3fb2b780 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL1Executable.java @@ -0,0 +1,66 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonL1; + +/** + * Executable for {@link ButtonL1}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class ButtonL1Executable extends GenericReceiverExecutable { + + /** Constructor. */ + public ButtonL1Executable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("gp_init"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return funcCall("gp_btnL1_is_noval"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("gp_term"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("gp_btnL1_read"); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL2Executable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL2Executable.java new file mode 100644 index 00000000..0e5a0645 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonL2Executable.java @@ -0,0 +1,66 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonL2; + +/** + * Executable for {@link ButtonL2}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class ButtonL2Executable extends GenericReceiverExecutable { + + /** Constructor. */ + public ButtonL2Executable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("gp_init"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return funcCall("gp_btnL2_is_noval"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("gp_term"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("gp_btnL2_read"); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR1Executable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR1Executable.java new file mode 100644 index 00000000..4761f167 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR1Executable.java @@ -0,0 +1,66 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonR1; + +/** + * Executable for {@link ButtonR1}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class ButtonR1Executable extends GenericReceiverExecutable { + + /** Constructor. */ + public ButtonR1Executable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("gp_init"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return funcCall("gp_btnR1_is_noval"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("gp_term"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("gp_btnR1_read"); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR2Executable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR2Executable.java new file mode 100644 index 00000000..59d42182 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/ButtonR2Executable.java @@ -0,0 +1,66 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonL2; + +/** + * Executable for {@link ButtonL2}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class ButtonR2Executable extends GenericReceiverExecutable { + + /** Constructor. */ + public ButtonR2Executable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("gp_init"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return funcCall("gp_btnR2_is_noval"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("gp_term"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("gp_btnR2_read"); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickXExecutable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickXExecutable.java new file mode 100644 index 00000000..c2d30bc1 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickXExecutable.java @@ -0,0 +1,66 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.gamepad.Left_StickX_Position; + +/** + * Executable for {@link Left_StickX_Position}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Left_StickXExecutable extends GenericReceiverExecutable { + + /** Constructor. */ + public Left_StickXExecutable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("gp_init"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return funcCall("gp_btnLX_is_noval"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("gp_term"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("gp_btnLX_read"); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickYExecutable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickYExecutable.java new file mode 100644 index 00000000..8516209e --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Left_StickYExecutable.java @@ -0,0 +1,66 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.gamepad.Left_StickY_Position; + +/** + * Executable for {@link Left_StickY_Position}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Left_StickYExecutable extends GenericReceiverExecutable { + + /** Constructor. */ + public Left_StickYExecutable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("gp_init"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return funcCall("gp_btnLY_is_noval"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("gp_term"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("gp_btnLY_read"); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickXExecutable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickXExecutable.java new file mode 100644 index 00000000..5d684e9d --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickXExecutable.java @@ -0,0 +1,66 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.gamepad.Right_StickX_Position; + +/** + * Executable for {@link Right_StickX_Position}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Right_StickXExecutable extends GenericReceiverExecutable { + + /** Constructor. */ + public Right_StickXExecutable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("gp_init"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return funcCall("gp_btnRX_is_noval"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("gp_term"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("gp_btnRX_read"); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickYExecutable.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickYExecutable.java new file mode 100644 index 00000000..afcb06d9 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/executable/gamepad/Right_StickYExecutable.java @@ -0,0 +1,66 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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 org.fortiss.af3.component.model.InputPort; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; +import org.fortiss.af3.platform.model.generic.GenericReceiver; +import org.fortiss.af3.platform.raspberry.model.gamepad.Right_StickY_Position; + +/** + * Executable for {@link Right_StickY_Position}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Right_StickYExecutable extends GenericReceiverExecutable { + + /** Constructor. */ + public Right_StickYExecutable(GenericReceiver modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getInitialization() { + return funcCall("gp_init"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return funcCall("gp_btnRY_is_noval"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getTermination() { + return funcCall("gp_term"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { + return funcCall("gp_btnRY_read"); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanBusTransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanBusTransformation.java new file mode 100644 index 00000000..e486ff8a --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanBusTransformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.CanBusExecutable; +import org.fortiss.af3.platform.raspberry.model.CanBus; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link CanBus}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class CanBusTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return CanBusExecutable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return CanBus.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof CanBus; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new CanBusExecutable((CanBus)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanBusTransmissionCatalogTransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanBusTransmissionCatalogTransformation.java new file mode 100644 index 00000000..7609aa34 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanBusTransmissionCatalogTransformation.java @@ -0,0 +1,61 @@ +/*--------------------------------------------------------------------------+ +$Id: GenericTransmisstionUnitTransmissionCatalogTransformation.java 5274 2012-08-02 07:54:11Z mou $ +| | +| Copyright 2011 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.deployment.generator.TransmissionCatalog; +import org.fortiss.af3.platform.model.generic.GenericTransmissionUnit; +import org.fortiss.af3.platform.raspberry.generator.executable.CanTransmissionCatalog; +import org.fortiss.af3.platform.raspberry.model.CanBus; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * {@link TransmissionCatalog} generator for {@link GenericTransmissionUnit}. + * + * @author hoelzl + * @author $Author: mou $ + * @version $Rev: 5274 $ + * @ConQAT.Rating GREEN Hash: C4318B1D240DC4CACC2BB0311CB2B23A + */ +public class CanBusTransmissionCatalogTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return CanTransmissionCatalog.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return CanBus.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof CanBus; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new CanTransmissionCatalog(); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanConnectorTransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanConnectorTransformation.java new file mode 100644 index 00000000..c1384349 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanConnectorTransformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.CanConnectorExecutable; +import org.fortiss.af3.platform.raspberry.model.CanConnector; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link CanConnector}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class CanConnectorTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return CanConnectorExecutable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return CanConnector.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof CanConnector; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new CanConnectorExecutable((CanConnector)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanConnectorTransmissionCatalogTransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanConnectorTransmissionCatalogTransformation.java new file mode 100644 index 00000000..d60a8b87 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/CanConnectorTransmissionCatalogTransformation.java @@ -0,0 +1,61 @@ +/*--------------------------------------------------------------------------+ +$Id: GenericTransceiverTransmissionCatalogTransformation.java 5274 2012-08-02 07:54:11Z mou $ +| | +| Copyright 2011 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.deployment.generator.TransmissionCatalog; +import org.fortiss.af3.platform.model.generic.GenericTransceiver; +import org.fortiss.af3.platform.raspberry.generator.executable.CanTransmissionCatalog; +import org.fortiss.af3.platform.raspberry.model.CanConnector; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * {@link TransmissionCatalog} generator for {@link GenericTransceiver}. + * + * @author hoelzl + * @author $Author: mou $ + * @version $Rev: 5274 $ + * @ConQAT.Rating GREEN Hash: 99AE1800CB3BA900FDB2FD75FC254AD4 + */ +public class CanConnectorTransmissionCatalogTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return CanTransmissionCatalog.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return CanConnector.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof CanConnector; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new CanTransmissionCatalog(); + } +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/GPITransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/GPITransformation.java new file mode 100644 index 00000000..ab91a614 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/GPITransformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.GPIExecutable; +import org.fortiss.af3.platform.raspberry.model.GPI; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link GPI}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class GPITransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return GPIExecutable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return GPI.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof GPI; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new GPIExecutable((GPI)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/GPOTransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/GPOTransformation.java new file mode 100644 index 00000000..9a010deb --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/GPOTransformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.GPOExecutable; +import org.fortiss.af3.platform.raspberry.model.GPO; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link GPO}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class GPOTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return GPOExecutable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return GPO.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof GPO; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new GPOExecutable((GPO)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/GamepadSensorTransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/GamepadSensorTransformation.java new file mode 100644 index 00000000..3e81e026 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/GamepadSensorTransformation.java @@ -0,0 +1,59 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.GamepadSensorExecutable; +import org.fortiss.af3.platform.raspberry.model.SensorGamepad; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class GamepadSensorTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return GamepadSensorExecutable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return SensorGamepad.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof SensorGamepad; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new GamepadSensorExecutable((SensorGamepad)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/IMUSensorTransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/IMUSensorTransformation.java new file mode 100644 index 00000000..6648dc62 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/IMUSensorTransformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.IMUSensorExecutable; +import org.fortiss.af3.platform.raspberry.model.SensorIMU; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link SensorIMU}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class IMUSensorTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return IMUSensorExecutable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return SensorIMU.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof SensorIMU; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new IMUSensorExecutable((SensorIMU)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/LaserRangeFinderSensorTransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/LaserRangeFinderSensorTransformation.java new file mode 100644 index 00000000..68e2a364 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/LaserRangeFinderSensorTransformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.LaserRangeFinderSensorExecutable; +import org.fortiss.af3.platform.raspberry.model.SensorLaserRangeFinder; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link SensorLaserRangeFinder}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class LaserRangeFinderSensorTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return LaserRangeFinderSensorExecutable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return SensorLaserRangeFinder.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof SensorLaserRangeFinder; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new LaserRangeFinderSensorExecutable((SensorLaserRangeFinder)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/LaserScannerSensorTransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/LaserScannerSensorTransformation.java new file mode 100644 index 00000000..e5c80421 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/LaserScannerSensorTransformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.LaserScannerSensorExecutable; +import org.fortiss.af3.platform.raspberry.model.SensorLaserScanner; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link SensorLaserScanner}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class LaserScannerSensorTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return LaserScannerSensorExecutable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return SensorLaserScanner.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof SensorLaserScanner; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new LaserScannerSensorExecutable((SensorLaserScanner)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/PWMActuatorTransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/PWMActuatorTransformation.java new file mode 100644 index 00000000..3edc3262 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/PWMActuatorTransformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.PWMActuatorExecutable; +import org.fortiss.af3.platform.raspberry.model.ActuatorPWM; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link ActuatorPWM}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class PWMActuatorTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return PWMActuatorExecutable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return ActuatorPWM.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof ActuatorPWM; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new PWMActuatorExecutable((ActuatorPWM)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/RaspberryPITransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/RaspberryPITransformation.java new file mode 100644 index 00000000..dabce839 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/RaspberryPITransformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.RaspberryPIExecutable; +import org.fortiss.af3.platform.raspberry.model.RaspberryPi; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation from {@link RaspberryPi} to {@link RaspberryPIExecutable}. + * + * @author eder + * @author $Author: eder $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class RaspberryPITransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return RaspberryPIExecutable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return RaspberryPi.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof RaspberryPi; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new RaspberryPIExecutable((RaspberryPi)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/WheelEncoderTransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/WheelEncoderTransformation.java new file mode 100644 index 00000000..88dcfa11 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/WheelEncoderTransformation.java @@ -0,0 +1,61 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.WheelEncoderExecutable; +import org.fortiss.af3.platform.raspberry.model.SensorLaserRangeFinder; +import org.fortiss.af3.platform.raspberry.model.WheelEncoder; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link SensorLaserRangeFinder}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class WheelEncoderTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return WheelEncoder.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return WheelEncoder.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof WheelEncoder; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new WheelEncoderExecutable((WheelEncoder)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button1Transformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button1Transformation.java new file mode 100644 index 00000000..e45b89e2 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button1Transformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.gamepad; + +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Button1Executable; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button1; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link Button1} + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Button1Transformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return Button1Executable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return Button1.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof Button1; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new Button1Executable((Button1)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button2Transformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button2Transformation.java new file mode 100644 index 00000000..8e3e58cf --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button2Transformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.gamepad; + +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Button2Executable; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button2; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link Button2}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Button2Transformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return Button2Executable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return Button2.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof Button2; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new Button2Executable((Button2)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button3Transformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button3Transformation.java new file mode 100644 index 00000000..c599e6c4 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button3Transformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.gamepad; + +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Button3Executable; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button3; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link Button3}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Button3Transformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return Button3Executable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return Button3.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof Button3; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new Button3Executable((Button3)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button4Transformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button4Transformation.java new file mode 100644 index 00000000..a5e9affb --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Button4Transformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.gamepad; + +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Button4Executable; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button4; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link Button4}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Button4Transformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return Button4Executable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return Button4.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof Button4; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new Button4Executable((Button4)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonL1Transformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonL1Transformation.java new file mode 100644 index 00000000..55a3f76a --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonL1Transformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.gamepad; + +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.ButtonL1Executable; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonL1; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link ButtonL1}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class ButtonL1Transformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return ButtonL1Executable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return ButtonL1.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof ButtonL1; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new ButtonL1Executable((ButtonL1)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonL2Transformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonL2Transformation.java new file mode 100644 index 00000000..2b358b73 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonL2Transformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.gamepad; + +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.ButtonL2Executable; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonL2; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link ButtonL2}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class ButtonL2Transformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return ButtonL2Executable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return ButtonL2.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof ButtonL2; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new ButtonL2Executable((ButtonL2)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonR1Transformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonR1Transformation.java new file mode 100644 index 00000000..ccfbbef4 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonR1Transformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.gamepad; + +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.ButtonR1Executable; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonR1; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link ButtonR1}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class ButtonR1Transformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return ButtonR1Executable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return ButtonR1.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof ButtonR1; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new ButtonR1Executable((ButtonR1)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonR2Transformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonR2Transformation.java new file mode 100644 index 00000000..3e66560c --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/ButtonR2Transformation.java @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.gamepad; + +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.ButtonR2Executable; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonR2; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link ButtonR2}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class ButtonR2Transformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return ButtonR2Executable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return ButtonR2.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof ButtonR2; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new ButtonR2Executable((ButtonR2)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Left_StickXTransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Left_StickXTransformation.java new file mode 100644 index 00000000..90c1713f --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Left_StickXTransformation.java @@ -0,0 +1,61 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.gamepad; + +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.ButtonR2Executable; +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Left_StickXExecutable; +import org.fortiss.af3.platform.raspberry.model.gamepad.Left_StickX_Position; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link Left_StickX_Position}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Left_StickXTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return ButtonR2Executable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return Left_StickX_Position.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof Left_StickX_Position; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new Left_StickXExecutable((Left_StickX_Position)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Left_StickYTransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Left_StickYTransformation.java new file mode 100644 index 00000000..2d322eaf --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Left_StickYTransformation.java @@ -0,0 +1,61 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.gamepad; + +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.ButtonR2Executable; +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Left_StickYExecutable; +import org.fortiss.af3.platform.raspberry.model.gamepad.Left_StickY_Position; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link Left_StickY_Position}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Left_StickYTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return ButtonR2Executable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return Left_StickY_Position.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof Left_StickY_Position; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new Left_StickYExecutable((Left_StickY_Position)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Right_StickXTransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Right_StickXTransformation.java new file mode 100644 index 00000000..984b3312 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Right_StickXTransformation.java @@ -0,0 +1,61 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.gamepad; + +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.ButtonR2Executable; +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Right_StickXExecutable; +import org.fortiss.af3.platform.raspberry.model.gamepad.Right_StickX_Position; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link Right_StickX_Position}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Right_StickXTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return ButtonR2Executable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return Right_StickX_Position.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof Right_StickX_Position; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new Right_StickXExecutable((Right_StickX_Position)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Right_StickYTransformation.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Right_StickYTransformation.java new file mode 100644 index 00000000..ba6b02da --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/generator/transform/gamepad/Right_StickYTransformation.java @@ -0,0 +1,61 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.gamepad; + +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.ButtonR2Executable; +import org.fortiss.af3.platform.raspberry.generator.executable.gamepad.Right_StickYExecutable; +import org.fortiss.af3.platform.raspberry.model.gamepad.Right_StickY_Position; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link Right_StickY_Position}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class Right_StickYTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return ButtonR2Executable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return Right_StickY_Position.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof Right_StickY_Position; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new Right_StickYExecutable((Right_StickY_Position)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/util/RaspberryModelElementFactory.java b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/util/RaspberryModelElementFactory.java new file mode 100644 index 00000000..9d7c2d5f --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/util/RaspberryModelElementFactory.java @@ -0,0 +1,261 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 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.util; + +import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createConnectorLayout; + +import org.fortiss.af3.platform.raspberry.model.ActuatorConnector; +import org.fortiss.af3.platform.raspberry.model.ActuatorPWM; +import org.fortiss.af3.platform.raspberry.model.CanBus; +import org.fortiss.af3.platform.raspberry.model.CanConnector; +import org.fortiss.af3.platform.raspberry.model.GPI; +import org.fortiss.af3.platform.raspberry.model.GPO; +import org.fortiss.af3.platform.raspberry.model.ModelFactory; +import org.fortiss.af3.platform.raspberry.model.RaspberryPi; +import org.fortiss.af3.platform.raspberry.model.SensorConnector; +import org.fortiss.af3.platform.raspberry.model.SensorGamepad; +import org.fortiss.af3.platform.raspberry.model.SensorIMU; +import org.fortiss.af3.platform.raspberry.model.SensorLaserRangeFinder; +import org.fortiss.af3.platform.raspberry.model.SensorLaserScanner; +import org.fortiss.af3.platform.raspberry.model.WheelEncoder; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button1; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button2; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button3; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button4; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonL1; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonL2; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonR1; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonR2; +import org.fortiss.af3.platform.raspberry.model.gamepad.GamepadFactory; +import org.fortiss.af3.platform.raspberry.model.gamepad.Left_StickX_Position; +import org.fortiss.af3.platform.raspberry.model.gamepad.Left_StickY_Position; +import org.fortiss.af3.platform.raspberry.model.gamepad.Right_StickX_Position; +import org.fortiss.af3.platform.raspberry.model.gamepad.Right_StickY_Position; +import org.fortiss.tooling.base.utils.LayoutModelElementFactory; + +/** + * Model Element for RaspberryPi and related models. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class RaspberryModelElementFactory { + + /** Creates a {@link RaspberryPi}. */ + public static RaspberryPi createRaspberryPi() { + final RaspberryPi pi = ModelFactory.eINSTANCE.createRaspberryPi(); + LayoutModelElementFactory.createNodeElementLayout(pi); + pi.setName("RaspberryPI"); + return pi; + } + + /** Creates a {@link CanBus}. */ + public static CanBus createCanBus() { + final CanBus bus = ModelFactory.eINSTANCE.createCanBus(); + LayoutModelElementFactory.createNodeElementLayout(bus); + bus.setName("CanBus"); + return bus; + } + + /** Creates a {@link CanConnector}. */ + public static CanConnector createCanConnector() { + CanConnector canConnector = ModelFactory.eINSTANCE.createCanConnector(); + canConnector.setName("CanConnector"); + createConnectorLayout(canConnector); + return canConnector; + } + + /** Creates a {@link SensorConnector}. */ + public static SensorConnector createSensorConnector() { + SensorConnector connector = ModelFactory.eINSTANCE.createSensorConnector(); + connector.setName("Sensor"); + createConnectorLayout(connector); + return connector; + } + + /** Creates a {@link SensorGamepad} */ + public static SensorGamepad createGamepadSensor() { + SensorGamepad connector = ModelFactory.eINSTANCE.createSensorGamepad(); + connector.setName("Gamepad"); + createConnectorLayout(connector); + return connector; + } + + /** Creates a {@link SensorIMU}. */ + public static SensorIMU createSensorIMU() { + SensorIMU connector = ModelFactory.eINSTANCE.createSensorIMU(); + connector.setName("IMU"); + createConnectorLayout(connector); + return connector; + } + + /** Creates a {@link SensorLaserRangeFinder}. */ + public static SensorLaserRangeFinder createSensorLaserRangeFinder() { + SensorLaserRangeFinder connector = ModelFactory.eINSTANCE.createSensorLaserRangeFinder(); + connector.setName("LaserRangeFinder"); + createConnectorLayout(connector); + return connector; + } + + /** Creates a {@link SensorLaserScanner}. */ + public static SensorLaserScanner createSensorLaserScanner() { + SensorLaserScanner connector = ModelFactory.eINSTANCE.createSensorLaserScanner(); + connector.setName("LaserScanner"); + createConnectorLayout(connector); + return connector; + } + + /** Creates a {@link ActuatorConnector}. */ + public static ActuatorConnector createActuatorConnector() { + ActuatorConnector connector = ModelFactory.eINSTANCE.createActuatorConnector(); + connector.setName("Sensor"); + createConnectorLayout(connector); + return connector; + } + + /** Creates a {@link ActuatorPWM}. */ + public static ActuatorPWM createActuatorPWM() { + ActuatorPWM connector = ModelFactory.eINSTANCE.createActuatorPWM(); + connector.setName("PWM"); + createConnectorLayout(connector); + return connector; + } + + /** Creates a {@link GPI}. */ + public static GPI createGPI() { + GPI gpi = ModelFactory.eINSTANCE.createGPI(); + gpi.setName("GPI"); + createConnectorLayout(gpi); + return gpi; + } + + /** Creates a {@link GPI}. */ + public static GPO createGPO() { + GPO gpo = ModelFactory.eINSTANCE.createGPO(); + gpo.setName("GPO"); + createConnectorLayout(gpo); + return gpo; + } + + /** Creates a {@link Button1}. */ + public static Button1 createButton1() { + Button1 button = GamepadFactory.eINSTANCE.createButton1(); + button.setName("Button1_Triangle"); + createConnectorLayout(button); + return button; + } + + /** Creates a {@link Button2}. */ + public static Button2 createButton2() { + Button2 button = GamepadFactory.eINSTANCE.createButton2(); + button.setName("Button2_Circle"); + createConnectorLayout(button); + return button; + } + + /** Creates a {@link Button3}. */ + public static Button3 createButton3() { + Button3 button = GamepadFactory.eINSTANCE.createButton3(); + button.setName("Button3_X"); + createConnectorLayout(button); + return button; + } + + /** Creates a {@link Button4}. */ + public static Button4 createButton4() { + Button4 button = GamepadFactory.eINSTANCE.createButton4(); + button.setName("Button4_Square"); + createConnectorLayout(button); + return button; + } + + /** Creates a {@link ButtonR1}. */ + public static ButtonR1 createButtonR1() { + ButtonR1 button = GamepadFactory.eINSTANCE.createButtonR1(); + button.setName("ButtonR1"); + createConnectorLayout(button); + return button; + } + + /** Creates a {@link ButtonL1}. */ + public static ButtonL1 createButtonL1() { + ButtonL1 button = GamepadFactory.eINSTANCE.createButtonL1(); + button.setName("ButtonL1"); + createConnectorLayout(button); + return button; + } + + /** Creates a {@link ButtonR2}. */ + public static ButtonR2 createButtonR2() { + ButtonR2 button = GamepadFactory.eINSTANCE.createButtonR2(); + button.setName("ButtonR2"); + createConnectorLayout(button); + return button; + } + + /** Creates a {@link ButtonL2}. */ + public static ButtonL2 createButtonL2() { + ButtonL2 button = GamepadFactory.eINSTANCE.createButtonL2(); + button.setName("ButtonL2"); + createConnectorLayout(button); + return button; + } + + /** Creates a {@link Left_StickX_Position}. */ + public static Left_StickX_Position createLeftStickX() { + Left_StickX_Position button = GamepadFactory.eINSTANCE.createLeft_StickX_Position(); + button.setName("Left_StickX"); + createConnectorLayout(button); + return button; + } + + /** Creates a {@link Left_StickY_Position}. */ + public static Left_StickY_Position createLeftStickY() { + Left_StickY_Position button = GamepadFactory.eINSTANCE.createLeft_StickY_Position(); + button.setName("Left_StickY"); + createConnectorLayout(button); + return button; + } + + /** Creates a {@link Right_StickX_Position}. */ + public static Right_StickX_Position createRightStickX() { + Right_StickX_Position button = GamepadFactory.eINSTANCE.createRight_StickX_Position(); + button.setName("Right_StickX"); + createConnectorLayout(button); + return button; + } + + /** Creates a {@link Right_StickY_Position}. */ + public static Right_StickY_Position createRightStickY() { + Right_StickY_Position button = GamepadFactory.eINSTANCE.createRight_StickY_Position(); + button.setName("Right_StickY"); + createConnectorLayout(button); + return button; + } + + /** Creates a {@link Right_StickY_Position}. */ + public static WheelEncoder createWheelEncoder() { + WheelEncoder wEncoder = ModelFactory.eINSTANCE.createWheelEncoder(); + wEncoder.setName("WheelEncoder"); + createConnectorLayout(wEncoder); + return wEncoder; + } + +} -- GitLab