Search in sources :

Example 26 with FeatureGroup

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

the class ConnectionImpl method getAllDstContextComponent.

/*
	 * (non-Javadoc)
	 *
	 * @see org.osate.aadl2.Connection#getAllDstContextComponent()
	 */
public NamedElement getAllDstContextComponent() {
    Connection conn = getRootConnection();
    Context dcxt = conn.getAllDestinationContext();
    if (dcxt instanceof FeatureGroup) {
        return conn.getContainingComponentImpl();
    }
    return dcxt;
}
Also used : Context(org.osate.aadl2.Context) FeatureGroup(org.osate.aadl2.FeatureGroup) Connection(org.osate.aadl2.Connection)

Example 27 with FeatureGroup

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

the class ConnectionImpl method getAllSrcContextComponent.

/*
	 * (non-Javadoc)
	 *
	 * @see org.osate.aadl2.Connection#getAllSrcContextComponent()
	 */
public NamedElement getAllSrcContextComponent() {
    Connection conn = getRootConnection();
    Context scxt = conn.getAllSourceContext();
    if (scxt instanceof FeatureGroup) {
        return conn.getContainingComponentImpl();
    }
    return scxt;
}
Also used : Context(org.osate.aadl2.Context) FeatureGroup(org.osate.aadl2.FeatureGroup) Connection(org.osate.aadl2.Connection)

Example 28 with FeatureGroup

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

the class FeatureGroupImpl method isInverseOf.

/**
 * check for inverseof between two features.
 * If they are feature groups then we check both the inverse of on the feature group and whether the feature group type is inverseof.
 * @param f1
 * @param f2
 * @return boolean
 */
public boolean isInverseOf(FeatureGroup fg2) {
    FeatureGroupType fgt1 = getAllFeatureGroupType();
    FeatureGroupType fgt2 = fg2.getAllFeatureGroupType();
    if (fgt1.isInverseOf(fgt2) && (isInverse() == fg2.isInverse())) {
        return true;
    }
    if (fgt1 == fgt2 && (isInverse() != fg2.isInverse())) {
        return true;
    }
    return false;
}
Also used : FeatureGroupType(org.osate.aadl2.FeatureGroupType)

Example 29 with FeatureGroup

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

the class PropertyImpl method getPropertyValueFromDeclarativeModel.

protected void getPropertyValueFromDeclarativeModel(EvaluationContext ctx, PropertyAcc pas) throws InvalidModelException {
    InstanceObject io = ctx.getInstanceObject();
    List<? extends NamedElement> compDecls = io.getInstantiatedObjects();
    if (compDecls == null) {
    }
    // Here we assume compDecls is empty or has only one element
    if (!compDecls.isEmpty()) {
        NamedElement compDecl = compDecls.get(0);
        if (compDecl == null) {
            return;
        }
        InstantiatedClassifier ic = ctx.getClassifierCache().get(io);
        Classifier cl = (ic == null) ? null : ic.getClassifier();
        if (compDecl instanceof Subcomponent) {
            ((SubcomponentImpl) compDecl).getPropertyValue(this, pas, cl, false);
        } else if (compDecl instanceof FeatureGroup) {
            ((FeatureGroupImpl) compDecl).getPropertyValue(this, pas, cl, false);
        } else if (compDecl instanceof Feature) {
            ((FeatureImpl) compDecl).getPropertyValue(this, pas, cl, false);
        } else if (compDecl instanceof PortConnection) {
            ((PortConnectionImpl) compDecl).getPropertyValue(this, pas);
        } else {
            compDecl.getPropertyValueInternal(this, pas, true);
        }
    }
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) FeatureGroup(org.osate.aadl2.FeatureGroup) InstantiatedClassifier(org.osate.aadl2.instance.util.InstanceUtil.InstantiatedClassifier) Subcomponent(org.osate.aadl2.Subcomponent) InstantiatedClassifier(org.osate.aadl2.instance.util.InstanceUtil.InstantiatedClassifier) Classifier(org.osate.aadl2.Classifier) NamedElement(org.osate.aadl2.NamedElement) Feature(org.osate.aadl2.Feature) PortConnection(org.osate.aadl2.PortConnection)

