Search in sources :

Example 11 with FeatureGroup

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

the class Aadl2Validator method checkFeatureGroupConnectionDirection.

/**
 * Check category of source and destination Section 9.5 Legality rules L5-8
 */
private void checkFeatureGroupConnectionDirection(Connection connection) {
    if (connection.isAllBidirectional()) {
        // this is checked separately
        return;
    }
    final ClassifierMatchingRule classifierMatchingRuleValue = org.osate.aadl2.contrib.modeling.ModelingProperties.getClassifierMatchingRule(connection).orElse(ClassifierMatchingRule.CLASSIFIER_MATCH);
    if (classifierMatchingRuleValue == ClassifierMatchingRule.SUBSET) {
        // in case of subset if the connection is directional we do not have to match
        return;
    }
    ConnectionEnd source = connection.getAllLastSource();
    ConnectionEnd destination = connection.getAllLastDestination();
    if (source instanceof FeatureGroupConnectionEnd && destination instanceof FeatureGroupConnectionEnd) {
        Context srccxt = connection.getAllSourceContext();
        Context dstcxt = connection.getAllDestinationContext();
        DirectionType sourceDirection = ((FeatureGroup) source).getDirection();
        List<NamedElement> sourceChain = getConnectionChain(connection.getRootConnection().getSource());
        if (isInvertNeeded(sourceChain.subList(0, sourceChain.size() - 1))) {
            sourceDirection = sourceDirection.getInverseDirection();
        }
        DirectionType destinationDirection = ((FeatureGroup) destination).getDirection();
        List<NamedElement> destinationChain = getConnectionChain(connection.getRootConnection().getDestination());
        if (isInvertNeeded(destinationChain.subList(0, destinationChain.size() - 1))) {
            destinationDirection = destinationDirection.getInverseDirection();
        }
        checkThroughConnection(connection);
        if (srccxt instanceof Subcomponent && dstcxt instanceof Subcomponent) {
            // sibling to sibling
            if (sourceDirection.equals(DirectionType.IN)) {
                error("The direction of the source " + source.getName() + " of a directional feature group connection must not be in", connection, Aadl2Package.eINSTANCE.getConnection_Source(), MAKE_CONNECTION_BIDIRECTIONAL);
            } else if (sourceDirection.equals(DirectionType.IN_OUT)) {
                checkDirectionOfFeatureGroupMembers(sourceChain, DirectionType.IN, connection, Aadl2Package.eINSTANCE.getConnection_Source());
            }
            if (destinationDirection.equals(DirectionType.OUT)) {
                error("The direction of the destination " + destination.getName() + " of a directional feature group connection must not be out", connection, Aadl2Package.eINSTANCE.getConnection_Destination(), MAKE_CONNECTION_BIDIRECTIONAL);
            } else if (destinationDirection.equals(DirectionType.IN_OUT)) {
                checkDirectionOfFeatureGroupMembers(destinationChain, DirectionType.OUT, connection, Aadl2Package.eINSTANCE.getConnection_Destination());
            }
        } else if (!(srccxt instanceof Subcomponent)) {
            // going down
            if (sourceDirection.equals(DirectionType.OUT)) {
                error("The direction of the source " + source.getName() + " of this incoming directional feature group connection must not be out", connection, Aadl2Package.eINSTANCE.getConnection_Source(), MAKE_CONNECTION_BIDIRECTIONAL);
            } else if (sourceDirection.equals(DirectionType.IN_OUT)) {
                checkDirectionOfFeatureGroupMembers(sourceChain, DirectionType.OUT, connection, Aadl2Package.eINSTANCE.getConnection_Source());
            }
            if (destinationDirection.equals(DirectionType.OUT)) {
                error("The direction of the destination " + destination.getName() + " of this incoming directional feature group connection must not be out", connection, Aadl2Package.eINSTANCE.getConnection_Destination(), MAKE_CONNECTION_BIDIRECTIONAL);
            } else if (destinationDirection.equals(DirectionType.IN_OUT)) {
                checkDirectionOfFeatureGroupMembers(destinationChain, DirectionType.OUT, connection, Aadl2Package.eINSTANCE.getConnection_Destination());
            }
        } else if (!(dstcxt instanceof Subcomponent)) {
            // going up
            if (sourceDirection.equals(DirectionType.IN)) {
                error("The direction of the source " + source.getName() + " of this outgoing directional feature group connection must not be in", connection, Aadl2Package.eINSTANCE.getConnection_Destination(), MAKE_CONNECTION_BIDIRECTIONAL);
            } else if (sourceDirection.equals(DirectionType.IN_OUT)) {
                checkDirectionOfFeatureGroupMembers(sourceChain, DirectionType.IN, connection, Aadl2Package.eINSTANCE.getConnection_Source());
            }
            if (destinationDirection.equals(DirectionType.IN)) {
                error("The direction of the destination " + destination.getName() + " of this outgoing directional feature group connection must not be in", connection, Aadl2Package.eINSTANCE.getConnection_Destination(), MAKE_CONNECTION_BIDIRECTIONAL);
            } else if (destinationDirection.equals(DirectionType.IN_OUT)) {
                checkDirectionOfFeatureGroupMembers(destinationChain, DirectionType.IN, connection, Aadl2Package.eINSTANCE.getConnection_Destination());
            }
        }
    }
}
Also used : ClassifierMatchingRule(org.osate.aadl2.contrib.modeling.ClassifierMatchingRule)

