From 135ff00fedcd8bdaa55fce4de42b57ab8f783144 Mon Sep 17 00:00:00 2001 From: Florian Hoelzl <hoelzl@fortiss.org> Date: Fri, 8 Dec 2017 09:55:32 +0000 Subject: [PATCH] Added simple rumble feature actuator. refs 2507 --- .../trunk/plugin.xml | 12 +++- .../ui/editpart/EditPartFactory.java | 3 +- .../RumblepadSimpleRumbleFeatureHandler.java | 41 +++++++++++++ .../ui/prototype/ProtoypeProvider.java | 7 +++ .../trunk/model/raspberry.ecore | 1 + .../trunk/plugin.xml | 13 +++++ .../compose/RaspberryPiCompositor.java | 31 +++------- .../SimpleRumbleFeatureExecutable.java | 57 +++++++++++++++++++ .../rumblepad/ButtonATransformation.java | 3 +- .../SimpleRumbleFeatureTransformation.java | 55 ++++++++++++++++++ .../util/RaspberryModelElementFactory.java | 9 +++ 11 files changed, 204 insertions(+), 28 deletions(-) create mode 100644 org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/handler/RumblepadSimpleRumbleFeatureHandler.java create mode 100644 org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/rumblepad/SimpleRumbleFeatureExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/transform/rumblepad/SimpleRumbleFeatureTransformation.java diff --git a/org.fortiss.af3.platform.raspberry.ui/trunk/plugin.xml b/org.fortiss.af3.platform.raspberry.ui/trunk/plugin.xml index 5826e263..c9951a8f 100644 --- a/org.fortiss.af3.platform.raspberry.ui/trunk/plugin.xml +++ b/org.fortiss.af3.platform.raspberry.ui/trunk/plugin.xml @@ -51,13 +51,16 @@ <modelElementClass modelElementClass="org.fortiss.af3.platform.raspberry.model.ActuatorPWM"> </modelElementClass> - <modelElementClass + <modelElementClass modelElementClass="org.fortiss.af3.platform.raspberry.model.gamepad.GamepadReceiverBase"> </modelElementClass> - <modelElementClass + <modelElementClass modelElementClass="org.fortiss.af3.platform.raspberry.model.rumblepad.RumblepadReceiverBase"> </modelElementClass> - <modelElementClass + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.rumblepad.SimpleRumbleFeature"> + </modelElementClass> + <modelElementClass modelElementClass="org.fortiss.af3.platform.raspberry.model.brick.UIDUnit"> </modelElementClass> </editPartFactory> @@ -237,6 +240,9 @@ <modelElementClass modelElementClass="org.fortiss.af3.platform.raspberry.model.rumblepad.Right_StickY_Position"> </modelElementClass> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.rumblepad.SimpleRumbleFeature"> + </modelElementClass> </modelElementHandler> </extension> <extension diff --git a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/editpart/EditPartFactory.java b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/editpart/EditPartFactory.java index d1dc2aff..4d8d18ea 100644 --- a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/editpart/EditPartFactory.java +++ b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/editpart/EditPartFactory.java @@ -27,6 +27,7 @@ import org.fortiss.af3.platform.raspberry.model.RaspberryPi; import org.fortiss.af3.platform.raspberry.model.brick.UIDUnit; import org.fortiss.af3.platform.raspberry.model.gamepad.GamepadReceiverBase; import org.fortiss.af3.platform.raspberry.model.rumblepad.RumblepadReceiverBase; +import org.fortiss.af3.platform.raspberry.model.rumblepad.SimpleRumbleFeature; import org.fortiss.af3.platform.ui.DefaultStyle; import org.fortiss.af3.platform.ui.editpart.generic.ExecutionUnitEditPart; import org.fortiss.af3.platform.ui.editpart.generic.StickyPlatformConnectorUnitEditPart; @@ -63,7 +64,7 @@ public class EditPartFactory implements IEditPartFactory { return new TransmissionUnitDefaultEditPart((CanBus)model); } else if(model instanceof CanConnector || model instanceof ActuatorPWM || model instanceof GamepadReceiverBase || model instanceof RumblepadReceiverBase || - model instanceof UIDUnit) { + model instanceof SimpleRumbleFeature || model instanceof UIDUnit) { return new StickyPlatformConnectorUnitEditPart((PlatformConnectorUnit)model); } return null; diff --git a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/handler/RumblepadSimpleRumbleFeatureHandler.java b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/handler/RumblepadSimpleRumbleFeatureHandler.java new file mode 100644 index 00000000..bc0e9f10 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/handler/RumblepadSimpleRumbleFeatureHandler.java @@ -0,0 +1,41 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| 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.ui.handler; + +import static org.fortiss.af3.platform.raspberry.ui.AF3PlatformRaspberryUIActivator.getImageDescriptor; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.fortiss.af3.platform.raspberry.model.rumblepad.SimpleRumbleFeature; +import org.fortiss.tooling.kernel.ui.extension.base.NamedCommentedModelElementHandlerBase; + +/** + * Handler for {@link SimpleRumbleFeature}s. + * + * @author hoelzl + * @author $Author$ + * @version $Rev$ + * @ConQAT.Rating GREEN Hash: D80CF94CBBADB4627AAEDA1F34ABF0A5 + */ +public class RumblepadSimpleRumbleFeatureHandler extends + NamedCommentedModelElementHandlerBase<SimpleRumbleFeature> { + /** {@inheritDoc} */ + @Override + public ImageDescriptor getIconImageDescriptor() { + return getImageDescriptor("icons/gamepad.png"); + } +} diff --git a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/prototype/ProtoypeProvider.java b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/prototype/ProtoypeProvider.java index 42fb8584..bcf32e06 100644 --- a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/prototype/ProtoypeProvider.java +++ b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/prototype/ProtoypeProvider.java @@ -64,6 +64,7 @@ import org.fortiss.af3.platform.raspberry.model.rumblepad.DPadRight; import org.fortiss.af3.platform.raspberry.model.rumblepad.DPadUp; import org.fortiss.af3.platform.raspberry.model.rumblepad.L2_Position; import org.fortiss.af3.platform.raspberry.model.rumblepad.R2_Position; +import org.fortiss.af3.platform.raspberry.model.rumblepad.SimpleRumbleFeature; import org.fortiss.af3.platform.raspberry.util.RaspberryModelElementFactory; import org.fortiss.tooling.kernel.extension.base.PrototypeProviderBase; import org.fortiss.tooling.kernel.extension.data.PrototypeCategory; @@ -326,5 +327,11 @@ public class ProtoypeProvider extends PrototypeProviderBase { setNodePosition(rpbh, 0, 0); setConnectorPosition(rpbh, 0, 0); registerPrototype(rpbh.getName(), rpbh, RUMBLEPAD); + + SimpleRumbleFeature srf = + RaspberryModelElementFactory.createRumbleSimpleRumbleFeaturePosition(); + setNodePosition(srf, 0, 0); + setConnectorPosition(srf, 0, 0); + registerPrototype(srf.getName(), srf, RUMBLEPAD); } } diff --git a/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore b/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore index e6a243ff..1d6e7239 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore +++ b/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore @@ -72,5 +72,6 @@ <eClassifiers xsi:type="ecore:EClass" name="ButtonStart" eSuperTypes="#//rumblepad/RumblepadReceiverBase"/> <eClassifiers xsi:type="ecore:EClass" name="ButtonSelect" eSuperTypes="#//rumblepad/RumblepadReceiverBase"/> <eClassifiers xsi:type="ecore:EClass" name="ButtonHome" eSuperTypes="#//rumblepad/RumblepadReceiverBase"/> + <eClassifiers xsi:type="ecore:EClass" name="SimpleRumbleFeature" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Transmitter"/> </eSubpackages> </ecore:EPackage> diff --git a/org.fortiss.af3.platform.raspberry/trunk/plugin.xml b/org.fortiss.af3.platform.raspberry/trunk/plugin.xml index ba71e304..bb31f79c 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/plugin.xml +++ b/org.fortiss.af3.platform.raspberry/trunk/plugin.xml @@ -585,6 +585,19 @@ </objectClass> </target> </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.rumblepad.SimpleRumbleFeatureTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.rumblepad.SimpleRumbleFeature"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.executable.rumblepad.SimpleRumbleFeatureExecutable"> + </objectClass> + </target> + </transformationProvider> </extension> </plugin> diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/RaspberryPiCompositor.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/RaspberryPiCompositor.java index 8363aad9..8f81bdb6 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/RaspberryPiCompositor.java +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/compose/RaspberryPiCompositor.java @@ -34,19 +34,9 @@ import org.fortiss.af3.platform.raspberry.model.brick.AngularVelocityYSensor; import org.fortiss.af3.platform.raspberry.model.brick.AngularVelocityZSensor; import org.fortiss.af3.platform.raspberry.model.brick.LaserRangeSensor; import org.fortiss.af3.platform.raspberry.model.brick.UltraSonicSensor; -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; +import org.fortiss.af3.platform.raspberry.model.gamepad.GamepadReceiverBase; import org.fortiss.af3.platform.raspberry.model.rumblepad.RumblepadReceiverBase; +import org.fortiss.af3.platform.raspberry.model.rumblepad.SimpleRumbleFeature; import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext; import org.fortiss.tooling.kernel.extension.data.Prototype; @@ -78,16 +68,13 @@ public class RaspberryPiCompositor extends protected boolean isCorrectElementClass(IPlatformArchitectureElement container, EObject contained) { final boolean instanceOfAny2 = - isInstanceOfAny(contained, CanConnector.class, ActuatorPWM.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, UltraSonicSensor.class, - LaserRangeSensor.class, AccelerationXSensor.class, - AccelerationYSensor.class, AccelerationZSensor.class, - AngularVelocityXSensor.class, AngularVelocityYSensor.class, - AngularVelocityZSensor.class, ActuatorDigits.class, - RumblepadReceiverBase.class); + isInstanceOfAny(contained, CanConnector.class, ActuatorPWM.class, + GamepadReceiverBase.class, UltraSonicSensor.class, LaserRangeSensor.class, + AccelerationXSensor.class, AccelerationYSensor.class, + AccelerationZSensor.class, AngularVelocityXSensor.class, + AngularVelocityYSensor.class, AngularVelocityZSensor.class, + ActuatorDigits.class, RumblepadReceiverBase.class, + SimpleRumbleFeature.class); if(container != null) { final boolean instanceOfAny = isInstanceOfAny(container, RaspberryPi.class); return instanceOfAny && instanceOfAny2; diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/rumblepad/SimpleRumbleFeatureExecutable.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/rumblepad/SimpleRumbleFeatureExecutable.java new file mode 100644 index 00000000..a772611c --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/rumblepad/SimpleRumbleFeatureExecutable.java @@ -0,0 +1,57 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| 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.rumblepad; + +import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.funcCall; + +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.platform.language.executable.TransmitterExecutableBase; +import org.fortiss.af3.platform.raspberry.model.rumblepad.SimpleRumbleFeature; + +/** + * Executable for {@link SimpleRumbleFeature}. + */ +public class SimpleRumbleFeatureExecutable extends TransmitterExecutableBase<SimpleRumbleFeature> { + /** Constructor. */ + public SimpleRumbleFeatureExecutable(SimpleRumbleFeature modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + public IExpressionTerm getInitialization() { + return funcCall("rp_init"); + } + + /** {@inheritDoc} */ + public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { + return funcCall("rp_simpleRumble_is_noval"); + } + + /** {@inheritDoc} */ + public IExpressionTerm getTermination() { + return funcCall("rp_term"); + } + + /** {@inheritDoc} */ + @Override + public IExpressionTerm getValueWriteAccessor(OutputPort logicalSignal, IExpressionTerm value) { + return funcCall("rp_simpleRumble_write"); + } +} diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/transform/rumblepad/ButtonATransformation.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/transform/rumblepad/ButtonATransformation.java index 9a6f60f1..ec684a40 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/transform/rumblepad/ButtonATransformation.java +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/transform/rumblepad/ButtonATransformation.java @@ -19,7 +19,6 @@ package org.fortiss.af3.platform.raspberry.generator.transform.rumblepad; import org.fortiss.af3.platform.raspberry.generator.executable.rumblepad.ButtonAExecutable; import org.fortiss.af3.platform.raspberry.model.rumblepad.ButtonA; -import org.fortiss.af3.platform.raspberry.model.rumblepad.ButtonL1; import org.fortiss.tooling.kernel.extension.ITransformationProvider; import org.fortiss.tooling.kernel.extension.data.ITransformationContext; @@ -49,7 +48,7 @@ public class ButtonATransformation implements ITransformationProvider { /** {@inheritDoc} */ @Override public boolean canTransform(Object source, ITransformationContext context) { - return source instanceof ButtonL1; + return source instanceof ButtonA; } /** {@inheritDoc} */ diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/transform/rumblepad/SimpleRumbleFeatureTransformation.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/transform/rumblepad/SimpleRumbleFeatureTransformation.java new file mode 100644 index 00000000..7ece4ff6 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/transform/rumblepad/SimpleRumbleFeatureTransformation.java @@ -0,0 +1,55 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| 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.rumblepad; + +import org.fortiss.af3.platform.raspberry.generator.executable.rumblepad.SimpleRumbleFeatureExecutable; +import org.fortiss.af3.platform.raspberry.model.rumblepad.SimpleRumbleFeature; +import org.fortiss.tooling.kernel.extension.ITransformationProvider; +import org.fortiss.tooling.kernel.extension.data.ITransformationContext; + +/** + * Transformation for {@link SimpleRumbleFeature}. + */ +public class SimpleRumbleFeatureTransformation implements ITransformationProvider { + + /** {@inheritDoc} */ + @Override + public Class<?> getTargetClass() { + return SimpleRumbleFeatureExecutable.class; + } + + /** {@inheritDoc} */ + @Override + public boolean + canHandleChainTransformation(Class<?> sourceClass, ITransformationContext context) { + return SimpleRumbleFeature.class.isAssignableFrom(sourceClass); + } + + /** {@inheritDoc} */ + @Override + public boolean canTransform(Object source, ITransformationContext context) { + return source instanceof SimpleRumbleFeature; + } + + /** {@inheritDoc} */ + @Override + public Object transform(Object source, ITransformationContext context) { + return new SimpleRumbleFeatureExecutable((SimpleRumbleFeature)source); + } + +} diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/util/RaspberryModelElementFactory.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/util/RaspberryModelElementFactory.java index 34800101..19280544 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/util/RaspberryModelElementFactory.java +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/util/RaspberryModelElementFactory.java @@ -63,6 +63,7 @@ import org.fortiss.af3.platform.raspberry.model.rumblepad.DPadUp; import org.fortiss.af3.platform.raspberry.model.rumblepad.L2_Position; import org.fortiss.af3.platform.raspberry.model.rumblepad.R2_Position; import org.fortiss.af3.platform.raspberry.model.rumblepad.RumblepadFactory; +import org.fortiss.af3.platform.raspberry.model.rumblepad.SimpleRumbleFeature; import org.fortiss.tooling.base.utils.LayoutModelElementFactory; /** @@ -460,4 +461,12 @@ public class RaspberryModelElementFactory { createConnectorLayout(button); return button; } + + /** Creates a {@link SimpleRumbleFeature}. */ + public static SimpleRumbleFeature createRumbleSimpleRumbleFeaturePosition() { + SimpleRumbleFeature rumble = RumblepadFactory.eINSTANCE.createSimpleRumbleFeature(); + rumble.setName("SimpleRumbleFeature"); + createConnectorLayout(rumble); + return rumble; + } } -- GitLab