Search in sources :

Example 96 with Subcomponent

use of org.osate.aadl2.Subcomponent in project osate2 by osate.

the class CheckBindingConstraints method runAnalysis.

public static List<Issue> runAnalysis(IProgressMonitor monitor, SystemInstance si) {
    List<Issue> issuesList = new ArrayList<>();
    SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
    System.out.println(si.getSystemOperationModes().size());
    SubMonitor loopMonitor = subMonitor.split(100).setWorkRemaining(si.getSystemOperationModes().size());
    for (SOMIterator somIter = new SOMIterator(si); somIter.hasNext(); ) {
        SystemOperationMode som = somIter.next();
        SubMonitor iterationMonitor = loopMonitor.split(1);
        iterationMonitor.setWorkRemaining(8);
        // Processor binding
        SubMonitor processorChild = iterationMonitor.split(2);
        subMonitor.setTaskName("Getting Processor Binding Components");
        processorChild.split(1);
        List<ComponentInstance> processorBindingComponents = getComponents(monitor, si, ComponentCategory.THREAD, ComponentCategory.VIRTUAL_PROCESSOR, ComponentCategory.DEVICE).collect(Collectors.toList());
        processorChild.setTaskName("Checking Processor Bindings");
        processorChild.split(1);
        issuesList.addAll(checkBindingConstraints(processorBindingComponents.stream(), "processor", GetProperties::getActualProcessorBinding, GetProperties::getAllowedProcessorBinding, GetProperties::getAllowedProcessorBindingClass, som));
        // Dispatch Protocol
        subMonitor.setTaskName("Checking Dispacth Protocols");
        SubMonitor dispatchChild = iterationMonitor.split(1);
        issuesList.addAll(checkDispatchProtocol(processorBindingComponents.stream(), som));
        // Memory binding
        subMonitor.setTaskName("Getting Memory Components");
        SubMonitor memrChild = iterationMonitor.split(2);
        memrChild.split(1);
        Stream<ComponentInstance> memoryBindingComponents = getComponents(monitor, si, ComponentCategory.THREAD, ComponentCategory.DEVICE, ComponentCategory.DATA, ComponentCategory.SUBPROGRAM, ComponentCategory.PROCESSOR, ComponentCategory.VIRTUAL_PROCESSOR);
        subMonitor.setTaskName("Checking Memory Bindings");
        memrChild.split(1);
        Stream<FeatureInstance> memoryBindingFeatures = getFeatures(monitor, si, FeatureCategory.DATA_PORT, FeatureCategory.EVENT_DATA_PORT);
        Stream<InstanceObject> memoryBindingElements = Stream.concat(memoryBindingComponents, memoryBindingFeatures);
        issuesList.addAll(checkBindingConstraints(memoryBindingElements, "memory", GetProperties::getActualMemoryBinding, GetProperties::getAllowedMemoryBinding, GetProperties::getAllowedMemoryBindingClass, som));
        // Connection binding (only handles connection and virtual bus)
        subMonitor.setTaskName("Checking Connection Bindings");
        SubMonitor conenctionChild = iterationMonitor.split(1);
        Stream<ComponentInstance> connectionBindingComponents = getComponents(monitor, si, ComponentCategory.VIRTUAL_BUS);
        Stream<ConnectionInstance> connectionBindingConnections = getConnections(monitor, si);
        List<InstanceObject> connectionBindingElements = Stream.concat(connectionBindingComponents, connectionBindingConnections).collect(Collectors.toList());
        issuesList.addAll(checkBindingConstraints(connectionBindingElements.stream(), "connection", GetProperties::getActualConnectionBinding, GetProperties::getAllowedConnectionBinding, GetProperties::getAllowedConnectionBindingClass, som));
        // Connection Quality of Service
        subMonitor.setTaskName("Checking Connection Quality of Services");
        SubMonitor qualityChild = iterationMonitor.split(1);
        issuesList.addAll(checkRequiredAndProvided(connectionBindingElements.stream(), GetProperties::getRequiredConnectionQualityOfService, "Required_Connection_Quality_Of_Service", GetProperties::getProvidedConnectionQualityOfService, qos -> qos.getName(), som));
        // Virtual Bus Class
        subMonitor.setTaskName("Checking Virtual Bus Bindings");
        SubMonitor busChild = iterationMonitor.split(1);
        Function<ComponentInstance, Collection<ComponentClassifier>> getProvidedVBClass = boundElement -> {
            Stream<ComponentClassifier> providedProperty = GetProperties.getProvidedVirtualBusClass(boundElement).stream();
            Stream<ComponentClassifier> providedBySubcomponent = boundElement.getComponentInstances().stream().map(subcomponent -> subcomponent.getClassifier());
            return Stream.concat(providedProperty, providedBySubcomponent).collect(Collectors.toSet());
        };
        issuesList.addAll(checkRequiredAndProvided(connectionBindingElements.stream(), GetProperties::getRequiredVirtualBusClass, "Required_Virtual_Bus_Class", getProvidedVBClass, vbClass -> vbClass.getName(), som));
        busChild.setWorkRemaining(0);
    }
    subMonitor.setWorkRemaining(0);
    return issuesList;
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) Arrays(java.util.Arrays) Element(org.osate.aadl2.Element) Spliterators(java.util.Spliterators) SubMonitor(org.eclipse.core.runtime.SubMonitor) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) DeploymentProperties(org.osate.aadl2.contrib.deployment.DeploymentProperties) StreamSupport(java.util.stream.StreamSupport) GetProperties(org.osate.xtext.aadl2.properties.util.GetProperties) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) EnumSet(java.util.EnumSet) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) FeatureCategory(org.osate.aadl2.instance.FeatureCategory) SystemInstance(org.osate.aadl2.instance.SystemInstance) SOMIterator(org.osate.aadl2.modelsupport.modeltraversal.SOMIterator) AadlUtil(org.osate.aadl2.modelsupport.util.AadlUtil) Iterator(java.util.Iterator) Aadl2Util(org.osate.aadl2.util.Aadl2Util) Collection(java.util.Collection) Set(java.util.Set) EObject(org.eclipse.emf.ecore.EObject) Collectors(java.util.stream.Collectors) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Consumer(java.util.function.Consumer) List(java.util.List) Stream(java.util.stream.Stream) ComponentCategory(org.osate.aadl2.ComponentCategory) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) Optional(java.util.Optional) AaxlReadOnlyHandlerAsJob(org.osate.ui.handlers.AaxlReadOnlyHandlerAsJob) StringExtensions(org.eclipse.xtext.xbase.lib.StringExtensions) NamedElement(org.osate.aadl2.NamedElement) Collections(java.util.Collections) Spliterator(java.util.Spliterator) Dialog(org.osate.ui.dialogs.Dialog) InstanceObject(org.osate.aadl2.instance.InstanceObject) SOMIterator(org.osate.aadl2.modelsupport.modeltraversal.SOMIterator) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ArrayList(java.util.ArrayList) SubMonitor(org.eclipse.core.runtime.SubMonitor) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) InstanceObject(org.osate.aadl2.instance.InstanceObject) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) Collection(java.util.Collection) Stream(java.util.stream.Stream)

