Search in sources :

Example 26 with SystemOperationMode

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

the class NamedElementImpl method getNonModalPropertyValue.

/**
 * Retrieves the property value (single or list) of a non-modal property.  Throws an exception
 * if its a modal value or undefined.
 * @param property Property
 * @return The property expression or null if the property has no value.
 */
public PropertyExpression getNonModalPropertyValue(final Property property) throws InvalidModelException, PropertyNotPresentException, PropertyIsModalException, IllegalStateException, IllegalArgumentException, PropertyDoesNotApplyToHolderException {
    PropertyAssociation pa = getPropertyValue(property, false).first();
    if (pa == null) {
        if (property.getDefaultValue() == null) {
            throw new PropertyNotPresentException(this, property, "No property association was found");
        }
        return property.getDefaultValue();
    } else {
        if (!pa.isModal()) {
            // should always exist because it's not modal
            if (pa.getOwnedValues().isEmpty()) {
                throw new PropertyNotPresentException(this, property, "Property association has no value (yet)");
            }
            return pa.getOwnedValues().get(0).getOwnedValue();
        } else {
            // If we are an InstanceObject, get the value in the current SOM
            if (this instanceof InstanceObject) {
                final SystemInstance si = ((InstanceObject) this).getSystemInstance();
                final SystemOperationMode som = si.getCurrentSystemOperationMode();
                if (som != null) {
                    PropertyExpression defaultPE = null;
                    // find value in SOM
                    for (ModalPropertyValue mpv : pa.getOwnedValues()) {
                        if (mpv.getInModes() == null || mpv.getInModes().size() == 0) {
                            defaultPE = mpv.getOwnedValue();
                        } else if (mpv.getInModes().contains(som)) {
                            return mpv.getOwnedValue();
                        }
                    }
                    // default
                    if (defaultPE != null) {
                        return defaultPE;
                    }
                    // use global default
                    return property.getDefaultValue();
                } else {
                    throw new PropertyIsModalException(this, property, "Cannot use simple property lookup because the instance model has not been projected into a System Operation Mode." + "  This occurred when looking up Property " + property.getName() + " on NamedElement " + getName() + ".");
                }
            } else {
                throw new PropertyIsModalException(this, property, "A non-modal property lookup method was called for a modal property." + "  This occurred when looking up Property " + property.getName() + " on NamedElement " + getName() + ".");
            }
        }
    }
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) PropertyIsModalException(org.osate.aadl2.properties.PropertyIsModalException) ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyAssociation(org.osate.aadl2.PropertyAssociation) SystemInstance(org.osate.aadl2.instance.SystemInstance) PropertyExpression(org.osate.aadl2.PropertyExpression) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode)

Example 27 with SystemOperationMode

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

the class FlowLatencyAnalysisSwitch method invoke.

/**
 * Invoke the analysis on all ETEF owned by the given component instance and return Result collection
 *
 * @param etef The end to end flow instance
 * @param som The mode to run the analysis in. If null then run all SOMs
 * @param asynchronousSystem Whether the system is treated as asynchronous
 * @param majorFrameDelay Whether partition output is performed at a major frame (as opposed to the partition end)
 * @param worstCaseDeadline Use deadline based processing (as opposed to max compute execution time)
 * @param bestCaseEmptyQueue Assume empty queue (instead of full)
 * @param disableQueuingLatency <code>true</code> if queuing latency should always be reported as zero
 * @return A populated report in AnalysisResult format.
 * @since org.osate.analysis.flows 3.0
 */