Example 12 with FeatureGroup

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

the class FlowLatencyAnalysisSwitch method getTimeInMilliSec2.

private RealRange getTimeInMilliSec2(final FlowElementInstance fei, final ComponentInstance ci, final boolean isPeriodic, final Function<NamedElement, Optional<IntegerRangeWithUnits<TimeUnits>>> getExecTime) {
    /*
		 * If the flow element is a component instance or if the thread is periodic, we use the thread's
		 * computation time. Otherwise we try to use the compute execution time from the flow's input feature.
		 */
    if (!(isPeriodic || fei == ci)) {
        // the flow element is a FlowSpecificationInstance (It is not periodic or a component instance)
        final FlowSpecificationInstance fsi = (FlowSpecificationInstance) fei;
        final FlowEnd allInEnd = fsi.getFlowSpecification().getAllInEnd();
        if (allInEnd != null) {
            // we have an input feature
            FeatureInstance fi = null;
            if (allInEnd.getContext() instanceof FeatureGroup) {
                final FeatureInstance fgi = ci.findFeatureInstance((FeatureGroup) allInEnd.getContext());
                fi = fgi.findFeatureInstance(allInEnd.getFeature());
            } else {
                fi = ci.findFeatureInstance(allInEnd.getFeature());
            }
            final FeatureCategory featureCategory = fi.getCategory();
            if (featureCategory == FeatureCategory.EVENT_PORT || featureCategory == FeatureCategory.EVENT_DATA_PORT) {
                final Optional<IntegerRangeWithUnits<TimeUnits>> fromFeature = getExecTime.apply(fi);
                if (fromFeature.isPresent()) {
                    return AnalysisUtils.scaleTimeRange(PropertyUtils.scaleRange(fromFeature.get(), TimeUnits.MS), fi);
                }
            // otherwise fall through and get from component
            }
        // otherwise fall through and get from component
        }
    }
    final ComponentCategory componentCategory = ci.getCategory();
    if (componentCategory == ComponentCategory.THREAD || componentCategory == ComponentCategory.DEVICE || componentCategory == ComponentCategory.SUBPROGRAM || componentCategory == ComponentCategory.ABSTRACT) {
        return AnalysisUtils.scaleTimeRange(PropertyUtils.scaleRange(getExecTime.apply(ci), TimeUnits.MS).orElse(RealRange.ZEROED), ci);
    } else {
        return RealRange.ZEROED;
    }
}
Also used : FeatureGroup(org.osate.aadl2.FeatureGroup) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) IntegerRangeWithUnits(org.osate.pluginsupport.properties.IntegerRangeWithUnits) FlowSpecificationInstance(org.osate.aadl2.instance.FlowSpecificationInstance) ComponentCategory(org.osate.aadl2.ComponentCategory) FeatureCategory(org.osate.aadl2.instance.FeatureCategory) FlowEnd(org.osate.aadl2.FlowEnd)

Example 13 with FeatureGroup

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

the class GroupHolderItemProvider method getImage.

/**
 * This returns GroupHolder.gif.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 */
