Search in sources :

Example 36 with SystemInstance

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

the class NewBusLoadAnalysis method analyzeBody.

private AnalysisResult analyzeBody(final IProgressMonitor monitor, final Element obj) {
    if (obj instanceof InstanceObject) {
        final SystemInstance root = ((InstanceObject) obj).getSystemInstance();
        final AnalysisResult analysisResult = ResultUtil.createAnalysisResult("Bus  Load", root);
        analysisResult.setResultType(ResultType.SUCCESS);
        analysisResult.setMessage("Bus load analysis of " + root.getFullName());
        final SOMIterator soms = new SOMIterator(root);
        while (soms.hasNext()) {
            final SystemOperationMode som = soms.nextSOM();
            final Result somResult = ResultUtil.createResult(Aadl2Util.isPrintableSOMName(som) ? Aadl2Util.getPrintableSOMMembers(som) : "", som, ResultType.SUCCESS);
            analysisResult.getResults().add(somResult);
            final BusLoadModel busLoadModel = BusLoadModelBuilder.buildModel(root, som);
            analyzeBusLoadModel(busLoadModel, somResult, monitor);
        }
        monitor.done();
        return analysisResult;
    } else {
        Dialog.showError("Bound Bus Bandwidth Analysis Error", "Can only check system instances");
        return null;
    }
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) SOMIterator(org.osate.aadl2.modelsupport.modeltraversal.SOMIterator) SystemInstance(org.osate.aadl2.instance.SystemInstance) BusLoadModel(org.osate.analysis.resource.budgets.internal.models.busload.BusLoadModel) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) AnalysisResult(org.osate.result.AnalysisResult) Result(org.osate.result.Result) AnalysisResult(org.osate.result.AnalysisResult)

Example 37 with SystemInstance

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

the class AbstractResourceAnalysis method sumBudgets.

/**
 * calculate the budget of components with budgets, i.e., application
 * components and devices For application components they are required,
 * while for devices they are optional
 *
 * @param ci component instance whose subtree is to be added up
 * @param rk Property Definition of property to be added
 * @param unit Unit in which the property value should be retrieved
 * @param somName String name of SOM (used in reporting)
 * @return double total, zero, if no budget, -1 if hardware only in
 *         substructure
 */
protected double sumBudgets(ComponentInstance ci, ResourceKind rk, final SystemOperationMode som, String prefix) {
    if (!ci.isActive(som)) {
        return 0.0;
    }
    double subtotal = 0.0;
    EList<ComponentInstance> subcis = ci.getComponentInstances();
    boolean HWOnly = false;
    boolean isSystemInstance = ci instanceof SystemInstance;
    int subbudgetcount = 0;
    int subcount = 0;
    if (subcis.size() == 0) {
        if (isHardware(ci)) {
            return -1;
        }
    } else {
        // track HWonly if subcomponents
        HWOnly = true;
    }
    for (Iterator<ComponentInstance> it = subcis.iterator(); it.hasNext(); ) {
        ComponentInstance subci = it.next();
        double subresult = sumBudgets(subci, rk, som, isSystemInstance ? "" : prefix + prefixSymbol);
        if (subresult >= 0) {
            HWOnly = false;
            subtotal += subresult;
            if (subci.getCategory() == ComponentCategory.DEVICE) {
                if (subresult > 0) {
                    // only count device if it has a budget
                    subcount++;
                    subbudgetcount++;
                }
            } else {
                // track how many non-devices and whether they have a budget
                subcount++;
                if (subresult > 0) {
                    subbudgetcount++;
                }
            }
        }
    }
    if (HWOnly) {
        return -1;
    }
    final Enum<?> budgetUnit = rk == ResourceKind.MIPS ? ProcessorSpeedUnits.MIPS : SizeUnits.KBYTE;
    double budget = getBudget(ci, rk);
    if (rk.equals(ResourceKind.RAM) || rk.equals(ResourceKind.ROM) || rk.equals(ResourceKind.Memory)) {
        double actualsize = getMemoryUseActual(ci, rk.name(), SizeUnits.KBYTE);
        subtotal += actualsize;
    }
    String resourceName = ci.getCategory().getName();
    String notes = "";
    if (rk == ResourceKind.MIPS && ci.getCategory() == ComponentCategory.THREAD) {
        subtotal = getThreadExecutioninMIPS(ci);
    }
    components = components + subcount;
    budgetedComponents = budgetedComponents + subbudgetcount;
    if (budget > 0 && subtotal > budget) {
        notes = String.format("Error: subtotal/actual exceeds budget %.3f by %.3f " + budgetUnit.name(), budget, (subtotal - budget));
    } else if (budget > 0 && subtotal < budget) {
        notes = String.format(resourceName + " " + ci.getInstanceObjectPath() + " total %.3f " + budgetUnit.name() + " below budget %.3f " + budgetUnit.name() + " (%.1f %% slack)", subtotal, budget, (budget - subtotal) / budget * 100);
    }
    if (!isSystemInstance) {
        detailedLog(prefix, ci, budget, subtotal, resourceName, budgetUnit, notes);
    }
    return subtotal == 0 ? budget : subtotal;
}
Also used : SystemInstance(org.osate.aadl2.instance.SystemInstance) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 38 with SystemInstance

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

