From e99510421f5e3026131c130b70b5b4412557294f Mon Sep 17 00:00:00 2001 From: Johannes Eder <eder@fortiss.org> Date: Tue, 30 May 2017 11:44:42 +0000 Subject: [PATCH] new sensor model elements in model elements view --- .../ui/prototype/ProtoypeProvider.java | 98 ++++++++++++++++++- .../trunk/META-INF/MANIFEST.MF | 1 + .../compose/RaspberryPiCompositor.java | 22 ++++- 3 files changed, 114 insertions(+), 7 deletions(-) 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 e3e9fe54..1240414a 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 @@ -27,13 +27,27 @@ import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createRec 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.RaspberryPi; -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.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.util.RaspberryModelElementFactory; import org.fortiss.tooling.kernel.extension.base.PrototypeProviderBase; +import org.fortiss.tooling.kernel.extension.data.PrototypeCategory; /** * @@ -46,12 +60,16 @@ public class ProtoypeProvider extends PrototypeProviderBase { /** Stores the category to display for these prototypes. */ protected final static String CATEGORY_NAME = "RaspberryPI Platform"; + /** Category for gamepad elements. */ + protected final static String GAMEPAD = "Gamepad"; /** {@inheritDoc} */ @Override protected void registerPrototypes() { RaspberryPi pi = RaspberryModelElementFactory.createRaspberryPi(); registerPrimaryPrototype("RaspberryPi", pi, CATEGORY_NAME); + PrototypeCategory prototypeCategory = registerPrototypeCategory(CATEGORY_NAME); + registerPrototypeCategory(prototypeCategory, GAMEPAD); CanBus bus = RaspberryModelElementFactory.createCanBus(); setNodeBounds(bus, @@ -83,10 +101,10 @@ 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); + // 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); @@ -98,5 +116,75 @@ public class ProtoypeProvider extends PrototypeProviderBase { setConnectorPosition(pwm, 0, 0); registerPrototype("PWM_Actuator", pwm, CATEGORY_NAME); + GPI gpi = RaspberryModelElementFactory.createGPI(); + setNodePosition(gpi, 0, 0); + setConnectorPosition(gpi, 0, 0); + registerPrototype("GPI", gpi, CATEGORY_NAME); + + GPO gpo = RaspberryModelElementFactory.createGPO(); + setNodePosition(gpo, 0, 0); + setConnectorPosition(gpo, 0, 0); + registerPrototype("GPO", gpo, CATEGORY_NAME); + + Button1 button1 = RaspberryModelElementFactory.createButton1(); + setNodePosition(button1, 0, 0); + setConnectorPosition(button1, 0, 0); + registerPrototype(button1.getName(), button1, GAMEPAD); + + Button2 button2 = RaspberryModelElementFactory.createButton2(); + setNodePosition(button2, 0, 0); + setConnectorPosition(button2, 0, 0); + registerPrototype(button2.getName(), button2, GAMEPAD); + + Button3 button3 = RaspberryModelElementFactory.createButton3(); + setNodePosition(button3, 0, 0); + setConnectorPosition(button3, 0, 0); + registerPrototype(button3.getName(), button3, GAMEPAD); + + Button4 button4 = RaspberryModelElementFactory.createButton4(); + setNodePosition(button4, 0, 0); + setConnectorPosition(button4, 0, 0); + registerPrototype(button4.getName(), button4, GAMEPAD); + + ButtonL1 buttonL1 = RaspberryModelElementFactory.createButtonL1(); + setNodePosition(buttonL1, 0, 0); + setConnectorPosition(buttonL1, 0, 0); + registerPrototype(buttonL1.getName(), buttonL1, GAMEPAD); + + ButtonL2 buttonL2 = RaspberryModelElementFactory.createButtonL2(); + setNodePosition(buttonL2, 0, 0); + setConnectorPosition(buttonL2, 0, 0); + registerPrototype(buttonL2.getName(), buttonL2, GAMEPAD); + + ButtonR1 buttonR1 = RaspberryModelElementFactory.createButtonR1(); + setNodePosition(buttonR1, 0, 0); + setConnectorPosition(buttonR1, 0, 0); + registerPrototype(buttonR1.getName(), buttonR1, GAMEPAD); + + ButtonR2 buttonR2 = RaspberryModelElementFactory.createButtonR2(); + setNodePosition(buttonR2, 0, 0); + setConnectorPosition(buttonR2, 0, 0); + registerPrototype(buttonR2.getName(), buttonR2, GAMEPAD); + + Left_StickX_Position Left_StickX = RaspberryModelElementFactory.createLeftStickX(); + setNodePosition(Left_StickX, 0, 0); + setConnectorPosition(Left_StickX, 0, 0); + registerPrototype(Left_StickX.getName(), Left_StickX, GAMEPAD); + + Left_StickY_Position Left_StickY = RaspberryModelElementFactory.createLeftStickY(); + setNodePosition(Left_StickY, 0, 0); + setConnectorPosition(Left_StickY, 0, 0); + registerPrototype(Left_StickY.getName(), Left_StickY, GAMEPAD); + + Right_StickX_Position Right_StickX = RaspberryModelElementFactory.createRightStickX(); + setNodePosition(Right_StickX, 0, 0); + setConnectorPosition(Right_StickX, 0, 0); + registerPrototype(Right_StickX.getName(), Right_StickX, GAMEPAD); + + Right_StickY_Position Right_StickY = RaspberryModelElementFactory.createRightStickY(); + setNodePosition(Right_StickY, 0, 0); + setConnectorPosition(Right_StickY, 0, 0); + registerPrototype(Right_StickY.getName(), Right_StickY, GAMEPAD); + } } diff --git a/org.fortiss.af3.platform.raspberry/trunk/META-INF/MANIFEST.MF b/org.fortiss.af3.platform.raspberry/trunk/META-INF/MANIFEST.MF index 50da611d..d371b809 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/META-INF/MANIFEST.MF +++ b/org.fortiss.af3.platform.raspberry/trunk/META-INF/MANIFEST.MF @@ -8,6 +8,7 @@ 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.impl, org.fortiss.af3.platform.raspberry.model.util, org.fortiss.af3.platform.raspberry.util 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 a2e54f45..4d7c81c2 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 @@ -25,12 +25,25 @@ 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.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.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; /** * @@ -46,10 +59,15 @@ public class RaspberryPiCompositor extends @Override protected boolean isCorrectElementClass(IPlatformArchitectureElement container, EObject contained) { + final boolean instanceOfAny2 = isInstanceOfAny(contained, CanConnector.class, SensorConnector.class, ActuatorConnector.class, ActuatorPWM.class, SensorLaserRangeFinder.class, - SensorGamepad.class, SensorLaserScanner.class, SensorIMU.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); if(container != null) { final boolean instanceOfAny = isInstanceOfAny(container, RaspberryPi.class); return instanceOfAny && instanceOfAny2; -- GitLab