Search in sources :

Example 1 with Counterexample

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

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

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

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

the class ExportAction method buildCounterexample.

private static Counterexample buildCounterexample(final AGREESimulationState engineState) {
    assert engineState != null;
    final Counterexample cex = new Counterexample(engineState.getNumberOfFrames());
    populateCounterexample(cex, engineState.getRootElements(), engineState);
    return cex;
}
Also used : Counterexample(jkind.results.Counterexample)

Example 5 with Counterexample

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

the class TcgXmlReader method constructTests.

public List<TestCase> constructTests(List<Element> testElements) {
    List<TestCase> testCases = new ArrayList<>();
    for (Element elem : testElements) {
        String name = elem.getAttribute("name");
        String description = getTextElement(elem, "Description");
        int length = Integer.parseInt(getTextElement(elem, "Length"));
        Counterexample cex = getCounterexample(elem, length);
        TestCase tc = new TestCase(name, description, cex);
        testCases.add(tc);
    }
    return testCases;
}
Also used : TestCase(com.rockwellcollins.atc.tcg.suite.TestCase) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) Counterexample(jkind.results.Counterexample)

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