Search in sources :

Example 6 with PropertyAcc

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

the class SubcomponentImpl method getPropertyValueInternal.

// TODO-lw: Why don't we return immediately if a pa was found?
public final void getPropertyValueInternal(final Property prop, final PropertyAcc pas, final boolean fromInstanceSlaveCall, final boolean all) throws InvalidModelException {
    final ComponentImplementation owner = (ComponentImplementation) getContainingClassifier();
    // local contained value
    if (!fromInstanceSlaveCall) {
        pas.addLocalContained(this, owner);
    }
    // get local value
    pas.addLocal(this);
    // collect values from refined subcomponents
    Subcomponent refined = getRefined();
    while (refined != null) {
        if (!fromInstanceSlaveCall) {
            pas.addLocalContained(refined, refined.getContainingClassifier());
        }
        pas.addLocal(refined);
        refined = refined.getRefined();
    }
    // get values from classifier
    final ComponentClassifier cc = getClassifier();
    if (cc != null) {
        cc.getPropertyValueInternal(prop, pas, fromInstanceSlaveCall, all);
    }
    // get values from container
    if (!fromInstanceSlaveCall && prop.isInherit()) {
        owner.getPropertyValueInternal(prop, pas, fromInstanceSlaveCall, all);
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Subcomponent(org.osate.aadl2.Subcomponent)

Example 7 with PropertyAcc

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

the class GetProperties method isAssignedPropertyValue.

/**
 * returns true if property is explicitly assigned
 *
 * @param element  NamedELement
 * @param pn Property definition
 * @return
 */
public static boolean isAssignedPropertyValue(NamedElement element, Property pn) {
    try {
        final PropertyAcc propertyAccumulator = element.getPropertyValue(pn);
        PropertyAssociation firstAssociation = propertyAccumulator.first();
        return firstAssociation != null;
    } catch (org.osate.aadl2.properties.PropertyDoesNotApplyToHolderException exception) {
        return false;
    }
}
Also used : PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) PropertyAcc(org.osate.aadl2.properties.PropertyAcc)

Example 8 with PropertyAcc

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

the class GetProperties method getSourceName.

public static String getSourceName(final NamedElement ne) {
    try {
        Property sn = lookupPropertyDefinition(ne, ProgrammingProperties._NAME, ProgrammingProperties.SOURCE_NAME);
        PropertyAcc pacc = ne.getPropertyValue(sn);
        if (pacc.getAssociations().size() > 0) {
            ModalPropertyValue mdv = pacc.getAssociations().get(0).getOwnedValues().get(0);
            PropertyExpression pe = mdv.getOwnedValue();
            // System.out.println("pe=" + pe);
            StringLiteral sl = (StringLiteral) pe;
            return sl.getValue();
        }
        // System.out.println("pacc" + pacc.getAssociations().get(0).getOwnedValues().get(0));
        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)

Example 9 with PropertyAcc

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

the class ConnectionImpl method getPropertyValueInternal.

public final void getPropertyValueInternal(final Property pn, final PropertyAcc pas, final boolean fromInstanceSlaveCall, final boolean all) throws InvalidModelException {
    final ComponentImplementation partOf = (ComponentImplementation) getContainingClassifier();
    // First look in the container's contained property associations
    if (!fromInstanceSlaveCall && pas.addLocalContained(this, partOf)) {
        if (!all) {
            return;
        }
    }
    /*
		 * Next see if the property is defined in connection's properties
		 * subclause (could merge this with the loop below, but I want to make
		 * the steps more explicit.)
		 */
    if (pas.addLocal(this)) {
        if (!all) {
            return;
        }
    }
    // Next find the value by walking up the connection's refinement
    // sequence
    Connection refined = getRefined();
    while (refined != null) {
        if (!fromInstanceSlaveCall && pas.addLocalContained(refined, refined.getContainingClassifier())) {
            if (!all) {
                return;
            }
        }
        if (pas.addLocal(refined)) {
            if (!all) {
                return;
            }
        }
        refined = refined.getRefined();
    }
    /*
		 * if still not set, and the property is "inherit", try the containing
		 * component implementation.
		 */
    if (!fromInstanceSlaveCall && pn.isInherit()) {
        partOf.getPropertyValueInternal(pn, pas, fromInstanceSlaveCall, all);
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) Connection(org.osate.aadl2.Connection)

Example 10 with PropertyAcc

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

the class FeatureImpl method getPropertyValueInternal.

public void getPropertyValueInternal(final Property prop, final PropertyAcc pas, final boolean fromInstanceSlaveCall, final boolean all) throws InvalidModelException {
    Classifier owner = getContainingClassifier();
    if (pas.addLocalContained(this, owner) && !all || pas.addLocal(this)) {
        if (!all) {
            return;
        }
    }
    // values from refined features
    Feature refined = getRefined();
    while (refined != null) {
        if (pas.addLocalContained(refined, refined.getContainingClassifier())) {
            if (!all) {
                return;
            }
        }
        if (pas.addLocal(refined)) {
            if (!all) {
                return;
            }
        }
        refined = refined.getRefined();
    }
    getPropertyValueInternalHelper(prop, pas, fromInstanceSlaveCall, all);
    // feature group TYPE, not an implementation.
    if (prop.isInherit()) {
        owner.getPropertyValueInternal(prop, pas, fromInstanceSlaveCall, all);
    }
}
Also used : FeatureClassifier(org.osate.aadl2.FeatureClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) Feature(org.osate.aadl2.Feature)

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