Search in sources :

Example 16 with Value

use of jkind.lustre.values.Value 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 17 with Value

use of jkind.lustre.values.Value 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

Value (jkind.lustre.values.Value)17 BooleanValue (jkind.lustre.values.BooleanValue)11 IntegerValue (jkind.lustre.values.IntegerValue)9 RealValue (jkind.lustre.values.RealValue)9 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 Signal (jkind.results.Signal)6 EObject (org.eclipse.emf.ecore.EObject)6 List (java.util.List)4 BinaryExpr (jkind.lustre.BinaryExpr)4 BoolExpr (jkind.lustre.BoolExpr)4 IntExpr (jkind.lustre.IntExpr)4 RealExpr (jkind.lustre.RealExpr)4 ArrayValue (jkind.lustre.values.ArrayValue)4 EnumValue (jkind.lustre.values.EnumValue)4 TupleValue (jkind.lustre.values.TupleValue)4 Counterexample (jkind.results.Counterexample)4 Layout (jkind.results.layout.Layout)4 AgreeSubclause (com.rockwellcollins.atc.agree.agree.AgreeSubclause)3 AgreeUtils (com.rockwellcollins.atc.agree.analysis.AgreeUtils)3