@Override
public Object getImage(Object object) {
    String imgFile = BehaviorElementItemProvider.OSATE_IMG_PATH;
    GroupHolder holder = (GroupHolder) object;
    NamedElement group = holder.getGroup();
    if (group instanceof ThreadGroup)
        imgFile += "ThreadGroup";
    else if (group instanceof FeatureGroup)
        imgFile += "FeatureGroup";
    else // SubprogramGroup and SubprogramGroupAccess cases.
    {
        imgFile += "Subprogram";
    }
    return overlayImage(object, getResourceLocator().getImage(imgFile));
}
Also used : FeatureGroup(org.osate.aadl2.FeatureGroup) GroupHolder(org.osate.ba.aadlba.GroupHolder) ThreadGroup(org.osate.aadl2.ThreadGroup) NamedElement(org.osate.aadl2.NamedElement)

Example 14 with FeatureGroup

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

the class GroupPrototypeHolderItemProvider method getImage.

/**
 * This returns GroupPrototypeHolder.gif.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 */
@Override
public Object getImage(Object object) {
    String imgFile = BehaviorElementItemProvider.OSATE_IMG_PATH;
    PrototypeHolder holder = (PrototypeHolder) object;
    PrototypeBinding pb = holder.getPrototypeBinding();
    if (pb != null) {
        FeatureType type = FeatureType.ABSTRACT_FEATURE;
        if (pb instanceof ComponentPrototypeBinding) {
            type = AadlBaUtils.getCompPrototypeType((ComponentPrototypeBinding) pb);
        } else if (pb instanceof FeatureGroupPrototypeBinding) {
            type = FeatureType.FEATURE_GROUP_PROTOTYPE;
        } else if (pb instanceof FeaturePrototypeBinding) {
            type = AadlBaUtils.getFeatPrototypeType((FeaturePrototypeBinding) pb);
        }
        switch(type) {
            case FEATURE_GROUP_PROTOTYPE:
                {
                    imgFile += "FeatureGroup";
                    break;
                }
            case THREAD_GROUP_PROTOTYPE:
                {
                    imgFile += "ThreadGroup";
                    break;
                }
            case REQUIRES_SUBPROGRAM_GROUP_ACCESS_PROTOTYPE:
            case PROVIDES_SUBPROGRAM_GROUP_ACCESS_PROTOTYPE:
            case SUBPROGRAM_GROUP_PROTOTYPE:
                {
                    imgFile += "Subprogram";
                    break;
                }
            default:
                imgFile = "full/obj16/IfStatement";
        }
    }
    return overlayImage(object, getResourceLocator().getImage(imgFile));
}
Also used : FeatureType(org.osate.ba.aadlba.FeatureType) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) PrototypeBinding(org.osate.aadl2.PrototypeBinding) PrototypeHolder(org.osate.ba.aadlba.PrototypeHolder)

Example 15 with FeatureGroup

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

the class AadlBaUtils method getClassifier.

/**
 * Returns the given Element object's classifier.
 * If the Element object is a prototype, it will try to resolve it as
 * follow: returns the data prototype binded classifier at first withing the
 * element's parent container otherwise the constraining classifier.
 * It returns {@code null} if the prototype is not defined.
 * <BR><BR>
 * This method support instances of:<BR>
 * <BR>_Feature (port, data access, subprogram access, parameter, etc.)
 * <BR>_Subcomponent (data subcomponent, subprogram subcomponent, etc.)
 * <BR>_BehaviorVariable
 * <BR>_IterativeVariable (for/forall's iterative variable)
 * <BR>_Prototype (all excepted FeatureGroupPrototype)
 * <BR>_PrototypeBinding (all excepted FeatureGroupPrototypeBinding)
 * <BR>_ClassifierValue (struct or union data subcomponent)
 * <BR><BR>
 * If the given Element object is not one of those types, an
 * UnsupportedOperationException is thrown.
 *
 * @param el the given Element object
 * @param parentContainer the element's parent component.
 * @return the given element's classifier or {@code null} if the prototype is
 * not defined
 * @exception UnsupportedOperationException for unsupported element
 * object types.
 */