Example 30 with FeatureGroup

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

the class InstanceUtil method getInstantiatedClassifier.

/**
 * Get the component or feature group classifier that is instantiated by an
 * instance object. Resolve prototypes if needed.
 *
 * @param iobj the instance object
 * @param index the index of the instance object in an array
 * @param classifierCache an optional cache of known instantiated
 *            classifiers, may be null
 * @return the instantiated classifier together with bindings for anonymous
 *         classifiers
 */
public static InstantiatedClassifier getInstantiatedClassifier(InstanceObject iobj, int index, HashMap<InstanceObject, InstantiatedClassifier> classifierCache) {
    InstantiatedClassifier ic = null;
    if (classifierCache != null) {
        final InstantiatedClassifier temp = classifierCache.get(iobj);
        if (temp != null) {
            return temp == InstantiatedClassifier.NULL ? null : temp;
        }
    }
    if (iobj instanceof SystemInstance) {
        ic = new InstantiatedClassifier(((SystemInstance) iobj).getComponentImplementation(), null);
    }
    if (ic == null) {
        Classifier classifier = null;
        EList<PrototypeBinding> prototypeBindings = null;
        Prototype prototype = null;
        if (iobj instanceof ComponentInstance) {
            Subcomponent sub = ((ComponentInstance) iobj).getSubcomponent();
            classifier = sub.getClassifier();
            prototypeBindings = sub.getOwnedPrototypeBindings();
            prototype = sub.getPrototype();
        } else if (iobj instanceof FeatureInstance) {
            FeatureType ft = ((FeatureGroup) ((FeatureInstance) iobj).getFeature()).getFeatureType();
            classifier = (ft instanceof Classifier) ? (Classifier) ft : null;
            prototype = (ft instanceof Prototype) ? (Prototype) ft : null;
        } else {
            return null;
        }
        if (classifier != null) {
            ic = new InstantiatedClassifier(classifier, prototypeBindings);
        }
        // no classifier => try prototype
        if (ic == null) {
            if (prototype != null) {
                // resolve prototype
                if (prototype instanceof ComponentPrototype) {
                    ComponentPrototypeActual cpa = resolveComponentPrototype(prototype, iobj, classifierCache);
                    if (cpa != null) {
                        ic = new InstantiatedClassifier((ComponentClassifier) cpa.getSubcomponentType(), cpa.getBindings());
                    } else {
                        // ISSUE 986: If the constraining classifier is missing (null), then don't create an InstantiatedClassifier object
                        final ComponentClassifier cc = ((ComponentPrototype) prototype).getConstrainingClassifier();
                        if (cc != null) {
                            ic = new InstantiatedClassifier(cc, noBindings);
                        }
                    }
                } else if (prototype instanceof FeatureGroupPrototype) {
                    FeatureGroupPrototypeActual fpa = resolveFeatureGroupPrototype(prototype, iobj, classifierCache);
                    if (fpa != null) {
                        ic = new InstantiatedClassifier((FeatureGroupType) fpa.getFeatureType(), fpa.getBindings());
                    } else {
                        ic = new InstantiatedClassifier(((FeatureGroupPrototype) prototype).getConstrainingFeatureGroupType(), noBindings);
                    }
                }
            }
        }
    }
    if (classifierCache != null) {
        classifierCache.put(iobj, ic == null ? InstantiatedClassifier.NULL : ic);
    }
    return ic;
}
Also used : FeatureType(org.osate.aadl2.FeatureType) ComponentClassifier(org.osate.aadl2.ComponentClassifier) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) Prototype(org.osate.aadl2.Prototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) FeatureGroupPrototypeActual(org.osate.aadl2.FeatureGroupPrototypeActual) ComponentPrototype(org.osate.aadl2.ComponentPrototype) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) ComponentPrototypeActual(org.osate.aadl2.ComponentPrototypeActual) SystemInstance(org.osate.aadl2.instance.SystemInstance) Subcomponent(org.osate.aadl2.Subcomponent) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) PrototypeBinding(org.osate.aadl2.PrototypeBinding)

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