Search in sources :

Example 1 with Renaming

use of jkind.api.results.Renaming 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 Renaming

use of jkind.api.results.Renaming 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 Renaming

use of jkind.api.results.Renaming in project AGREE by loonwerks.

the class ExportAction method buildExportArguments.

private ExportArguments buildExportArguments() {
    final SimulationUIService simUiService = (SimulationUIService) Objects.requireNonNull(PlatformUI.getWorkbench().getService(SimulationUIService.class), "Unable to retrieve Simulation UI Service");
    final SimulatorState simulatorState = simUiService.getCurrentState();
    if (!(simulatorState.getEngineState() instanceof AGREESimulationState)) {
        throw new RuntimeException("Simulation engine state must be an AGREESimulationState");
    }
    if (!(simulatorState.getSimulationEngine() instanceof AGREESimulationEngine)) {
        throw new RuntimeException("Simulation engine must be an AGREESimulationEngine");
    }
    final AGREESimulationState agreeSimState = (AGREESimulationState) simulatorState.getEngineState();
    final AGREESimulationEngine engine = (AGREESimulationEngine) simulatorState.getSimulationEngine();
    final ComponentImplementation componentImplementation = engine.getSystemInstance().getComponentImplementation();
    final Counterexample cex = buildCounterexample(agreeSimState);
    final Renaming renaming = engine.getSimulationProgram().getAgreeRenaming();
    return new ExportArguments() {

        @Override
        public ComponentImplementation getComponentImplementation() {
            return componentImplementation;
        }

        @Override
        public Counterexample getCounterexample() {
            return cex;
        }

        @Override
        public Renaming getAgreeRenaming() {
            return renaming;
        }
    };
}
Also used : SimulationUIService(edu.uah.rsesc.aadlsimulator.ui.services.SimulationUIService) ComponentImplementation(org.osate.aadl2.ComponentImplementation) AGREESimulationState(edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationState) ExportArguments(edu.uah.rsesc.aadlsimulator.agree.ext.AGREESimulationExporter.ExportArguments) AGREESimulationEngine(edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationEngine) SimulatorState(edu.uah.rsesc.aadlsimulator.ui.services.SimulatorState) Counterexample(jkind.results.Counterexample) Renaming(jkind.api.results.Renaming)

Example 4 with Renaming

use of jkind.api.results.Renaming in project AGREE by loonwerks.

the class AgreeMenuListener method addViewSupportConsole.

private IAction addViewSupportConsole(String text, IMenuManager manager, AnalysisResult result) {
    return new Action(text) {

        @Override
        public void run() {
            Map<String, EObject> tempRefMap = linker.getReferenceMap(result.getParent());
            if (tempRefMap == null) {
                tempRefMap = linker.getReferenceMap(result);
            }
            final Map<String, EObject> refMap = tempRefMap;
            final MessageConsole console = findConsole("Support");
            Renaming tempRenaming = linker.getRenaming(result);
            while (tempRenaming == null) {
                AnalysisResult parent = result.getParent();
                if (parent == null) {
                    throw new AgreeException("Problem finding renaming");
                }
                tempRenaming = linker.getRenaming(parent);
            }
            final Renaming renaming = tempRenaming;
            showConsole(console);
            console.clearConsole();
            if (patternListener != null) {
                console.removePatternMatchListener(patternListener);
            }
            patternListener = new AgreePatternListener(refMap);
            console.addPatternMatchListener(patternListener);
            new Thread(() -> {
                if (renaming instanceof AgreeRenaming) {
                    writeIvcResult(result, console, (AgreeRenaming) renaming);
                }
            }).start();
        }
    };
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) MessageConsole(org.eclipse.ui.console.MessageConsole) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) EObject(org.eclipse.emf.ecore.EObject) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) AnalysisResult(jkind.api.results.AnalysisResult) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) Renaming(jkind.api.results.Renaming)

Example 5 with Renaming

use of jkind.api.results.Renaming in project AGREE by loonwerks.

the class AgreeMenuListener method addViewTraceabilityConsole.

private IAction addViewTraceabilityConsole(String text, IMenuManager manager, AnalysisResult result) {
    return new Action(text) {

        @Override
        public void run() {
            Map<String, EObject> tempRefMap = linker.getReferenceMap(result.getParent());
            if (tempRefMap == null) {
                tempRefMap = linker.getReferenceMap(result);
            }
            final Map<String, EObject> refMap = tempRefMap;
            final MessageConsole console = findConsole("Traceability");
            final Renaming renaming = linker.getRenaming(result);
            showConsole(console);
            console.clearConsole();
            console.addPatternMatchListener(new AgreePatternListener(refMap));
            new Thread(() -> {
                try {
                    MessageConsoleStream out = console.newMessageStream();
                    printHLine(out, 2);
                    out.println("Traceability for Valid Contract Guarantees");
                    printHLine(out, 2);
                    out.println("");
                    List<PropertyResult> allProperties = new ArrayList<PropertyResult>(((JKindResult) result).getPropertyResults());
                    if (!allProperties.isEmpty()) {
                        for (PropertyResult prop : allProperties) {
                            if (prop.getStatus().equals(jkind.api.results.Status.VALID)) {
                                if (renaming instanceof AgreeRenaming) {
                                    writeIvcResult(prop, console, (AgreeRenaming) renaming);
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }).start();
        }
    };
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) MessageConsole(org.eclipse.ui.console.MessageConsole) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) MessageConsoleStream(org.eclipse.ui.console.MessageConsoleStream) PropertyResult(jkind.api.results.PropertyResult) PartInitException(org.eclipse.ui.PartInitException) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) Renaming(jkind.api.results.Renaming) JKindResult(jkind.api.results.JKindResult) EObject(org.eclipse.emf.ecore.EObject) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

Renaming (jkind.api.results.Renaming)7 EObject (org.eclipse.emf.ecore.EObject)6 Action (org.eclipse.jface.action.Action)6 IAction (org.eclipse.jface.action.IAction)6 Counterexample (jkind.results.Counterexample)5 ComponentImplementation (org.osate.aadl2.ComponentImplementation)5 AgreeRenaming (com.rockwellcollins.atc.agree.analysis.AgreeRenaming)4 Layout (jkind.results.layout.Layout)4 IMenuManager (org.eclipse.jface.action.IMenuManager)4 MenuManager (org.eclipse.jface.action.MenuManager)4 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)3 AnalysisResult (jkind.api.results.AnalysisResult)3 PropertyResult (jkind.api.results.PropertyResult)3 MessageConsole (org.eclipse.ui.console.MessageConsole)3 CexExtractor (com.rockwellcollins.atc.agree.analysis.extentions.CexExtractor)2 CexExtractorRegistry (com.rockwellcollins.atc.agree.analysis.extentions.CexExtractorRegistry)2 TcgExtractor (com.rockwellcollins.atc.tcg.extensions.TcgExtractor)2 TcgExtractorRegistry (com.rockwellcollins.atc.tcg.extensions.TcgExtractorRegistry)2 TcgRenaming (com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming)2 IOException (java.io.IOException)2