Search in sources :

Example 11 with Counterexample

use of jkind.results.Counterexample in project AGREE by loonwerks.

the class TestCaseGeneratorMenuListener method viewCexConsole.

private void viewCexConsole(final Counterexample cex, final Layout layout, Map<String, EObject> refMap, TcgRenaming tcgRenaming) {
    final MessageConsole console = findConsole("Test Case");
    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());
                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 = tcgRenaming.mapAgreeToEObject(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 -> AgreeMenuListener.printSignal(out, it, cex.getLength()));
                out.println("State:");
                stateSignals.forEach(it -> AgreeMenuListener.printSignal(out, it, cex.getLength()));
                out.println("Outputs:");
                outputSignals.forEach(it -> AgreeMenuListener.printSignal(out, it, cex.getLength()));
                out.println();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }).start();
}
Also used : 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) PartInitException(org.eclipse.ui.PartInitException) IConsoleView(org.eclipse.ui.console.IConsoleView) Map(java.util.Map) TcgRenaming(com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming) AgreePatternListener(com.rockwellcollins.atc.agree.analysis.views.AgreePatternListener) PlatformUI(org.eclipse.ui.PlatformUI) MenuManager(org.eclipse.jface.action.MenuManager) TestSuite(com.rockwellcollins.atc.tcg.suite.TestSuite) Property(jkind.results.Property) EObject(org.eclipse.emf.ecore.EObject) MessageConsole(org.eclipse.ui.console.MessageConsole) ExtensionRegistry(com.rockwellcollins.atc.tcg.extensions.ExtensionRegistry) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) 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) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AgreeMenuListener(com.rockwellcollins.atc.agree.analysis.views.AgreeMenuListener) Dialog(org.osate.ui.dialogs.Dialog) Counterexample(jkind.results.Counterexample) IMenuListener(org.eclipse.jface.action.IMenuListener) TcgExtractorRegistry(com.rockwellcollins.atc.tcg.extensions.TcgExtractorRegistry) AgreeSubclause(com.rockwellcollins.atc.agree.agree.AgreeSubclause) ComponentImplementation(org.osate.aadl2.ComponentImplementation) ArrayList(java.util.ArrayList) IConsole(org.eclipse.ui.console.IConsole) AgreeResultsLinker(com.rockwellcollins.atc.agree.analysis.views.AgreeResultsLinker) JKindResult(jkind.api.results.JKindResult) ConsolePlugin(org.eclipse.ui.console.ConsolePlugin) IConsoleConstants(org.eclipse.ui.console.IConsoleConstants) JRealizabilityResult(jkind.api.results.JRealizabilityResult) AssumeStatement(com.rockwellcollins.atc.agree.agree.AssumeStatement) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) IOException(java.io.IOException) Action(org.eclipse.jface.action.Action) UnknownProperty(jkind.results.UnknownProperty) Signal(jkind.results.Signal) File(java.io.File) LemmaStatement(com.rockwellcollins.atc.agree.agree.LemmaStatement) Value(jkind.lustre.values.Value) IMenuManager(org.eclipse.jface.action.IMenuManager) PropertyResult(jkind.api.results.PropertyResult) MessageConsoleStream(org.eclipse.ui.console.MessageConsoleStream) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) TcgExtractor(com.rockwellcollins.atc.tcg.extensions.TcgExtractor) TestSuiteUtils(com.rockwellcollins.atc.tcg.suite.TestSuiteUtils) Renaming(jkind.api.results.Renaming) MessageConsole(org.eclipse.ui.console.MessageConsole) MessageConsoleStream(org.eclipse.ui.console.MessageConsoleStream) AgreePatternListener(com.rockwellcollins.atc.agree.analysis.views.AgreePatternListener) 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)

Example 12 with Counterexample

use of jkind.results.Counterexample in project AGREE by loonwerks.

the class TestSuiteMenuListener method viewCexConsole.

