diff --git a/org.fortiss.af3.platform.raspberry/model/raspberry.ecore b/org.fortiss.af3.platform.raspberry/model/raspberry.ecore index 1706b361720a1bbbbd74a3111516a0a35100d9d2..573e8bf34d840cd8cfa5f8e576139211db68d49c 100644 --- a/org.fortiss.af3.platform.raspberry/model/raspberry.ecore +++ b/org.fortiss.af3.platform.raspberry/model/raspberry.ecore @@ -2,7 +2,7 @@ <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="../../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"/> @@ -14,20 +14,20 @@ <eStructuralFeatures xsi:type="ecore:EAttribute" name="controlcenterServerPort" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="CanBus" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//TransmissionUnit"/> - <eClassifiers xsi:type="ecore:EClass" name="CanConnector" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Transceiver"/> + <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="#//RaspberryPiTransmitterBase"> <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="ConsoleOutput" eSuperTypes="#//RaspberryPiTransmitterBase"/> <eClassifiers xsi:type="ecore:EClass" name="RaspberryPiTransmitterBase" abstract="true" - eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Transmitter"/> + eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Transmitter"/> <eClassifiers xsi:type="ecore:EClass" name="RaspberryPiReceiverBase" abstract="true" - eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Receiver"/> + eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Receiver"/> <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" - eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Receiver"/> + eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Receiver"/> <eClassifiers xsi:type="ecore:EClass" name="Button1" eSuperTypes="#//gamepad/GamepadReceiverBase"/> <eClassifiers xsi:type="ecore:EClass" name="Button2" eSuperTypes="#//gamepad/GamepadReceiverBase"/> <eClassifiers xsi:type="ecore:EClass" name="Button3" eSuperTypes="#//gamepad/GamepadReceiverBase"/> @@ -43,28 +43,28 @@ </eSubpackages> <eSubpackages name="brick" nsURI="http://www.fortiss.org/af3/platform/raspberry/brick" nsPrefix="org-fortiss-af3-platform-raspberry"> - <eClassifiers xsi:type="ecore:EClass" name="UIDUnit" abstract="true" eSuperTypes="../../org.fortiss.tooling.kernel/model/kernel.ecore#//INamedCommentedElement"> + <eClassifiers xsi:type="ecore:EClass" name="UIDUnit" abstract="true" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//INamedCommentedElement"> <eStructuralFeatures xsi:type="ecore:EAttribute" name="uniqueBrickletID" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="UltraSonicSensor" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> - <eClassifiers xsi:type="ecore:EClass" name="LaserRangeSensor" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> - <eClassifiers xsi:type="ecore:EClass" name="AccelerationXSensor" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> - <eClassifiers xsi:type="ecore:EClass" name="AccelerationYSensor" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> - <eClassifiers xsi:type="ecore:EClass" name="AccelerationZSensor" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> - <eClassifiers xsi:type="ecore:EClass" name="AngularVelocityXSensor" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> - <eClassifiers xsi:type="ecore:EClass" name="AngularVelocityYSensor" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> - <eClassifiers xsi:type="ecore:EClass" name="AngularVelocityZSensor" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> - <eClassifiers xsi:type="ecore:EClass" name="ActuatorDigits" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Transmitter #//brick/UIDUnit"> + <eClassifiers xsi:type="ecore:EClass" name="UltraSonicSensor" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> + <eClassifiers xsi:type="ecore:EClass" name="LaserRangeSensor" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> + <eClassifiers xsi:type="ecore:EClass" name="AccelerationXSensor" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> + <eClassifiers xsi:type="ecore:EClass" name="AccelerationYSensor" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> + <eClassifiers xsi:type="ecore:EClass" name="AccelerationZSensor" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> + <eClassifiers xsi:type="ecore:EClass" name="AngularVelocityXSensor" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> + <eClassifiers xsi:type="ecore:EClass" name="AngularVelocityYSensor" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> + <eClassifiers xsi:type="ecore:EClass" name="AngularVelocityZSensor" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Receiver #//brick/UIDUnit"/> + <eClassifiers xsi:type="ecore:EClass" name="ActuatorDigits" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Transmitter #//brick/UIDUnit"> <eStructuralFeatures xsi:type="ecore:EAttribute" name="showHexValue" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/> </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="LEDButtonRActuator" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Transmitter #//brick/UIDUnit"/> - <eClassifiers xsi:type="ecore:EClass" name="LEDButtonGActuator" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Transmitter #//brick/UIDUnit"/> - <eClassifiers xsi:type="ecore:EClass" name="LEDButtonBActuator" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Transmitter #//brick/UIDUnit"/> + <eClassifiers xsi:type="ecore:EClass" name="LEDButtonRActuator" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Transmitter #//brick/UIDUnit"/> + <eClassifiers xsi:type="ecore:EClass" name="LEDButtonGActuator" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Transmitter #//brick/UIDUnit"/> + <eClassifiers xsi:type="ecore:EClass" name="LEDButtonBActuator" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Transmitter #//brick/UIDUnit"/> </eSubpackages> <eSubpackages name="rumblepad" nsURI="http://www.fortiss.org/af3/platform/raspberry/rumblepad" nsPrefix="org-fortiss-af3-platform-raspberry-rumblepad"> <eClassifiers xsi:type="ecore:EClass" name="RumblepadReceiverBase" abstract="true" - eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Receiver"/> + eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Receiver"/> <eClassifiers xsi:type="ecore:EClass" name="ButtonA" eSuperTypes="#//rumblepad/RumblepadReceiverBase"/> <eClassifiers xsi:type="ecore:EClass" name="ButtonB" eSuperTypes="#//rumblepad/RumblepadReceiverBase"/> <eClassifiers xsi:type="ecore:EClass" name="ButtonX" eSuperTypes="#//rumblepad/RumblepadReceiverBase"/> @@ -86,9 +86,9 @@ <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"/> - <eClassifiers xsi:type="ecore:EClass" name="RumbleMagnitudeStrong" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Transmitter"/> - <eClassifiers xsi:type="ecore:EClass" name="RumbleMagnitudeWeak" eSuperTypes="../../org.fortiss.af3.platform/model/platform.ecore#//Transmitter"/> + <eClassifiers xsi:type="ecore:EClass" name="SimpleRumbleFeature" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Transmitter"/> + <eClassifiers xsi:type="ecore:EClass" name="RumbleMagnitudeStrong" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Transmitter"/> + <eClassifiers xsi:type="ecore:EClass" name="RumbleMagnitudeWeak" eSuperTypes="platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//Transmitter"/> </eSubpackages> <eSubpackages name="motorcontrol" nsURI="http://www.fortiss.org/af3/platform/raspberry/motorcontrol" nsPrefix="org-fortiss-af3-platform-raspberry-motorcontrol"> diff --git a/org.fortiss.af3.platform.raspberry/model/raspberry.genmodel b/org.fortiss.af3.platform.raspberry/model/raspberry.genmodel index 5e98fec3b817b4be22749427683a4d7ab9a8535a..982285f9e9a45010eefe8c4aac551b082789d39c 100644 --- a/org.fortiss.af3.platform.raspberry/model/raspberry.genmodel +++ b/org.fortiss.af3.platform.raspberry/model/raspberry.genmodel @@ -107,5 +107,24 @@ <genClasses ecoreClass="raspberry.ecore#//controlcenter/ControlCenterUpstreamOutput"/> <genClasses ecoreClass="raspberry.ecore#//controlcenter/ControlCenterDownstreamInput"/> </nestedGenPackages> + <nestedGenPackages prefix="V2v" basePackage="org.fortiss.af3.platform.raspberry.model" + disposableProviderFactory="true" ecorePackage="raspberry.ecore#//v2v"> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VPlatoonInput"/> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VPlatoonOutput"/> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VLeaderHeartbeatInput"/> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VLeaderHeartbeatOutput"/> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VFollowerInput"/> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VFollowerOutput"/> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VLeavePlatoonInput"/> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VLeavePlatoonOutput"/> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VSplitInput"/> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VSplitOutput"/> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VNewLeaderInput"/> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VNewLeaderOutput"/> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VFusePlatoonInput"/> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VFusePlatoonOutput"/> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VInput"/> + <genClasses ecoreClass="raspberry.ecore#//v2v/V2VOuput"/> + </nestedGenPackages> </genPackages> </genmodel:GenModel> diff --git a/org.fortiss.af3.platform.raspberry/plugin.xml b/org.fortiss.af3.platform.raspberry/plugin.xml index d2a572fab978dbb72b429b882d19ba604f4e850d..c331e3fe0b16bf659d35f5560ebc04c38f8cc666 100644 --- a/org.fortiss.af3.platform.raspberry/plugin.xml +++ b/org.fortiss.af3.platform.raspberry/plugin.xml @@ -201,6 +201,19 @@ </objectClass> </target> </transformationProvider> + <transformationProvider + transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.brick.ActuatorDigitsTransformation"> + <source> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.model.brick.ActuatorDigits"> + </objectClass> + </source> + <target> + <objectClass + objectClass="org.fortiss.af3.platform.raspberry.generator.extension.brick.ActuatorDigitsGeneratorExtension"> + </objectClass> + </target> + </transformationProvider> <transformationProvider transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.brick.LaserRangeTransformation"> <source> diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/extension/.ratings b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/extension/.ratings index 4d7a84e1750b3ba64d70d737d013ec3a3635cc08..001d5a64f77246e06157336ded185a81e856cae6 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/extension/.ratings +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/extension/.ratings @@ -5,4 +5,4 @@ ConsoleOutputGeneratorExtension.java d57db44d57630a50e26c9eeed90d6631bf99db5d YE MultiUnitMainGenerator.java 458754b89c2d79db3fee08baa444424772e40fb7 RED PWMActuatorGeneratorExtension.java 8cbfd72070cfc1c8a4da4ccc1d18a6b3e75cea7f YELLOW RaspberryPIGeneratorExtension.java 2cd95ddc54d7562bd9fa0b8a4018c25eda01b5a8 RED -SingleUnitMainGenerator.java 93d0370b01330ab023e02761df818d36fac42b0f RED +SingleUnitMainGenerator.java bea3d14367798b0ac6e832328f57cd6e7ea05425 RED diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/extension/SingleUnitMainGenerator.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/extension/SingleUnitMainGenerator.java index 93d0370b01330ab023e02761df818d36fac42b0f..bea3d14367798b0ac6e832328f57cd6e7ea05425 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/extension/SingleUnitMainGenerator.java +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/extension/SingleUnitMainGenerator.java @@ -306,7 +306,8 @@ class SingleUnitMainGenerator { String sPostfix = null; if(exec instanceof ISingletonGeneratorExtension) { sPostfix = - singletonPostfixMap.get(((ISingletonGeneratorExtension)exec).getSingletonIdentifier()); + singletonPostfixMap.get(((ISingletonGeneratorExtension)exec) + .getSingletonIdentifier()); } String iPostfix = instancePostfixMap.get(exec); if(exec instanceof IWriteableGeneratorExtension) { @@ -316,7 +317,7 @@ class SingleUnitMainGenerator { String novalCode = wexec.getNoValWriteCode(iPostfix, sPostfix, outport); if(novalCode != null) { String novalVariable = getPortNoValIdentifier(sourceVariable); - return "if (" + novalVariable + ") {\n" + novalCode + "}\n else {\n" + writeCode + + return "if (" + novalVariable + ") {\n" + novalCode + "} else {\n" + writeCode + "}\n"; } return writeCode; @@ -331,7 +332,8 @@ class SingleUnitMainGenerator { String sPostfix = null; if(exec instanceof ISingletonGeneratorExtension) { sPostfix = - singletonPostfixMap.get(((ISingletonGeneratorExtension)exec).getSingletonIdentifier()); + singletonPostfixMap.get(((ISingletonGeneratorExtension)exec) + .getSingletonIdentifier()); } String iPostfix = instancePostfixMap.get(exec); if(exec instanceof IReadableGeneratorExtension) { diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/extension/brick/.ratings b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/extension/brick/.ratings index 3554096a596721307c581253205613dca2e4f10e..72b0f75c3d2c275edd9301af241ff3acd002e972 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/extension/brick/.ratings +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/extension/brick/.ratings @@ -1,3 +1,4 @@ +ActuatorDigitsGeneratorExtension.java 5df8861318c5b8002785ae4ff9fb9af0d095b7bc YELLOW BrickGeneratorExtensionBase.java 01442772f80ebf32eaf0507495a4380d0de034b1 YELLOW LaserRangeSensorGeneratorExtension.java ff0c1e5e96a69b7deb6d7675e40f18510a36e7a0 YELLOW UltraSonicSensorGeneratorExtension.java cbd4555e28600ce8f47c737330adfc9b5581bae8 YELLOW diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/extension/brick/ActuatorDigitsGeneratorExtension.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/extension/brick/ActuatorDigitsGeneratorExtension.java new file mode 100644 index 0000000000000000000000000000000000000000..5df8861318c5b8002785ae4ff9fb9af0d095b7bc --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/extension/brick/ActuatorDigitsGeneratorExtension.java @@ -0,0 +1,102 @@ +/*-------------------------------------------------------------------------+ +| Copyright 2018 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.extension.brick; + +import org.fortiss.af3.component.model.OutputPort; +import org.fortiss.af3.platform.raspberry.generator.framework.IInstanceInitializationGeneratorExtension; +import org.fortiss.af3.platform.raspberry.generator.framework.IWriteableGeneratorExtension; +import org.fortiss.af3.platform.raspberry.model.brick.ActuatorDigits; + +/** + * Generator extension for {@link ActuatorDigits}s. + * + * @author hoelzl + */ +public class ActuatorDigitsGeneratorExtension extends BrickGeneratorExtensionBase<ActuatorDigits> + implements IWriteableGeneratorExtension, IInstanceInitializationGeneratorExtension { + /** Constructor. */ + public ActuatorDigitsGeneratorExtension(ActuatorDigits modelElement) { + super(modelElement); + } + + /** {@inheritDoc} */ + @Override + public String getHeaderFileName() { + return "bricklet_segment_display_4x7.h"; + } + + /** {@inheritDoc} */ + @Override + public String getVariableDeclaration(String postfix, String singletonPostfix) { + StringBuilder sb = new StringBuilder(); + sb.append("static SegmentDisplay4x7 segment_display_" + postfix + ";\n"); + return sb.toString(); + } + + /** {@inheritDoc} */ + @Override + public String getInstanceAuxiliaryFunctions(String postfix, String singletonPostfix) { + StringBuilder sb = new StringBuilder(); + sb.append("static void set_led_display_" + postfix + + "(SegmentDisplay4x7 *segment_display, uint16_t value, bool showHex) {\n"); + sb.append("static const uint8_t digits_" + postfix + "[] = {0x3f,0x06,0x5b,0x4f,\n"); + sb.append(" 0x66,0x6d,0x7d,0x07,\n"); + sb.append(" 0x7f,0x6f,0x77,0x7c,\n"); + sb.append(" 0x39,0x5e,0x79,0x71};\n"); + sb.append("if(showHex) {\n"); + sb.append("uint8_t segments[4] = {(uint8_t) digits_" + postfix + + "[(value >> 12) & 0x0F], (uint8_t) digits_" + postfix + + "[(value >> 8) & 0x0F], (uint8_t) digits_" + postfix + + "[(value >> 4) & 0x0F], (uint8_t) digits_" + postfix + "[value & 0x0F]};\n"); + sb.append("segment_display_4x7_set_segments(segment_display, segments, 5, false);\n"); + sb.append("} else {\n"); + sb.append("uint8_t segments[4] = {(uint8_t) digits_" + postfix + + "[(value%10000)/1000], (uint8_t) digits_" + postfix + + "[(value%1000)/100], (uint8_t) digits_" + postfix + + "[(value%100)/10], (uint8_t) digits_" + postfix + "[value%10]};\n"); + sb.append("segment_display_4x7_set_segments(segment_display, segments, 5, false);\n"); + sb.append("}\n"); + sb.append("}\n\n"); + return sb.toString(); + } + + /** {@inheritDoc} */ + @Override + public String getInitializationCode(String postfix, String singletonPostfix) { + StringBuilder sb = new StringBuilder(); + sb.append("segment_display_4x7_create(&segment_display_" + postfix + ", \"" + + modelElement.getUniqueBrickletID() + "\", &" + + getConnectionVariable(singletonPostfix) + ");\n"); + return sb.toString(); + } + + /** {@inheritDoc} */ + @Override + public String getWriteCode(String postfix, String singletonPostfix, OutputPort logicalSignal, + String value) { + StringBuilder sb = new StringBuilder(); + sb.append("set_led_display_" + postfix + "(&segment_display_" + postfix + ", (uint16_t)" + + value + ", " + modelElement.isShowHexValue() + ");\n"); + return sb.toString(); + } + + /** {@inheritDoc} */ + @Override + public String getNoValWriteCode(String postfix, String singletonPostfix, + OutputPort logicalSignal) { + return null; + } +} diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/transform/brick/.ratings b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/transform/brick/.ratings index beb82b2eccf4d4c777b2682b659eae694aa86f63..dd7fad4f379543a55532cb1f7634977cc34f3627 100644 --- a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/transform/brick/.ratings +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/transform/brick/.ratings @@ -1,2 +1,3 @@ +ActuatorDigitsTransformation.java 7b7b0fb3f185cd05ae4f45766366bc2e6c2e872a YELLOW LaserRangeTransformation.java 270d75e0bbdea4e7e917b10455d5b71210667e82 YELLOW UltraSonicTransformation.java d278ee2d489f467f0df2cd25895afaee879035d0 YELLOW diff --git a/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/transform/brick/ActuatorDigitsTransformation.java b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/transform/brick/ActuatorDigitsTransformation.java new file mode 100644 index 0000000000000000000000000000000000000000..7b7b0fb3f185cd05ae4f45766366bc2e6c2e872a --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/src/org/fortiss/af3/platform/raspberry/generator/transform/brick/ActuatorDigitsTransformation.java @@ -0,0 +1,28 @@ +/*-------------------------------------------------------------------------+ +| Copyright 2018 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.brick; + +import org.fortiss.af3.platform.raspberry.generator.extension.brick.ActuatorDigitsGeneratorExtension; +import org.fortiss.af3.platform.raspberry.generator.transform.RasPiGeneratorTransformationBase; +import org.fortiss.af3.platform.raspberry.model.brick.ActuatorDigits; + +/** Transformation for {@link ActuatorDigits}. */ +public class ActuatorDigitsTransformation extends RasPiGeneratorTransformationBase { + /** Constructor. */ + public ActuatorDigitsTransformation() { + super(ActuatorDigits.class, ActuatorDigitsGeneratorExtension.class); + } +}