Search in sources :

Example 1 with Layout

use of jkind.results.layout.Layout 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 Layout

use of jkind.results.layout.Layout 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 3 with Layout

use of jkind.results.layout.Layout in project AGREE by loonwerks.

the class AgreeCounterexampleContentProvider method getElements.

@Override
public Object[] getElements(Object inputElement) {
    Counterexample cex = (Counterexample) inputElement;
    List<Object> result = new ArrayList<>();
    boolean first = true;
    for (String category : layout.getCategories()) {
        List<Signal<Value>> signals = cex.getCategorySignals(layout, category);
        if (!signals.isEmpty()) {
            if (first) {
                first = false;
            } else {
                result.add(new Spacer());
            }
            result.add(new CategoryHeader(category));
            List<Signal<Value>> inputSignals = signals.stream().filter(it -> {
                EObject ref = refMap.get(it.getName());
                return (ref instanceof org.osate.aadl2.Port) && ((org.osate.aadl2.Port) ref).isIn();
            }).collect(Collectors.toList());
            List<Signal<Value>> outputSignals = signals.stream().filter(it -> {
                EObject ref = refMap.get(it.getName());
                return (ref instanceof org.osate.aadl2.Port) && ((org.osate.aadl2.Port) ref).isOut();
            }).collect(Collectors.toList());
            List<Signal<Value>> otherSignals = signals.stream().filter(it -> !(inputSignals.contains(it) || outputSignals.contains(it))).collect(Collectors.toList());
            result.addAll(SignalGrouper.group(null, Stream.of(inputSignals, otherSignals, outputSignals).flatMap(Collection::stream).collect(Collectors.toList())));
        }
    }
    return result.toArray();
}
Also used : SignalGrouper(jkind.api.ui.counterexample.SignalGrouper) Collection(java.util.Collection) EObject(org.eclipse.emf.ecore.EObject) CounterexampleContentProvider(jkind.api.ui.counterexample.CounterexampleContentProvider) Signal(jkind.results.Signal) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Value(jkind.lustre.values.Value) Layout(jkind.results.layout.Layout) List(java.util.List) Stream(java.util.stream.Stream) CategoryHeader(jkind.api.ui.counterexample.CategoryHeader) Map(java.util.Map) Counterexample(jkind.results.Counterexample) Spacer(jkind.api.ui.counterexample.Spacer) ArrayList(java.util.ArrayList) Counterexample(jkind.results.Counterexample) Signal(jkind.results.Signal) Spacer(jkind.api.ui.counterexample.Spacer) EObject(org.eclipse.emf.ecore.EObject) EObject(org.eclipse.emf.ecore.EObject) CategoryHeader(jkind.api.ui.counterexample.CategoryHeader)

Example 4 with Layout

use of jkind.results.layout.Layout in project AGREE by loonwerks.

the class AgreeMenuListener method addViewCounterexampleMenu.

private void addViewCounterexampleMenu(IMenuManager manager, AnalysisResult original) {
    AnalysisResult result = transformResult(original);
    final List<Counterexample> cexs = getCounterexamples(result);
    final Property property = getProperty(result);
    CexExtractorRegistry cexReg = (CexExtractorRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.CEX_EXTRACTOR_EXT_ID);
    List<CexExtractor> extractors = cexReg.getCexExtractors();
    if (cexs != null) {
        for (Counterexample cex : cexs) {
            final String cexType = getCounterexampleType(result);
            Map<String, EObject> tempRefMap = linker.getReferenceMap(result.getParent());
            if (tempRefMap == null) {
                tempRefMap = linker.getReferenceMap(result);
            }
            Layout tempLayout = linker.getLayout(result.getParent());
            if (tempLayout == null) {
                tempLayout = linker.getLayout(result);
            }
            Renaming tempRenaming = linker.getRenaming(result.getParent());
            if (tempRenaming == null) {
                tempRenaming = linker.getRenaming(result);
            }
            final Layout layout = tempLayout;
            final Map<String, EObject> refMap = tempRefMap;
            final AgreeRenaming renaming = (AgreeRenaming) tempRenaming;
            final Counterexample translatedCex = translateCounterexampleArrayIndices(cex);
            MenuManager sub = new MenuManager("View " + cexType + "Counterexample in");
            manager.add(sub);
            sub.add(new Action("Console") {

                @Override
                public void run() {
                    viewCexConsole(translatedCex, layout, refMap, 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);
                }
            });
            InvalidProperty invalid = findInvalidProperty(original);
            if (invalid != null) {
                String report = invalid.getReport();
                if (report != null) {
                    sub.add(new Action("Web Browser") {

                        @Override
                        public void run() {
                            viewCexBrowser(report);
                        }
                    });
                }
            }
            // send counterexamples to external plugins
            EObject agreeProperty = refMap.get(result.getName());
            ComponentImplementation compImpl = linker.getComponent(result.getParent());
            for (CexExtractor ex : extractors) {
                sub.add(new Action(ex.getDisplayText()) {

                    @Override
                    public void run() {
                        ex.receiveCex(compImpl, property, agreeProperty, cex, refMap);
                    }
                });
            }
        }
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) CexExtractorRegistry(com.rockwellcollins.atc.agree.analysis.extentions.CexExtractorRegistry) CexExtractor(com.rockwellcollins.atc.agree.analysis.extentions.CexExtractor) Counterexample(jkind.results.Counterexample) AnalysisResult(jkind.api.results.AnalysisResult) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) 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) ValidProperty(jkind.results.ValidProperty) Property(jkind.results.Property) InvalidProperty(jkind.results.InvalidProperty) UnknownProperty(jkind.results.UnknownProperty) InvalidProperty(jkind.results.InvalidProperty)