Example 97 with Subcomponent

use of org.osate.aadl2.Subcomponent in project osate2 by osate.

the class PropertyUtils method getSubcomponentList.

/**
 * May return an empty list.
 *
 * @param object
 * @param propertyName
 * @return
 */
public static List<Subcomponent> getSubcomponentList(ProcessorSubcomponent object, String propertyName) {
    List<Subcomponent> res = new ArrayList<Subcomponent>();
    PropertyAssociation pa = findPropertyAssociation(propertyName, object);
    if (pa != null) {
        Property p = pa.getProperty();
        if (p.getName().equalsIgnoreCase(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 ReferenceValue) {
                            ReferenceValue c = ((ReferenceValue) pe);
                            ContainmentPathElement cpe = c.getContainmentPathElements().get(c.getContainmentPathElements().size() - 1);
                            res.add((Subcomponent) cpe.getNamedElement());
                        }
                    }
                }
            }
        }
    }
    // try on a refined NamedElement
    if (object instanceof RefinableElement) {
        RefinableElement re = object;
        if (re.getRefinedElement() != null) {
            List<Subcomponent> l = getSubcomponentList((ProcessorSubcomponent) re.getRefinedElement(), propertyName);
            if (!l.isEmpty()) {
                res.addAll(l);
            }
        }
    }
    return res;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) ReferenceValue(org.osate.aadl2.ReferenceValue) ProcessorSubcomponent(org.osate.aadl2.ProcessorSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ListValue(org.osate.aadl2.ListValue) ArrayList(java.util.ArrayList) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) PropertyExpression(org.osate.aadl2.PropertyExpression) RefinableElement(org.osate.aadl2.RefinableElement) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property)

