Search in sources :

Example 76 with SystemInstance

use of org.osate.aadl2.instance.SystemInstance in project osate-plugin by sireum.

the class LaunchSireumHandler method runJob.

@Override
public IStatus runJob(Element elem, IProgressMonitor monitor) {
    MessageConsole console = displayConsole();
    console.clearConsole();
    if (!Util.emitSireumVersion(console)) {
        displayPopup("AIR generation was unsuccessful");
        return Status.CANCEL_STATUS;
    }
    SystemInstance si = getSystemInstance(elem);
    if (si == null) {
        Dialog.showError(getToolName(), "Please select a system implementation or a system instance");
        return Status.CANCEL_STATUS;
    }
    writeToConsole("Generating AIR ...");
    Aadl model = Util.getAir(si, true, console);
    if (model != null) {
        SerializerType ser = PreferenceValues.getSERIALIZATION_METHOD_OPT();
        writeToConsole("Serializing AIR to " + ser.name() + " ...");
        String s = Util.serialize(model, ser);
        Display.getDefault().syncExec(() -> {
            FileDialog fd = new FileDialog(getShell(), SWT.SAVE);
            fd.setFileName("aadl." + (ser == SerializerType.MSG_PACK ? "msgpack" : "json"));
            fd.setText("Specify filename");
            fd.setFilterPath(getProjectPath(si).toString());
            String fname = fd.open();
            if (fname != null) {
                File fout = new File(fname);
                writeFile(fout, s, false);
                writeToConsole("Wrote: " + fout.getAbsolutePath());
            }
        });
        refreshWorkspace();
        return Status.OK_STATUS;
    } else {
        Dialog.showError(getToolName(), "Could not generate AIR");
        return Status.CANCEL_STATUS;
    }
}
Also used : MessageConsole(org.eclipse.ui.console.MessageConsole) SystemInstance(org.osate.aadl2.instance.SystemInstance) Aadl(org.sireum.hamr.ir.Aadl) SerializerType(org.sireum.aadl.osate.util.Util.SerializerType) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File)

Example 77 with SystemInstance

use of org.osate.aadl2.instance.SystemInstance in project AMASE by loonwerks.

the class FaultsVerifyAllHandler method runJob.

@Override
protected IStatus runJob(Element root, IProgressMonitor monitor) {
    EphemeralImplementationUtil implUtil = new EphemeralImplementationUtil(monitor);
    // this flag is set by the rerun handler to prevent clearing the advice map
    if (!calledFromRerun) {
        rerunAdviceMap.clear();
    }
    calledFromRerun = false;
    disableRerunHandler();
    handlerService = getWindow().getService(IHandlerService.class);
    try {
        // Make sure the user selected a component implementation
        ComponentImplementation ci = getComponentImplementation(root, implUtil);
        SystemInstance si = getSysInstance(ci, implUtil);
        AnalysisResult result;
        CompositeAnalysisResult wrapper = new CompositeAnalysisResult("");
        if (isRecursive()) {
            if (AgreeUtils.usingKind2()) {
                throw new AgreeException("Kind2 only supports monolithic verification");
            }
            result = buildAnalysisResult(ci.getName(), si);
            wrapper.addChild(result);
            result = wrapper;
        } else if (isRealizability()) {
            AgreeProgram agreeProgram = new AgreeASTBuilder().getAgreeProgram(si, false);
            Program program = LustreAstBuilder.getRealizabilityLustreProgram(agreeProgram);
            wrapper.addChild(createVerification("Realizability Check", si, program, agreeProgram, AnalysisType.Realizability));
            result = wrapper;
        } else {
            CompositeAnalysisResult wrapperTop = new CompositeAnalysisResult("Verification for " + ci.getName());
            wrapVerificationResult(si, wrapperTop);
            wrapper.addChild(wrapperTop);
            result = wrapper;
        }
        showView(result, linker);
        return doAnalysis(ci, monitor);
    } catch (Throwable e) {
        String messages = getNestedMessages(e);
        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, messages, e);
    } finally {
        implUtil.cleanup();
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Program(jkind.lustre.Program) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram) EphemeralImplementationUtil(com.rockwellcollins.atc.agree.analysis.EphemeralImplementationUtil) AnalysisResult(jkind.api.results.AnalysisResult) CompositeAnalysisResult(jkind.api.results.CompositeAnalysisResult) IHandlerService(org.eclipse.ui.handlers.IHandlerService) AgreeASTBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeASTBuilder) SystemInstance(org.osate.aadl2.instance.SystemInstance) CompositeAnalysisResult(jkind.api.results.CompositeAnalysisResult) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException)

Example 78 with SystemInstance

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

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

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

the class BoundResourceAnalysis method getMemoryBindings.

/*
	 * Issue 2169: This is copied from InstanceModelUtil.getBoundSWComponents, but we had
	 * to specialize it because now processor/virtual processors are treated as things
	 * that have memory and the original method gets the wrong things from the processors.
	 *
	 * associatedObject is of category memory, system, processor, virtual processor, abstract
	 */
private static EList<ComponentInstance> getMemoryBindings(final ComponentInstance associatedObject) {
    EList<Element> boundComponents = null;
    final SystemInstance root = associatedObject.getSystemInstance();
    final ComponentCategory cc = associatedObject.getCategory();
    if (cc == ComponentCategory.MEMORY || cc == ComponentCategory.SYSTEM || cc == ComponentCategory.PROCESSOR || cc == ComponentCategory.VIRTUAL_PROCESSOR || cc == ComponentCategory.ABSTRACT) {
        boundComponents = new ForAllElement() {

            @Override
            protected boolean suchThat(Element obj) {
                final List<InstanceObject> boundMemoryList = DeploymentProperties.getActualMemoryBinding((ComponentInstance) obj).orElse(Collections.emptyList());
                if (boundMemoryList.isEmpty()) {
                    return false;
                }
                return boundMemoryList.contains(associatedObject);
            }
        }.processPostOrderComponentInstance(root);
    } else {
        return new BasicEList<ComponentInstance>();
    }
    EList<ComponentInstance> topobjects = new BasicEList<ComponentInstance>();
    for (Object componentInstance : boundComponents) {
        InstanceModelUtil.addAsRoot(topobjects, (ComponentInstance) componentInstance);
    }
    return topobjects;
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) SystemInstance(org.osate.aadl2.instance.SystemInstance) Element(org.osate.aadl2.Element) ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) BasicEList(org.eclipse.emf.common.util.BasicEList) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) InstanceObject(org.osate.aadl2.instance.InstanceObject) ComponentCategory(org.osate.aadl2.ComponentCategory)

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