From 92c251c3099f423a9cc050f110154e1489fa1f07 Mon Sep 17 00:00:00 2001 From: Johannes Eder <eder@fortiss.org> Date: Tue, 27 Jun 2017 12:13:35 +0000 Subject: [PATCH] added WheelEncoder model --- .../ui/prototype/ProtoypeProvider.java | 21 ++----- .../trunk/model/raspberry.ecore | 1 + .../trunk/model/raspberry.genmodel | 1 + .../trunk/plugin.xml | 13 ++++ .../compose/RaspberryPiCompositor.java | 3 +- .../executable/WheelEncoderExecutable.java | 39 ++++++++++++ .../transform/WheelEncoderTransformation.java | 61 +++++++++++++++++++ .../util/RaspberryModelElementFactory.java | 9 +++ 8 files changed, 132 insertions(+), 16 deletions(-) create mode 100644 org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/WheelEncoderExecutable.java create mode 100644 org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/transform/WheelEncoderTransformation.java 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 1240414a..448ebb2f 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 @@ -33,6 +33,7 @@ import org.fortiss.af3.platform.raspberry.model.RaspberryPi; 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; @@ -81,11 +82,6 @@ public class ProtoypeProvider extends PrototypeProviderBase { setConnectorPosition(con, 0, 0); registerPrototype("CanConnector", con, CATEGORY_NAME); - // SensorConnector sensor = RaspberryModelElementFactory.createSensorConnector(); - // setNodePosition(sensor, 0, 0); - // setConnectorPosition(sensor, 0, 0); - // registerPrototype("GenericPI_Sensor", sensor, CATEGORY_NAME); - SensorIMU imu = RaspberryModelElementFactory.createSensorIMU(); setNodePosition(imu, 0, 0); setConnectorPosition(imu, 0, 0); @@ -101,16 +97,6 @@ public class ProtoypeProvider extends PrototypeProviderBase { setConnectorPosition(sls, 0, 0); registerPrototype("LaserScanner_Sensor", sls, CATEGORY_NAME); - // SensorGamepad pad = RaspberryModelElementFactory.createGamepadSensor(); - // setNodePosition(pad, 0, 0); - // setConnectorPosition(pad, 0, 0); - // registerPrototype("Gamepad_Sensor", pad, CATEGORY_NAME); - - // ActuatorConnector actuator = RaspberryModelElementFactory.createActuatorConnector(); - // setNodePosition(actuator, 0, 0); - // setConnectorPosition(actuator, 0, 0); - // registerPrototype("GenericPI_Actuator", actuator, CATEGORY_NAME); - ActuatorPWM pwm = RaspberryModelElementFactory.createActuatorPWM(); setNodePosition(pwm, 0, 0); setConnectorPosition(pwm, 0, 0); @@ -126,6 +112,11 @@ public class ProtoypeProvider extends PrototypeProviderBase { setConnectorPosition(gpo, 0, 0); registerPrototype("GPO", gpo, CATEGORY_NAME); + WheelEncoder wEncoder = RaspberryModelElementFactory.createWheelEncoder(); + setNodePosition(wEncoder, 0, 0); + setConnectorPosition(wEncoder, 0, 0); + registerPrototype("WheelEncoder", wEncoder, CATEGORY_NAME); + Button1 button1 = RaspberryModelElementFactory.createButton1(); setNodePosition(button1, 0, 0); setConnectorPosition(button1, 0, 0); diff --git a/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore b/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore index 38984afb..7dbfc2b5 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore +++ b/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore @@ -14,6 +14,7 @@ <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"/> diff --git a/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.genmodel b/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.genmodel index 65e79bd8..156f41bf 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.genmodel +++ b/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.genmodel @@ -19,6 +19,7 @@ <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"/> diff --git a/org.fortiss.af3.platform.raspberry/trunk/plugin.xml b/org.fortiss.af3.platform.raspberry/trunk/plugin.xml index e4206d22..397e4f32 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/plugin.xml +++ b/org.fortiss.af3.platform.raspberry/trunk/plugin.xml @@ -391,6 +391,19 @@ </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"> 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 4d7c81c2..7a6d8b6e 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 @@ -32,6 +32,7 @@ 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; @@ -67,7 +68,7 @@ public class RaspberryPiCompositor extends 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); + Right_StickY_Position.class, WheelEncoder.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/WheelEncoderExecutable.java b/org.fortiss.af3.platform.raspberry/trunk/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/trunk/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/trunk/src/org/fortiss/af3/platform/raspberry/generator/transform/WheelEncoderTransformation.java b/org.fortiss.af3.platform.raspberry/trunk/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/trunk/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/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 f5b95a53..9d7c2d5f 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 @@ -32,6 +32,7 @@ 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; @@ -249,4 +250,12 @@ public class RaspberryModelElementFactory { 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