Example 98 with Subcomponent

use of org.osate.aadl2.Subcomponent in project osate2 by osate.

the class AadlContribUtils method getDataSize.

private static double getDataSize(final NamedElement ne, final SizeUnits unit, final int nesting) {
    final double elementSize = PropertyUtils.getScaled(MemoryProperties::getDataSize, ne, unit).orElseGet(() -> {
        final ComponentCategory cc = ne instanceof ComponentClassifier ? ((ComponentClassifier) ne).getCategory() : (ne instanceof ComponentInstance ? ((ComponentInstance) ne).getCategory() : null);
        if (cc != ComponentCategory.BUS && cc != ComponentCategory.VIRTUAL_BUS) {
            return PropertyUtils.getScaled(MemoryProperties::getSourceDataSize, ne, unit).orElse(0.0);
        } else {
            return 0.0;
        }
    });
    final long multiplier = ne instanceof DataSubcomponent ? AadlUtil.getMultiplicity(ne) : 1;
    if (elementSize != 0.0) {
        return elementSize * multiplier;
    } else {
        if ((nesting <= 10) && (ne instanceof DataSubcomponent || ne instanceof DataImplementation)) {
            // mult is one or the array size of the data subcomponent.
            return sumElementsDataSize(ne, unit, nesting + 1) * multiplier;
        } else {
            return 0.0;
        }
    }
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) DataSubcomponent(org.osate.aadl2.DataSubcomponent) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) DataImplementation(org.osate.aadl2.DataImplementation) ComponentCategory(org.osate.aadl2.ComponentCategory)

Example 99 with Subcomponent

use of org.osate.aadl2.Subcomponent in project osate2 by osate.

the class AadlContribUtils method sumElementsDataSize.

private static double sumElementsDataSize(final NamedElement ne, final SizeUnits unit, final int nesting) {
    double res = 0.0;
    Classifier cl = null;
    if (ne instanceof Classifier) {
        cl = (Classifier) ne;
    } else if (ne instanceof FeatureInstance) {
        cl = ((FeatureInstance) ne).getFeature().getAllClassifier();
    } else if (ne instanceof Feature) {
        cl = ((Feature) ne).getClassifier();
    } else if (ne instanceof DataSubcomponent) {
        cl = ((DataSubcomponent) ne).getClassifier();
    }
    if (cl != null) {
        if (cl instanceof FeatureGroupType) {
            EList<Feature> fl = ((FeatureGroupType) cl).getAllFeatures();
            for (Feature f : fl) {
                res = res + getDataSize(f, unit, nesting);
            }
        } else if (cl instanceof DataImplementation) {
            for (Subcomponent ds : ((DataImplementation) cl).getAllSubcomponents()) {
                if (!AadlUtil.isSameOrExtends(cl, ds.getAllClassifier())) {
                    res = res + getDataSize(ds, unit, nesting);
                }
            }
        }
    }
    return res;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) DataSubcomponent(org.osate.aadl2.DataSubcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) FeatureGroupType(org.osate.aadl2.FeatureGroupType) DataImplementation(org.osate.aadl2.DataImplementation) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) Feature(org.osate.aadl2.Feature)

