Search in sources :

Example 1 with AnalysisResult

use of jkind.api.results.AnalysisResult in project AGREE by loonwerks.

the class TestCaseGeneratorMenuListener method menuAboutToShow.

@Override
public void menuAboutToShow(IMenuManager manager) {
    IStructuredSelection selection = (IStructuredSelection) table.getViewer().getSelection();
    if (!selection.isEmpty()) {
        AnalysisResult result = (AnalysisResult) selection.getFirstElement();
        addLinkedMenus(manager, result);
    }
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AnalysisResult(jkind.api.results.AnalysisResult)

Example 2 with AnalysisResult

use of jkind.api.results.AnalysisResult in project AGREE by loonwerks.

the class VerifyHandler 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 3 with AnalysisResult

use of jkind.api.results.AnalysisResult in project AGREE by loonwerks.

the class VerifyHandler method buildAnalysisResult.

protected AnalysisResult buildAnalysisResult(String name, ComponentInstance ci) {
    CompositeAnalysisResult result = new CompositeAnalysisResult("Verification for " + name);
    if (containsAGREEAnnex(ci)) {
        wrapVerificationResult(ci, result);
        ComponentImplementation compImpl = AgreeUtils.getInstanceImplementation(ci);
        for (ComponentInstance subInst : ci.getComponentInstances()) {
            if (AgreeUtils.getInstanceImplementation(subInst) != null) {
                AnalysisResult buildAnalysisResult = buildAnalysisResult(subInst.getName(), subInst);
                if (buildAnalysisResult != null) {
                    result.addChild(buildAnalysisResult);
                }
            }
        }
        if (result.getChildren().size() != 0) {
            linker.setComponent(result, compImpl);
            return result;
        }
    }
    return null;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) CompositeAnalysisResult(jkind.api.results.CompositeAnalysisResult) AnalysisResult(jkind.api.results.AnalysisResult) CompositeAnalysisResult(jkind.api.results.CompositeAnalysisResult)

Example 4 with AnalysisResult

use of jkind.api.results.AnalysisResult in project AGREE by loonwerks.

the class AgreeMenuListener method menuAboutToShow.

@Override
public void menuAboutToShow(IMenuManager manager) {
    IStructuredSelection selection = (IStructuredSelection) tree.getViewer().getSelection();
    if (!selection.isEmpty()) {
        AnalysisResult result = (AnalysisResult) selection.getFirstElement();
        addLinkedMenus(manager, result);
    }
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AnalysisResult(jkind.api.results.AnalysisResult)

Example 5 with AnalysisResult

use of jkind.api.results.AnalysisResult in project AGREE by loonwerks.

the class AgreeFileUtil method printLog.

/**
 * Prints the AGREE analysis result in json format to the property log file
 * (specified in AGREE preferences), along with a timestamp and hashcode.
 * @param result - The result of the AGREE analysis.
 * @param timestamp - The time at which the analysis started
 * @param hash - The hashcode for the combined model files
 */
public static void printLog(JKindResult result, long timestamp, String hashcode) {
    if (hashcode == null) {
        return;
    }
    try {
        // This class could be called concurrently from multiple threads
        // so wrap the following read/write behavior in a mutex
        mutex.acquire();
        try {
            // Figure out the top-level analysis this result is part of
            // and keep track of ancestor trace so we know where to insert this analysis
            AnalysisResult topLevelAnalysis = result;
            List<String> ancestorTrace = new ArrayList<>();
            while (topLevelAnalysis.getParent() != null && !topLevelAnalysis.getParent().getName().isEmpty()) {
                topLevelAnalysis = topLevelAnalysis.getParent();
                ancestorTrace.add(0, topLevelAnalysis.getName());
            }
            // Get the results from the current agree analysis
            AgreeLogResult agreeLogResult = parsePropertyResult(result);
            agreeLogResult.setTimestamp(timestamp);
            agreeLogResult.setHashcode(hashcode);
            // Read in the agree property log file
            List<AgreeLogResult> agreeLog = readAgreeLog();
            // Insert the agree result in the agree log structure
            insertAgreeLogResult(agreeLogResult, agreeLog, ancestorTrace);
            // Write the agree property results back to the file
            // The contents of the file will be overwritten
            writeAgreeLog(agreeLog);
        } finally {
            mutex.release();
        }
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("Could not write to the AGREE analysis log.\n");
    }
    return;
}
Also used : ArrayList(java.util.ArrayList) AnalysisResult(jkind.api.results.AnalysisResult) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

AnalysisResult (jkind.api.results.AnalysisResult)18 CompositeAnalysisResult (jkind.api.results.CompositeAnalysisResult)11 ComponentImplementation (org.osate.aadl2.ComponentImplementation)10 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)7 IStatus (org.eclipse.core.runtime.IStatus)6 Status (org.eclipse.core.runtime.Status)6 IHandlerService (org.eclipse.ui.handlers.IHandlerService)6 EphemeralImplementationUtil (com.rockwellcollins.atc.agree.analysis.EphemeralImplementationUtil)5 AgreeASTBuilder (com.rockwellcollins.atc.agree.analysis.ast.AgreeASTBuilder)5 AgreeProgram (com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram)5 Program (jkind.lustre.Program)5 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)5 SystemInstance (org.osate.aadl2.instance.SystemInstance)5 AgreeRenaming (com.rockwellcollins.atc.agree.analysis.AgreeRenaming)4 ArrayList (java.util.ArrayList)3 JRealizabilityResult (jkind.api.results.JRealizabilityResult)3 EObject (org.eclipse.emf.ecore.EObject)3 Activator (com.rockwellcollins.atc.agree.analysis.Activator)2 AgreeLayout (com.rockwellcollins.atc.agree.analysis.AgreeLayout)2 AgreeLogger (com.rockwellcollins.atc.agree.analysis.AgreeLogger)2