Search in sources :

Example 1 with AnalysisResult

use of org.osate.result.AnalysisResult 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 ci The component instance that owns the end to end flow instances
 * @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(ComponentInstance ci, SystemOperationMode som, boolean asynchronousSystem, boolean majorFrameDelay, boolean worstCaseDeadline, boolean bestCaseEmptyQueue, boolean disableQueuingLatency) {
    SystemInstance root = ci.getSystemInstance();
    if (som == null) {
        if (root.getSystemOperationModes().isEmpty() || root.getSystemOperationModes().get(0).getCurrentModes().isEmpty()) {
            // no SOM
            invokeOnSOM(ci, 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(ci, eachsom, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
                root.clearCurrentSystemOperationMode();
            }
        }
    } else {
        invokeOnSOM(ci, som, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
    }
    // Issue 1148
    fillInQueuingTimes(ci.getSystemInstance());
    final List<Result> finalizedResults = report.finalizeAllEntries();
    return FlowLatencyUtil.recordAsAnalysisResult(finalizedResults, ci, 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 2 with AnalysisResult

use of org.osate.result.AnalysisResult in project osate2 by osate.

the class FlowLatencyUtil method recordAsAnalysisResult.

/**
 * @since org.osate.analysis.flows 3.0
 */
public static AnalysisResult recordAsAnalysisResult(Collection<Result> results, EObject root, boolean asynchronousSystem, boolean majorFrameDelay, boolean worstCaseDeadline, boolean bestCaseEmptyQueue, boolean disableQueuingLatency) {
    AnalysisResult latencyResults = createLatencyAnalysisResult(root, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
    if (!results.isEmpty()) {
        latencyResults.getResults().addAll(results);
    } else {
        Result err = ResultUtil.createErrorResult("No latency analysis result", root);
        latencyResults.getResults().add(err);
    }
    return latencyResults;
}
Also used : AnalysisResult(org.osate.result.AnalysisResult) Result(org.osate.result.Result) AnalysisResult(org.osate.result.AnalysisResult)

Example 3 with AnalysisResult

use of org.osate.result.AnalysisResult in project osate2 by osate.

the class LatencyCSVReport method getReportContent.

private static StringBuffer getReportContent(AnalysisResult ar) {
    StringBuffer report = new StringBuffer();
    String reportheader = "Latency analysis with preference settings: " + FlowLatencyUtil.getParametersAsDescriptions(ar);
    report.append(reportheader + System.lineSeparator() + System.lineSeparator());
    for (Result result : ar.getResults()) {
        String flowname = ((InstanceObject) result.getModelElement()).getComponentInstancePath();
        SystemInstance si = ((InstanceObject) result.getModelElement()).getSystemInstance();
        String systemName = si.getComponentClassifier().getName();
        String inMode = ResultUtil.getString(result, 0);
        String analysisheader = "\"Latency results for end-to-end flow '" + flowname + "' of system '" + systemName + "' " + inMode + "\"";
        report.append(analysisheader + System.lineSeparator() + System.lineSeparator());
        report.append("Result,Min Specified,Min Actual,Min Method,Max Specified,Max Actual,Max Method,Comments" + System.lineSeparator());
        for (Result contributor : result.getSubResults()) {
            for (Result subc : contributor.getSubResults()) {
                addContributor(report, subc, true);
            }
            addContributor(report, contributor, false);
        }
        report.append("Latency Total," + ResultUtil.getReal(result, 3) + "ms," + ResultUtil.getReal(result, 1) + "ms,," + ResultUtil.getReal(result, 4) + "ms," + ResultUtil.getReal(result, 2) + "ms" + System.lineSeparator());
        report.append("Specified End To End Latency,," + ResultUtil.getReal(result, 5) + "ms,,," + ResultUtil.getReal(result, 6) + "ms" + System.lineSeparator());
        report.append("End to end Latency Summary" + System.lineSeparator());
        for (Diagnostic dia : result.getDiagnostics()) {
            report.append(dia.getDiagnosticType() + "," + dia.getMessage() + System.lineSeparator());
        }
        report.append(System.lineSeparator() + System.lineSeparator() + System.lineSeparator());
    }
    return report;
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) SystemInstance(org.osate.aadl2.instance.SystemInstance) Diagnostic(org.osate.result.Diagnostic) Result(org.osate.result.Result) AnalysisResult(org.osate.result.AnalysisResult)

Example 4 with AnalysisResult

use of org.osate.result.AnalysisResult in project osate2 by osate.

the class LatencyExcelReport method generateExcelReport.

public static void generateExcelReport(AnalysisResult latres) {
    IFile file = getExcelFile(latres);
    try {
        if (file.exists()) {
            file.delete(true, null);
        }
        if (!latres.getResults().isEmpty()) {
            AadlUtil.makeSureFoldersExist(file.getFullPath());
            String reportHeader = "Latency analysis with preference settings: " + FlowLatencyUtil.getParametersAsDescriptions(latres);
            WorkbookSettings wbSettings = new WorkbookSettings();
            wbSettings.setLocale(new Locale("en", "EN"));
            wbSettings.setCellValidationDisabled(false);
            wbSettings.setRationalization(false);
            WritableWorkbook workbook = Workbook.createWorkbook(file.getLocation().toFile(), wbSettings);
            int sheetNumber = 0, i = 1;
            for (Result result : latres.getResults()) {
                InstanceObject instanceObject = (InstanceObject) result.getModelElement();
                String flowName = instanceObject.getComponentInstancePath();
                String systemName = instanceObject.getSystemInstance().getComponentClassifier().getName();
                String inMode = ResultUtil.getString(result, 0);
                String sheetName;
                if (inMode.isEmpty()) {
                    sheetName = flowName;
                } else {
                    sheetName = flowName + " in mode " + inMode;
                }
                // adjust the name to keep worksheet name unique
                if (sheetName != null && sheetName.length() > 31) {
                    String s = String.valueOf(i++);
                    sheetName = sheetName.substring(0, 31 - s.length()) + s;
                }
                WritableSheet sheet = workbook.createSheet(sheetName, sheetNumber);
                sheet.addCell(new Label(0, 0, reportHeader, BOLD_FORMAT));
                sheet.addCell(new Label(0, 2, "Latency results for end-to-end flow '" + flowName + "' of system '" + systemName + "'" + inMode, BOLD_FORMAT));
                sheet.addCell(new Label(0, 4, "Result", BOLD_FORMAT));
                sheet.addCell(new Label(1, 4, "Min Specified", BOLD_FORMAT));
                sheet.addCell(new Label(2, 4, "Min Actual", BOLD_FORMAT));
                sheet.addCell(new Label(3, 4, "Min Method", BOLD_FORMAT));
                sheet.addCell(new Label(4, 4, "Max Specified", BOLD_FORMAT));
                sheet.addCell(new Label(5, 4, "Max Actual", BOLD_FORMAT));
                sheet.addCell(new Label(6, 4, "Max Method", BOLD_FORMAT));
                sheet.addCell(new Label(7, 4, "Comments", BOLD_FORMAT));
                int row = 5;
                for (Result contributor : result.getSubResults()) {
                    for (Result subc : contributor.getSubResults()) {
                        addContributor(sheet, row, subc, true);
                        row++;
                    }
                    addContributor(sheet, row, contributor, false);
                    row++;
                }
                sheet.addCell(new Label(0, row, "Latency Total"));
                sheet.addCell(new Label(1, row, ResultUtil.getReal(result, 3) + "ms"));
                sheet.addCell(new Label(2, row, ResultUtil.getReal(result, 1) + "ms"));
                sheet.addCell(new Label(4, row, ResultUtil.getReal(result, 4) + "ms"));
                sheet.addCell(new Label(5, row, ResultUtil.getReal(result, 2) + "ms"));
                row++;
                sheet.addCell(new Label(0, row, "Specified End To End Latency"));
                sheet.addCell(new Label(2, row, ResultUtil.getReal(result, 5) + "ms"));
                sheet.addCell(new Label(5, row, ResultUtil.getReal(result, 6) + "ms"));
                row++;
                sheet.addCell(new Label(0, row, "End To End Latency Summary", BOLD_FORMAT));
                row++;
                for (Diagnostic dia : result.getDiagnostics()) {
                    sheet.addCell(new Label(0, row, dia.getDiagnosticType().toString(), getCellFormat(dia)));
                    sheet.addCell(new Label(1, row, dia.getMessage()));
                    row++;
                }
                sheetNumber++;
            }
            workbook.write();
            workbook.close();
            file.refreshLocal(IResource.DEPTH_INFINITE, null);
        }
    } catch (CoreException e) {
        StatusManager.getManager().handle(e, FlowanalysisPlugin.getDefault().getBundle().getSymbolicName());
    } catch (IOException | WriteException e) {
        String pluginId = FlowanalysisPlugin.getDefault().getBundle().getSymbolicName();
        IStatus status = new Status(IStatus.ERROR, pluginId, e.getMessage(), e);
        StatusManager.getManager().handle(status);
    }
}
Also used : Locale(java.util.Locale) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) WriteException(jxl.write.WriteException) IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) Label(jxl.write.Label) Diagnostic(org.osate.result.Diagnostic) WorkbookSettings(jxl.WorkbookSettings) WritableSheet(jxl.write.WritableSheet) IOException(java.io.IOException) Result(org.osate.result.Result) AnalysisResult(org.osate.result.AnalysisResult) WritableWorkbook(jxl.write.WritableWorkbook) InstanceObject(org.osate.aadl2.instance.InstanceObject) CoreException(org.eclipse.core.runtime.CoreException)

Example 5 with AnalysisResult

use of org.osate.result.AnalysisResult 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)

Aggregations

AnalysisResult (org.osate.result.AnalysisResult)12 Result (org.osate.result.Result)8 InstanceObject (org.osate.aadl2.instance.InstanceObject)4 SystemInstance (org.osate.aadl2.instance.SystemInstance)4 SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)4 Diagnostic (org.osate.result.Diagnostic)2 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 Locale (java.util.Locale)1 WorkbookSettings (jxl.WorkbookSettings)1 Label (jxl.write.Label)1 WritableSheet (jxl.write.WritableSheet)1 WritableWorkbook (jxl.write.WritableWorkbook)1 WriteException (jxl.write.WriteException)1 IFile (org.eclipse.core.resources.IFile)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 Event (org.osate.aadl2.errormodel.FaultTree.Event)1 SOMIterator (org.osate.aadl2.modelsupport.modeltraversal.SOMIterator)1