Example 100 with Subcomponent

use of org.osate.aadl2.Subcomponent in project osate2 by osate.

the class AadlUtil method getIngoingConnections.

/**
 * Get ingoing connections to subcomponents from a specified feature of the
 * component impl
 *
 * @param feature component impl feature that is the source of a connection
 * @param context the outer feature (feature group) or null
 * @param useConnection Predicate that indicates if the connection should be added to the result.  Each ingoing
 * connection is tested before being added to the result.  This predicate should return <code>true</code> if the
 * connection should be added to the result.
 * @return EList connections with feature as source
 * @since 2.0
 */
public static EList<Connection> getIngoingConnections(ComponentImplementation cimpl, Feature feature, Predicate<Connection> useConnection) {
    EList<Connection> result = new BasicEList<Connection>();
    // The local feature could be a refinement of the feature through which the connection enters the component
    Feature local = (Feature) cimpl.findNamedElement(feature.getName());
    List<Feature> features = local.getAllFeatureRefinements();
    EList<Connection> cimplconns = cimpl.getAllConnections();
    for (Connection conn : cimplconns) {
        if (features.contains(conn.getAllSource()) && !(conn.getAllSourceContext() instanceof Subcomponent) || (conn.isAllBidirectional() && features.contains(conn.getAllDestination()) && !(conn.getAllDestinationContext() instanceof Subcomponent))) {
            if (useConnection.test(conn)) {
                result.add(conn);
            }
        }
        if ((features.contains(conn.getAllSourceContext()) || (conn.isAllBidirectional() && features.contains(conn.getAllDestinationContext())))) {
            if (useConnection.test(conn)) {
                result.add(conn);
            }
        }
    }
    return result;
}
Also used : BasicEList(org.eclipse.emf.common.util.BasicEList) ThreadSubcomponent(org.osate.aadl2.ThreadSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ThreadGroupSubcomponent(org.osate.aadl2.ThreadGroupSubcomponent) DeviceSubcomponent(org.osate.aadl2.DeviceSubcomponent) ProcessSubcomponent(org.osate.aadl2.ProcessSubcomponent) SystemSubcomponent(org.osate.aadl2.SystemSubcomponent) AbstractSubcomponent(org.osate.aadl2.AbstractSubcomponent) ProcessorSubcomponent(org.osate.aadl2.ProcessorSubcomponent) FeatureGroupConnection(org.osate.aadl2.FeatureGroupConnection) Connection(org.osate.aadl2.Connection) Feature(org.osate.aadl2.Feature) AbstractFeature(org.osate.aadl2.AbstractFeature)

Aggregations

Subcomponent (org.osate.aadl2.Subcomponent)118 ComponentClassifier (org.osate.aadl2.ComponentClassifier)53 Classifier (org.osate.aadl2.Classifier)46 ComponentImplementation (org.osate.aadl2.ComponentImplementation)40 NamedElement (org.osate.aadl2.NamedElement)40 Feature (org.osate.aadl2.Feature)37 DataSubcomponent (org.osate.aadl2.DataSubcomponent)33 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)33 ArrayList (java.util.ArrayList)31 EObject (org.eclipse.emf.ecore.EObject)25 Connection (org.osate.aadl2.Connection)24 FeatureGroup (org.osate.aadl2.FeatureGroup)21 SubprogramSubcomponent (org.osate.aadl2.SubprogramSubcomponent)21 Property (org.osate.aadl2.Property)20 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)19 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)17 FeatureGroupType (org.osate.aadl2.FeatureGroupType)17 Element (org.osate.aadl2.Element)16 List (java.util.List)15 AadlPackage (org.osate.aadl2.AadlPackage)15