Skip to content
Snippets Groups Projects
Commit 602e613b authored by Johannes Eder's avatar Johannes Eder
Browse files

specific sensor and actuator elements

parent c2a022eb
No related branches found
No related tags found
No related merge requests found
Showing
with 276 additions and 3 deletions
...@@ -25,10 +25,14 @@ import static org.fortiss.tooling.base.utils.LayoutDataUtils.setNodePosition; ...@@ -25,10 +25,14 @@ import static org.fortiss.tooling.base.utils.LayoutDataUtils.setNodePosition;
import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createRectangle; import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createRectangle;
import org.fortiss.af3.platform.raspberry.model.ActuatorConnector; 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.CanBus;
import org.fortiss.af3.platform.raspberry.model.CanConnector; import org.fortiss.af3.platform.raspberry.model.CanConnector;
import org.fortiss.af3.platform.raspberry.model.RaspberryPi; import org.fortiss.af3.platform.raspberry.model.RaspberryPi;
import org.fortiss.af3.platform.raspberry.model.SensorConnector; 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.util.RaspberryModelElementFactory; import org.fortiss.af3.platform.raspberry.util.RaspberryModelElementFactory;
import org.fortiss.tooling.kernel.extension.base.PrototypeProviderBase; import org.fortiss.tooling.kernel.extension.base.PrototypeProviderBase;
...@@ -63,12 +67,32 @@ public class ProtoypeProvider extends PrototypeProviderBase { ...@@ -63,12 +67,32 @@ public class ProtoypeProvider extends PrototypeProviderBase {
SensorConnector sensor = RaspberryModelElementFactory.createSensorConnector(); SensorConnector sensor = RaspberryModelElementFactory.createSensorConnector();
setNodePosition(sensor, 0, 0); setNodePosition(sensor, 0, 0);
setConnectorPosition(sensor, 0, 0); setConnectorPosition(sensor, 0, 0);
registerPrototype("Sensor", sensor, CATEGORY_NAME); registerPrototype("GenericPI_Sensor", sensor, CATEGORY_NAME);
SensorIMU imu = RaspberryModelElementFactory.createSensorIMU();
setNodePosition(imu, 0, 0);
setConnectorPosition(imu, 0, 0);
registerPrototype("IMU_Sensor", imu, CATEGORY_NAME);
SensorLaserRangeFinder slrf = RaspberryModelElementFactory.createSensorLaserRangeFinder();
setNodePosition(slrf, 0, 0);
setConnectorPosition(slrf, 0, 0);
registerPrototype("LaserRangeFinder_Sensor", slrf, CATEGORY_NAME);
SensorLaserScanner sls = RaspberryModelElementFactory.createSensorLaserScanner();
setNodePosition(sls, 0, 0);
setConnectorPosition(sls, 0, 0);
registerPrototype("LaserScanner_Sensor", sls, CATEGORY_NAME);
ActuatorConnector actuator = RaspberryModelElementFactory.createActuatorConnector(); ActuatorConnector actuator = RaspberryModelElementFactory.createActuatorConnector();
setNodePosition(actuator, 0, 0); setNodePosition(actuator, 0, 0);
setConnectorPosition(actuator, 0, 0); setConnectorPosition(actuator, 0, 0);
registerPrototype("Actuator", actuator, CATEGORY_NAME); registerPrototype("GenericPI_Actuator", actuator, CATEGORY_NAME);
ActuatorPWM pwm = RaspberryModelElementFactory.createActuatorPWM();
setNodePosition(pwm, 0, 0);
setConnectorPosition(pwm, 0, 0);
registerPrototype("PWM_Actuator", pwm, CATEGORY_NAME);
} }
} }
...@@ -7,4 +7,9 @@ ...@@ -7,4 +7,9 @@
<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="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="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="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"/>
</ecore:EPackage> </ecore:EPackage>
...@@ -12,5 +12,10 @@ ...@@ -12,5 +12,10 @@
<genClasses ecoreClass="raspberry.ecore#//CanConnector"/> <genClasses ecoreClass="raspberry.ecore#//CanConnector"/>
<genClasses ecoreClass="raspberry.ecore#//SensorConnector"/> <genClasses ecoreClass="raspberry.ecore#//SensorConnector"/>
<genClasses ecoreClass="raspberry.ecore#//ActuatorConnector"/> <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"/>
</genPackages> </genPackages>
</genmodel:GenModel> </genmodel:GenModel>
...@@ -61,6 +61,22 @@ ...@@ -61,6 +61,22 @@
</target> </target>
</modelConnectionCompositor> </modelConnectionCompositor>
</extension> </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>
</extension>
......
...@@ -23,9 +23,13 @@ import org.eclipse.emf.ecore.EObject; ...@@ -23,9 +23,13 @@ import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.platform.compose.PlatformArchitectureElementCompositorBase; import org.fortiss.af3.platform.compose.PlatformArchitectureElementCompositorBase;
import org.fortiss.af3.platform.model.IPlatformArchitectureElement; import org.fortiss.af3.platform.model.IPlatformArchitectureElement;
import org.fortiss.af3.platform.raspberry.model.ActuatorConnector; 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.CanConnector;
import org.fortiss.af3.platform.raspberry.model.RaspberryPi; import org.fortiss.af3.platform.raspberry.model.RaspberryPi;
import org.fortiss.af3.platform.raspberry.model.SensorConnector; import org.fortiss.af3.platform.raspberry.model.SensorConnector;
import org.fortiss.af3.platform.raspberry.model.SensorGamepad;
import org.fortiss.af3.platform.raspberry.model.SensorLaserRangeFinder;
import org.fortiss.af3.platform.raspberry.model.SensorLaserScanner;
/** /**
* *
...@@ -43,7 +47,8 @@ public class RaspberryPiCompositor extends ...@@ -43,7 +47,8 @@ public class RaspberryPiCompositor extends
EObject contained) { EObject contained) {
final boolean instanceOfAny2 = final boolean instanceOfAny2 =
isInstanceOfAny(contained, CanConnector.class, SensorConnector.class, isInstanceOfAny(contained, CanConnector.class, SensorConnector.class,
ActuatorConnector.class); ActuatorConnector.class, ActuatorPWM.class, SensorLaserRangeFinder.class,
SensorGamepad.class, SensorLaserScanner.class);
if(container != null) { if(container != null) {
final boolean instanceOfAny = isInstanceOfAny(container, RaspberryPi.class); final boolean instanceOfAny = isInstanceOfAny(container, RaspberryPi.class);
return instanceOfAny && instanceOfAny2; return instanceOfAny && instanceOfAny2;
......
/*--------------------------------------------------------------------------+
$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 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.platform.generic.generator.executable.GenericExecutionUnitExecutable;
import org.fortiss.af3.platform.language.executable.IReadableExecutable;
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.tooling.kernel.extension.data.ITransformationContext;
/**
*
* @author eder
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public class RaspberryPIExecutable extends GenericExecutionUnitExecutable {
/** 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) {
return super.createExecutionUnitSourcePackage(name, deployedComponents, deployedPorts,
context);
}
/** {@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");
}
}
/*--------------------------------------------------------------------------+
$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;
/**
*
* @author eder
* @author $Author: hoelzl $
* @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);
}
}
...@@ -20,11 +20,15 @@ package org.fortiss.af3.platform.raspberry.util; ...@@ -20,11 +20,15 @@ package org.fortiss.af3.platform.raspberry.util;
import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createConnectorLayout; import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createConnectorLayout;
import org.fortiss.af3.platform.raspberry.model.ActuatorConnector; 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.CanBus;
import org.fortiss.af3.platform.raspberry.model.CanConnector; import org.fortiss.af3.platform.raspberry.model.CanConnector;
import org.fortiss.af3.platform.raspberry.model.ModelFactory; import org.fortiss.af3.platform.raspberry.model.ModelFactory;
import org.fortiss.af3.platform.raspberry.model.RaspberryPi; import org.fortiss.af3.platform.raspberry.model.RaspberryPi;
import org.fortiss.af3.platform.raspberry.model.SensorConnector; 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.tooling.base.utils.LayoutModelElementFactory; import org.fortiss.tooling.base.utils.LayoutModelElementFactory;
/** /**
...@@ -69,6 +73,30 @@ public class RaspberryModelElementFactory { ...@@ -69,6 +73,30 @@ public class RaspberryModelElementFactory {
return connector; return connector;
} }
/** Creates a {@link SensorIMU}. */
public static SensorIMU createSensorIMU() {
SensorIMU connector = ModelFactory.eINSTANCE.createSensorIMU();
connector.setName("IMU_In");
createConnectorLayout(connector);
return connector;
}
/** Creates a {@link SensorLaserRangeFinder}. */
public static SensorLaserRangeFinder createSensorLaserRangeFinder() {
SensorLaserRangeFinder connector = ModelFactory.eINSTANCE.createSensorLaserRangeFinder();
connector.setName("LaserRangeFinder_In");
createConnectorLayout(connector);
return connector;
}
/** Creates a {@link SensorLaserScanner}. */
public static SensorLaserScanner createSensorLaserScanner() {
SensorLaserScanner connector = ModelFactory.eINSTANCE.createSensorLaserScanner();
connector.setName("LaserScanner_In");
createConnectorLayout(connector);
return connector;
}
/** Creates a {@link ActuatorConnector}. */ /** Creates a {@link ActuatorConnector}. */
public static ActuatorConnector createActuatorConnector() { public static ActuatorConnector createActuatorConnector() {
ActuatorConnector connector = ModelFactory.eINSTANCE.createActuatorConnector(); ActuatorConnector connector = ModelFactory.eINSTANCE.createActuatorConnector();
...@@ -76,4 +104,12 @@ public class RaspberryModelElementFactory { ...@@ -76,4 +104,12 @@ public class RaspberryModelElementFactory {
createConnectorLayout(connector); createConnectorLayout(connector);
return connector; return connector;
} }
/** Creates a {@link ActuatorPWM}. */
public static ActuatorPWM createActuatorPWM() {
ActuatorPWM connector = ModelFactory.eINSTANCE.createActuatorPWM();
connector.setName("PWM_Out");
createConnectorLayout(connector);
return connector;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment