Search in sources :

Example 11 with InstanceReferenceValue

use of org.osate.aadl2.instance.InstanceReferenceValue in project osate2 by osate.

the class SetInstanceModelBindings method execute.

public void execute() {
    for (Iterator iter = threadsToProc.keySet().iterator(); iter.hasNext(); ) {
        final ComponentInstance thread = (ComponentInstance) iter.next();
        final InstanceReferenceValue val = (InstanceReferenceValue) threadsToProc.get(thread);
        thread.setPropertyValue(GetProperties.getActualProcessorBindingProperty(thread), val);
    }
}
Also used : Iterator(java.util.Iterator) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue)

Example 12 with InstanceReferenceValue

use of org.osate.aadl2.instance.InstanceReferenceValue in project osate2 by osate.

the class SetInstanceModelBindings method redo.

public void redo() {
    // same as execute
    for (Iterator iter = threadsToProc.keySet().iterator(); iter.hasNext(); ) {
        final ComponentInstance thread = (ComponentInstance) iter.next();
        final InstanceReferenceValue val = (InstanceReferenceValue) threadsToProc.get(thread);
        thread.setPropertyValue(GetProperties.getActualProcessorBindingProperty(thread), val);
    }
}
Also used : Iterator(java.util.Iterator) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue)

Example 13 with InstanceReferenceValue

use of org.osate.aadl2.instance.InstanceReferenceValue in project osate2 by osate.

the class PropertyUtils method getComponentInstanceList.

/**
 * TODO: DOC ME !
 *
 * May return null.
 *
 * @param object
 * @param propertyName
 * @return
 */
public static List<ComponentInstance> getComponentInstanceList(NamedElement object, String propertyName) {
    List<ComponentInstance> res = null;
    PropertyAssociation pa = findPropertyAssociation(propertyName, object);
    if (pa != null) {
        res = new ArrayList<ComponentInstance>();
        Property p = pa.getProperty();
        if (p.getName().equals(propertyName)) {
            List<ModalPropertyValue> values = pa.getOwnedValues();
            if (values.size() == 1) {
                ModalPropertyValue v = values.get(0);
                PropertyExpression expr = v.getOwnedValue();
                if (expr instanceof ListValue) {
                    ListValue lv = (ListValue) expr;
                    for (PropertyExpression pe : lv.getOwnedListElements()) {
                        if (pe instanceof InstanceReferenceValue) {
                            InstanceReferenceValue c = ((InstanceReferenceValue) pe);
                            res.add((ComponentInstance) c.getReferencedInstanceObject());
                        }
                    }
                }
            }
        }
    }
    return res;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ListValue(org.osate.aadl2.ListValue) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) PropertyExpression(org.osate.aadl2.PropertyExpression) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property)

Example 14 with InstanceReferenceValue

use of org.osate.aadl2.instance.InstanceReferenceValue in project osate2 by osate.

the class DeploymentProperties method getAllowedMemoryBinding.

public static Optional<List<InstanceObject>> getAllowedMemoryBinding(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getAllowedMemoryBinding_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(((ListValue) resolved).getOwnedListElements().stream().map(element1 -> {
            PropertyExpression resolved1 = CodeGenUtil.resolveNamedValue(element1, lookupContext, mode);
            return ((InstanceReferenceValue) resolved1).getReferencedInstanceObject();
        }).collect(Collectors.toList()));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) ListValue(org.osate.aadl2.ListValue) PropertyExpression(org.osate.aadl2.PropertyExpression) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) Property(org.osate.aadl2.Property)

Example 15 with InstanceReferenceValue

use of org.osate.aadl2.instance.InstanceReferenceValue in project osate2 by osate.

the class DeploymentProperties method getAllowedProcessorBinding.

public static Optional<List<InstanceObject>> getAllowedProcessorBinding(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getAllowedProcessorBinding_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(((ListValue) resolved).getOwnedListElements().stream().map(element1 -> {
            PropertyExpression resolved1 = CodeGenUtil.resolveNamedValue(element1, lookupContext, mode);
            return ((InstanceReferenceValue) resolved1).getReferencedInstanceObject();
        }).collect(Collectors.toList()));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) ListValue(org.osate.aadl2.ListValue) PropertyExpression(org.osate.aadl2.PropertyExpression) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) Property(org.osate.aadl2.Property)

Aggregations

PropertyExpression (org.osate.aadl2.PropertyExpression)38 InstanceReferenceValue (org.osate.aadl2.instance.InstanceReferenceValue)36 Property (org.osate.aadl2.Property)33 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)31 ListValue (org.osate.aadl2.ListValue)18 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)15 BasicProperty (org.osate.aadl2.BasicProperty)11 PropertyLookupException (org.osate.aadl2.properties.PropertyLookupException)11 ArrayList (java.util.ArrayList)7 InstanceObject (org.osate.aadl2.instance.InstanceObject)6 RecordValue (org.osate.aadl2.RecordValue)5 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)4 Classifier (org.osate.aadl2.Classifier)4 ClassifierValue (org.osate.aadl2.ClassifierValue)4 IntegerLiteral (org.osate.aadl2.IntegerLiteral)4 NamedValue (org.osate.aadl2.NamedValue)4 StringLiteral (org.osate.aadl2.StringLiteral)4 Iterator (java.util.Iterator)3 AbstractNamedValue (org.osate.aadl2.AbstractNamedValue)3 BooleanLiteral (org.osate.aadl2.BooleanLiteral)3