Example 5 with Layout

use of jkind.results.layout.Layout in project AGREE by loonwerks.

the class AgreeMenuListener method viewCexConsole.

private void viewCexConsole(final Counterexample cex, final Layout layout, Map<String, EObject> refMap, final AgreeRenaming renaming) {
    final MessageConsole console = findConsole("Counterexample");
    showConsole(console);
    console.clearConsole();
    console.addPatternMatchListener(new AgreePatternListener(refMap));
    /*
		 * From the Eclipse API: "Clients should avoid writing large amounts of
		 * output to this stream in the UI thread. The console needs to process
		 * the output in the UI thread and if the client hogs the UI thread
		 * writing output to the console, the console will not be able to
		 * process the output."
		 */
    new Thread(() -> {
        try (MessageConsoleStream out = console.newMessageStream()) {
            for (String category : layout.getCategories()) {
                if (isEmpty(category, cex, layout)) {
                    continue;
                }
                printHLine(out, cex.getLength());
                if (category == "") {
                    out.println("Variables for the selected component implementation");
                } else {
                    out.println("Variables for " + category);
                }
                printHLine(out, cex.getLength());
                out.print(String.format("%-60s", "Variable Name"));
                for (int k1 = 0; k1 < cex.getLength(); k1++) {
                    out.print(String.format("%-15s", k1));
                }
                out.println();
                printHLine(out, cex.getLength());
                List<Signal<Value>> inputSignals = new ArrayList<>();
                List<Signal<Value>> outputSignals = new ArrayList<>();
                List<Signal<Value>> stateSignals = new ArrayList<>();
                for (Signal<Value> signal : cex.getCategorySignals(layout, category)) {
                    // dont' print out values for properties
                    if (signal.getName().contains(":")) {
                        continue;
                    }
                    String signalName = signal.getName();
                    EObject ref = renaming.findBestReference(signalName);
                    boolean isInput = (ref instanceof org.osate.aadl2.Port) ? ((org.osate.aadl2.Port) ref).isIn() : false;
                    boolean isOutput = (ref instanceof org.osate.aadl2.Port) ? ((org.osate.aadl2.Port) ref).isOut() : false;
                    if (isInput) {
                        inputSignals.add(signal);
                    } else if (isOutput) {
                        outputSignals.add(signal);
                    } else {
                        stateSignals.add(signal);
                    }
                }
                out.println("Inputs:");
                inputSignals.forEach(it -> printSignal(out, it, cex.getLength()));
                out.println("State:");
                stateSignals.forEach(it -> printSignal(out, it, cex.getLength()));
                out.println("Outputs:");
                outputSignals.forEach(it -> printSignal(out, it, cex.getLength()));
                out.println();
            }
            printHLine(out, cex.getLength());
            // print uninterpreted functions using Jkind CounterexampleFormatter
            AgreeUninterpretedFunctionFormatter uFcnFormatter = new AgreeUninterpretedFunctionFormatter(cex);
            out.println(uFcnFormatter.functions());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }).start();
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Program(jkind.lustre.Program) AnalysisResult(jkind.api.results.AnalysisResult) IAction(org.eclipse.jface.action.IAction) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) GlobalURIEditorOpener(org.eclipse.xtext.ui.editor.GlobalURIEditorOpener) Matcher(java.util.regex.Matcher) AgreeAutomaterRegistry(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry) PartInitException(org.eclipse.ui.PartInitException) IConsoleView(org.eclipse.ui.console.IConsoleView) Map(java.util.Map) BigInteger(java.math.BigInteger) ValidProperty(jkind.results.ValidProperty) AgreePattern(com.rockwellcollins.atc.agree.analysis.realtime.AgreePattern) PlatformUI(org.eclipse.ui.PlatformUI) MenuManager(org.eclipse.jface.action.MenuManager) Property(jkind.results.Property) Set(java.util.Set) EObject(org.eclipse.emf.ecore.EObject) MessageConsole(org.eclipse.ui.console.MessageConsole) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) CexExtractorRegistry(com.rockwellcollins.atc.agree.analysis.extentions.CexExtractorRegistry) Layout(jkind.results.layout.Layout) List(java.util.List) AgreeUtils(com.rockwellcollins.atc.agree.analysis.AgreeUtils) GuaranteeStatement(com.rockwellcollins.atc.agree.agree.GuaranteeStatement) InvalidProperty(jkind.results.InvalidProperty) IConsoleManager(org.eclipse.ui.console.IConsoleManager) Pattern(java.util.regex.Pattern) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AgreeAutomater(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater) ExtensionRegistry(com.rockwellcollins.atc.agree.analysis.extentions.ExtensionRegistry) Dialog(org.osate.ui.dialogs.Dialog) Counterexample(jkind.results.Counterexample) IMenuListener(org.eclipse.jface.action.IMenuListener) ConsistencyResult(com.rockwellcollins.atc.agree.analysis.ConsistencyResult) AgreeSubclause(com.rockwellcollins.atc.agree.agree.AgreeSubclause) Activator(com.rockwellcollins.atc.agree.analysis.Activator) ComponentImplementation(org.osate.aadl2.ComponentImplementation) ArrayList(java.util.ArrayList) IConsole(org.eclipse.ui.console.IConsole) HashSet(java.util.HashSet) JKindResult(jkind.api.results.JKindResult) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) ConsolePlugin(org.eclipse.ui.console.ConsolePlugin) AnalysisResultTree(jkind.api.ui.results.AnalysisResultTree) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) IConsoleConstants(org.eclipse.ui.console.IConsoleConstants) JRealizabilityResult(jkind.api.results.JRealizabilityResult) MalformedURLException(java.net.MalformedURLException) AssumeStatement(com.rockwellcollins.atc.agree.agree.AssumeStatement) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) IOException(java.io.IOException) Action(org.eclipse.jface.action.Action) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) UnknownProperty(jkind.results.UnknownProperty) Signal(jkind.results.Signal) CexExtractor(com.rockwellcollins.atc.agree.analysis.extentions.CexExtractor) File(java.io.File) LemmaStatement(com.rockwellcollins.atc.agree.agree.LemmaStatement) Value(jkind.lustre.values.Value) PreferenceConstants(com.rockwellcollins.atc.agree.analysis.preferences.PreferenceConstants) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) IMenuManager(org.eclipse.jface.action.IMenuManager) PropertyResult(jkind.api.results.PropertyResult) MessageConsoleStream(org.eclipse.ui.console.MessageConsoleStream) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) Renaming(jkind.api.results.Renaming) Collections(java.util.Collections) MessageConsole(org.eclipse.ui.console.MessageConsole) MessageConsoleStream(org.eclipse.ui.console.MessageConsoleStream) IOException(java.io.IOException) Signal(jkind.results.Signal) EObject(org.eclipse.emf.ecore.EObject) Value(jkind.lustre.values.Value) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

Counterexample (jkind.results.Counterexample)7 Layout (jkind.results.layout.Layout)7 EObject (org.eclipse.emf.ecore.EObject)7 Renaming (jkind.api.results.Renaming)6 Action (org.eclipse.jface.action.Action)6 IAction (org.eclipse.jface.action.IAction)6 IMenuManager (org.eclipse.jface.action.IMenuManager)6 MenuManager (org.eclipse.jface.action.MenuManager)6 ComponentImplementation (org.osate.aadl2.ComponentImplementation)6 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Map (java.util.Map)4 AnalysisResult (jkind.api.results.AnalysisResult)4 Value (jkind.lustre.values.Value)4 Signal (jkind.results.Signal)4 AgreeSubclause (com.rockwellcollins.atc.agree.agree.AgreeSubclause)3 AgreeUtils (com.rockwellcollins.atc.agree.analysis.AgreeUtils)3 File (java.io.File)3 IOException (java.io.IOException)3 Program (jkind.lustre.Program)3