Search in sources :

Example 21 with InstanceObject

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

the class GetProperties method getActualProcessorBinding.

// /**
// * this method only picks up the first element, which may not be a bus
// * @param connection Connection Instance
// * @return
// */
// public static ComponentInstance getBoundBus(final ConnectionInstance
// connection) {
// List<ComponentInstance> ret = getActualConnectionBinding(connection);
// ComponentInstance ci = ret.isEmpty() ? null : ret.get(0);
// if (ci != null) {
// return ci;
// }
// return null;
// }
public static List<ComponentInstance> getActualProcessorBinding(final ComponentInstance io) {
    ArrayList<ComponentInstance> components = new ArrayList<ComponentInstance>();
    Property actualProcessorBinding = lookupPropertyDefinition(io, DeploymentProperties._NAME, DeploymentProperties.ACTUAL_PROCESSOR_BINDING);
    List<? extends PropertyExpression> propertyValues;
    try {
        propertyValues = io.getPropertyValueList(actualProcessorBinding);
    } catch (Exception e) {
        return components;
    }
    for (PropertyExpression propertyExpression : propertyValues) {
        if (propertyExpression != null) {
            InstanceObject obj = ((InstanceReferenceValue) propertyExpression).getReferencedInstanceObject();
            components.add((ComponentInstance) obj);
        }
    }
    return components;
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException) PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException)

Example 22 with InstanceObject

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

the class GetProperties method getAllowedMemoryBinding.

public static List<ComponentInstance> getAllowedMemoryBinding(final InstanceObject io) {
    Property allowedMemoryBinding = lookupPropertyDefinition(io, DeploymentProperties._NAME, DeploymentProperties.ALLOWED_MEMORY_BINDING);
    ArrayList<ComponentInstance> components = new ArrayList<>();
    List<? extends PropertyExpression> propertyValues;
    try {
        propertyValues = io.getPropertyValueList(allowedMemoryBinding);
    } catch (Exception e) {
        return components;
    }
    for (PropertyExpression propertyExpression : propertyValues) {
        components.add((ComponentInstance) ((InstanceReferenceValue) propertyExpression).getReferencedInstanceObject());
    }
    return components;
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException) PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException)

Example 23 with InstanceObject

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

the class GetProperties method getActualConnectionBinding.

public static List<ComponentInstance> getActualConnectionBinding(final InstanceObject io) {
    ArrayList<ComponentInstance> components = new ArrayList<ComponentInstance>();
    Property actualConnectionBinding = lookupPropertyDefinition(io, DeploymentProperties._NAME, DeploymentProperties.ACTUAL_CONNECTION_BINDING);
    List<? extends PropertyExpression> propertyValues;
    try {
        propertyValues = io.getPropertyValueList(actualConnectionBinding);
    } catch (Exception e) {
        return components;
    }
    for (PropertyExpression propertyExpression : propertyValues) {
        components.add((ComponentInstance) ((InstanceReferenceValue) propertyExpression).getReferencedInstanceObject());
    }
    return components;
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException) PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException)

Example 24 with InstanceObject

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

the class GetProperties method getOutgoingMessageRatePerSecond.

/*
	 * Look for Message_Rate or SEI::Data_Rate first. Then pick up Output_Rate,
	 * whose default value is 1 per dispatch That rate is converted to persecond
	 * using Period. If Period is zero then the resulting data rate is zero as
	 * well.
	 */
public static double getOutgoingMessageRatePerSecond(final NamedElement ne) {
    double res = GetProperties.getMessageRatePerSecond(ne);
    if (res > 0) {
        return res;
    }
    Property outputRate = lookupPropertyDefinition(ne, CommunicationProperties._NAME, CommunicationProperties.OUTPUT_RATE);
    RecordValue rec = GetProperties.getOutPutRate(ne);
    if (rec != null) {
        res = GetProperties.getMaxDataRate(rec);
        EnumerationLiteral unit = GetProperties.getRateUnit(rec);
        double period = 0;
        if (unit == null || unit.getName().equalsIgnoreCase("PerDispatch")) {
            if (ne instanceof InstanceObject) {
                period = GetProperties.getPeriodInSeconds(((InstanceObject) ne).getContainingComponentInstance(), 0);
            } else {
                period = GetProperties.getPeriodInSeconds(ne.getContainingClassifier(), 0);
            }
            if (period == 0) {
                return 0;
            }
            res = res / period;
        }
        if (res > 0) {
            return res;
        }
    }
    double period = GetProperties.getPeriodInSeconds(ne.getContainingClassifier(), 0);
    if (period == 0) {
        return 0;
    }
    res = 1 / period;
    return res;
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) RecordValue(org.osate.aadl2.RecordValue) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 25 with InstanceObject

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