public static Classifier getClassifier(Element el, Classifier parentContainer) {
    Classifier result = null;
    if (el instanceof Feature) {
        Feature f = (Feature) el;
        if (el instanceof FeatureGroup) {
            org.osate.aadl2.FeatureType ft = ((FeatureGroup) el).getFeatureType();
            if (ft != null) {
                if (ft instanceof FeatureGroupType) {
                    result = (FeatureGroupType) ft;
                } else // FeatureGroupPrototype case
                {
                    result = getClassifier((FeatureGroupPrototype) ft, parentContainer);
                }
            }
        } else {
            // Feature case.
            result = f.getClassifier();
            // Feature without classifier returns null.
            if (result == null && f.getPrototype() != null) {
                result = prototypeResolver(f.getPrototype(), parentContainer);
            }
        }
    } else if (el instanceof Subcomponent) {
        Subcomponent sub = (Subcomponent) el;
        if (el instanceof SubprogramGroupSubcomponent) {
            result = ((SubprogramGroupSubcomponent) el).getClassifier();
        } else {
            // Subcomponent case.
            result = sub.getClassifier();
            // Subcomponent without classifier returns null.
            if (result == null && sub.getPrototype() != null) {
                result = prototypeResolver(sub.getPrototype(), parentContainer);
            }
        }
    } else if (el instanceof BehaviorVariable) {
        // Local variable case (BehaviorVariable).
        BehaviorVariable bv = (BehaviorVariable) el;
        result = bv.getDataClassifier();
    } else if (el instanceof IterativeVariable) {
        // Iterative variable case.
        result = ((IterativeVariable) el).getDataClassifier();
    } else if (el instanceof Prototype) {
        result = prototypeResolver((Prototype) el, parentContainer);
    } else if (el instanceof PrototypeBinding) {
        // Prototype binding case.
        result = prototypeBindingResolver((PrototypeBinding) el);
    } else if (el instanceof ClassifierValue) {
        // struct or union member case (ClassifierValue).
        result = ((ClassifierValue) el).getClassifier();
    } else if (el instanceof StructUnionElement) {
        return ((StructUnionElement) el).getDataClassifier();
    } else {
        // Reports error.
        String errorMsg = "getClassifier : " + el.getClass().getSimpleName() + " is not supported yet.";
        System.err.println(errorMsg);
        throw new UnsupportedOperationException(errorMsg);
    }
    return result;
}
Also used : IterativeVariable(org.osate.ba.aadlba.IterativeVariable) FeatureGroup(org.osate.aadl2.FeatureGroup) Prototype(org.osate.aadl2.Prototype) DataPrototype(org.osate.aadl2.DataPrototype) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) ClassifierValue(org.osate.aadl2.ClassifierValue) BehaviorVariable(org.osate.ba.aadlba.BehaviorVariable) FeatureGroupType(org.osate.aadl2.FeatureGroupType) SubprogramGroupSubcomponent(org.osate.aadl2.SubprogramGroupSubcomponent) SubprogramClassifier(org.osate.aadl2.SubprogramClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) ProcessClassifier(org.osate.aadl2.ProcessClassifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) AadlString(org.osate.aadl2.AadlString) StructUnionElement(org.osate.ba.aadlba.StructUnionElement) Feature(org.osate.aadl2.Feature) AbstractFeature(org.osate.aadl2.AbstractFeature) DirectedFeature(org.osate.aadl2.DirectedFeature) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) Subcomponent(org.osate.aadl2.Subcomponent) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) SubprogramGroupSubcomponent(org.osate.aadl2.SubprogramGroupSubcomponent) SystemSubcomponent(org.osate.aadl2.SystemSubcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) PrototypeBinding(org.osate.aadl2.PrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding)

Aggregations

FeatureGroup (org.osate.aadl2.FeatureGroup)45 FeatureGroupType (org.osate.aadl2.FeatureGroupType)24 Feature (org.osate.aadl2.Feature)16 Subcomponent (org.osate.aadl2.Subcomponent)16 Classifier (org.osate.aadl2.Classifier)14 NamedElement (org.osate.aadl2.NamedElement)12 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)12 ComponentClassifier (org.osate.aadl2.ComponentClassifier)11 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)10 Context (org.osate.aadl2.Context)9 SubprogramSubcomponent (org.osate.aadl2.SubprogramSubcomponent)9 ArrayList (java.util.ArrayList)8 DataSubcomponent (org.osate.aadl2.DataSubcomponent)8 ModeTransition (org.osate.aadl2.ModeTransition)8 EObject (org.eclipse.emf.ecore.EObject)7 ComponentPrototype (org.osate.aadl2.ComponentPrototype)7 FeatureGroupPrototype (org.osate.aadl2.FeatureGroupPrototype)7 ComponentType (org.osate.aadl2.ComponentType)6 ConnectionEnd (org.osate.aadl2.ConnectionEnd)6 Mode (org.osate.aadl2.Mode)6