private void viewCexConsole(final Counterexample cex, final Layout layout, Map<String, EObject> refMap, final TcgRenaming tcgRenaming) {
    final MessageConsole console = findConsole("Test Case");
    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());
                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 = tcgRenaming.mapAgreeToEObject(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 -> AgreeMenuListener.printSignal(out, it, cex.getLength()));
                out.println("State:");
                stateSignals.forEach(it -> AgreeMenuListener.printSignal(out, it, cex.getLength()));
                out.println("Outputs:");
                outputSignals.forEach(it -> AgreeMenuListener.printSignal(out, it, cex.getLength()));
                out.println();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }).start();
}
Also used : Program(jkind.lustre.Program) AgreeSubclause(com.rockwellcollins.atc.agree.agree.AgreeSubclause) AnalysisResult(jkind.api.results.AnalysisResult) IAction(org.eclipse.jface.action.IAction) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ComponentImplementation(org.osate.aadl2.ComponentImplementation) GlobalURIEditorOpener(org.eclipse.xtext.ui.editor.GlobalURIEditorOpener) ArrayList(java.util.ArrayList) IConsole(org.eclipse.ui.console.IConsole) AgreeResultsLinker(com.rockwellcollins.atc.agree.analysis.views.AgreeResultsLinker) PartInitException(org.eclipse.ui.PartInitException) IConsoleView(org.eclipse.ui.console.IConsoleView) Map(java.util.Map) StringSelection(java.awt.datatransfer.StringSelection) ConsolePlugin(org.eclipse.ui.console.ConsolePlugin) TcgRenaming(com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming) AgreePatternListener(com.rockwellcollins.atc.agree.analysis.views.AgreePatternListener) IConsoleConstants(org.eclipse.ui.console.IConsoleConstants) PlatformUI(org.eclipse.ui.PlatformUI) MenuManager(org.eclipse.jface.action.MenuManager) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) IOException(java.io.IOException) EObject(org.eclipse.emf.ecore.EObject) Action(org.eclipse.jface.action.Action) MessageConsole(org.eclipse.ui.console.MessageConsole) Signal(jkind.results.Signal) Collectors(java.util.stream.Collectors) ExtensionRegistry(com.rockwellcollins.atc.tcg.extensions.ExtensionRegistry) File(java.io.File) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Value(jkind.lustre.values.Value) Layout(jkind.results.layout.Layout) List(java.util.List) AgreeUtils(com.rockwellcollins.atc.agree.analysis.AgreeUtils) IMenuManager(org.eclipse.jface.action.IMenuManager) MessageConsoleStream(org.eclipse.ui.console.MessageConsoleStream) TestCase(com.rockwellcollins.atc.tcg.suite.TestCase) IConsoleManager(org.eclipse.ui.console.IConsoleManager) TcgExtractor(com.rockwellcollins.atc.tcg.extensions.TcgExtractor) Renaming(jkind.api.results.Renaming) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AgreeMenuListener(com.rockwellcollins.atc.agree.analysis.views.AgreeMenuListener) Dialog(org.osate.ui.dialogs.Dialog) Counterexample(jkind.results.Counterexample) IMenuListener(org.eclipse.jface.action.IMenuListener) Toolkit(java.awt.Toolkit) TcgExtractorRegistry(com.rockwellcollins.atc.tcg.extensions.TcgExtractorRegistry) MessageConsole(org.eclipse.ui.console.MessageConsole) MessageConsoleStream(org.eclipse.ui.console.MessageConsoleStream) AgreePatternListener(com.rockwellcollins.atc.agree.analysis.views.AgreePatternListener) IOException(java.io.IOException) Signal(jkind.results.Signal) EObject(org.eclipse.emf.ecore.EObject) Value(jkind.lustre.values.Value) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Counterexample (jkind.results.Counterexample)12 Renaming (jkind.api.results.Renaming)7 Layout (jkind.results.layout.Layout)7 EObject (org.eclipse.emf.ecore.EObject)7 ComponentImplementation (org.osate.aadl2.ComponentImplementation)7 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 ArrayList (java.util.ArrayList)5 Signal (jkind.results.Signal)5 List (java.util.List)4 Map (java.util.Map)4 AnalysisResult (jkind.api.results.AnalysisResult)4 PropertyResult (jkind.api.results.PropertyResult)4 Program (jkind.lustre.Program)4 Value (jkind.lustre.values.Value)4 InvalidProperty (jkind.results.InvalidProperty)4 Property (jkind.results.Property)4 UnknownProperty (jkind.results.UnknownProperty)4