Search in sources :

Example 26 with PROCESSOR

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

the class NotBoundResourceAnalysis method analyzeResourceBudget.

public void analyzeResourceBudget(final SystemInstance si, final SystemOperationMode som) {
    init();
    @SuppressWarnings("unchecked") EList<ComponentInstance> proclist = (EList<ComponentInstance>) (EList<?>) new ForAllElement().processPreOrderComponentInstance(si, ComponentCategory.PROCESSOR);
    logHeader("\n\nDetailed Processor MIPS Capacity Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
    logHeader("Component,Capacity");
    capacity = sumCapacity(proclist, ResourceKind.MIPS, "processor", ProcessorSpeedUnits.MIPS);
    detailedLogTotal1(null, capacity, ProcessorSpeedUnits.MIPS);
    @SuppressWarnings("unchecked") EList<ComponentInstance> vproclist = (EList<ComponentInstance>) (EList<?>) new ForAllElement().processPreOrderComponentInstance(si, ComponentCategory.VIRTUAL_PROCESSOR);
    if (!vproclist.isEmpty()) {
        logHeader("\n\nDetailed Virtual Processor MIPS Capacity Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
        logHeader("Component,Capacity");
        vcapacity = sumVPMIPSBudget(vproclist);
        detailedLogTotal1(null, vcapacity, ProcessorSpeedUnits.MIPS);
    }
    logHeader("\n\nDetailed MIPS Budget Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
    logHeader("Component,Budget,Actual,Notes");
    budgetTotal = sumBudgets(si, ResourceKind.MIPS, som, "");
    if (budgetTotal >= 0) {
        detailedLogTotal2(null, budgetTotal, ProcessorSpeedUnits.MIPS);
        errManager.infoSummaryReportOnly(si, null, "Resource Summary: " + Aadl2Util.getPrintableSOMName(som));
        report(si, "MIPS", ProcessorSpeedUnits.MIPS, som);
    }
    init();
    @SuppressWarnings("unchecked") EList<ComponentInstance> memlist = (EList<ComponentInstance>) (EList<?>) new ForAllElement().processPreOrderComponentInstance(si, ComponentCategory.MEMORY);
    capacity = capacityTotal(memlist, ResourceKind.Memory, "Memory");
    if (capacity > 0) {
        logHeader("\n\nDetailed Memory Capacity Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
        logHeader("Component,Capacity");
        capacity = sumCapacity(memlist, ResourceKind.Memory, "Memory", SizeUnits.KBYTE);
        detailedLogTotal1(null, capacity, SizeUnits.KBYTE);
        logHeader("\n\nDetailed Memory Budget Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
        logHeader("Component,Budget,Actual,Notes");
        budgetTotal = sumBudgets(si, ResourceKind.Memory, som, "");
        if (budgetTotal >= 0) {
            detailedLogTotal2(null, budgetTotal, SizeUnits.KBYTE);
            report(si, "Memory", SizeUnits.KBYTE, som);
        }
    }
    init();
    capacity = capacityTotal(memlist, ResourceKind.RAM, "RAM");
    if (capacity > 0) {
        logHeader("\n\nDetailed RAM Capacity Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
        logHeader("Component,Capacity");
        capacity = sumCapacity(memlist, ResourceKind.RAM, "RAM", SizeUnits.KBYTE);
        detailedLogTotal1(null, capacity, SizeUnits.KBYTE);
        logHeader("\n\nDetailed RAM Budget Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
        logHeader("Component,Budget,Actual,Notes");
        budgetTotal = sumBudgets(si, ResourceKind.RAM, som, "");
        if (budgetTotal >= 0) {
            detailedLogTotal2(null, budgetTotal, SizeUnits.KBYTE);
            report(si, "RAM", SizeUnits.KBYTE, som);
        }
    }
    init();
    capacity = capacityTotal(memlist, ResourceKind.ROM, "ROM");
    if (capacity > 0) {
        logHeader("\n\nDetailed ROM Capacity Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
        logHeader("Component,Capacity");
        capacity = sumCapacity(memlist, ResourceKind.ROM, "ROM", SizeUnits.KBYTE);
        detailedLogTotal1(null, capacity, SizeUnits.KBYTE);
        logHeader("\n\nDetailed ROM Budget Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
        logHeader("Component,Budget,Actual,Notes");
        budgetTotal = sumBudgets(si, ResourceKind.ROM, som, "");
        if (budgetTotal >= 0) {
            detailedLogTotal2(null, budgetTotal, SizeUnits.KBYTE);
            report(si, "ROM", SizeUnits.KBYTE, som);
        }
    }
}
Also used : EList(org.eclipse.emf.common.util.EList) ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 27 with PROCESSOR

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

the class PriorityInversion method checkPriorityInversion.

/**
 * check for priority inversion of threads bound to the given processor
 * @param curProcessor Component Instance of processor
 */
public void checkPriorityInversion(ComponentInstance curProcessor) {
    SystemInstance root = curProcessor.getSystemInstance();
    final ComponentInstance currentProcessor = curProcessor;
    EList<Element> boundThreads = new ForAllElement() {

        @Override
        protected boolean suchThat(Element obj) {
            if (!InstanceModelUtil.isPeriodicThread((ComponentInstance) obj)) {
                return false;
            }
            List<ComponentInstance> boundProcessor;
            try {
                boundProcessor = GetProperties.getActualProcessorBinding((ComponentInstance) obj);
            } catch (PropertyNotPresentException e) {
                return false;
            }
            return boundProcessor.contains(currentProcessor);
        }
    }.processPreOrderComponentInstance(root, ComponentCategory.THREAD);
    // we will sort the thread list by period and
    // check to make sure the assigned priority is monotonically decreasing
    ECollections.sort(boundThreads, (obj1, obj2) -> {
        final double a = PropertyUtils.getScaled(TimingProperties::getPeriod, (ComponentInstance) obj1, TimeUnits.MS).orElse(0.0);
        final double b = PropertyUtils.getScaled(TimingProperties::getPeriod, (ComponentInstance) obj2, TimeUnits.MS).orElse(0.0);
        if (a > b) {
            return 1;
        }
        if (a == b) {
            return 0;
        }
        return -1;
    });
    checkDecreasingPriority(boundThreads);
}
Also used : ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) SystemInstance(org.osate.aadl2.instance.SystemInstance) Element(org.osate.aadl2.Element) ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) EList(org.eclipse.emf.common.util.EList) List(java.util.List)

Example 28 with PROCESSOR

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

the class ProcessorCheck method perform.

@Override
public void perform(SystemInstance si) {
    /**
     * processor needs to define their schedule
     */
    if (vxworks() || deos()) {
        final List<ComponentInstance> badProcessors = si.getAllComponentInstances().stream().filter(comp -> comp.getCategory() == ComponentCategory.PROCESSOR).filter(cpu -> GetProperties.getModuleSchedule(cpu).size() == 0).collect(Collectors.toList());
        for (ComponentInstance cpu : badProcessors) {
            addError(new ErrorReport(cpu, "Processor must define the property ARINC653::Module_Schedule"));
        }
    }
    /**
     * For vxworks, we need to check that the Source_Name property is
     * defined on each virtual processor.
     */
    if (vxworks()) {
        final List<ComponentInstance> virtualProcessorsWithoutSourceName = si.getAllComponentInstances(ComponentCategory.VIRTUAL_PROCESSOR).stream().filter(comp -> ((comp.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) && (GetProperties.getSourceName(comp) == null))).collect(Collectors.toList());
        for (ComponentInstance vp : virtualProcessorsWithoutSourceName) {
            addError(new ErrorReport(vp, "Virtual Processor must define the property Programming_Properties::Source_Name"));
        }
    }
    /**
     * For vxworks, we need to check that the Source_Name property is
     * defined on each virtual processor.
     */
    if (deos()) {
        final List<ComponentInstance> virtualProcessorsWithoutExecutionTime = si.getAllComponentInstances(ComponentCategory.VIRTUAL_PROCESSOR).stream().filter(comp -> ((comp.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) && (GetProperties.getExecutionTimeInMS(comp) == 0))).collect(Collectors.toList());
        for (ComponentInstance vp : virtualProcessorsWithoutExecutionTime) {
            addError(new ErrorReport(vp, "Virtual processor must define the property Timing_Properties::Execution_Time"));
        }
        final List<ComponentInstance> virtualProcessorsWithoutPeriod = si.getAllComponentInstances(ComponentCategory.VIRTUAL_PROCESSOR).stream().filter(comp -> ((comp.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) && (PropertyUtils.getScaled(TimingProperties::getPeriod, comp, TimeUnits.MS).orElse(0.0) == 0))).collect(Collectors.toList());
        for (ComponentInstance vp : virtualProcessorsWithoutPeriod) {
            addError(new ErrorReport(vp, "Virtual processor must define the property Timing_Properties::Period"));
        }
    }
    if (pok()) {
        OsateDebug.osateDebug("pok case");
        /**
         * For each CPU, we check that every virtual processor contained in
         * the cpu is correctly referenced in the schedule slots
         */
        for (ComponentInstance cpu : si.getComponentInstances().stream().filter(comp -> comp.getCategory() == ComponentCategory.PROCESSOR).collect(Collectors.toList())) {
            final List<ComponentInstance> unreferencedVirtualProcessors = cpu.getComponentInstances().stream().filter(comp -> ((comp.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) && (PokProperties.getSlotsAllocation(cpu).contains(comp) == false))).collect(Collectors.toList());
            for (ComponentInstance vp : unreferencedVirtualProcessors) {
                addError(new ErrorReport(vp, "Virtual processor must be declared in the containing processor's POK::Slots_Allocation property"));
            }
            int slotsAllocationSize = PokProperties.getSlotsAllocation(cpu).size();
            int slotsSize = PokProperties.getTimeSlotInMs(cpu).size();
            if (slotsAllocationSize != slotsSize) {
                addError(new ErrorReport(cpu, "Property POK::Slots_Allocation has " + slotsAllocationSize + " elements, but property POK::Slots has " + slotsSize + "elements"));
            }
        }
    // List<ComponentInstance> badProcessors = (List<ComponentInstance>)
    // si.getAllComponentInstances().stream()
    // .filter( comp -> comp.getCategory() ==
    // ComponentCategory.PROCESSOR).filter( cpu ->
    // GetProperties.getModuleSchedule(cpu).size() ==
    // 0).collect(Collectors.toList());
    // 
    // for (ComponentInstance cpu : badProcessors)
    // {
    // addError (new ErrorReport (cpu, "Need to define the processor
    // schedule"));
    // }
    }
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) SystemInstance(org.osate.aadl2.instance.SystemInstance) List(java.util.List) TimingProperties(org.osate.aadl2.contrib.timing.TimingProperties) ComponentCategory(org.osate.aadl2.ComponentCategory) PropertyUtils(org.osate.pluginsupport.properties.PropertyUtils) TimeUnits(org.osate.aadl2.contrib.aadlproject.TimeUnits) GetProperties(org.osate.xtext.aadl2.properties.util.GetProperties) OsateDebug(org.osate.aadl2.util.OsateDebug) Collectors(java.util.stream.Collectors) ErrorReport(org.osate.codegen.checker.report.ErrorReport) PokProperties(org.osate.codegen.checker.utils.PokProperties) ErrorReport(org.osate.codegen.checker.report.ErrorReport) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 29 with PROCESSOR

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

the class CreateConnectionsSwitch method doModeTransitionConnections.

/**
 * As we are following connection declarations we need to check whether the
 * destination of the connection is named in one of the mode transitions of
 * the component instance that is the destination of the connection being
 * added
 *
 * @param parentci
 *            The component that is the context in which the connections are
 *            declared
 * @param pci
 *            PortConnectionInstance that is being created
 * @param conn
 *            connection being added to the ConnectionInstance
 * @return true if we created a ModetransitionInstance
 */
private boolean doModeTransitionConnections(final ComponentInstance parentci, ConnectionInfo connInfo, Connection conn) {
    boolean didTransition = false;
    if (!(conn instanceof PortConnection || conn instanceof FeatureGroupConnection)) {
        return false;
    }
    ComponentInstance parent = null;
    Context fc = conn.getAllDestinationContext();
    Element connContext = null;
    if (fc instanceof ComponentImplementation || fc instanceof FeatureGroup) {
        // we
        // have
        // an
        // outgoing
        // connection
        parent = (ComponentInstance) parentci.eContainer();
        connContext = parentci.getSubcomponent();
    } else if (fc instanceof Subcomponent) {
        parent = parentci.findSubcomponentInstance((Subcomponent) fc);
        connContext = ((Subcomponent) fc).getAllClassifier();
    }
    if (parent == null) {
        return false;
    }
    EList<ModeTransitionInstance> mtl = parent.getModeTransitionInstances();
    Feature f = (Feature) conn.getAllDestination();
    for (ModeTransitionInstance mti : mtl) {
        ModeTransition mt = mti.getModeTransition();
        Context co = null;
        for (ModeTransitionTrigger trigger : mt.getOwnedTriggers()) {
            TriggerPort tp = trigger.getTriggerPort();
            if (tp instanceof Port) {
                Port o = (Port) tp;
                co = trigger.getContext();
                NamedElement context = co;
                if (context instanceof FeatureGroup) {
                    context = parent.getSubcomponent().getAllClassifier();
                }
                if (f == o && context == connContext) {
                    final ConnectionInstance mtci = addConnectionInstance(parentci.getSystemInstance(), connInfo.convertToModeTransition(), mti);
                    fillInModes(mtci);
                    fillInModeTransitions(mtci);
                    didTransition = true;
                }
            } else {
            // TODO-LW: what if it's a processor port or internal event?
            }
        }
    }
    return didTransition;
}
Also used : Context(org.osate.aadl2.Context) ComponentImplementation(org.osate.aadl2.ComponentImplementation) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) FeatureGroup(org.osate.aadl2.FeatureGroup) Element(org.osate.aadl2.Element) NamedElement(org.osate.aadl2.NamedElement) ConnectedElement(org.osate.aadl2.ConnectedElement) Port(org.osate.aadl2.Port) TriggerPort(org.osate.aadl2.TriggerPort) TriggerPort(org.osate.aadl2.TriggerPort) ModeTransition(org.osate.aadl2.ModeTransition) ModeTransitionInstance(org.osate.aadl2.instance.ModeTransitionInstance) InternalFeature(org.osate.aadl2.InternalFeature) ProcessorFeature(org.osate.aadl2.ProcessorFeature) Feature(org.osate.aadl2.Feature) PortConnection(org.osate.aadl2.PortConnection) FeatureGroupConnection(org.osate.aadl2.FeatureGroupConnection) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) NamedElement(org.osate.aadl2.NamedElement) ModeTransitionTrigger(org.osate.aadl2.ModeTransitionTrigger)

Example 30 with PROCESSOR

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

the class CreateConnectionsSwitch method doModeTransitionConnections.

// ------------------------------------------------------------------------
// Methods related to mode transition connections
// ------------------------------------------------------------------------
/**
 * handles the situation that a mode transition may name an event port in a
 * thread (or other leaf component instance) and that port is not the
 * destination of a connection instance - it is the start of a connection
 * instance
 *
 * @param ci
 *            ComponentInstance
 * @param fi
 *            FeatureInstance
 * @return true if we created a ModetransitionInstance
 */
private boolean doModeTransitionConnections(ComponentInstance ci, FeatureInstance fi) {
    boolean didTransition = false;
    if (fi.getCategory() == FeatureCategory.EVENT_PORT) {
        Subcomponent sub = ci.getSubcomponent();
        Feature f = fi.getFeature();
        for (ModeTransitionInstance mti : ci.getContainingComponentInstance().getModeTransitionInstances()) {
            for (ModeTransitionTrigger trigger : mti.getModeTransition().getOwnedTriggers()) {
                TriggerPort tp = trigger.getTriggerPort();
                if (tp instanceof Port) {
                    Port p = (Port) tp;
                    Context c = trigger.getContext();
                    if (f == p && c == sub) {
                        addConnectionInstance(ci.getSystemInstance(), ConnectionInfo.newModeTransition(fi), mti);
                        didTransition = true;
                    }
                } else {
                // TODO-LW: what if it's a processor port or internal
                // event?
                }
            }
        }
    }
    return didTransition;
}
Also used : Context(org.osate.aadl2.Context) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) Port(org.osate.aadl2.Port) TriggerPort(org.osate.aadl2.TriggerPort) TriggerPort(org.osate.aadl2.TriggerPort) ModeTransitionInstance(org.osate.aadl2.instance.ModeTransitionInstance) InternalFeature(org.osate.aadl2.InternalFeature) ProcessorFeature(org.osate.aadl2.ProcessorFeature) Feature(org.osate.aadl2.Feature) ModeTransitionTrigger(org.osate.aadl2.ModeTransitionTrigger)

Aggregations

ComponentInstance (org.osate.aadl2.instance.ComponentInstance)37 ComponentCategory (org.osate.aadl2.ComponentCategory)12 Property (org.osate.aadl2.Property)12 Element (org.osate.aadl2.Element)11 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)10 Iterator (java.util.Iterator)9 List (java.util.List)9 BasicProperty (org.osate.aadl2.BasicProperty)9 UnitLiteral (org.osate.aadl2.UnitLiteral)9 ForAllElement (org.osate.aadl2.modelsupport.modeltraversal.ForAllElement)9 NamedElement (org.osate.aadl2.NamedElement)8 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)8 InstanceObject (org.osate.aadl2.instance.InstanceObject)8 EList (org.eclipse.emf.common.util.EList)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 EObject (org.eclipse.emf.ecore.EObject)6 SystemInstance (org.osate.aadl2.instance.SystemInstance)6 BasicEList (org.eclipse.emf.common.util.BasicEList)5 ComponentImplementation (org.osate.aadl2.ComponentImplementation)5