Search in sources :

Example 11 with ComponentCategory

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

the class FlowLatencyUtil method getModuleSchedule.

public static List<ScheduleWindow> getModuleSchedule(final ComponentInstance partition) {
    if (partition == null) {
        return null;
    } else {
        final ComponentInstance module = getModule(partition);
        if (module == null) {
            return null;
        } else {
            final ComponentCategory moduleCategory = module.getCategory();
            if (moduleCategory == ComponentCategory.PROCESSOR || moduleCategory == ComponentCategory.VIRTUAL_PROCESSOR || moduleCategory == ComponentCategory.ABSTRACT) {
                /* Only keep those windows that have a partition specified */
                final List<ScheduleWindow> windows = Arinc653.getModuleSchedule(module).orElse(Collections.emptyList());
                windows.removeIf(sw -> !sw.getPartition().isPresent());
                return windows;
            } else {
                return Collections.emptyList();
            }
        }
    }
}
Also used : ScheduleWindow(org.osate.contribution.sei.arinc653.ScheduleWindow) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ComponentCategory(org.osate.aadl2.ComponentCategory)

Example 12 with ComponentCategory

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

the class FlowLatencyUtil method getPartitionPeriod.

/**
 * get the partition period, either from the virtual processor representing the partition, or from the major frame of the ARINC653 specification of a processor
 * @return partition period as latency contributor
 */
public static double getPartitionPeriod(final ComponentInstance part) {
    // first look for major frame value on processor
    final ComponentInstance module = getModule(part);
    final ComponentCategory moduleCategory = module != null ? module.getCategory() : null;
    double result = 0.0;
    if (moduleCategory == ComponentCategory.PROCESSOR || moduleCategory == ComponentCategory.VIRTUAL_PROCESSOR || moduleCategory == ComponentCategory.ABSTRACT) {
        result = PropertyUtils.getScaled(Arinc653::getModuleMajorFrame, module, TimeUnits.MS).orElse(0.0);
    }
    if (result == 0.0) {
        // look for period on partition
        result = PropertyUtils.getScaled(TimingProperties::getPeriod, part, TimeUnits.MS).orElse(0.0);
        if (result == 0.0) {
            // look for major frame value on virtual processor (partition)
            result = PropertyUtils.getScaled(Arinc653::getModuleMajorFrame, part, TimeUnits.MS).orElse(0.0);
        }
    }
    return result;
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) Arinc653(org.osate.contribution.sei.arinc653.Arinc653) ComponentCategory(org.osate.aadl2.ComponentCategory) TimingProperties(org.osate.aadl2.contrib.timing.TimingProperties)

Example 13 with ComponentCategory

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

the class Binpack method getAllowedProcessorBindings.

/**
 * Get the processor components that a given thread is allowed to be bound to
 * based on the thread's ALLOWED_PROCESSOR_BINDING and
 * ALLOWED_PROCESSOR_BINDING_CLASS property values. The processors are
 * search for in the same system instance that the given thread component is
 * a part of.
 *
 * @param thread
 *                 The thread.
 * @return An unmodifiable set of processor ComponentInstances.
 * @exception IllegalArgumentException
 *                      Thrown if the category of the component instance
 *                      referenced by <code>thread</code> is not
 *                      {@link ComponentCategory#THREAD_LITERAL}.
 */
