From bb0dad06132f5852fedfb9c4bfac1defb5e42b80 Mon Sep 17 00:00:00 2001 From: Khan <khan@fortiss.org> Date: Tue, 5 Jul 2016 15:05:06 +0000 Subject: [PATCH] changes to the raspberry platform / code generator --- .../CoreToBusConnectionCompositor.java | 95 ---- ...pberryPi1ToCANBusConnectionCompositor.java | 96 ---- ...pberryPi2ToCANBusConnectionCompositor.java | 96 ---- ...pberryPi3ToCANBusConnectionCompositor.java | 96 ---- .../model/annotation/AnnotationFactory.java | 9 + .../model/annotation/AnnotationPackage.java | 94 ++++ .../raspberry/model/annotation/PAddress.java | 19 + .../model/annotation/PeripheralAddress.java | 51 +++ .../impl/AnnotationFactoryImpl.java | 11 + .../impl/AnnotationPackageImpl.java | 35 ++ .../impl/PeripheralAddressImpl.java | 431 ++++++++++++++++++ .../util/AnnotationAdapterFactory.java | 18 + .../annotation/util/AnnotationSwitch.java | 26 ++ .../trunk/model/raspberry.ecore | 3 + .../trunk/model/raspberry.genmodel | 3 + .../trunk/plugin.xml | 19 + .../PeripheralAddressValueProvider.java | 48 ++ ...tion.java => RaspberryFileGeneration.java} | 10 +- .../executable/ActuatorOutExecutable.java | 38 +- .../generator/executable/BusExecutable.java | 171 ++++++- .../executable/BusMasterPortExecutable.java | 18 +- .../generator/executable/CoreExecutable.java | 149 +++++- .../executable/RaspberryPi2Executable.java | 27 ++ .../executable/SensorInExecutable.java | 39 +- .../raspberry/utils/RaspberryUtils.java | 11 + 25 files changed, 1150 insertions(+), 463 deletions(-) delete mode 100644 org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/CoreToBusConnectionCompositor.java delete mode 100644 org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/RaspberryPi1ToCANBusConnectionCompositor.java delete mode 100644 org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/RaspberryPi2ToCANBusConnectionCompositor.java delete mode 100644 org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/RaspberryPi3ToCANBusConnectionCompositor.java create mode 100644 org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/PAddress.java create mode 100644 org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/PeripheralAddress.java create mode 100644 org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/impl/PeripheralAddressImpl.java create mode 100644 org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/annotation/valueprovider/PeripheralAddressValueProvider.java rename org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generated/files/{RaspberryPortTypeGeneration.java => RaspberryFileGeneration.java} (88%) diff --git a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/CoreToBusConnectionCompositor.java b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/CoreToBusConnectionCompositor.java deleted file mode 100644 index b250e82d..00000000 --- a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/CoreToBusConnectionCompositor.java +++ /dev/null @@ -1,95 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id$ -| | -| Copyright 2016 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.compose.connections; - -import static org.fortiss.af3.platform.raspberry.utils.RaspberryModelElementFactory.createBusMasterInterface; -import static org.fortiss.af3.platform.raspberry.utils.RaspberryModelElementFactory.createBusMasterPort; -import static org.fortiss.af3.platform.utils.PlatformModelElementFactory.createTransmissionConnection; - -import org.fortiss.af3.platform.model.GenericPlatformUnit; -import org.fortiss.af3.platform.raspberry.model.Bus; -import org.fortiss.af3.platform.raspberry.model.Core; -import org.fortiss.tooling.base.compose.HierarchicElementConnectionCompositorBase; -import org.fortiss.tooling.base.model.element.IConnection; -import org.fortiss.tooling.base.model.element.IConnector; -import org.fortiss.tooling.kernel.extension.data.IConnectionCompositionContext; -import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; -import org.fortiss.tooling.kernel.service.IPersistencyService; - -/** - * - * @author chaudhary - * @author $Author$ - * @version $Rev$ - * @ConQAT.Rating RED Hash: - */ -public class CoreToBusConnectionCompositor extends - HierarchicElementConnectionCompositorBase<GenericPlatformUnit, Core, Bus> { - - /** {@inheritDoc} */ - @Override - public boolean canConnect(Core source, Bus target, GenericPlatformUnit parent, - IConnectionCompositionContext context) { - - if(source.eContainer() != target.eContainer()) { - return false; - } - return super.canConnect(source, target, parent, context); - } - - /** {@inheritDoc} */ - @Override - public boolean connect(Core source, Bus target, GenericPlatformUnit parent, - IConnectionCompositionContext context) { - IConnector sourceConnector = createEntryConnector(); - avoidDuplicateConnectorName(source, sourceConnector); - - IConnector targetConnector = createExitConnector(); - avoidDuplicateConnectorName(target, targetConnector); - - ITopLevelElement topElement = IPersistencyService.INSTANCE.getTopLevelElementFor(parent); - if(topElement != null) { - topElement.prepareIDs(sourceConnector); - topElement.prepareIDs(targetConnector); - } - createNewSourceDropContext(source, context, sourceConnector); - createNewTargetDropContext(target, context, targetConnector); - - createConnection(sourceConnector, targetConnector, parent, topElement); - return true; - } - - /** {@inheritDoc} */ - @Override - protected IConnector createEntryConnector() { - return createBusMasterPort("BusMasterPort"); - } - - /** {@inheritDoc} */ - @Override - protected IConnector createExitConnector() { - return createBusMasterInterface("BusMasterInterface"); - } - - /** {@inheritDoc} */ - @Override - protected IConnection createConnection() { - return createTransmissionConnection(); - } - -} diff --git a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/RaspberryPi1ToCANBusConnectionCompositor.java b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/RaspberryPi1ToCANBusConnectionCompositor.java deleted file mode 100644 index 6d7feaef..00000000 --- a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/RaspberryPi1ToCANBusConnectionCompositor.java +++ /dev/null @@ -1,96 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id$ -| | -| Copyright 2016 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.compose.connections; - -import static org.fortiss.af3.platform.raspberry.utils.RaspberryModelElementFactory.createCANBusMasterInterface; -import static org.fortiss.af3.platform.raspberry.utils.RaspberryModelElementFactory.createCANBusMasterPort; -import static org.fortiss.af3.platform.utils.PlatformModelElementFactory.createTransmissionConnection; - -import org.fortiss.af3.platform.model.PlatformArchitecture; -import org.fortiss.af3.platform.raspberry.model.CANBus; -import org.fortiss.af3.platform.raspberry.model.RaspberryPi1; -import org.fortiss.tooling.base.compose.HierarchicElementConnectionCompositorBase; -import org.fortiss.tooling.base.model.element.IConnection; -import org.fortiss.tooling.base.model.element.IConnector; -import org.fortiss.tooling.kernel.extension.data.IConnectionCompositionContext; -import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; -import org.fortiss.tooling.kernel.service.IPersistencyService; - -/** - * - * @author chaudhary - * @author $Author$ - * @version $Rev$ - * @ConQAT.Rating RED Hash: - */ -public class RaspberryPi1ToCANBusConnectionCompositor extends - HierarchicElementConnectionCompositorBase<PlatformArchitecture, RaspberryPi1, CANBus> { - - /** {@inheritDoc} */ - @Override - public boolean canConnect(RaspberryPi1 source, CANBus target, PlatformArchitecture parent, - IConnectionCompositionContext context) { - - if(source.eContainer() != target.eContainer()) { - return false; - } - return super.canConnect(source, target, parent, context); - } - - /** {@inheritDoc} */ - @Override - public boolean connect(RaspberryPi1 source, CANBus target, PlatformArchitecture parent, - IConnectionCompositionContext context) { - IConnector sourceConnector = createEntryConnector(); - avoidDuplicateConnectorName(source, sourceConnector); - - IConnector targetConnector = createExitConnector(); - avoidDuplicateConnectorName(target, targetConnector); - - ITopLevelElement topElement = IPersistencyService.INSTANCE.getTopLevelElementFor(parent); - if(topElement != null) { - topElement.prepareIDs(sourceConnector); - topElement.prepareIDs(targetConnector); - } - createNewSourceDropContext(source, context, sourceConnector); - createNewTargetDropContext(target, context, targetConnector); - - createConnection(sourceConnector, targetConnector, parent, topElement); - return true; - } - - /** {@inheritDoc} */ - @Override - protected IConnector createEntryConnector() { - return createCANBusMasterPort("CANBusMasterPort"); - - } - - /** {@inheritDoc} */ - @Override - protected IConnector createExitConnector() { - return createCANBusMasterInterface("CANBusMasterInterface"); - } - - /** {@inheritDoc} */ - @Override - protected IConnection createConnection() { - return createTransmissionConnection(); - } - -} diff --git a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/RaspberryPi2ToCANBusConnectionCompositor.java b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/RaspberryPi2ToCANBusConnectionCompositor.java deleted file mode 100644 index 144fe3a2..00000000 --- a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/RaspberryPi2ToCANBusConnectionCompositor.java +++ /dev/null @@ -1,96 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id$ -| | -| Copyright 2016 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.compose.connections; - -import static org.fortiss.af3.platform.raspberry.utils.RaspberryModelElementFactory.createCANBusMasterInterface; -import static org.fortiss.af3.platform.raspberry.utils.RaspberryModelElementFactory.createCANBusMasterPort; -import static org.fortiss.af3.platform.utils.PlatformModelElementFactory.createTransmissionConnection; - -import org.fortiss.af3.platform.model.PlatformArchitecture; -import org.fortiss.af3.platform.raspberry.model.CANBus; -import org.fortiss.af3.platform.raspberry.model.RaspberryPi2; -import org.fortiss.tooling.base.compose.HierarchicElementConnectionCompositorBase; -import org.fortiss.tooling.base.model.element.IConnection; -import org.fortiss.tooling.base.model.element.IConnector; -import org.fortiss.tooling.kernel.extension.data.IConnectionCompositionContext; -import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; -import org.fortiss.tooling.kernel.service.IPersistencyService; - -/** - * - * @author chaudhary - * @author $Author$ - * @version $Rev$ - * @ConQAT.Rating RED Hash: - */ -public class RaspberryPi2ToCANBusConnectionCompositor extends - HierarchicElementConnectionCompositorBase<PlatformArchitecture, RaspberryPi2, CANBus> { - - /** {@inheritDoc} */ - @Override - public boolean canConnect(RaspberryPi2 source, CANBus target, PlatformArchitecture parent, - IConnectionCompositionContext context) { - - if(source.eContainer() != target.eContainer()) { - return false; - } - return super.canConnect(source, target, parent, context); - } - - /** {@inheritDoc} */ - @Override - public boolean connect(RaspberryPi2 source, CANBus target, PlatformArchitecture parent, - IConnectionCompositionContext context) { - IConnector sourceConnector = createEntryConnector(); - avoidDuplicateConnectorName(source, sourceConnector); - - IConnector targetConnector = createExitConnector(); - avoidDuplicateConnectorName(target, targetConnector); - - ITopLevelElement topElement = IPersistencyService.INSTANCE.getTopLevelElementFor(parent); - if(topElement != null) { - topElement.prepareIDs(sourceConnector); - topElement.prepareIDs(targetConnector); - } - createNewSourceDropContext(source, context, sourceConnector); - createNewTargetDropContext(target, context, targetConnector); - - createConnection(sourceConnector, targetConnector, parent, topElement); - return true; - } - - /** {@inheritDoc} */ - @Override - protected IConnector createEntryConnector() { - return createCANBusMasterPort("CANBusMasterPort"); - - } - - /** {@inheritDoc} */ - @Override - protected IConnector createExitConnector() { - return createCANBusMasterInterface("CANBusMasterInterface"); - } - - /** {@inheritDoc} */ - @Override - protected IConnection createConnection() { - return createTransmissionConnection(); - } - -} diff --git a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/RaspberryPi3ToCANBusConnectionCompositor.java b/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/RaspberryPi3ToCANBusConnectionCompositor.java deleted file mode 100644 index 84a717a3..00000000 --- a/org.fortiss.af3.platform.raspberry.ui/trunk/src/org/fortiss/af3/platform/raspberry/ui/compose/connections/RaspberryPi3ToCANBusConnectionCompositor.java +++ /dev/null @@ -1,96 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id$ -| | -| Copyright 2016 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.compose.connections; - -import static org.fortiss.af3.platform.raspberry.utils.RaspberryModelElementFactory.createCANBusMasterInterface; -import static org.fortiss.af3.platform.raspberry.utils.RaspberryModelElementFactory.createCANBusMasterPort; -import static org.fortiss.af3.platform.utils.PlatformModelElementFactory.createTransmissionConnection; - -import org.fortiss.af3.platform.model.PlatformArchitecture; -import org.fortiss.af3.platform.raspberry.model.CANBus; -import org.fortiss.af3.platform.raspberry.model.RaspberryPi3; -import org.fortiss.tooling.base.compose.HierarchicElementConnectionCompositorBase; -import org.fortiss.tooling.base.model.element.IConnection; -import org.fortiss.tooling.base.model.element.IConnector; -import org.fortiss.tooling.kernel.extension.data.IConnectionCompositionContext; -import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; -import org.fortiss.tooling.kernel.service.IPersistencyService; - -/** - * - * @author chaudhary - * @author $Author$ - * @version $Rev$ - * @ConQAT.Rating RED Hash: - */ -public class RaspberryPi3ToCANBusConnectionCompositor extends - HierarchicElementConnectionCompositorBase<PlatformArchitecture, RaspberryPi3, CANBus> { - - /** {@inheritDoc} */ - @Override - public boolean canConnect(RaspberryPi3 source, CANBus target, PlatformArchitecture parent, - IConnectionCompositionContext context) { - - if(source.eContainer() != target.eContainer()) { - return false; - } - return super.canConnect(source, target, parent, context); - } - - /** {@inheritDoc} */ - @Override - public boolean connect(RaspberryPi3 source, CANBus target, PlatformArchitecture parent, - IConnectionCompositionContext context) { - IConnector sourceConnector = createEntryConnector(); - avoidDuplicateConnectorName(source, sourceConnector); - - IConnector targetConnector = createExitConnector(); - avoidDuplicateConnectorName(target, targetConnector); - - ITopLevelElement topElement = IPersistencyService.INSTANCE.getTopLevelElementFor(parent); - if(topElement != null) { - topElement.prepareIDs(sourceConnector); - topElement.prepareIDs(targetConnector); - } - createNewSourceDropContext(source, context, sourceConnector); - createNewTargetDropContext(target, context, targetConnector); - - createConnection(sourceConnector, targetConnector, parent, topElement); - return true; - } - - /** {@inheritDoc} */ - @Override - protected IConnector createEntryConnector() { - return createCANBusMasterPort("CANBusMasterPort"); - - } - - /** {@inheritDoc} */ - @Override - protected IConnector createExitConnector() { - return createCANBusMasterInterface("CANBusMasterInterface"); - } - - /** {@inheritDoc} */ - @Override - protected IConnection createConnection() { - return createTransmissionConnection(); - } - -} diff --git a/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/AnnotationFactory.java b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/AnnotationFactory.java index dcfa1e82..1e90bb79 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/AnnotationFactory.java +++ b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/AnnotationFactory.java @@ -39,6 +39,15 @@ public interface AnnotationFactory extends EFactory { */ PinNumber createPinNumber(); + /** + * Returns a new object of class '<em>Peripheral Address</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Peripheral Address</em>'. + * @generated + */ + PeripheralAddress createPeripheralAddress(); + /** * Returns the package supported by this factory. * <!-- begin-user-doc --> diff --git a/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/AnnotationPackage.java b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/AnnotationPackage.java index b6e29792..67db9920 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/AnnotationPackage.java +++ b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/AnnotationPackage.java @@ -167,6 +167,61 @@ public interface AnnotationPackage extends EPackage { int PIN_NUMBER_FEATURE_COUNT = ElementPackage.IANNOTATED_SPECIFICATION_FEATURE_COUNT + 1; + /** + * The meta object id for the '{@link org.fortiss.af3.platform.raspberry.model.annotation.impl.PeripheralAddressImpl <em>Peripheral Address</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.fortiss.af3.platform.raspberry.model.annotation.impl.PeripheralAddressImpl + * @see org.fortiss.af3.platform.raspberry.model.annotation.impl.AnnotationPackageImpl#getPeripheralAddress() + * @generated + */ + int PERIPHERAL_ADDRESS = 2; + + /** + * The feature id for the '<em><b>Id</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PERIPHERAL_ADDRESS__ID = ElementPackage.IANNOTATED_SPECIFICATION__ID; + + /** + * The feature id for the '<em><b>Specification Of</b></em>' container reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PERIPHERAL_ADDRESS__SPECIFICATION_OF = ElementPackage.IANNOTATED_SPECIFICATION__SPECIFICATION_OF; + + /** + * The feature id for the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PERIPHERAL_ADDRESS__NAME = ElementPackage.IANNOTATED_SPECIFICATION__NAME; + + /** + * The feature id for the '<em><b>Peripheral Address</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PERIPHERAL_ADDRESS__PERIPHERAL_ADDRESS = ElementPackage.IANNOTATED_SPECIFICATION_FEATURE_COUNT + 0; + + /** + * The number of structural features of the '<em>Peripheral Address</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PERIPHERAL_ADDRESS_FEATURE_COUNT = ElementPackage.IANNOTATED_SPECIFICATION_FEATURE_COUNT + 1; + /** * Returns the meta object for class '{@link org.fortiss.af3.platform.raspberry.model.annotation.CoreAddress <em>Core Address</em>}'. * <!-- begin-user-doc --> @@ -209,6 +264,27 @@ public interface AnnotationPackage extends EPackage { */ EAttribute getPinNumber_PinNumber(); + /** + * Returns the meta object for class '{@link org.fortiss.af3.platform.raspberry.model.annotation.PeripheralAddress <em>Peripheral Address</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Peripheral Address</em>'. + * @see org.fortiss.af3.platform.raspberry.model.annotation.PeripheralAddress + * @generated + */ + EClass getPeripheralAddress(); + + /** + * Returns the meta object for the attribute '{@link org.fortiss.af3.platform.raspberry.model.annotation.PeripheralAddress#getPeripheralAddress <em>Peripheral Address</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Peripheral Address</em>'. + * @see org.fortiss.af3.platform.raspberry.model.annotation.PeripheralAddress#getPeripheralAddress() + * @see #getPeripheralAddress() + * @generated + */ + EAttribute getPeripheralAddress_PeripheralAddress(); + /** * Returns the factory that creates the instances of the model. * <!-- begin-user-doc --> @@ -267,6 +343,24 @@ public interface AnnotationPackage extends EPackage { */ EAttribute PIN_NUMBER__PIN_NUMBER = eINSTANCE.getPinNumber_PinNumber(); + /** + * The meta object literal for the '{@link org.fortiss.af3.platform.raspberry.model.annotation.impl.PeripheralAddressImpl <em>Peripheral Address</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.fortiss.af3.platform.raspberry.model.annotation.impl.PeripheralAddressImpl + * @see org.fortiss.af3.platform.raspberry.model.annotation.impl.AnnotationPackageImpl#getPeripheralAddress() + * @generated + */ + EClass PERIPHERAL_ADDRESS = eINSTANCE.getPeripheralAddress(); + + /** + * The meta object literal for the '<em><b>Peripheral Address</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EAttribute PERIPHERAL_ADDRESS__PERIPHERAL_ADDRESS = eINSTANCE.getPeripheralAddress_PeripheralAddress(); + } } //AnnotationPackage diff --git a/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/PAddress.java b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/PAddress.java new file mode 100644 index 00000000..0c35cee7 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/PAddress.java @@ -0,0 +1,19 @@ +/** + */ +package org.fortiss.af3.platform.raspberry.model.annotation; + +import org.fortiss.tooling.base.model.element.IAnnotatedSpecification; +import org.fortiss.tooling.base.model.element.IHiddenSpecification; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>PAddress</b></em>'. + * <!-- end-user-doc --> + * + * + * @see org.fortiss.af3.platform.raspberry.model.annotation.AnnotationPackage#getPAddress() + * @model + * @generated + */ +public interface PAddress extends IAnnotatedSpecification, IHiddenSpecification { +} // PAddress diff --git a/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/PeripheralAddress.java b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/PeripheralAddress.java new file mode 100644 index 00000000..08150acf --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/PeripheralAddress.java @@ -0,0 +1,51 @@ +/** + */ +package org.fortiss.af3.platform.raspberry.model.annotation; + +import org.fortiss.tooling.base.model.element.IAnnotatedSpecification; +import org.fortiss.tooling.base.model.element.IHiddenSpecification; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Peripheral Address</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.fortiss.af3.platform.raspberry.model.annotation.PeripheralAddress#getPeripheralAddress <em>Peripheral Address</em>}</li> + * </ul> + * </p> + * + * @see org.fortiss.af3.platform.raspberry.model.annotation.AnnotationPackage#getPeripheralAddress() + * @model + * @generated + */ +public interface PeripheralAddress extends IAnnotatedSpecification, IHiddenSpecification { + /** + * Returns the value of the '<em><b>Peripheral Address</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Peripheral Address</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Peripheral Address</em>' attribute. + * @see #setPeripheralAddress(int) + * @see org.fortiss.af3.platform.raspberry.model.annotation.AnnotationPackage#getPeripheralAddress_PeripheralAddress() + * @model + * @generated + */ + int getPeripheralAddress(); + + /** + * Sets the value of the '{@link org.fortiss.af3.platform.raspberry.model.annotation.PeripheralAddress#getPeripheralAddress <em>Peripheral Address</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Peripheral Address</em>' attribute. + * @see #getPeripheralAddress() + * @generated + */ + void setPeripheralAddress(int value); + +} // PeripheralAddress diff --git a/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/impl/AnnotationFactoryImpl.java b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/impl/AnnotationFactoryImpl.java index 2b03f68b..b2806fb6 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/impl/AnnotationFactoryImpl.java +++ b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/impl/AnnotationFactoryImpl.java @@ -58,6 +58,7 @@ public class AnnotationFactoryImpl extends EFactoryImpl implements AnnotationFac switch (eClass.getClassifierID()) { case AnnotationPackage.CORE_ADDRESS: return createCoreAddress(); case AnnotationPackage.PIN_NUMBER: return createPinNumber(); + case AnnotationPackage.PERIPHERAL_ADDRESS: return createPeripheralAddress(); default: throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); } @@ -83,6 +84,16 @@ public class AnnotationFactoryImpl extends EFactoryImpl implements AnnotationFac return pinNumber; } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public PeripheralAddress createPeripheralAddress() { + PeripheralAddressImpl peripheralAddress = new PeripheralAddressImpl(); + return peripheralAddress; + } + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> diff --git a/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/impl/AnnotationPackageImpl.java b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/impl/AnnotationPackageImpl.java index 3a5c5e64..c114cd6f 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/impl/AnnotationPackageImpl.java +++ b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/impl/AnnotationPackageImpl.java @@ -15,6 +15,8 @@ import org.fortiss.af3.platform.raspberry.model.ModelPackage; import org.fortiss.af3.platform.raspberry.model.annotation.AnnotationFactory; import org.fortiss.af3.platform.raspberry.model.annotation.AnnotationPackage; import org.fortiss.af3.platform.raspberry.model.annotation.CoreAddress; +import org.fortiss.af3.platform.raspberry.model.annotation.PAddress; +import org.fortiss.af3.platform.raspberry.model.annotation.PeripheralAddress; import org.fortiss.af3.platform.raspberry.model.annotation.PinNumber; import org.fortiss.af3.platform.raspberry.model.impl.ModelPackageImpl; @@ -42,6 +44,13 @@ public class AnnotationPackageImpl extends EPackageImpl implements AnnotationPac */ private EClass pinNumberEClass = null; + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass peripheralAddressEClass = null; + /** * Creates an instance of the model <b>Package</b>, registered with * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package @@ -147,6 +156,24 @@ public class AnnotationPackageImpl extends EPackageImpl implements AnnotationPac return (EAttribute)pinNumberEClass.getEStructuralFeatures().get(0); } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getPeripheralAddress() { + return peripheralAddressEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getPeripheralAddress_PeripheralAddress() { + return (EAttribute)peripheralAddressEClass.getEStructuralFeatures().get(0); + } + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -180,6 +207,9 @@ public class AnnotationPackageImpl extends EPackageImpl implements AnnotationPac pinNumberEClass = createEClass(PIN_NUMBER); createEAttribute(pinNumberEClass, PIN_NUMBER__PIN_NUMBER); + + peripheralAddressEClass = createEClass(PERIPHERAL_ADDRESS); + createEAttribute(peripheralAddressEClass, PERIPHERAL_ADDRESS__PERIPHERAL_ADDRESS); } /** @@ -217,6 +247,8 @@ public class AnnotationPackageImpl extends EPackageImpl implements AnnotationPac coreAddressEClass.getESuperTypes().add(theElementPackage.getIHiddenSpecification()); pinNumberEClass.getESuperTypes().add(theElementPackage.getIAnnotatedSpecification()); pinNumberEClass.getESuperTypes().add(theElementPackage.getIHiddenSpecification()); + peripheralAddressEClass.getESuperTypes().add(theElementPackage.getIAnnotatedSpecification()); + peripheralAddressEClass.getESuperTypes().add(theElementPackage.getIHiddenSpecification()); // Initialize classes and features; add operations and parameters initEClass(coreAddressEClass, CoreAddress.class, "CoreAddress", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); @@ -224,6 +256,9 @@ public class AnnotationPackageImpl extends EPackageImpl implements AnnotationPac initEClass(pinNumberEClass, PinNumber.class, "PinNumber", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEAttribute(getPinNumber_PinNumber(), ecorePackage.getEInt(), "pinNumber", null, 0, 1, PinNumber.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(peripheralAddressEClass, PeripheralAddress.class, "PeripheralAddress", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getPeripheralAddress_PeripheralAddress(), ecorePackage.getEInt(), "peripheralAddress", null, 0, 1, PeripheralAddress.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); } } //AnnotationPackageImpl diff --git a/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/impl/PeripheralAddressImpl.java b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/impl/PeripheralAddressImpl.java new file mode 100644 index 00000000..49456d11 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/impl/PeripheralAddressImpl.java @@ -0,0 +1,431 @@ +/** + */ +package org.fortiss.af3.platform.raspberry.model.annotation.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; + +import org.eclipse.emf.ecore.util.EcoreUtil; + +import org.fortiss.af3.platform.raspberry.model.annotation.AnnotationPackage; +import org.fortiss.af3.platform.raspberry.model.annotation.PeripheralAddress; + +import org.fortiss.tooling.base.model.element.ElementPackage; +import org.fortiss.tooling.base.model.element.IHiddenSpecification; +import org.fortiss.tooling.base.model.element.IModelElement; + +import org.fortiss.tooling.kernel.model.FortissToolingKernelPackage; +import org.fortiss.tooling.kernel.model.INamedElement; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Peripheral Address</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.fortiss.af3.platform.raspberry.model.annotation.impl.PeripheralAddressImpl#getId <em>Id</em>}</li> + * <li>{@link org.fortiss.af3.platform.raspberry.model.annotation.impl.PeripheralAddressImpl#getSpecificationOf <em>Specification Of</em>}</li> + * <li>{@link org.fortiss.af3.platform.raspberry.model.annotation.impl.PeripheralAddressImpl#getName <em>Name</em>}</li> + * <li>{@link org.fortiss.af3.platform.raspberry.model.annotation.impl.PeripheralAddressImpl#getPeripheralAddress <em>Peripheral Address</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class PeripheralAddressImpl extends EObjectImpl implements PeripheralAddress { + /** + * The default value of the '{@link #getId() <em>Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getId() + * @generated + * @ordered + */ + protected static final int ID_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getId() <em>Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getId() + * @generated + * @ordered + */ + protected int id = ID_EDEFAULT; + + /** + * The default value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * The default value of the '{@link #getPeripheralAddress() <em>Peripheral Address</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getPeripheralAddress() + * @generated + * @ordered + */ + protected static final int PERIPHERAL_ADDRESS_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getPeripheralAddress() <em>Peripheral Address</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getPeripheralAddress() + * @generated + * @ordered + */ + protected int peripheralAddress = PERIPHERAL_ADDRESS_EDEFAULT; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected PeripheralAddressImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() { + return AnnotationPackage.Literals.PERIPHERAL_ADDRESS; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public int getId() { + return id; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setId(int newId) { + int oldId = id; + id = newId; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, AnnotationPackage.PERIPHERAL_ADDRESS__ID, oldId, id)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public IModelElement getSpecificationOf() { + if (eContainerFeatureID() != AnnotationPackage.PERIPHERAL_ADDRESS__SPECIFICATION_OF) return null; + return (IModelElement)eContainer(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public IModelElement basicGetSpecificationOf() { + if (eContainerFeatureID() != AnnotationPackage.PERIPHERAL_ADDRESS__SPECIFICATION_OF) return null; + return (IModelElement)eInternalContainer(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain basicSetSpecificationOf(IModelElement newSpecificationOf, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject)newSpecificationOf, AnnotationPackage.PERIPHERAL_ADDRESS__SPECIFICATION_OF, msgs); + return msgs; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setSpecificationOf(IModelElement newSpecificationOf) { + if (newSpecificationOf != eInternalContainer() || (eContainerFeatureID() != AnnotationPackage.PERIPHERAL_ADDRESS__SPECIFICATION_OF && newSpecificationOf != null)) { + if (EcoreUtil.isAncestor(this, newSpecificationOf)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if (newSpecificationOf != null) + msgs = ((InternalEObject)newSpecificationOf).eInverseAdd(this, ElementPackage.IMODEL_ELEMENT__SPECIFICATIONS, IModelElement.class, msgs); + msgs = basicSetSpecificationOf(newSpecificationOf, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, AnnotationPackage.PERIPHERAL_ADDRESS__SPECIFICATION_OF, newSpecificationOf, newSpecificationOf)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getName() { + return name; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setName(String newName) { + String oldName = name; + name = newName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, AnnotationPackage.PERIPHERAL_ADDRESS__NAME, oldName, name)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public int getPeripheralAddress() { + return peripheralAddress; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setPeripheralAddress(int newPeripheralAddress) { + int oldPeripheralAddress = peripheralAddress; + peripheralAddress = newPeripheralAddress; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, AnnotationPackage.PERIPHERAL_ADDRESS__PERIPHERAL_ADDRESS, oldPeripheralAddress, peripheralAddress)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case AnnotationPackage.PERIPHERAL_ADDRESS__SPECIFICATION_OF: + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetSpecificationOf((IModelElement)otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case AnnotationPackage.PERIPHERAL_ADDRESS__SPECIFICATION_OF: + return basicSetSpecificationOf(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch (eContainerFeatureID()) { + case AnnotationPackage.PERIPHERAL_ADDRESS__SPECIFICATION_OF: + return eInternalContainer().eInverseRemove(this, ElementPackage.IMODEL_ELEMENT__SPECIFICATIONS, IModelElement.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case AnnotationPackage.PERIPHERAL_ADDRESS__ID: + return getId(); + case AnnotationPackage.PERIPHERAL_ADDRESS__SPECIFICATION_OF: + if (resolve) return getSpecificationOf(); + return basicGetSpecificationOf(); + case AnnotationPackage.PERIPHERAL_ADDRESS__NAME: + return getName(); + case AnnotationPackage.PERIPHERAL_ADDRESS__PERIPHERAL_ADDRESS: + return getPeripheralAddress(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case AnnotationPackage.PERIPHERAL_ADDRESS__ID: + setId((Integer)newValue); + return; + case AnnotationPackage.PERIPHERAL_ADDRESS__SPECIFICATION_OF: + setSpecificationOf((IModelElement)newValue); + return; + case AnnotationPackage.PERIPHERAL_ADDRESS__NAME: + setName((String)newValue); + return; + case AnnotationPackage.PERIPHERAL_ADDRESS__PERIPHERAL_ADDRESS: + setPeripheralAddress((Integer)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case AnnotationPackage.PERIPHERAL_ADDRESS__ID: + setId(ID_EDEFAULT); + return; + case AnnotationPackage.PERIPHERAL_ADDRESS__SPECIFICATION_OF: + setSpecificationOf((IModelElement)null); + return; + case AnnotationPackage.PERIPHERAL_ADDRESS__NAME: + setName(NAME_EDEFAULT); + return; + case AnnotationPackage.PERIPHERAL_ADDRESS__PERIPHERAL_ADDRESS: + setPeripheralAddress(PERIPHERAL_ADDRESS_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case AnnotationPackage.PERIPHERAL_ADDRESS__ID: + return id != ID_EDEFAULT; + case AnnotationPackage.PERIPHERAL_ADDRESS__SPECIFICATION_OF: + return basicGetSpecificationOf() != null; + case AnnotationPackage.PERIPHERAL_ADDRESS__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + case AnnotationPackage.PERIPHERAL_ADDRESS__PERIPHERAL_ADDRESS: + return peripheralAddress != PERIPHERAL_ADDRESS_EDEFAULT; + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { + if (baseClass == INamedElement.class) { + switch (derivedFeatureID) { + case AnnotationPackage.PERIPHERAL_ADDRESS__NAME: return FortissToolingKernelPackage.INAMED_ELEMENT__NAME; + default: return -1; + } + } + if (baseClass == IHiddenSpecification.class) { + switch (derivedFeatureID) { + default: return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { + if (baseClass == INamedElement.class) { + switch (baseFeatureID) { + case FortissToolingKernelPackage.INAMED_ELEMENT__NAME: return AnnotationPackage.PERIPHERAL_ADDRESS__NAME; + default: return -1; + } + } + if (baseClass == IHiddenSpecification.class) { + switch (baseFeatureID) { + default: return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (id: "); + result.append(id); + result.append(", name: "); + result.append(name); + result.append(", peripheralAddress: "); + result.append(peripheralAddress); + result.append(')'); + return result.toString(); + } + +} //PeripheralAddressImpl diff --git a/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/util/AnnotationAdapterFactory.java b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/util/AnnotationAdapterFactory.java index 9bf9eb82..2b303216 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/util/AnnotationAdapterFactory.java +++ b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/util/AnnotationAdapterFactory.java @@ -83,6 +83,10 @@ public class AnnotationAdapterFactory extends AdapterFactoryImpl { return createPinNumberAdapter(); } @Override + public Adapter casePeripheralAddress(PeripheralAddress object) { + return createPeripheralAddressAdapter(); + } + @Override public Adapter caseIIdLabeled(IIdLabeled object) { return createIIdLabeledAdapter(); } @@ -150,6 +154,20 @@ public class AnnotationAdapterFactory extends AdapterFactoryImpl { return null; } + /** + * Creates a new adapter for an object of class '{@link org.fortiss.af3.platform.raspberry.model.annotation.PeripheralAddress <em>Peripheral Address</em>}'. + * <!-- begin-user-doc --> + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * <!-- end-user-doc --> + * @return the new adapter. + * @see org.fortiss.af3.platform.raspberry.model.annotation.PeripheralAddress + * @generated + */ + public Adapter createPeripheralAddressAdapter() { + return null; + } + /** * Creates a new adapter for an object of class '{@link org.fortiss.tooling.kernel.model.IIdLabeled <em>IId Labeled</em>}'. * <!-- begin-user-doc --> diff --git a/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/util/AnnotationSwitch.java b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/util/AnnotationSwitch.java index 14e2caa2..25ed6efc 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/util/AnnotationSwitch.java +++ b/org.fortiss.af3.platform.raspberry/trunk/generated-src/org/fortiss/af3/platform/raspberry/model/annotation/util/AnnotationSwitch.java @@ -95,6 +95,17 @@ public class AnnotationSwitch<T> extends Switch<T> { if (result == null) result = defaultCase(theEObject); return result; } + case AnnotationPackage.PERIPHERAL_ADDRESS: { + PeripheralAddress peripheralAddress = (PeripheralAddress)theEObject; + T result = casePeripheralAddress(peripheralAddress); + if (result == null) result = caseIAnnotatedSpecification(peripheralAddress); + if (result == null) result = caseIHiddenSpecification(peripheralAddress); + if (result == null) result = caseIModelElementSpecification(peripheralAddress); + if (result == null) result = caseINamedElement(peripheralAddress); + if (result == null) result = caseIIdLabeled(peripheralAddress); + if (result == null) result = defaultCase(theEObject); + return result; + } default: return defaultCase(theEObject); } } @@ -129,6 +140,21 @@ public class AnnotationSwitch<T> extends Switch<T> { return null; } + /** + * Returns the result of interpreting the object as an instance of '<em>Peripheral Address</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>Peripheral Address</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePeripheralAddress(PeripheralAddress object) { + return null; + } + /** * Returns the result of interpreting the object as an instance of '<em>IId Labeled</em>'. * <!-- begin-user-doc --> diff --git a/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore b/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore index a5f76266..7028de30 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore +++ b/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.ecore @@ -40,5 +40,8 @@ <eClassifiers xsi:type="ecore:EClass" name="PinNumber" 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="pinNumber" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="PeripheralAddress" 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="peripheralAddress" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> + </eClassifiers> </eSubpackages> </ecore:EPackage> diff --git a/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.genmodel b/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.genmodel index 2779c477..2cac1d3e 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.genmodel +++ b/org.fortiss.af3.platform.raspberry/trunk/model/raspberry.genmodel @@ -35,6 +35,9 @@ <genClasses ecoreClass="raspberry.ecore#//annotation/PinNumber"> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute raspberry.ecore#//annotation/PinNumber/pinNumber"/> </genClasses> + <genClasses ecoreClass="raspberry.ecore#//annotation/PeripheralAddress"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute raspberry.ecore#//annotation/PeripheralAddress/peripheralAddress"/> + </genClasses> </nestedGenPackages> </genPackages> </genmodel:GenModel> diff --git a/org.fortiss.af3.platform.raspberry/trunk/plugin.xml b/org.fortiss.af3.platform.raspberry/trunk/plugin.xml index f757f503..615d4377 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/plugin.xml +++ b/org.fortiss.af3.platform.raspberry/trunk/plugin.xml @@ -356,5 +356,24 @@ </modelElementClass> </annotation> </extension> + + <extension + point="org.fortiss.tooling.base.annotation"> + <annotation + binding="org.fortiss.af3.platform.raspberry.annotation.valueprovider.PeripheralAddressValueProvider"> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.Sensor"> + </modelElementClass> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.Actuator"> + </modelElementClass> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.SensorIn"> + </modelElementClass> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.ActuatorOut"> + </modelElementClass> + </annotation> + </extension> </plugin> diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/annotation/valueprovider/PeripheralAddressValueProvider.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/annotation/valueprovider/PeripheralAddressValueProvider.java new file mode 100644 index 00000000..a7751110 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/annotation/valueprovider/PeripheralAddressValueProvider.java @@ -0,0 +1,48 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| Copyright 2016 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.valueprovider; + +import org.fortiss.af3.platform.raspberry.model.annotation.AnnotationPackage; +import org.fortiss.af3.platform.raspberry.model.annotation.PeripheralAddress; +import org.fortiss.tooling.base.annotation.valueprovider.EStructuralFeatureValueProviderBase; + +/** + * + * @author zverlov + * @author $Author$ + * @version $Rev$ + * @ConQAT.Rating RED Hash: + */ +public class PeripheralAddressValueProvider extends + EStructuralFeatureValueProviderBase<PeripheralAddress> { + + /** + * + */ + public PeripheralAddressValueProvider() { + super(AnnotationPackage.Literals.PERIPHERAL_ADDRESS, + AnnotationPackage.Literals.PERIPHERAL_ADDRESS__PERIPHERAL_ADDRESS); + } + + /** {@inheritDoc} */ + @Override + public String getAnnotationName(PeripheralAddress specification) { + return "Peripheral Address"; + } + +} diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generated/files/RaspberryPortTypeGeneration.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generated/files/RaspberryFileGeneration.java similarity index 88% rename from org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generated/files/RaspberryPortTypeGeneration.java rename to org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generated/files/RaspberryFileGeneration.java index b5798a0b..be9b4b36 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generated/files/RaspberryPortTypeGeneration.java +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generated/files/RaspberryFileGeneration.java @@ -24,24 +24,24 @@ package org.fortiss.af3.platform.raspberry.generated.files; * @version $Rev: 16640 $ * @ConQAT.Rating RED Hash: */ -public class RaspberryPortTypeGeneration { +public class RaspberryFileGeneration { /** Information relevant to the ports. */ - private String portInfo; + private String text; /** Contents of the PortsInfo. */ private String content; /** Constructor. */ - public RaspberryPortTypeGeneration(String portSpecs) { - this.portInfo = portSpecs; + public RaspberryFileGeneration(String specs) { + this.text = specs; this.content = ""; } /** Calls the methods that create the portSpecs. */ public void createInfofile() { - content += portInfo; + content += text; } /** Return the current content of the portSpecs. */ diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/ActuatorOutExecutable.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/ActuatorOutExecutable.java index f757b27e..e98807f8 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/ActuatorOutExecutable.java +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/ActuatorOutExecutable.java @@ -19,6 +19,7 @@ package org.fortiss.af3.platform.raspberry.generator.executable; import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.createVar; import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.funcCall; +import static org.fortiss.af3.platform.raspberry.utils.RaspberryUtils.funcCallMultipleArgs; import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation; import org.fortiss.af3.component.model.OutputPort; @@ -29,6 +30,7 @@ import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.ITermE import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.IWriteExecutableWithNoValSupport; import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.InitExecutable; import org.fortiss.af3.platform.raspberry.model.ActuatorOut; +import org.fortiss.af3.platform.raspberry.model.annotation.PeripheralAddress; import org.fortiss.af3.platform.raspberry.model.annotation.PinNumber; /** @@ -52,25 +54,23 @@ public class ActuatorOutExecutable extends TransmitterExecutableBase<ActuatorOut /** {@inheritDoc} */ @Override public IExpressionTerm getInitialization() { - String actuatorId = modelElement.getName() + "_ID_" + modelElement.getId(); + String actuatorId = "ActuatorOut_ID_" + modelElement.getId();// modelElement.getName() return funcCall("init_Actuator", createVar(actuatorId)); } /** {@inheritDoc} */ @Override public IExpressionTerm getTermination() { - String actuatorId = modelElement.getName() + "_ID_" + modelElement.getId(); + String actuatorId = "ActuatorOut_ID_" + modelElement.getId(); return funcCall("term_Actuator", createVar(actuatorId)); } /** {@inheritDoc} */ @Override - /* generates call: write_Actuator(pinNr, varName) */ + /* generates call: write_Actuator(id, pinNr, address) */ public IExpressionTerm getValueWriteAccessor(OutputPort logicalSignal, IExpressionTerm value) { - PinNumber ias = getAnnotation(modelElement, PinNumber.class); - int pinNr = ias.getPinNumber(); - String actuatorId = modelElement.getName() + "_ID_" + modelElement.getId(); - return funcCall("write_Actuator", createVar(pinNr + ""), createVar(actuatorId)); + return funcCallMultipleArgs("write_Actuator", createVar("Id"), createVar("pinNr"), + createVar("address")); } @@ -82,13 +82,12 @@ public class ActuatorOutExecutable extends TransmitterExecutableBase<ActuatorOut /** {@inheritDoc} */ @Override - /* generates call: write_Actuator(pinNr, varName) */ + /* generates call: write_Actuator(id, pinNr, address) */ public IExpressionTerm getValueWriteAccessor(OutputPort logicalSignal, IExpressionTerm value, Deployment depl) { - PinNumber ias = getAnnotation(modelElement, PinNumber.class); - int pinNr = ias.getPinNumber(); - String actuatorId = modelElement.getName() + "_ID_" + modelElement.getId(); - return funcCall("write_Actuator", createVar(pinNr + ""), createVar(actuatorId)); + String actuatorId = "ActuatorOut_ID_" + modelElement.getId();// modelElement.getName() + String val = logicalSignal.getName() + "_ID_" + logicalSignal.getId(); + return funcCall("write_Actuator", createVar(actuatorId), createVar(val)); } /** {@inheritDoc} */ @@ -102,7 +101,7 @@ public class ActuatorOutExecutable extends TransmitterExecutableBase<ActuatorOut @Override public IExpressionTerm getTermination(Deployment depl) { // TODO Auto-generated method stub - String actuatorId = modelElement.getName() + "_ID_" + modelElement.getId(); + String actuatorId = "ActuatorOut_ID_" + modelElement.getId(); return funcCall("term_Actuator", createVar(actuatorId)); } @@ -124,9 +123,18 @@ public class ActuatorOutExecutable extends TransmitterExecutableBase<ActuatorOut /** {@inheritDoc} */ @Override public IExpressionTerm getInitialization(Deployment depl) { - // TODO Auto-generated method stub - String actuatorId = modelElement.getName() + "_ID_" + modelElement.getId(); + String actuatorId = "ActuatorOut_ID_" + modelElement.getId();// modelElement.getName() return funcCall("init_Actuator", createVar(actuatorId)); } + /** Get PinNr, Address and ID of an Actuator. */ + public String getActuatorDetails() { + PinNumber ias = getAnnotation(modelElement, PinNumber.class); + int pinNr = ias.getPinNumber(); + PeripheralAddress pa = getAnnotation(modelElement, PeripheralAddress.class); + int actuatorAddress = pa.getPeripheralAddress(); + int actuatorId = modelElement.getId(); + return "{" + actuatorId + ", " + pinNr + ", " + actuatorAddress + "} \n"; + } + } diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/BusExecutable.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/BusExecutable.java index 0047e525..8df770ef 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/BusExecutable.java +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/BusExecutable.java @@ -22,10 +22,12 @@ import static org.fortiss.af3.platform.raspberry.utils.RaspberryUtils.getEcuForC import static org.fortiss.af3.platform.raspberry.utils.RaspberryUtils.getTargetComponent; import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.findElementById; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; -import org.fortiss.af3.bounds.model.VariableBoundsSpecification; +import org.eclipse.emf.common.util.EList; import org.fortiss.af3.component.model.Component; import org.fortiss.af3.component.model.OutputPort; import org.fortiss.af3.component.model.Port; @@ -36,7 +38,14 @@ import org.fortiss.af3.generator.common.model.source.SourcePackage; import org.fortiss.af3.platform.language.executable.TransmissionUnitExecutableBase; import org.fortiss.af3.platform.model.ExecutionUnit; import org.fortiss.af3.platform.model.TransmissionUnit; -import org.fortiss.af3.platform.raspberry.generated.files.RaspberryPortTypeGeneration; +import org.fortiss.af3.platform.raspberry.generated.files.RaspberryFileGeneration; +import org.fortiss.af3.platform.raspberry.model.annotation.PeripheralAddress; +import org.fortiss.af3.platform.raspberry.model.annotation.PinNumber; +import org.fortiss.af3.platform.raspberry.model.impl.ActuatorOutImpl; +import org.fortiss.af3.platform.raspberry.model.impl.SensorInImpl; +import org.fortiss.tooling.base.model.element.IConnector; +import org.fortiss.tooling.base.model.element.IHierarchicElement; +import org.fortiss.tooling.base.model.element.IModelElementSpecification; /** * @@ -63,44 +72,168 @@ public class BusExecutable extends TransmissionUnitExecutableBase<TransmissionUn findBusSignals(deploymentID, topComponent, pack); } - /** Finds Information about Signals that are transmitted over the Bus. */ + /** + * Finds Information about Signals that are transmitted over the Bus and form fields of the + * message. + */ public void findBusSignals(int deploymentID, Component topComponent, SourcePackage pack) { - String resultString = ""; + String messageString = "message msg { \n"; + int counter = 0; Deployment currentDeployment = (Deployment)findElementById(deploymentID, topComponent.eContainer().eContainer()); for(ComponentAllocation allocation : currentDeployment.getComponentAllocations()) { Component c1 = allocation.getComponent(); + Object lastPort = null; for(Object port : c1.getConnectors()) { if(port instanceof OutputPort) { for(Component c2 : getTargetComponent((OutputPort)port)) { if(getEcuForComponent(c1, currentDeployment) != getEcuForComponent(c2, currentDeployment) && getEcuForComponent(c2, currentDeployment) != null) { - resultString += "Name: " + ((OutputPort)port).getName() + ", "; for(Object specs : ((OutputPort)port).getSpecifications()) { - if(specs instanceof PortSpecification) { + if(specs instanceof PortSpecification && port != lastPort) { + lastPort = port; + counter = counter + 1; PortSpecification portSpec = (PortSpecification)specs; - resultString += "Type: " + portSpec.getType() + ", "; - } - if(specs instanceof VariableBoundsSpecification) { - VariableBoundsSpecification varBoundSpec = - (VariableBoundsSpecification)specs; - resultString += - "From: " + varBoundSpec.getLowerBound() + " To: " + - varBoundSpec.getUpperBound() + " "; + String prtType; + switch(portSpec.getType().toString()) { + case "int": + prtType = "int32"; + break; + case "boolean": + prtType = "bool"; + break; + default: + prtType = portSpec.getType().toString(); + break; + } + messageString += + "\t optional " + prtType + " " + + ((OutputPort)port).getName() + "= " + counter + + ";\n"; } } - resultString += "\n"; } } } } + } + messageString += "}"; + createFile(pack, messageString, "message.proto"); + createSensorHeaderFile(pack); + createActuatorHeaderFile(pack); + createFilesPeripheralDetails(pack); + } + + /** Determine Sensors, Actuators their IDs and PinNumbers. */ + private void createFilesPeripheralDetails(SourcePackage pack) { + String sensorList = "#include \"sensors.h\" \n\n"; + sensorList += "sensors sen[] \n{ \n"; + String actuatorList = "#include \"actuators.h\" \n\n"; + actuatorList += "actuators act[] \n{\n"; + + List<SensorInImpl> sens = new ArrayList<SensorInImpl>(); + List<ActuatorOutImpl> acts = new ArrayList<ActuatorOutImpl>(); + EList<IHierarchicElement> el = modelElement.getContainer().getContainedElements(); + for(IHierarchicElement ce : el) { + EList<IConnector> conList = ce.getConnectors(); + for(IConnector conn : conList) { + if(conn instanceof SensorInImpl) { + sens.add((SensorInImpl)conn); + } + if(conn instanceof ActuatorOutImpl) { + acts.add((ActuatorOutImpl)conn); + } + } + } + sensorList = addSensorSpecsToList(sensorList, sens); + actuatorList = addActuatorSpecsToList(actuatorList, acts); + sensorList += "\n };"; + actuatorList += "\n };"; + + createFile(pack, sensorList, "sensors.c"); + createFile(pack, actuatorList, "actuators.c"); + + } + + /** Add specification of peripheral to the respective list of Sensors. */ + private String addSensorSpecsToList(String sensorList, List<SensorInImpl> sens) { + for(SensorInImpl sen : sens) { + int Id = sen.getId(); + HashMap<String, Integer> hmap = new HashMap<String, Integer>(); + hmap.put("Id", Id); + EList<IModelElementSpecification> specs = sen.getSpecifications(); + for(IModelElementSpecification spec : specs) { + if(spec instanceof PinNumber) { + int pinNr = ((PinNumber)spec).getPinNumber(); + hmap.put("pinNr", pinNr); + } + if(spec instanceof PeripheralAddress) { + int address = ((PeripheralAddress)spec).getPeripheralAddress(); + hmap.put("address", address); + } + } + sensorList += + " {" + hmap.get("Id") + ", " + hmap.get("pinNr") + ", " + hmap.get("address") + + "} "; + if(sen.getId() != sens.get(sens.size() - 1).getId()) + sensorList += ", \n"; + } + return sensorList; + } + /** Add specification of peripheral to the respective list of Sensors. */ + private String addActuatorSpecsToList(String actuatorList, List<ActuatorOutImpl> acts) { + for(ActuatorOutImpl act : acts) { + int Id = act.getId(); + HashMap<String, Integer> hmap = new HashMap<String, Integer>(); + hmap.put("Id", Id); + EList<IModelElementSpecification> specs = act.getSpecifications(); + for(IModelElementSpecification spec : specs) { + if(spec instanceof PinNumber) { + int pinNr = ((PinNumber)spec).getPinNumber(); + hmap.put("pinNr", pinNr); + } + if(spec instanceof PeripheralAddress) { + int address = ((PeripheralAddress)spec).getPeripheralAddress(); + hmap.put("address", address); + } + } + actuatorList += + " {" + hmap.get("Id") + ", " + hmap.get("pinNr") + ", " + hmap.get("address") + + "} "; + if(act.getId() != acts.get(acts.size() - 1).getId()) + actuatorList += ", \n"; } + return actuatorList; + } + + /** Create Header Files defining structure for sensor. */ + private void createSensorHeaderFile(SourcePackage pack) { + String content = "#indef __SENSORS.H \n"; + content += "#define __SENSORS.H \n\n"; + content += "struct \n { \n"; + content += " int Id; \n int pinNr; \n int address; \n } sensors; \n "; + content += "extern sensors sen[];\n \n"; + content += " #endif \n \n"; + createFile(pack, content, "sensors.h"); + } + + /** Create Header Files defining structure for actuator. */ + private void createActuatorHeaderFile(SourcePackage pack) { + String content = "#indef __ACTUATORS.H \n"; + content += "#define __ACTUATORS.H \n\n"; + content += "struct \n { \n"; + content += " int Id; \n int pinNr; \n int address; \n } actuators; \n "; + content += "extern actuators act[];\n \n"; + content += " #endif \n \n"; + createFile(pack, content, "actuators.h"); + } - RaspberryPortTypeGeneration rspPortInfoGen = new RaspberryPortTypeGeneration(resultString); - rspPortInfoGen.createInfofile(); - pack.addUnit(createStaticContentSourceUnit("PortSpecifications", - rspPortInfoGen.getContent(), false)); + /** Create file with a given Name and given text. */ + private void createFile(SourcePackage pack, String text, String name) { + RaspberryFileGeneration file = new RaspberryFileGeneration(text); + file.createInfofile(); + pack.addUnit(createStaticContentSourceUnit(name, file.getContent(), false)); } } diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/BusMasterPortExecutable.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/BusMasterPortExecutable.java index 4c509ab6..0e3f1e97 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/BusMasterPortExecutable.java +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/BusMasterPortExecutable.java @@ -63,14 +63,15 @@ public class BusMasterPortExecutable extends TransceiverExecutableBase<BusMaster @Override public IExpressionTerm getInitialization(Deployment depl) { int currentCoreAddress = getParentCoreAddress(); - return funcCall("init_" + modelElement.getName(), createVar(currentCoreAddress + "")); + return funcCall("init_BusMasterPort", createVar(currentCoreAddress + ""));// + + // modelElement.getName() } /** {@inheritDoc} */ @Override public IExpressionTerm getTermination(Deployment depl) { int currentCoreAddress = getParentCoreAddress(); - return funcCall("term_" + modelElement.getName(), createVar(currentCoreAddress + "")); + return funcCall("term_BusMasterPort", createVar(currentCoreAddress + "")); } /** {@inheritDoc} */ @@ -79,8 +80,7 @@ public class BusMasterPortExecutable extends TransceiverExecutableBase<BusMaster Deployment depl) { int coreAddress = getTargetCoreAddress(logicalSignal, depl); String signalId = logicalSignal.getName() + "_ID_" + logicalSignal.getId(); - return funcCall("write_" + modelElement.getName(), createVar(coreAddress + ""), - createVar(signalId)); + return funcCall("write_BusMasterPort", createVar(coreAddress + ""), createVar(signalId)); } /** {@inheritDoc} */ @@ -88,20 +88,20 @@ public class BusMasterPortExecutable extends TransceiverExecutableBase<BusMaster public IExpressionTerm getValueReadAccessor(InputPort logicalSignal, Deployment depl) { Port sourceSignal = getSourceSignal(logicalSignal); String signalId = sourceSignal.getName() + "_ID_" + sourceSignal.getId(); - return funcCall("read_" + modelElement.getName(), createVar(signalId)); + return funcCall("read_BusMasterPort", createVar(signalId)); } /** {@inheritDoc} */ @Override public IExpressionTerm getNoValWriteAccessor(OutputPort logicalSignal) { - return funcCall("set_noval_" + modelElement.getName()); + return funcCall("set_noval_BusMasterPort"); } /** {@inheritDoc} */ @Override public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { - return funcCall("is_noval_" + modelElement.getName()); + return funcCall("is_noval_BusMasterPort"); } /** Get source signal for the current port */ @@ -154,14 +154,14 @@ public class BusMasterPortExecutable extends TransceiverExecutableBase<BusMaster @Override public IExpressionTerm getTermination() { // TODO Auto-generated method stub - return funcCall("term_" + modelElement.getName()); + return funcCall("term_BusMasterPort"); } /** {@inheritDoc} */ @Override public IExpressionTerm getInitialization() { // TODO Auto-generated method stub - return funcCall("init_" + modelElement.getName()); + return funcCall("init_BusMasterPort"); } /** {@inheritDoc} */ diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/CoreExecutable.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/CoreExecutable.java index 3ef20de8..b5c843b7 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/CoreExecutable.java +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/CoreExecutable.java @@ -29,12 +29,14 @@ import static org.fortiss.af3.component.utils.GeneratorModelElementFactory.creat import static org.fortiss.af3.component.utils.GeneratorModelElementFactory.createLocalFunction; import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.assignment; import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.createDataDictionary; +import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.definedConst; import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.funcCall; import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.ifthenelse; import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.sequence; import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFacade.addUserHeaderInclude; import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createCSourcePackage; import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createConfigureFile; +import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createInclude; import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createMakedefsFile; import static org.fortiss.af3.generator.common.utils.SourceModelElementFactory.createStaticContentSourceUnit; import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement; @@ -62,6 +64,8 @@ import org.fortiss.af3.expression.model.terms.IExpressionTerm; import org.fortiss.af3.expression.model.terms.imperative.Assignment; import org.fortiss.af3.expression.model.terms.imperative.IStatementTerm; import org.fortiss.af3.expression.model.terms.imperative.StatementSequence; +import org.fortiss.af3.expression.model.types.TInt; +import org.fortiss.af3.expression.model.types.TypesFactory; import org.fortiss.af3.expression.utils.ExpressionModelElementFactory; import org.fortiss.af3.generator.common.model.c.CImplementationFile; import org.fortiss.af3.generator.common.model.c.CSourcePackage; @@ -179,8 +183,7 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac DataDictionary dataDict = getRootElement(deployedComponents.get(0).getSecond(), DataDictionary.class); if(dataDict == null) { - dataDict = createDataDictionary(); // dummy element => predefined types are - // created + dataDict = createDataDictionary(); } CSourcePackage dataDictionaryPackage = createTransformedObjectFor(dataDict, CSourcePackage.class, context); @@ -204,11 +207,13 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac return sourcePackage; } + /** Creates Makefile using available template. */ private StaticContentSourceUnit createMakeFileUsingTemplate(SourcePackage pack, String exName) { String content = RaspberryTemplateLoader.getMakeFileTemplate(exName).toString(); return createStaticContentSourceUnit("Makefile", content, false); } + /** Creates make.mk using available template. */ private StaticContentSourceUnit createMakeMKUsingTemplate(SourcePackage pack) { String content = RaspberryTemplateLoader.getMakeMkFileTemplate().toString(); return createStaticContentSourceUnit("make.mk", content, false); @@ -218,6 +223,12 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac private void fixSystemCImports(CImplementationFile system, Set<PlatformConnectorUnit> usedUnits, Set<GenericTransceiver> usedTransceivers) { // Add includes for user code of generic HAL implementation + // String dirName = ((GenericPlatformUnit)modelElement.eContainer()).getName(); + system.getImports().add(createInclude("message.pb-c", false)); + system.getImports().add(createInclude("pi", false)); + system.getImports().add(createInclude("stdio", true)); + system.getImports().add(createInclude("unistd", true)); + // addStandardHeaderInclude(system, dirName + "/message"); for(GenericTransceiver gt : usedTransceivers) { addUserHeaderInclude(system, gt.getName()); } @@ -269,6 +280,12 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac Set<GenericTransceiver> usedTransceivers, Deployment depl) { List<IStatementTerm> body = new ArrayList<IStatementTerm>(); + // Assignment msgDec = assignment(definedConst("Msg msg")); + boolean writeMsgFlag = modifyBusMsg(deployedPorts); + if(writeMsgFlag == true) { + body.add(assignment(definedConst("Msg msg"))); + body.add(assignment(definedConst("msg_init(&msg)"))); + } // Search for local channels, i.e. channels that begin and end at components deployed to // this generic execution unit. // If such channels are found, we have to place the corresponding assignments here, since @@ -300,6 +317,12 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac writeOutputsForComponent(comp, deployedPorts, body, depl); } } + // Messages only written to Bus for cores that modifies the messages + if(writeMsgFlag == true) { + body.add(assignment(definedConst("write_BusMasterPort(msg)"))); + } + // createBusWriteCall(deployedPorts, body); + // Notify transceivers about end of output writing. for(GenericTransceiver gt : usedTransceivers) { body.add(assignment(funcCall("finish_output_" + gt.getName()))); @@ -343,14 +366,29 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac body.add(customAssignment); body.add(assignment(funcCall("terminate_system"))); - return createLocalFunction("main", null, sequence(body)); + return createLocalFunction("main", createTInt(), sequence(body)); } - /** Creates the read input function. */ + /** + * Creates the read input function for IOs. + */ protected LocalFunction createReadInputFunction( List<Pair<PlatformConnectorUnit, Port>> deployedPorts, Set<GenericTransceiver> usedTransceivers, Deployment depl) { List<IStatementTerm> body = new ArrayList<IStatementTerm>(); + + boolean readMsgFlag = false; + for(Pair<PlatformConnectorUnit, Port> prt : deployedPorts) { + ExecutableBase<? extends PlatformConnectorUnit> exc = + getPlatformArchitectureExecutable().getExecutable(prt.getFirst()); + if(exc instanceof BusMasterPortExecutable && prt.getSecond() instanceof InputPort) { + readMsgFlag = true; + } + } + + if(readMsgFlag == true) { + body.add(assignment(definedConst("message msg;\n read_BusMasterPort(&msg)"))); + } // Notify transceivers about start input reading. for(GenericTransceiver gt : usedTransceivers) { body.add(assignment(funcCall("prepare_input_" + gt.getName()))); @@ -370,33 +408,106 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac return createLocalFunction("read_input", null, sequence(body)); } - /** Creates the read code for the given executable and port */ + /** Creates the read code for the given executable and port. */ protected void createReadAccess(IReadExecutable exec, InputPort p, List<IStatementTerm> body, Deployment depl) { - IStatementTerm valueAssign = getPortValueAssignment(p, exec.getValueReadAccessor(p, depl)); - if(exec instanceof IReadExecutableWithNoValSupport) { - IExpressionTerm guard = - ((IReadExecutableWithNoValSupport)exec).getNoValGuardAccessor(p); - StatementSequence thenBlock = sequence(getPortNoValAssignment(p)); - StatementSequence elseBlock = sequence(valueAssign); - body.add(ifthenelse(guard, thenBlock, elseBlock)); + if(exec instanceof BusMasterPortExecutable) { + readMessageFromBus(exec, p, body); } else { - body.add(valueAssign); + IStatementTerm valueAssign = + getPortValueAssignment(p, exec.getValueReadAccessor(p, depl)); + if(exec instanceof IReadExecutableWithNoValSupport) { + IExpressionTerm guard = + ((IReadExecutableWithNoValSupport)exec).getNoValGuardAccessor(p); + StatementSequence thenBlock = sequence(getPortNoValAssignment(p)); + StatementSequence elseBlock = sequence(valueAssign); + body.add(ifthenelse(guard, thenBlock, elseBlock)); + } else { + body.add(valueAssign); + } + } } /** Creates the write code for the given executable and port. */ protected void createWriteAccess(IWriteExecutable exec, OutputPort p, List<IStatementTerm> body, Deployment depl) { - Assignment valueAssign = assignment(exec.getValueWriteAccessor(p, getPortValue(p), depl)); + if(exec instanceof BusMasterPortExecutable) { + writeMessageToBus(exec, p, body); + + } else { + Assignment valueAssign = + assignment(exec.getValueWriteAccessor(p, getPortValue(p), depl)); + if(exec instanceof IWriteExecutableWithNoValSupport) { + IExpressionTerm guard = testPortVariableForNoVal(p); + Assignment thenBlock = + assignment(((IWriteExecutableWithNoValSupport)exec) + .getNoValWriteAccessor(p)); + body.add(ifthenelse(guard, sequence(thenBlock), sequence(valueAssign))); + } else { + body.add(valueAssign); + } + } + } + + /** Creates a {@link TInt} Type. */ + private static TInt createTInt() { + return TypesFactory.eINSTANCE.createTInt(); + } + + /** Create read code for the given {@link BusMasterPortExecutable} and analyze message fields. */ + private void readMessageFromBus(IReadExecutable exec, InputPort p, List<IStatementTerm> body) { + Port sourcePort = p.getIncomingChannels().get(0).getSource(); + String noValGuard = " if (msg.has_" + sourcePort.getName() + "==0) {\n"; + String thenBlock = "noval_" + p.getName() + "_ID_" + p.getId() + "= true;\n}\n"; + String elseBlock = "else { \n noval_" + p.getName() + "_ID_" + p.getId() + "= false;\n"; + String valueAssignRHS = " msg." + sourcePort.getName(); + String valueAssign = p.getName() + "_ID_" + p.getId() + "=" + valueAssignRHS + "; \n} \n"; + String content = noValGuard + thenBlock + elseBlock + valueAssign; + if(exec instanceof IReadExecutableWithNoValSupport) { + Assignment sampleProto = + assignment(ExpressionModelElementFactory.definedConst(content)); + body.add(sampleProto); + } else { + Assignment sampleProto = + assignment(ExpressionModelElementFactory.definedConst(valueAssign)); + body.add(sampleProto); + } + } + + /** Create write code for the given {@link BusMasterPortExecutable}, update message fields. */ + private void writeMessageToBus(IWriteExecutable exec, OutputPort p, List<IStatementTerm> body) { + String noValGuard = " if (noval_" + p.getName() + "_ID_" + p.getId() + "==true) {\n"; + String thenBlock = "msg.has_" + p.getName() + "= 0;\n}\n"; + String elseBlock = "else { \n msg.has_" + p.getName() + "= 1;\n"; + String valueAssign = + " msg." + p.getName() + " = " + p.getName() + "_ID_" + p.getId() + "; \n} \n"; + String content = noValGuard + thenBlock + elseBlock + valueAssign; if(exec instanceof IWriteExecutableWithNoValSupport) { - IExpressionTerm guard = testPortVariableForNoVal(p); - Assignment thenBlock = - assignment(((IWriteExecutableWithNoValSupport)exec).getNoValWriteAccessor(p)); - body.add(ifthenelse(guard, sequence(thenBlock), sequence(valueAssign))); + Assignment sampleProto = + assignment(ExpressionModelElementFactory.definedConst(content)); + body.add(sampleProto); } else { - body.add(valueAssign); + Assignment sampleProto = + assignment(ExpressionModelElementFactory.definedConst(valueAssign)); + body.add(sampleProto); + } + } + + /** + * Determine whether or not the message has been modified so that call for updated message write + * should be made. + */ + private boolean modifyBusMsg(List<Pair<PlatformConnectorUnit, Port>> deployedPorts) { + boolean writeMsgFlag = false; + for(Pair<PlatformConnectorUnit, Port> prt : deployedPorts) { + ExecutableBase<? extends PlatformConnectorUnit> exec = + getPlatformArchitectureExecutable().getExecutable(prt.getFirst()); + if(exec instanceof BusMasterPortExecutable && prt.getSecond() instanceof OutputPort) { + writeMsgFlag = true; + } } + return writeMsgFlag; } } diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPi2Executable.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPi2Executable.java index d533aaf9..713f1891 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPi2Executable.java +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPi2Executable.java @@ -17,7 +17,13 @@ $Id$ +--------------------------------------------------------------------------*/ package org.fortiss.af3.platform.raspberry.generator.executable; +import static org.fortiss.af3.generator.common.utils.SourceModelElementFactory.createStaticContentSourceUnit; + +import org.eclipse.emf.common.util.EList; +import org.fortiss.af3.generator.common.model.source.SourcePackage; import org.fortiss.af3.platform.language.executable.GenericPlatformUnitExecutableBase; +import org.fortiss.af3.platform.model.PlatformConnectorUnit; +import org.fortiss.af3.platform.raspberry.generated.files.RaspberryFileGeneration; import org.fortiss.af3.platform.raspberry.model.RaspberryPi2; /** @@ -37,4 +43,25 @@ public class RaspberryPi2Executable extends GenericPlatformUnitExecutableBase<Ra // TODO Auto-generated constructor stub } + /** Create files for Sensors and Actuators. */ + public void createPeripheralsInfo(SourcePackage pack) { + EList<PlatformConnectorUnit> conns = modelElement.getPlatformConnectorUnits(); + + String sensorList = "{\n"; + + for(PlatformConnectorUnit exec : conns) { + // ExecutableBase<? extends PlatformConnectorUnit> exec = + // getPlatformArchitectureExecutable().getExecutable((PlatformConnectorUnit)p); + + if(exec instanceof SensorExecutable) { + String details = ((SensorInExecutable)exec).getSensorDetails(); + sensorList += details; + } + } + sensorList += "\n}"; + RaspberryFileGeneration sensorsInfoGen = new RaspberryFileGeneration(sensorList); + sensorsInfoGen.createInfofile(); + pack.addUnit(createStaticContentSourceUnit("sensors.c", sensorsInfoGen.getContent(), false)); + } + } diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/SensorInExecutable.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/SensorInExecutable.java index d8652e9b..8bcd7791 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/SensorInExecutable.java +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/SensorInExecutable.java @@ -29,6 +29,7 @@ import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.IReadE import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.ITermExecutable; import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.InitExecutable; import org.fortiss.af3.platform.raspberry.model.SensorIn; +import org.fortiss.af3.platform.raspberry.model.annotation.PeripheralAddress; import org.fortiss.af3.platform.raspberry.model.annotation.PinNumber; /** @@ -52,14 +53,14 @@ public class SensorInExecutable extends ReceiverExecutableBase<SensorIn> impleme /** {@inheritDoc} */ @Override public IExpressionTerm getInitialization() { - String sensorId = modelElement.getName() + "_ID_" + modelElement.getId(); + String sensorId = "SensorIn_ID_" + modelElement.getId();// modelElement.getName() + return funcCall("init_Sensor", createVar(sensorId)); } /** {@inheritDoc} */ @Override public IExpressionTerm getTermination() { - String sensorId = modelElement.getName() + "_ID_" + modelElement.getId(); + String sensorId = "SensorIn_ID_" + modelElement.getId(); return funcCall("term_Sensor", createVar(sensorId)); } @@ -67,10 +68,11 @@ public class SensorInExecutable extends ReceiverExecutableBase<SensorIn> impleme @Override /* generates call: read_Sensor(pinNr, varName) */ public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { - PinNumber ias = getAnnotation(modelElement, PinNumber.class); - int pinNr = ias.getPinNumber(); - String sensorId = modelElement.getName() + "_ID_" + modelElement.getId(); - return funcCall("read_Sensor", createVar(pinNr + ""), createVar(sensorId)); + // PinNumber ias = getAnnotation(modelElement, PinNumber.class); + // int pinNr = ias.getPinNumber(); + String sensorId = "SensorIn_ID_" + modelElement.getId(); + String fcnName = "read_Sensor"; + return funcCall(fcnName, createVar(sensorId)); } /** {@inheritDoc} */ @@ -81,12 +83,11 @@ public class SensorInExecutable extends ReceiverExecutableBase<SensorIn> impleme /** {@inheritDoc} */ @Override - /* generates call: read_Sensor(pinNr, varName) */ + /* generates call: read_Sensor(id, pinNr, address) */ public IExpressionTerm getValueReadAccessor(InputPort logicalSignal, Deployment depl) { - PinNumber ias = getAnnotation(modelElement, PinNumber.class); - int pinNr = ias.getPinNumber(); - String sensorId = modelElement.getName() + "_ID_" + modelElement.getId(); - return funcCall("read_Sensor", createVar(pinNr + ""), createVar(sensorId)); + String sensorId = "SensorIn_ID_" + modelElement.getId(); + String fcnName = "read_Sensor"; + return funcCall(fcnName, createVar(sensorId)); } /** {@inheritDoc} */ @@ -107,7 +108,7 @@ public class SensorInExecutable extends ReceiverExecutableBase<SensorIn> impleme @Override public IExpressionTerm getTermination(Deployment depl) { // TODO Auto-generated method stub - String sensorId = modelElement.getName() + "_ID_" + modelElement.getId(); + String sensorId = "SensorIn_ID_" + modelElement.getId(); return funcCall("term_Sensor", createVar(sensorId)); } @@ -130,7 +131,19 @@ public class SensorInExecutable extends ReceiverExecutableBase<SensorIn> impleme @Override public IExpressionTerm getInitialization(Deployment depl) { // TODO Auto-generated method stub - String sensorId = modelElement.getName() + "_ID_" + modelElement.getId(); + String sensorId = "SensorIn_ID_" + modelElement.getId(); return funcCall("init_Sensor", createVar(sensorId)); } + + /** Get PinNr, Address and ID of a sensor. */ + + public String getSensorDetails() { + PinNumber ias = getAnnotation(modelElement, PinNumber.class); + int pinNr = ias.getPinNumber(); + PeripheralAddress pa = getAnnotation(modelElement, PeripheralAddress.class); + int sensorAddress = pa.getPeripheralAddress(); + int sensorId = modelElement.getId(); + return "{" + sensorId + ", " + pinNr + ", " + sensorAddress + "} \n"; + } + } diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/utils/RaspberryUtils.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/utils/RaspberryUtils.java index 33791fab..65b3559e 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/utils/RaspberryUtils.java +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/utils/RaspberryUtils.java @@ -25,7 +25,11 @@ import org.fortiss.af3.component.model.Component; import org.fortiss.af3.component.model.OutputPort; import org.fortiss.af3.deployment.model.ComponentAllocation; import org.fortiss.af3.deployment.model.Deployment; +import org.fortiss.af3.expression.model.terms.IExpressionTerm; +import org.fortiss.af3.expression.model.terms.impl.FunctionCallStaticImpl; +import org.fortiss.af3.expression.model.terms.impl.UserdefinedFunctionStaticImpl; import org.fortiss.af3.platform.model.ExecutionUnit; +import org.fortiss.af3.project.model.typesystem.IFunction; /** * @@ -54,4 +58,11 @@ public class RaspberryUtils { return null; } + + /** Generates a function call for more than two arguments */ + public static IExpressionTerm funcCallMultipleArgs(String funcName, IExpressionTerm arg0, + IExpressionTerm arg1, IExpressionTerm arg2) { + IFunction fun = UserdefinedFunctionStaticImpl.create(funcName); + return FunctionCallStaticImpl.create(fun, arg0, arg1, arg2); + } } -- GitLab