Search in sources :

Example 21 with PropertyAcc

use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.

the class PropertyImpl method getPropertyValue.

private PropertyAcc getPropertyValue(EvaluationContext ctx) throws IllegalStateException, InvalidModelException, PropertyDoesNotApplyToHolderException, IllegalArgumentException {
    // Error if the property is not acceptable
    final PropertyAcc pas = new PropertyAcc(this);
    getPropertyValueInternal(ctx, pas);
    return pas;
}
Also used : PropertyAcc(org.osate.aadl2.properties.PropertyAcc)

Example 22 with PropertyAcc

use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.

the class PropertyImpl method getPropertyValueInternal.

public final void getPropertyValueInternal(EvaluationContext ctx, final PropertyAcc paa) throws InvalidModelException {
    InstanceObject io = ctx.getInstanceObject();
    /*
		 * Only relevant for connection instances
		 */
    if (ctx.getSCProp() != null) {
        if (paa.add(ctx.getSCProp())) {
            return;
        }
    }
    /*
		 * First see if the property is defined locally in the instance. Such
		 * local property associations arise from component property
		 * associations in the declarative spec, from explicit programmatic
		 * setting of the property, or as cached results from earlier property
		 * lookups.
		 */
    if (paa.addLocal(io)) {
        return;
    }
    getPropertyValueFromDeclarativeModel(ctx, paa);
    /*
		 * If the property is "inherit", get it from the enclosing component
		 * instance. Don't short-circuit this step because the property caching
		 * during instantiation doesn't catch contained property values that may
		 * be attached to an ancestor instance and that might be inherited by
		 * this instance.
		 */
    if (isInherit()) {
        io = (InstanceObject) io.eContainer();
        if (io != null) {
            getPropertyValueInternal(new EvaluationContext(io, ctx.getClassifierCache()), paa);
        }
    }
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) EvaluationContext(org.osate.aadl2.properties.EvaluationContext)

Example 23 with PropertyAcc

use of org.osate.aadl2.properties.PropertyAcc 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 24 with PropertyAcc

use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.

the class SubcomponentImpl method getPropertyValue.

public void getPropertyValue(Property prop, PropertyAcc pas, Classifier cl, final boolean all) {
    final ComponentImplementation owner = (ComponentImplementation) getContainingClassifier();
    if (pas.addLocalContained(this, owner)) {
        return;
    }
    // get local value
    if (pas.addLocal(this)) {
        return;
    }
    // collect values from refined subcomponents
    Subcomponent refined = getRefined();
    while (refined != null) {
        if (pas.addLocal(refined)) {
            return;
        }
        refined = refined.getRefined();
    }
    // get values from classifier
    if (cl != null) {
        cl.getPropertyValueInternal(prop, pas, true, all);
    } else {
        final ComponentClassifier cc = getClassifier();
        if (cc != null) {
            cc.getPropertyValueInternal(prop, pas, true, all);
        }
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Subcomponent(org.osate.aadl2.Subcomponent)

Example 25 with PropertyAcc

use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.

the class GetProperties method getPlatform.

public static String getPlatform(final NamedElement ne) {
    try {
        Property sn = lookupPropertyDefinition(ne, SEI._NAME, SEI.PLATFORM);
        PropertyAcc pacc = ne.getPropertyValue(sn);
        if (pacc.getAssociations().size() > 0) {
            ModalPropertyValue mdv = pacc.getAssociations().get(0).getOwnedValues().get(0);
            PropertyExpression pe = mdv.getOwnedValue();
            StringLiteral sl = (StringLiteral) pe;
            return sl.getValue();
        }
        return null;
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) StringLiteral(org.osate.aadl2.StringLiteral) PropertyAcc(org.osate.aadl2.properties.PropertyAcc) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Aggregations

PropertyAcc (org.osate.aadl2.properties.PropertyAcc)11 ComponentImplementation (org.osate.aadl2.ComponentImplementation)8 Property (org.osate.aadl2.Property)7 PropertyAssociation (org.osate.aadl2.PropertyAssociation)7 PropertyExpression (org.osate.aadl2.PropertyExpression)7 Classifier (org.osate.aadl2.Classifier)5 ComponentClassifier (org.osate.aadl2.ComponentClassifier)5 Subcomponent (org.osate.aadl2.Subcomponent)5 Connection (org.osate.aadl2.Connection)3 DataSubcomponent (org.osate.aadl2.DataSubcomponent)3 Feature (org.osate.aadl2.Feature)3 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)3 InstanceObject (org.osate.aadl2.instance.InstanceObject)3 InvalidModelException (org.osate.aadl2.properties.InvalidModelException)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 AbstractSubcomponent (org.osate.aadl2.AbstractSubcomponent)2 AccessType (org.osate.aadl2.AccessType)2 BasicProperty (org.osate.aadl2.BasicProperty)2 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)2