the class BoundResourceAnalysis method checkMemoryLoads.

private void checkMemoryLoads(SystemInstance si, final SystemOperationMode som) {
    count = 0;
    ForAllElement countme = new ForAllElement() {

        @Override
        protected void process(Element obj) {
            if (canHaveMemory(obj)) {
                if (getROMCapacityInKB(obj) > 0.0 || getRAMCapacityInKB(obj) > 0.0 || getMemorySize(obj) > 0.0) {
                    count = count + 1;
                }
            }
        }
    };
    countme.processPreOrderComponentInstance(si);
    if (count > 0) {
        errManager.infoSummaryReportOnly(si, null, "\nMemory Summary Report: " + Aadl2Util.getPrintableSOMName(som));
    } else {
        errManager.infoSummaryReportOnly(si, null, "\nMemory Summary Report: " + Aadl2Util.getPrintableSOMName(som) + "\n  No Memory with Memory_Size or RAMCapacity or ROMCapacity");
    }
    ForAllElement mal = new ForAllElement() {

        @Override
        protected void process(Element obj) {
            if (canHaveMemory(obj)) {
                checkMemoryLoad((ComponentInstance) obj, 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)

Example 39 with SystemInstance

use of org.osate.aadl2.instance.SystemInstance 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 40 with SystemInstance

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

the class CheckPriorityInversion method analyzeInstanceModel.

@Override
protected void analyzeInstanceModel(final IProgressMonitor monitor, final AnalysisErrorReporterManager errManager, final SystemInstance root, final SystemOperationMode som) {
    monitor.beginTask(getActionName(), IProgressMonitor.UNKNOWN);
    try {
        final PriorityInversion pi = new PriorityInversion(errManager);
        pi.checkSystemPriorityInversion(root);
    } catch (InvalidModelException e) {
        error(e.getElement(), e.getMessage());
    }
    monitor.done();
}
Also used : InvalidModelException(org.osate.aadl2.properties.InvalidModelException) PriorityInversion(org.osate.analysis.scheduling.inversion.PriorityInversion)

Aggregations

SystemInstance (org.osate.aadl2.instance.SystemInstance)100 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)52 InstanceObject (org.osate.aadl2.instance.InstanceObject)26 ComponentImplementation (org.osate.aadl2.ComponentImplementation)25 Element (org.osate.aadl2.Element)25 SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)22 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)21 Classifier (org.osate.aadl2.Classifier)18 ForAllElement (org.osate.aadl2.modelsupport.modeltraversal.ForAllElement)18 ComponentCategory (org.osate.aadl2.ComponentCategory)17 NamedElement (org.osate.aadl2.NamedElement)16 List (java.util.List)14 Resource (org.eclipse.emf.ecore.resource.Resource)14 AadlPackage (org.osate.aadl2.AadlPackage)14 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)14 ArrayList (java.util.ArrayList)13 EList (org.eclipse.emf.common.util.EList)13 IOException (java.io.IOException)12 IStatus (org.eclipse.core.runtime.IStatus)12 Optional (java.util.Optional)10