Search in sources :

Example 6 with TcgRenaming

use of com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming 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 7 with TcgRenaming

use of com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming 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

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