Search in sources :

Example 11 with AccessType

use of org.osate.aadl2.AccessType in project osate2 by osate.

the class AccessSpecificationImpl method setKind.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setKind(AccessType newKind) {
    AccessType oldKind = kind;
    kind = newKind == null ? KIND_EDEFAULT : newKind;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, Aadl2Package.ACCESS_SPECIFICATION__KIND, oldKind, kind));
    }
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) AccessType(org.osate.aadl2.AccessType)

Example 12 with AccessType

use of org.osate.aadl2.AccessType in project osate2 by osate.

the class Aadl2Validator method checkDirectionOfFeatureGroupMembers.

/**
 * Checks that direction of matching features in feature group are opposite or the same.
 * This method is useful when the feature group types of the source and destination are independently specified
 * We check that by checking whether the connection has SUBSET, EQUIVALNCE, CONVERSION
 */
private void checkDirectionOfFeatureGroupMembers(Connection connection) {
    if (!(connection.getAllLastSource() instanceof FeatureGroup) || !(connection.getAllLastDestination() instanceof FeatureGroup)) {
        return;
    }
    FeatureGroup source = (FeatureGroup) connection.getAllLastSource();
    FeatureGroup destination = (FeatureGroup) connection.getAllLastDestination();
    FeatureGroupType sourceType = source.getAllFeatureGroupType();
    FeatureGroupType destinationType = destination.getAllFeatureGroupType();
    if (sourceType == null || destinationType == null) {
        return;
    }
    Context srcContext = connection.getAllSourceContext();
    Context dstContext = connection.getAllDestinationContext();
    // connection across or through a component
    boolean isSibling = (srcContext instanceof Subcomponent && dstContext instanceof Subcomponent);
    final ClassifierMatchingRule classifierMatchingRuleValue = org.osate.aadl2.contrib.modeling.ModelingProperties.getClassifierMatchingRule(connection).orElse(ClassifierMatchingRule.CLASSIFIER_MATCH);
    if (classifierMatchingRuleValue == ClassifierMatchingRule.EQUIVALENCE || classifierMatchingRuleValue == ClassifierMatchingRule.CONVERSION || classifierMatchingRuleValue == ClassifierMatchingRule.SUBSET) {
        EList<Feature> srcFeatures = sourceType.getAllFeatures();
        EList<Feature> dstFeatures = destinationType.getAllFeatures();
        if (srcFeatures.isEmpty() || dstFeatures.isEmpty()) {
            return;
        }
        for (Feature destinationFeature : dstFeatures) {
            if (destinationFeature instanceof DirectedFeature && !((DirectedFeature) destinationFeature).getDirection().equals(DirectionType.IN_OUT)) {
                DirectionType destinationDirection = ((DirectedFeature) destinationFeature).getDirection();
                List<NamedElement> destinationChain = getConnectionChain(connection.getRootConnection().getDestination());
                destinationChain.add(destinationFeature);
                if (isInvertNeeded(destinationChain)) {
                    destinationDirection = destinationDirection.getInverseDirection();
                }
                for (Feature sourceFeature : srcFeatures) {
                    if (destinationFeature.getName().equalsIgnoreCase(sourceFeature.getName())) {
                        if (sourceFeature instanceof DirectedFeature && !((DirectedFeature) sourceFeature).getDirection().equals(DirectionType.IN_OUT)) {
                            DirectionType sourceDirection = ((DirectedFeature) sourceFeature).getDirection();
                            List<NamedElement> sourceChain = getConnectionChain(connection.getRootConnection().getSource());
                            sourceChain.add(sourceFeature);
                            if (isInvertNeeded(sourceChain)) {
                                sourceDirection = sourceDirection.getInverseDirection();
                            }
                            // check for opposite or matching direction
                            if (isSibling) {
                                // opposite direction
                                if (sourceDirection == destinationDirection) {
                                    error(connection, "The direction of the source feature group feature '" + source.getName() + "." + sourceFeature.getName() + "' and destination feature group feature '" + destination.getName() + "." + destinationFeature.getName() + "' of connection " + connection.getName() + " must be opposites.");
                                }
                            } else {
                                // matching direction
                                if (sourceDirection != destinationDirection) {
                                    error(connection, "The direction of the source feature group feature '" + source.getName() + "." + sourceFeature.getName() + "' and destination feature group feature '" + destination.getName() + "." + destinationFeature.getName() + "' of connection " + connection.getName() + " must be same.");
                                }
                            }
                        } else {
                            // source not a directional feature while destination is
                            if (!(destinationFeature instanceof AbstractFeature && destinationDirection == DirectionType.IN_OUT && sourceFeature instanceof Access)) {
                                error(connection, "The source feature group access feature '" + source.getName() + "." + sourceFeature.getName() + "' cannot be connected to destination feature group directional feature '" + destination.getName() + "." + destinationFeature.getName());
                            }
                        }
                    }
                }
            } else if (destinationFeature instanceof Access) {
                AccessType destinationDirection = ((Access) destinationFeature).getKind();
                List<NamedElement> destinationChain = getConnectionChain(connection.getRootConnection().getDestination());
                destinationChain.add(destinationFeature);
                if (isInvertNeeded(destinationChain)) {
                    destinationDirection = destinationDirection.getInverseType();
                }
                for (Feature sourceFeature : srcFeatures) {
                    if (destinationFeature.getName().equalsIgnoreCase(sourceFeature.getName())) {
                        if (sourceFeature instanceof Access) {
                            AccessType sourceDirection = ((Access) sourceFeature).getKind();
                            List<NamedElement> sourceChain = getConnectionChain(connection.getRootConnection().getSource());
                            sourceChain.add(sourceFeature);
                            if (isInvertNeeded(sourceChain)) {
                                sourceDirection = sourceDirection.getInverseType();
                            }
                            // check for opposite or matching direction
                            if (isSibling) {
                                // opposite direction
                                if (sourceDirection == destinationDirection) {
                                    error(connection, "The direction of the source feature group access feature '" + source.getName() + "." + sourceFeature.getName() + "' and destination feature group access feature '" + destination.getName() + "." + destinationFeature.getName() + "' of connection " + connection.getName() + " must be opposites.");
                                }
                            } else {
                                // matching direction
                                if (sourceDirection != destinationDirection) {
                                    error(connection, "The direction of the source feature group access feature '" + source.getName() + "." + sourceFeature.getName() + "' and destination feature group access feature '" + destination.getName() + "." + destinationFeature.getName() + "' of connection " + connection.getName() + " must be same.");
                                }
                            }
                        } else {
                            // destination not a directional feature while is. Must be an abstract to be ok
                            if (!(sourceFeature instanceof AbstractFeature && ((AbstractFeature) sourceFeature).getDirection() == DirectionType.IN_OUT)) {
                                error(connection, "The source feature group directional feature '" + source.getName() + "." + sourceFeature.getName() + "' cannot be connected to destination feature group access feature '" + destination.getName() + "." + destinationFeature.getName());
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : Aadl2GrammarAccess(org.osate.xtext.aadl2.services.Aadl2GrammarAccess) ClassifierMatchingRule(org.osate.aadl2.contrib.modeling.ClassifierMatchingRule) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) BasicInternalEList(org.eclipse.emf.ecore.util.BasicInternalEList) List(java.util.List) BasicEList(org.eclipse.emf.common.util.BasicEList) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList)

Example 13 with AccessType

use of org.osate.aadl2.AccessType in project osate2 by osate.

the class AccessPropertySection method getAccessType.

private static AccessType getAccessType(final Set<Access> selectedAccesses) {
    final Iterator<Access> it = selectedAccesses.iterator();
    // Initial value of buttons
    final AccessType accessType = it.next().getKind();
    while (it.hasNext()) {
        // Check if all elements are of same access type
        if (accessType != it.next().getKind()) {
            return null;
        }
    }
    return accessType;
}
Also used : Access(org.osate.aadl2.Access) AccessType(org.osate.aadl2.AccessType)

Aggregations

AccessType (org.osate.aadl2.AccessType)11 ArrayList (java.util.ArrayList)4 Connection (org.osate.aadl2.Connection)3 ConnectionEnd (org.osate.aadl2.ConnectionEnd)3 DataSubcomponent (org.osate.aadl2.DataSubcomponent)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 EObject (org.eclipse.emf.ecore.EObject)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 Access (org.osate.aadl2.Access)2 AccessSpecification (org.osate.aadl2.AccessSpecification)2 Classifier (org.osate.aadl2.Classifier)2 ComponentClassifier (org.osate.aadl2.ComponentClassifier)2 ComponentImplementation (org.osate.aadl2.ComponentImplementation)2 Context (org.osate.aadl2.Context)2 DataAccess (org.osate.aadl2.DataAccess)2 DataPort (org.osate.aadl2.DataPort)2 DirectionType (org.osate.aadl2.DirectionType)2 FeaturePrototypeBinding (org.osate.aadl2.FeaturePrototypeBinding)2