the class Util method populateBindingPaths.

/**
 * populate direct bindings from the specified component to its resources
 *
 * @param ci
 */
protected static void populateBindingPaths(PropagationGraph pg, InstanceObject obj) {
    if (obj instanceof ComponentInstance) {
        final ComponentInstance ci = (ComponentInstance) obj;
        final ComponentCategory componentCategory = ci.getCategory();
        if (mayHaveActualProcessorBindings.contains(componentCategory)) {
            final List<InstanceObject> cpus = InstanceModelUtil.getProcessorBindings(ci);
            for (final InstanceObject cpu : cpus) {
                populateBindingPropagationPaths(pg, ci, (ComponentInstance) cpu, "processor");
            }
        }
        if (!(ci instanceof VirtualProcessor)) {
            // do memory bindings
            if (mayHaveActualMemoryBindings.contains(componentCategory)) {
                final List<InstanceObject> mems = InstanceModelUtil.getMemoryBindings(ci);
                for (final InstanceObject mem : mems) {
                    populateBindingPropagationPaths(pg, ci, (ComponentInstance) mem, "memory");
                }
            }
        }
        if (ci instanceof VirtualBus) {
            // do connection bindings
            if (mayHaveActualConnectionBindings.contains(componentCategory)) {
                final List<InstanceObject> boundresources = InstanceModelUtil.getConnectionBindings(ci);
                for (final InstanceObject bres : boundresources) {
                    populateBindingPropagationPaths(pg, ci, (ComponentInstance) bres, "connection");
                }
            }
        }
        if (mayHaveActualFunctionBinding.contains(componentCategory)) {
            final List<InstanceObject> systems = InstanceModelUtil.getFunctionBindings(ci);
            for (final InstanceObject system : systems) {
                populateBindingPropagationPaths(pg, ci, (ComponentInstance) system, "binding");
            }
        }
    } else if (obj instanceof ConnectionInstance) {
        // do connection bindings -- nb. all connections are allowed the actual_connection_binding property
        List<? extends InstanceObject> boundresources = InstanceModelUtil.getConnectionBindings(obj);
        if (boundresources.isEmpty()) {
            boundresources = InstanceModelUtil.deriveBoundBuses((ConnectionInstance) obj);
        }
        for (InstanceObject bres : boundresources) {
            populateBindingPropagationPaths(pg, (ConnectionInstance) obj, (ComponentInstance) bres, "connection");
        }
    }
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) VirtualProcessor(org.osate.aadl2.VirtualProcessor) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) VirtualBus(org.osate.aadl2.VirtualBus) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) BasicEList(org.eclipse.emf.common.util.BasicEList) EList(org.eclipse.emf.common.util.EList) List(java.util.List) ComponentCategory(org.osate.aadl2.ComponentCategory)

Aggregations

InstanceObject (org.osate.aadl2.instance.InstanceObject)77 PropertyExpression (org.osate.aadl2.PropertyExpression)38 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)36 Property (org.osate.aadl2.Property)35 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)31 SystemInstance (org.osate.aadl2.instance.SystemInstance)27 InstanceReferenceValue (org.osate.aadl2.instance.InstanceReferenceValue)24 ArrayList (java.util.ArrayList)19 ListValue (org.osate.aadl2.ListValue)17 NamedElement (org.osate.aadl2.NamedElement)17 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)15 Element (org.osate.aadl2.Element)14 Classifier (org.osate.aadl2.Classifier)13 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)12 List (java.util.List)11 EObject (org.eclipse.emf.ecore.EObject)11 Resource (org.eclipse.emf.ecore.resource.Resource)10 ComponentClassifier (org.osate.aadl2.ComponentClassifier)10 SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)10 URI (org.eclipse.emf.common.util.URI)9