Search in sources :

Example 16 with PropertyAcc

use of org.osate.aadl2.properties.PropertyAcc in project VERDICT by ge-high-assurance.

the class Aadl2CsvTranslator method getStrRepofPropVal.

public String getStrRepofPropVal(PropertyAcc propAcc) {
    String value = "";
    if (propAcc != null) {
        List<PropertyAssociation> propAssocs = propAcc.getAssociations();
        if (!propAssocs.isEmpty() && propAssocs.size() == 1) {
            PropertyAssociation propAssoc = propAssocs.get(0);
            // We assume that each property only has only 1 non-list value for now
            if (propAssoc.getOwnedValues().size() == 1) {
                ModalPropertyValue propVal = propAssoc.getOwnedValues().get(0);
                PropertyExpression exp = propVal.getOwnedValue();
                value = getStrRepofExpr(exp)[0];
            } else {
                throw new RuntimeException("Unexpected: property is a list of values with size = : " + propAssoc.getOwnedValues().size());
            }
        } else {
        // throw new RuntimeException("Unexpected property association size: " + propAssocs.size());
        }
    }
    return value;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) PropertyExpression(org.osate.aadl2.PropertyExpression)

Example 17 with PropertyAcc

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

the class FlowLatencyAnalysisSwitch method isAssignedPropertyValue.

private 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) PropertyAcc(org.osate.aadl2.properties.PropertyAcc)

Example 18 with PropertyAcc

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

the class ComponentTypeImpl method getPropertyValueInternal.

public final void getPropertyValueInternal(final Property property, final PropertyAcc paa, final boolean fromInstanceSlaveCall, final boolean all) throws InvalidModelException {
    /*
		 * First see if the property is defined in component's properties
		 * subclause (could merge this with the loop below, but I want to make
		 * the steps more explicit.)
		 */
    if (paa.addLocal(this)) {
        if (!all) {
            return;
        }
    }
    // Next walk the component type hierarchy
    // Avoid loops by stopping if we extend ourself
    final Set<ComponentType> seen = new HashSet<ComponentType>();
    ComponentType currentType = getExtended();
    while (currentType != null && !seen.contains(currentType)) {
        if (paa.addLocal(currentType)) {
            if (!all) {
                return;
            }
        }
        seen.add(currentType);
        currentType = currentType.getExtended();
    }
}
Also used : ComponentType(org.osate.aadl2.ComponentType) HashSet(java.util.HashSet)

Example 19 with PropertyAcc

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

the class ComponentImplementationImpl method getPropertyValueInternal.

public void getPropertyValueInternal(Property property, final PropertyAcc pas, final boolean fromInstanceSlaveCall, final boolean all) throws InvalidModelException {
    // this implementation's properties subclause
    if (pas.addLocal(this)) {
        if (!all) {
            return;
        }
    }
    // extended implementations
    // avoid loops
    final Set<ComponentImplementation> seen = new HashSet<ComponentImplementation>();
    ComponentImplementation currentImpl = getExtended();
    while (currentImpl != null && !seen.contains(currentImpl)) {
        if (pas.addLocal(currentImpl)) {
            if (!all) {
                return;
            }
        }
        seen.add(currentImpl);
        currentImpl = currentImpl.getExtended();
    }
    // the type
    if (getType() != null) {
        getType().getPropertyValueInternal(property, pas, fromInstanceSlaveCall, all);
    } else {
    // XXX we have an unresolved implementation or alias throw new InvalidModelException(this,
    // "Component implementation is missing its component type reference.");
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) HashSet(java.util.HashSet)

Example 20 with PropertyAcc

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

the class FlowSpecificationImpl method getPropertyValueInternal.

// FIXME-LW: instantiation
// /**
// * get in feature of a flow source, sink, or path spec.
// * In case of a refined flowspec get it from the flowspec being refined
// * @return Feature or null
// */
// // XXX: [AADL 1 -> AADL 2] Added to make instantiation work.
// public Feature getAllInFeature() {
// FlowSpecification fs = this;
// while (fs.getInFeature() == null && fs.getRefined() != null)
// fs = fs.getRefined();
// return fs.getInFeature();
// }
// 
// /**
// * get in flow context of a flow source, sink, or path spec.
// * In case of a refined flowspec get it from the flowspec being refined
// * @return Context or null
// */
// // XXX: [AADL 1 -> AADL 2] Added to make instantiation work.
// public Context getAllInContext() {
// FlowSpecification fs = this;
// while (fs.getInContext() == null && fs.getRefined() != null)
// fs = fs.getRefined();
// return fs.getInContext();
// }
// 
// /**
// * get out feature of a flow source, sink, or path spec.
// * In case of a refined flowspec get it from the flowspec being refined
// * @return Feature or null
// */
// // XXX: [AADL 1 -> AADL 2] Added to make instantiation work.
// public Feature getAllOutFeature() {
// FlowSpecification fs = this;
// while (fs.getOutFeature() == null && fs.getRefined() != null)
// fs = fs.getRefined();
// return fs.getOutFeature();
// }
// 
// /**
// * get out flow context of flow source, sink, or path spec.
// * In case of a refined flowspec get it from the flowspec being refined
// * @return Context or null
// */
// // XXX: [AADL 1 -> AADL 2] Added to make instantiation work.
// public Context getAllOutContext() {
// FlowSpecification fs = this;
// while (fs.getOutContext() == null && fs.getRefined() != null)
// fs = fs.getRefined();
// return fs.getOutContext();
// }
public final void getPropertyValueInternal(final Property prop, final PropertyAcc paa, final boolean fromInstanceSlaveCall, final boolean all) throws InvalidModelException {
    final Classifier owner = getContainingClassifier();
    if (!fromInstanceSlaveCall && paa.addLocalContained(this, owner)) {
        if (!all) {
            return;
        }
    }
    if (paa.addLocal(this)) {
        if (!all) {
            return;
        }
    }
    // values from refined flow specifications
    FlowSpecification refined = getRefined();
    while (refined != null) {
        if (!fromInstanceSlaveCall && paa.addLocalContained(refined, refined.getContainingClassifier())) {
            if (!all) {
                return;
            }
        }
        if (paa.addLocal(refined)) {
            if (!all) {
                return;
            }
        }
        refined = refined.getRefined();
    }
    // TYPE, not an implementation.
    if (!fromInstanceSlaveCall && prop.isInherit()) {
        if (owner != null) {
            owner.getPropertyValueInternal(prop, paa, fromInstanceSlaveCall, all);
        } else {
            throw new InvalidModelException(this, "Flow specification is not part of a component");
        }
    }
}
Also used : InvalidModelException(org.osate.aadl2.properties.InvalidModelException) FlowSpecification(org.osate.aadl2.FlowSpecification) Classifier(org.osate.aadl2.Classifier)

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