public AnalysisResult invoke(EndToEndFlowInstance etef, SystemOperationMode som, boolean asynchronousSystem, boolean majorFrameDelay, boolean worstCaseDeadline, boolean bestCaseEmptyQueue, boolean disableQueuingLatency) {
    SystemInstance root = etef.getSystemInstance();
    if (som == null) {
        // we need to run it for every SOM
        for (SystemOperationMode eachsom : root.getSystemOperationModes()) {
            root.setCurrentSystemOperationMode(eachsom);
            invokeOnSOM(etef, eachsom, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
            root.clearCurrentSystemOperationMode();
        }
    } else {
        invokeOnSOM(etef, som, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
    }
    // Issue 1148
    fillInQueuingTimes(etef.getSystemInstance());
    final List<Result> finalizedResults = finalizeResults();
    return FlowLatencyUtil.recordAsAnalysisResult(finalizedResults, etef, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
}
Also used : SystemInstance(org.osate.aadl2.instance.SystemInstance) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) Result(org.osate.result.Result) AnalysisResult(org.osate.result.AnalysisResult)

Example 28 with SystemOperationMode

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

the class FlowLatencyAnalysisSwitch method invoke.

/**
 * Invoke the analysis on all ETEF in system instance and return Result collection
 *
 * @param root The root system instance
 * @param som The mode to run the analysis in. If null then run all SOMs
 * @param asynchronousSystem Whether the system is treated as synchronous by default
 * @param majorFrameDelay Whether partition output is performed at a major frame (as opposed to the partition end)
 * @param worstCaseDeadline Use deadline based processing (as opposed to max compute execution time)
 * @param bestCaseEmptyQueue Assume empty queue (instead of full)
 * @param disableQueuingLatency <code>true</code> if queuing latency should always be reported as zero
 * @return A populated report in AnalysisResult format.
 * @since org.osate.analysis.flows 3.0
 */
// NB. This method is used to invoke the analysis from unit tests
public AnalysisResult invoke(SystemInstance root, SystemOperationMode som, boolean asynchronousSystem, boolean majorFrameDelay, boolean worstCaseDeadline, boolean bestCaseEmptyQueue, boolean disableQueuingLatency) {
    if (som == null) {
        if (root.getSystemOperationModes().isEmpty() || root.getSystemOperationModes().get(0).getCurrentModes().isEmpty()) {
            // no SOM
            invokeOnSOM(root, root.getSystemOperationModes().get(0), asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
        } else {
            // we need to run it for every SOM
            for (SystemOperationMode eachsom : root.getSystemOperationModes()) {
                root.setCurrentSystemOperationMode(eachsom);
                invokeOnSOM(root, eachsom, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
                root.clearCurrentSystemOperationMode();
            }
        }
    } else {
        invokeOnSOM(root, som, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
    }
    // Issue 1148
    final List<Result> finalizedResults = finalizeResults();
    return FlowLatencyUtil.recordAsAnalysisResult(finalizedResults, root, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
}
Also used : SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) Result(org.osate.result.Result) AnalysisResult(org.osate.result.AnalysisResult)

Example 29 with SystemOperationMode

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

the class BoundResourceAnalysis method checkProcessorLoad.

/**
 * check the load from components bound to the given processor The
 * components can be threads or higher level components.
 *
 * @param curProcessor Component Instance of processor
 */
private void checkProcessorLoad(ComponentInstance curProcessor, final SystemOperationMode som) {
    if (!curProcessor.isActive(som)) {
        return;
    }
    double MIPScapacity = getMIPSCapacityInMIPS(curProcessor, 0.0);
    if (MIPScapacity == 0 && InstanceModelUtil.isVirtualProcessor(curProcessor)) {
        MIPScapacity = PropertyUtils.getScaled(Sei::getMipsbudget, curProcessor, ProcessorSpeedUnits.MIPS).orElse(0.0);
    }
    EList<ComponentInstance> boundComponents = InstanceModelUtil.getBoundSWComponents(curProcessor);
    if (boundComponents.size() == 0 && MIPScapacity > 0) {
        errManager.infoSummary(curProcessor, som.getName(), "No application components bound to " + curProcessor.getComponentInstancePath() + " with MIPS capacity " + toStringScaled(MIPScapacity, ProcessorSpeedUnits.MIPS));
        return;
    }
    if (MIPScapacity == 0 && InstanceModelUtil.isVirtualProcessor(curProcessor)) {
        errManager.warningSummary(curProcessor, som.getName(), "Virtual processor " + curProcessor.getComponentInstancePath() + " has no MIPS capacity or budget.");
        return;
    }
    if (MIPScapacity == 0 && InstanceModelUtil.isProcessor(curProcessor)) {
        errManager.errorSummary(curProcessor, som.getName(), "Processor " + curProcessor.getComponentInstancePath() + " has no MIPS capacity but has bound components.");
    }
    if (InstanceModelUtil.isVirtualProcessor(curProcessor)) {
        logHeader("\n\nDetailed Workload Report: " + Aadl2Util.getPrintableSOMName(som) + " for Virtual Processor " + curProcessor.getComponentInstancePath() + " with Capacity " + toStringScaled(MIPScapacity, ProcessorSpeedUnits.MIPS) + "\n\nComponent,Budget,Actual");
    } else {
        logHeader("\n\nDetailed Workload Report: " + Aadl2Util.getPrintableSOMName(som) + " for Processor " + curProcessor.getComponentInstancePath() + " with Capacity " + toStringScaled(MIPScapacity, ProcessorSpeedUnits.MIPS) + "\n\nComponent,Budget,Actual");
    }
    double totalMIPS = 0.0;
    for (Iterator<ComponentInstance> it = boundComponents.iterator(); it.hasNext(); ) {
        ComponentInstance bci = it.next();
        double actualmips = sumBudgets(bci, ResourceKind.MIPS, som, "");
        if (actualmips > 0) {
            totalMIPS += actualmips;
        }
    }
    logHeader("Total,," + toStringScaled(totalMIPS, ProcessorSpeedUnits.MIPS));
    if (totalMIPS > MIPScapacity) {
        errManager.errorSummary(curProcessor, null, "  Processor " + curProcessor.getComponentInstancePath() + ": Total MIPS " + toStringScaled(totalMIPS, ProcessorSpeedUnits.MIPS) + " of bound tasks exceeds MIPS capacity " + toStringScaled(MIPScapacity, ProcessorSpeedUnits.MIPS));
    } else if (totalMIPS == 0.0) {
        errManager.warningSummary(curProcessor, null, "  Processor " + curProcessor.getComponentInstancePath() + ": Bound app's have no MIPS budget.");
    } else {
        errManager.infoSummary(curProcessor, null, "  Processor " + curProcessor.getComponentInstancePath() + ": Total MIPS " + toStringScaled(totalMIPS, ProcessorSpeedUnits.MIPS) + " of bound tasks within " + "MIPS capacity " + toStringScaled(MIPScapacity, ProcessorSpeedUnits.MIPS) + " of " + curProcessor.getComponentInstancePath());
    }
}
Also used : Sei(org.osate.contribution.sei.sei.Sei) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 30 with SystemOperationMode

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

the class BoundResourceAnalysis method analysisBody.

public void analysisBody(final IProgressMonitor monitor, final Element obj) {
    if (obj instanceof InstanceObject) {
        SystemInstance root = ((InstanceObject) obj).getSystemInstance();
        monitor.beginTask(actionName, IProgressMonitor.UNKNOWN);
        final SOMIterator soms = new SOMIterator(root);
        while (soms.hasNext()) {
            final SystemOperationMode som = soms.nextSOM();
            checkProcessorLoads(root, som);
            checkVirtualProcessorLoads(root, som);
            checkMemoryLoads(root, som);
        }
        monitor.done();
    } else {
        Dialog.showError("Bound Resource Analysis Error", "Can only check system instances");
    }
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) SOMIterator(org.osate.aadl2.modelsupport.modeltraversal.SOMIterator) SystemInstance(org.osate.aadl2.instance.SystemInstance) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode)

Aggregations

SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)27 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)21 SystemInstance (org.osate.aadl2.instance.SystemInstance)18 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)12 Classifier (org.osate.aadl2.Classifier)10 Element (org.osate.aadl2.Element)10 InstanceObject (org.osate.aadl2.instance.InstanceObject)9 ForAllElement (org.osate.aadl2.modelsupport.modeltraversal.ForAllElement)9 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)7 ArrayList (java.util.ArrayList)6 AadlPackage (org.osate.aadl2.AadlPackage)6 PropertyAssociation (org.osate.aadl2.PropertyAssociation)6 ModeInstance (org.osate.aadl2.instance.ModeInstance)6 InvalidModelException (org.osate.aadl2.properties.InvalidModelException)6 Optional (java.util.Optional)5 Inject (com.google.inject.Inject)4 HashSet (java.util.HashSet)4 EList (org.eclipse.emf.common.util.EList)4 ComponentClassifier (org.osate.aadl2.ComponentClassifier)4 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)4