Search in sources :

Example 1 with TcgRenaming

use of com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming in project AGREE by loonwerks.

the class TestCaseGeneratorMenuListener method addViewTestCaseMenu.

private void addViewTestCaseMenu(IMenuManager manager, AnalysisResult result) {
    final Counterexample cex = getCounterexample(result);
    TcgExtractorRegistry tcgReg = (TcgExtractorRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.TCG_EXTRACTOR_EXT_ID);
    List<TcgExtractor> extractors = tcgReg.getTcgExtractors();
    if (cex != null) {
        final String cexType = getCounterexampleType(result);
        final Layout layout = linker.getLayout(result.getParent());
        final Renaming renaming = linker.getRenaming(result.getParent());
        final Map<String, EObject> refMap = ((TcgRenaming) renaming).getTcgRefMap();
        final Counterexample translatedCex = AgreeMenuListener.translateCounterexampleArrayIndices(cex);
        MenuManager sub = new MenuManager("View " + cexType + "Test Case in");
        manager.add(sub);
        sub.add(new Action("Console") {

            @Override
            public void run() {
                viewCexConsole(translatedCex, layout, refMap, (TcgRenaming) renaming);
            }
        });
        sub.add(new Action("Eclipse") {

            @Override
            public void run() {
                viewCexEclipse(translatedCex, layout, refMap);
            }
        });
        sub.add(new Action("Spreadsheet") {

            @Override
            public void run() {
                viewCexSpreadsheet(translatedCex, layout);
            }
        });
        // send counterexamples to external plugins
        PropertyResult pr = (PropertyResult) result;
        EObject property = refMap.get(pr.getName());
        ComponentImplementation compImpl = linker.getComponent(result.getParent());
        for (TcgExtractor ex : extractors) {
            sub.add(new Action(ex.getDisplayText()) {

                @Override
                public void run() {
                    ex.receiveCex(compImpl, property, translatedCex, refMap);
                }
            });
        }
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) TcgExtractorRegistry(com.rockwellcollins.atc.tcg.extensions.TcgExtractorRegistry) TcgExtractor(com.rockwellcollins.atc.tcg.extensions.TcgExtractor) Counterexample(jkind.results.Counterexample) PropertyResult(jkind.api.results.PropertyResult) TcgRenaming(com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming) Renaming(jkind.api.results.Renaming) Layout(jkind.results.layout.Layout) EObject(org.eclipse.emf.ecore.EObject) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) TcgRenaming(com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming)

Example 2 with TcgRenaming

use of com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming in project AGREE by loonwerks.

the class TestCaseGeneratorMenuListener method addResultsLinkingMenu.

private void addResultsLinkingMenu(IMenuManager manager, AnalysisResult result) {
    if (result instanceof PropertyResult) {
        PropertyResult pr = (PropertyResult) result;
        Map<String, EObject> refMap = ((TcgRenaming) linker.getRenaming(result.getParent())).getTcgRefMap();
        if (refMap != null) {
            EObject property = refMap.get(pr.getName());
            if (property instanceof GuaranteeStatement) {
                manager.add(createHyperlinkAction("Go To Guarantee", property));
            }
            if (property instanceof LemmaStatement) {
                manager.add(createHyperlinkAction("Go To Lemma", property));
            }
            if (property instanceof AssumeStatement) {
                manager.add(createHyperlinkAction("Go To Assumption", property));
            }
            if (property instanceof CallExpr) {
                manager.add(createHyperlinkAction("Go To Node Call", property));
            }
        }
    }
}
Also used : GuaranteeStatement(com.rockwellcollins.atc.agree.agree.GuaranteeStatement) AssumeStatement(com.rockwellcollins.atc.agree.agree.AssumeStatement) EObject(org.eclipse.emf.ecore.EObject) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) TcgRenaming(com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming) LemmaStatement(com.rockwellcollins.atc.agree.agree.LemmaStatement) PropertyResult(jkind.api.results.PropertyResult)

Example 3 with TcgRenaming

use of com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming in project AGREE by loonwerks.

the class TestSuiteMenuListener method addViewTestCaseMenu.

private void addViewTestCaseMenu(IMenuManager manager, TestCase testCase) {
    final Counterexample cex = testCase.getCex();
    TcgExtractorRegistry tcgReg = (TcgExtractorRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.TCG_EXTRACTOR_EXT_ID);
    List<TcgExtractor> extractors = tcgReg.getTcgExtractors();
    if (cex != null) {
        /*
			 * TODO: getCounterexampleType?
			 */
        // final String cexType = getCounterexampleType(result);
        final String cexType = "";
        final Layout layout = linker.getLayout(result);
        final Renaming renaming = linker.getRenaming(result);
        final Map<String, EObject> refMap = ((TcgRenaming) linker.getRenaming(result)).getTcgRefMap();
        final Counterexample translatedCex = AgreeMenuListener.translateCounterexampleArrayIndices(cex);
        MenuManager sub = new MenuManager("View " + cexType + "Test Case in");
        manager.add(sub);
        sub.add(new Action("Console") {

            @Override
            public void run() {
                viewCexConsole(translatedCex, layout, refMap, (TcgRenaming) renaming);
            }
        });
        sub.add(new Action("Eclipse") {

            @Override
            public void run() {
                viewCexEclipse(translatedCex, layout, refMap);
            }
        });
        sub.add(new Action("Spreadsheet") {

            @Override
            public void run() {
                viewCexSpreadsheet(translatedCex, layout);
            }
        });
        // send counterexamples to external plugins
        EObject property = refMap.get(testCase.getName());
        ComponentImplementation compImpl = linker.getComponent(result);
        for (TcgExtractor ex : extractors) {
            sub.add(new Action(ex.getDisplayText()) {

                @Override
                public void run() {
                    ex.receiveCex(compImpl, property, translatedCex, refMap);
                }
            });
        }
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) TcgExtractorRegistry(com.rockwellcollins.atc.tcg.extensions.TcgExtractorRegistry) TcgExtractor(com.rockwellcollins.atc.tcg.extensions.TcgExtractor) Counterexample(jkind.results.Counterexample) TcgRenaming(com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming) Renaming(jkind.api.results.Renaming) Layout(jkind.results.layout.Layout) EObject(org.eclipse.emf.ecore.EObject) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) TcgRenaming(com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming)

