Skip to content
Snippets Groups Projects
Commit 32e8e160 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

Added property sections for Raspberry Pi units.

refs 3079
parent 71274ca0
No related branches found
No related tags found
No related merge requests found
Showing
with 161 additions and 96 deletions
......@@ -137,4 +137,20 @@
</modelElementClass>
</modelElementHandler>
</extension>
<extension
point="org.eclipse.ui.views.properties.tabbed.propertySections">
<propertySections
contributorId="org.fortiss.tooling.kernel.ui.properties.Contributor">
<propertySection
afterSection="org.fortiss.tooling.kernel.ui.internal.properties.NamedCommentedPropertySection"
class="org.fortiss.af3.platform.raspberry.ui.properties.RaspberryPiExecutionUnitPropertySection"
enablesFor="1"
id="org.fortiss.af3.platform.raspberry.ui.properties.RaspberryPiExecutionUnitPropertySection"
tab="org.fortiss.tooling.kernel.ui.property.tab.general">
<input
type="org.fortiss.af3.platform.raspberry.model.RaspberryPi">
</input>
</propertySection>
</propertySections>
</extension>
</plugin>
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2013 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.properties;
import static org.eclipse.jface.databinding.swt.SWTObservables.observeSelection;
import static org.eclipse.jface.databinding.swt.SWTObservables.observeText;
import static org.fortiss.af3.expression.ui.databinding.validate.IntToStringConverter.INT_STRING_CONVERTER;
import static org.fortiss.af3.expression.ui.databinding.validate.StringToIntConverter.STRING_INT_CONVERTER;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.performComplexTextBinding;
import static org.fortiss.tooling.kernel.ui.util.ObservableUtils.observeValue;
import org.conqat.ide.commons.ui.databinding.validate.NumberPositiveValidator;
import org.conqat.ide.commons.ui.databinding.validate.TextToIntegerValidator;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.fortiss.af3.platform.raspberry.model.RaspberryPi;
import org.fortiss.af3.platform.raspberry.model.RaspberryPiModelPackage;
import org.fortiss.tooling.kernel.ui.extension.base.PropertySectionBase;
/**
* Property section for {@link RaspberryPi}s.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 9E768B733BD37201F97399293FA0DFA7
*/
public class RaspberryPiExecutionUnitPropertySection extends PropertySectionBase {
/** The execution unit. */
private RaspberryPi unit;
/** The virtual keyboard port number widget. */
private Text canCoordinationIDText;
/** The cycle time widget. */
private Text cycleTimeText;
/** The IP address widget. */
private Text ipAddressText;
/** The coordinator flag button. */
private Button coordinatorFlagButton;
/** {@inheritDoc} */
@Override
public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) {
super.createControls(parent, tabbedPropertySheetPage);
canCoordinationIDText = createDecoratedText("CAN Unit ID");
cycleTimeText = createDecoratedText("Cycle Time (ms)");
coordinatorFlagButton = getWidgetFactory().createButton(composite, "", SWT.CHECK);
createFormEntry(coordinatorFlagButton, "Coordinator Unit");
coordinatorFlagButton.setSelection(false);
ipAddressText = createDecoratedText("IP Address");
}
/** {@inheritDoc} */
@Override
protected void setSectionInput(Object input) {
unit = (RaspberryPi)input;
}
/** {@inheritDoc} */
@Override
public void refresh() {
super.refresh();
IObservableValue modelObservable =
observeValue(unit,
RaspberryPiModelPackage.Literals.RASPBERRY_PI__CAN_COORDINATION_ID);
performComplexTextBinding(dbc, canCoordinationIDText, modelObservable,
INT_STRING_CONVERTER, STRING_INT_CONVERTER, TextToIntegerValidator.INSTANCE,
new NumberPositiveValidator());
modelObservable =
observeValue(unit, RaspberryPiModelPackage.Literals.RASPBERRY_PI__CYCLE_TIME);
performComplexTextBinding(dbc, cycleTimeText, modelObservable, INT_STRING_CONVERTER,
STRING_INT_CONVERTER, TextToIntegerValidator.INSTANCE,
new NumberPositiveValidator());
modelObservable =
observeValue(unit, RaspberryPiModelPackage.Literals.RASPBERRY_PI__IP_ADDRESS);
dbc.bindValue(observeText(ipAddressText, SWT.Modify), modelObservable);
modelObservable =
observeValue(unit, RaspberryPiModelPackage.Literals.RASPBERRY_PI__COORDINATOR_UNIT);
dbc.bindValue(observeSelection(coordinatorFlagButton), modelObservable);
}
}
......@@ -7,12 +7,9 @@ Bundle-ClassPath: .
Bundle-Vendor: fortiss GmbH
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.fortiss.af3.platform.raspberry.model,
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
......
......@@ -2,10 +2,21 @@
<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#//ExecutionUnit"/>
<eClassifiers xsi:type="ecore:EClass" name="RaspberryPi" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ExecutionUnit">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="canCoordinationID" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="ipAddress" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="coordinatorUnit" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="cycleTime" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="CanBus" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//TransmissionUnit"/>
<eClassifiers xsi:type="ecore:EClass" name="CanConnector" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Transceiver"/>
<eClassifiers xsi:type="ecore:EClass" name="ActuatorPWM" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Transmitter"/>
<eClassifiers xsi:type="ecore:EClass" name="ActuatorPWM" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Transmitter">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="channelID" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ActuatorDigits" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Transmitter">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="showHexValue" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="uniqueBrickletID" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<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="GamepadReceiverBase" abstract="true"
......@@ -23,10 +34,4 @@
<eClassifiers xsi:type="ecore:EClass" name="Right_StickX_Position" eSuperTypes="#//gamepad/GamepadReceiverBase"/>
<eClassifiers xsi:type="ecore:EClass" name="Right_StickY_Position" eSuperTypes="#//gamepad/GamepadReceiverBase"/>
</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>
......@@ -5,12 +5,23 @@
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"/>
<genPackages prefix="RaspberryPiModel" basePackage="org.fortiss.af3.platform.raspberry"
disposableProviderFactory="true" ecorePackage="raspberry.ecore#/">
<genClasses ecoreClass="raspberry.ecore#//RaspberryPi">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute raspberry.ecore#//RaspberryPi/canCoordinationID"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute raspberry.ecore#//RaspberryPi/ipAddress"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute raspberry.ecore#//RaspberryPi/coordinatorUnit"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute raspberry.ecore#//RaspberryPi/cycleTime"/>
</genClasses>
<genClasses ecoreClass="raspberry.ecore#//CanBus"/>
<genClasses ecoreClass="raspberry.ecore#//CanConnector"/>
<genClasses ecoreClass="raspberry.ecore#//ActuatorPWM"/>
<genClasses ecoreClass="raspberry.ecore#//ActuatorPWM">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute raspberry.ecore#//ActuatorPWM/channelID"/>
</genClasses>
<genClasses ecoreClass="raspberry.ecore#//ActuatorDigits">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute raspberry.ecore#//ActuatorDigits/showHexValue"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute raspberry.ecore#//ActuatorDigits/uniqueBrickletID"/>
</genClasses>
<nestedGenPackages prefix="Gamepad" basePackage="org.fortiss.af3.platform.raspberry.model"
disposableProviderFactory="true" ecorePackage="raspberry.ecore#//gamepad">
<genClasses image="false" ecoreClass="raspberry.ecore#//gamepad/GamepadReceiverBase"/>
......@@ -27,11 +38,5 @@
<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>
......@@ -14,7 +14,7 @@
<!-- @generated raspberry -->
<package
uri="http://www.fortiss.org/af3/platform/raspberry"
class="org.fortiss.af3.platform.raspberry.model.ModelPackage"
class="org.fortiss.af3.platform.raspberry.model.RaspberryPiModelPackage"
genModel="model/raspberry.genmodel"/>
</extension>
......@@ -26,13 +26,6 @@
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
......@@ -288,13 +281,4 @@
</target>
</transformationProvider>
</extension>
<extension
point="org.fortiss.tooling.base.annotation">
<annotation
binding="org.fortiss.af3.platform.raspberry.annotation.PWMChannelNumberValueProvider">
<modelElementClass
modelElementClass="org.fortiss.af3.platform.raspberry.model.ActuatorPWM">
</modelElementClass>
</annotation>
</extension>
</plugin>
/*--------------------------------------------------------------------------+
$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";
}
}
......@@ -19,13 +19,11 @@ 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 static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation;
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.ActuatorPWM;
import org.fortiss.af3.platform.raspberry.model.annotation.Channel;
/**
* Executable for {@link ActuatorPWM}.
......@@ -64,6 +62,6 @@ public class PWMActuatorExecutable extends TransmitterExecutableBase<ActuatorPWM
}
private int getPWMChannelFromModelElement(ActuatorPWM modelElement) {
return getAnnotation(modelElement, Channel.class).getChannel();
return modelElement.getChannelID();
}
}
......@@ -22,8 +22,8 @@ import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createCon
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.ModelFactory;
import org.fortiss.af3.platform.raspberry.model.RaspberryPi;
import org.fortiss.af3.platform.raspberry.model.RaspberryPiModelFactory;
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;
......@@ -51,15 +51,19 @@ public class RaspberryModelElementFactory {
/** Creates a {@link RaspberryPi}. */
public static RaspberryPi createRaspberryPi() {
final RaspberryPi pi = ModelFactory.eINSTANCE.createRaspberryPi();
final RaspberryPi pi = RaspberryPiModelFactory.eINSTANCE.createRaspberryPi();
LayoutModelElementFactory.createNodeElementLayout(pi);
pi.setName("RaspberryPI");
pi.setCanCoordinationID(255);
pi.setCycleTime(100);
pi.setIpAddress("192.168.21.241");
pi.setCoordinatorUnit(false);
return pi;
}
/** Creates a {@link CanBus}. */
public static CanBus createCanBus() {
final CanBus bus = ModelFactory.eINSTANCE.createCanBus();
final CanBus bus = RaspberryPiModelFactory.eINSTANCE.createCanBus();
LayoutModelElementFactory.createNodeElementLayout(bus);
bus.setName("CanBus");
return bus;
......@@ -67,7 +71,7 @@ public class RaspberryModelElementFactory {
/** Creates a {@link CanConnector}. */
public static CanConnector createCanConnector() {
CanConnector canConnector = ModelFactory.eINSTANCE.createCanConnector();
CanConnector canConnector = RaspberryPiModelFactory.eINSTANCE.createCanConnector();
canConnector.setName("CanConnector");
createConnectorLayout(canConnector);
return canConnector;
......@@ -75,7 +79,7 @@ public class RaspberryModelElementFactory {
/** Creates a {@link ActuatorPWM}. */
public static ActuatorPWM createActuatorPWM() {
ActuatorPWM connector = ModelFactory.eINSTANCE.createActuatorPWM();
ActuatorPWM connector = RaspberryPiModelFactory.eINSTANCE.createActuatorPWM();
connector.setName("PWM");
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