public Set<ComponentInstance> getAllowedProcessorBindings(final ComponentInstance thread) {
    if (thread.getCategory() != ComponentCategory.THREAD) {
        throw new IllegalArgumentException("Component \"" + thread.getName() + "\" is not a thread.");
    }
    List<ComponentInstance> allowedBindingsVals;
    try {
        allowedBindingsVals = GetProperties.getAllowedProcessorBinding(thread);
    } catch (PropertyNotPresentException e) {
        // Ignore this situation and move on.
        allowedBindingsVals = Collections.emptyList();
    }
    List<Classifier> allowedClassVals;
    try {
        allowedClassVals = GetProperties.getAllowedProcessorBindingClass(thread);
    } catch (PropertyNotPresentException e) {
        // Ignore this situation and move on.
        allowedClassVals = Collections.emptyList();
    }
    final Set<ComponentInstance> searchRoots = new HashSet<>();
    if (allowedBindingsVals.isEmpty()) {
        searchRoots.add(thread.getSystemInstance());
    } else {
        for (final Iterator<ComponentInstance> i = allowedBindingsVals.iterator(); i.hasNext(); ) {
            final ComponentInstance rv = i.next();
            searchRoots.add(rv);
        }
    }
    final Set<SystemClassifier> allowedSystemClassifiers = new HashSet<>();
    final Set<ProcessorClassifier> allowedProcClassifiers = new HashSet<>();
    for (final Iterator<Classifier> i = allowedClassVals.iterator(); i.hasNext(); ) {
        final Classifier cc = i.next();
        if (cc instanceof ProcessorClassifier) {
            // ComponentCategory.PROCESSOR) {
            allowedProcClassifiers.add((ProcessorClassifier) cc);
        } else if (cc instanceof SystemClassifier) {
            // cv.getValue() == ComponentCategory.SYSTEM_LITERAL) {
            allowedSystemClassifiers.add((SystemClassifier) cc);
        } else {
            internalError("Ill-formed allowed_processor_binding_class value: got a non-system non-processor component classifier");
        }
    }
    final Set<ComponentInstance> allowedProcs = new HashSet<>();
    for (final Iterator<ComponentInstance> i = searchRoots.iterator(); i.hasNext(); ) {
        final ComponentInstance ci = i.next();
        getAllowedProcessorBindings(ci, allowedProcs, allowedProcClassifiers, allowedSystemClassifiers);
    }
    return Collections.unmodifiableSet(allowedProcs);
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) Classifier(org.osate.aadl2.Classifier) SystemClassifier(org.osate.aadl2.SystemClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) SystemClassifier(org.osate.aadl2.SystemClassifier) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) HashSet(java.util.HashSet)

Example 14 with ComponentCategory

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

the class BusLoadModelBuilder method build.

// ==== Methods to build the model ====
public BusLoadModel build() {
    final BusLoadModel model = BusloadFactory.eINSTANCE.createBusLoadModel();
    final ForAllElement mal = new ForAllElement() {

        @Override
        protected void process(final Element obj) {
            final ComponentInstance ci = (ComponentInstance) obj;
            final ComponentCategory cat = ci.getCategory();
            if (cat == ComponentCategory.BUS) {
                addBus(model, ci, som);
            } else if (cat == ComponentCategory.VIRTUAL_BUS) {
                addVirtualBus(model, ci, som);
            }
        }
    };
    mal.processPreOrderComponentInstance(systemInstance);
    return model;
}
Also used : ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) BusLoadModel(org.osate.analysis.resource.budgets.internal.models.busload.BusLoadModel) Element(org.osate.aadl2.Element) ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ComponentCategory(org.osate.aadl2.ComponentCategory)

Example 15 with ComponentCategory

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

the class BusLoadAnalysis method checkBusLoads.

private void checkBusLoads(SystemInstance si, final SystemOperationMode som) {
    errManager.infoSummaryReportOnly(si, null, "\nBus Summary Report: " + Aadl2Util.getPrintableSOMName(som));
    ForAllElement mal = new ForAllElement() {

        @Override
        protected void process(final Element obj) {
            final ComponentInstance ci = (ComponentInstance) obj;
            final ComponentCategory cat = ci.getCategory();
            if (cat == ComponentCategory.BUS) {
                checkBusBandWidthLoad(ci, som);
            } else if (cat == ComponentCategory.VIRTUAL_BUS) {
                checkVirtualBusBandWidthLoad(ci, som);
            }
        }
    };
    mal.processPreOrderComponentInstance(si);
}
Also used : ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) Element(org.osate.aadl2.Element) ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ComponentCategory(org.osate.aadl2.ComponentCategory)

Aggregations

ComponentCategory (org.osate.aadl2.ComponentCategory)30 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)22 Element (org.osate.aadl2.Element)9 ForAllElement (org.osate.aadl2.modelsupport.modeltraversal.ForAllElement)8 SystemInstance (org.osate.aadl2.instance.SystemInstance)7 BasicEList (org.eclipse.emf.common.util.BasicEList)6 NamedElement (org.osate.aadl2.NamedElement)6 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)6 EList (org.eclipse.emf.common.util.EList)5 ComponentClassifier (org.osate.aadl2.ComponentClassifier)5 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)5 EObject (org.eclipse.emf.ecore.EObject)4 Aadl2Package (org.osate.aadl2.Aadl2Package)4 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 EcorePackage (org.eclipse.emf.ecore.EcorePackage)2 Classifier (org.osate.aadl2.Classifier)2 ComponentPrototype (org.osate.aadl2.ComponentPrototype)2