Example 4 with TcgRenaming

use of com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming in project AGREE by loonwerks.

the class TcgLinkerFactory method createVerification.

protected AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram) {
    AgreeRenaming agreeRenaming = new AgreeRenaming();
    AgreeLayout layout = new AgreeLayout();
    RenamingVisitor.addRenamings(lustreProgram, agreeRenaming, compInst, layout);
    TcgRenaming renaming = new TcgRenaming(agreeRenaming, agreeRenaming.getRefMap());
    Node mainNode = lustreProgram.getMainNode();
    if (mainNode == null) {
        throw new AgreeException("Could not find main lustre node after translation");
    }
    List<String> properties = new ArrayList<>();
    JKindResult result;
    result = new JKindResult(resultName, properties, renaming);
    queue.add(result);
    ComponentImplementation compImpl = AgreeUtils.getInstanceImplementation(compInst);
    linker.setAgreeProgram(result, agreeProgram);
    linker.setProgram(result, lustreProgram);
    linker.setComponent(result, compImpl);
    linker.setContract(result, getContract(compImpl));
    linker.setLayout(result, layout);
    // linker.setReferenceMap(result, renaming.getRefMap());
    linker.setLog(result, AgreeLogger.getLog());
    linker.setRenaming(result, renaming);
    // System.out.println(program);
    return result;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) TcgRenaming(com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming) JKindResult(jkind.api.results.JKindResult)

Example 5 with TcgRenaming

use of com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming in project AGREE by loonwerks.

the class VerifyHandler method doAnalysis.

protected IStatus doAnalysis(final Element root, final IProgressMonitor monitor) {
    Thread analysisThread = new Thread() {

        @Override
        public void run() {
            activateTerminateHandler(monitor);
            KindApi api = PreferencesUtil.getKindApi();
            while (!queue.isEmpty() && !monitor.isCanceled()) {
                JKindResult result = queue.peek();
                NullProgressMonitor subMonitor = new NullProgressMonitor();
                monitorRef.set(subMonitor);
                TcgRenaming tcgRenaming = (TcgRenaming) linker.getRenaming(result);
                Program ufcProgram = constructUfcProgram(linker.getProgram(result), tcgRenaming);
                ufcProgram.getMainNode().properties.forEach(p -> result.addProperty(p));
                writeIntermediateFiles(linker.getProgram(result), ufcProgram);
                try {
                    System.out.println("Calling jkind...");
                    api.execute(ufcProgram, result, monitor);
                    System.out.println("executed API...");
                    TestSuite testSuite = TestSuiteUtils.testSuiteFromJKindResult(result, linker.getComponent(result).getQualifiedName(), result.getName(), result.getText(), tcgRenaming);
                    emitResult(testSuite);
                // showSuiteView(testSuite, linker);
                } catch (JKindException e) {
                    System.out.println(result.getText());
                    System.out.println("******** Error Occurred: HERE IS THE LUSTRE ********");
                    System.out.println(linker.getProgram(result));
                    break;
                } finally {
                    deactivateTerminateHandler();
                    System.out.println("UFC generation complete");
                }
                queue.remove();
            }
        }
    };
    analysisThread.start();
    return Status.OK_STATUS;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Program(jkind.lustre.Program) JKindException(jkind.JKindException) TestSuite(com.rockwellcollins.atc.tcg.suite.TestSuite) KindApi(jkind.api.KindApi) TcgRenaming(com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming) JKindResult(jkind.api.results.JKindResult)

Aggregations

TcgRenaming (com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming)7 EObject (org.eclipse.emf.ecore.EObject)5 TcgExtractor (com.rockwellcollins.atc.tcg.extensions.TcgExtractor)4 TcgExtractorRegistry (com.rockwellcollins.atc.tcg.extensions.TcgExtractorRegistry)4 Renaming (jkind.api.results.Renaming)4 Counterexample (jkind.results.Counterexample)4 Layout (jkind.results.layout.Layout)4 Action (org.eclipse.jface.action.Action)4 IAction (org.eclipse.jface.action.IAction)4 IMenuManager (org.eclipse.jface.action.IMenuManager)4 MenuManager (org.eclipse.jface.action.MenuManager)4 ArrayList (java.util.ArrayList)3 Program (jkind.lustre.Program)3 ComponentImplementation (org.osate.aadl2.ComponentImplementation)3 AgreeSubclause (com.rockwellcollins.atc.agree.agree.AgreeSubclause)2 AgreeUtils (com.rockwellcollins.atc.agree.analysis.AgreeUtils)2 AgreeMenuListener (com.rockwellcollins.atc.agree.analysis.views.AgreeMenuListener)2 AgreePatternListener (com.rockwellcollins.atc.agree.analysis.views.AgreePatternListener)2 AgreeResultsLinker (com.rockwellcollins.atc.agree.analysis.views.AgreeResultsLinker)2 ExtensionRegistry (com.rockwellcollins.atc.tcg.extensions.ExtensionRegistry)2