Search in sources :

Example 1 with KindApi

use of jkind.api.KindApi in project AGREE by loonwerks.

the class PreferencesUtil method getConsistencyApi.

public static KindApi getConsistencyApi() {
    KindApi api = getKindApi();
    if (api instanceof JKindApi) {
        IPreferenceStore prefs = getPreferenceStore();
        int depth = prefs.getInt(PreferenceConstants.PREF_CONSIST_DEPTH) + 1;
        ((JKindApi) api).setN(depth);
        ((JKindApi) api).setPdrMax(0);
        if (prefs.getBoolean(PreferenceConstants.PREF_SUPPORT)) {
            ((JKindApi) api).setIvcReduction();
        }
    }
    return api;
}
Also used : KindApi(jkind.api.KindApi) JKindApi(jkind.api.JKindApi) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) JKindApi(jkind.api.JKindApi)

Example 2 with KindApi

use of jkind.api.KindApi in project AGREE by loonwerks.

the class VerifyHandler method doAnalysis.

protected IStatus doAnalysis(final Element root, final IProgressMonitor monitor) {
    Thread analysisThread = new Thread() {

        @Override
        public void run() {
            activateTerminateHandler(monitor);
            KindApi api = PreferencesUtil.getKindApi();
            while (!queue.isEmpty() && !monitor.isCanceled()) {
                JKindResult result = queue.peek();
                NullProgressMonitor subMonitor = new NullProgressMonitor();
                monitorRef.set(subMonitor);
                TcgRenaming tcgRenaming = (TcgRenaming) linker.getRenaming(result);
                Program ufcProgram = constructUfcProgram(linker.getProgram(result), tcgRenaming);
                ufcProgram.getMainNode().properties.forEach(p -> result.addProperty(p));
                writeIntermediateFiles(linker.getProgram(result), ufcProgram);
                try {
                    System.out.println("Calling jkind...");
                    api.execute(ufcProgram, result, monitor);
                    System.out.println("executed API...");
                    TestSuite testSuite = TestSuiteUtils.testSuiteFromJKindResult(result, linker.getComponent(result).getQualifiedName(), result.getName(), result.getText(), tcgRenaming);
                    emitResult(testSuite);
                // showSuiteView(testSuite, linker);
                } catch (JKindException e) {
                    System.out.println(result.getText());
                    System.out.println("******** Error Occurred: HERE IS THE LUSTRE ********");
                    System.out.println(linker.getProgram(result));
                    break;
                } finally {
                    deactivateTerminateHandler();
                    System.out.println("UFC generation complete");
                }
                queue.remove();
            }
        }
    };
    analysisThread.start();
    return Status.OK_STATUS;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Program(jkind.lustre.Program) JKindException(jkind.JKindException) TestSuite(com.rockwellcollins.atc.tcg.suite.TestSuite) KindApi(jkind.api.KindApi) TcgRenaming(com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming) JKindResult(jkind.api.results.JKindResult)

Example 3 with KindApi

use of jkind.api.KindApi in project AMASE by loonwerks.

the class PreferencesUtil method getKindApi.

public static KindApi getKindApi() {
    IPreferenceStore prefs = getPreferenceStore();
    String modelChecker = prefs.getString(PreferenceConstants.PREF_MODEL_CHECKER);
    String remoteUrl = prefs.getString(PreferenceConstants.PREF_REMOTE_URL);
    KindApi api = getKindApi(modelChecker, remoteUrl);
    if (prefs.getBoolean(PreferenceConstants.PREF_DEBUG)) {
        api.setApiDebug();
    }
    if (api instanceof JKindApi) {
        ((JKindApi) api).setAllIvcs();
    }
    return api;
}
Also used : KindApi(jkind.api.KindApi) JKindApi(jkind.api.JKindApi) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) JKindApi(jkind.api.JKindApi)

Example 4 with KindApi

use of jkind.api.KindApi in project AMASE by loonwerks.

the class FaultsVerifyAllHandler method doAnalysis.

@Override
protected IStatus doAnalysis(final Element root, final IProgressMonitor globalMonitor) {
    Thread analysisThread = new Thread() {

        @Override
        public void run() {
            // Record the analysis start time and get model hashcode for
            // saving to property analysis log, if necessary
            String modelHash = "";
            long startTime = 0;
            if (Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_PROP_LOG)) {
                try {
                    modelHash = AgreeFileUtil.getModelHashcode(root);
                    startTime = System.currentTimeMillis();
                } catch (Exception e) {
                    System.out.println(e.getMessage());
                    return;
                }
            }
            activateTerminateHandlers(globalMonitor);
            KindApi api = PreferencesUtil.getKindApi();
            KindApi consistApi = PreferencesUtil.getConsistencyApi();
            JRealizabilityApi realApi = PreferencesUtil.getJRealizabilityApi();
            // Due to the way the queue is constructed in traversal,
            // reversing the queue will result in subcomponent instances
            // being analyzed prior to their enclosing component instance.
            // Reverse the queue using a stack.
            {
                Stack<JKindResult> stack = new Stack<>();
                while (!queue.isEmpty()) {
                    stack.push(queue.remove());
                }
                while (!stack.empty()) {
                    queue.add(stack.pop());
                }
            }
            while (!queue.isEmpty() && !globalMonitor.isCanceled()) {
                JKindResult result = queue.peek();
                NullProgressMonitor subMonitor = new NullProgressMonitor();
                monitorRef.set(subMonitor);
                Program program = doFaultPropagationInjection(result, linker.getProgram(result));
                linker.setProgram(result, program);
                if (api instanceof JKindApi) {
                    String resultName = result.getName();
                    String adviceFileName = rerunAdviceMap.get(resultName);
                    if (adviceFileName == null) {
                        adviceFileName = "agree_advice" + adviceCount++;
                        rerunAdviceMap.put(resultName, adviceFileName);
                    } else {
                        ((JKindApi) api).setReadAdviceFile(adviceFileName);
                    }
                    ((JKindApi) api).setWriteAdviceFile(adviceFileName);
                }
                try {
                    if (result instanceof ConsistencyResult) {
                        consistApi.execute(program, result, subMonitor);
                    } else if (result instanceof JRealizabilityResult) {
                        realApi.execute(program, (JRealizabilityResult) result, subMonitor);
                    } else {
                        api.execute(program, result, subMonitor);
                    }
                } catch (JKindException e) {
                    System.out.println("******** JKindException Text ********");
                    e.printStackTrace(System.out);
                    String errStr = e.getMessage();
                    int l = Math.min(errStr.length(), 300);
                    System.out.println(e.getMessage().substring(0, l));
                    break;
                }
                // Print to property analysis log, if necessary
                if (Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_PROP_LOG)) {
                    AgreeFileUtil.printLog(result, startTime, modelHash);
                }
                queue.remove();
            }
            while (!queue.isEmpty()) {
                queue.remove().cancel();
            }
            AddFaultsToAgree.resetStaticVars();
            deactivateTerminateHandlers();
            enableRerunHandler(root);
        }
    };
    analysisThread.start();
    return Status.OK_STATUS;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) JRealizabilityResult(jkind.api.results.JRealizabilityResult) Program(jkind.lustre.Program) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram) JKindException(jkind.JKindException) PartInitException(org.eclipse.ui.PartInitException) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) JKindException(jkind.JKindException) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException) Stack(java.util.Stack) SafetyJKindResult(edu.umn.cs.crisys.safety.analysis.results.SafetyJKindResult) JKindResult(jkind.api.results.JKindResult) JKindApi(jkind.api.JKindApi) JRealizabilityApi(jkind.api.JRealizabilityApi) ConsistencyResult(com.rockwellcollins.atc.agree.analysis.ConsistencyResult) KindApi(jkind.api.KindApi) JKindApi(jkind.api.JKindApi)

Example 5 with KindApi

use of jkind.api.KindApi in project AMASE by loonwerks.

the class PreferencesUtil method getConsistencyApi.

public static KindApi getConsistencyApi() {
    KindApi api = getKindApi();
    if (api instanceof JKindApi) {
        IPreferenceStore prefs = getPreferenceStore();
        int depth = prefs.getInt(PreferenceConstants.PREF_CONSIST_DEPTH) + 1;
        ((JKindApi) api).setN(depth);
        ((JKindApi) api).disableInvariantGeneration();
        // ((JKindApi) api).disableKInduction();
        ((JKindApi) api).setPdrMax(0);
    }
    return api;
}
Also used : KindApi(jkind.api.KindApi) JKindApi(jkind.api.JKindApi) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) JKindApi(jkind.api.JKindApi)

Aggregations

KindApi (jkind.api.KindApi)10 JKindApi (jkind.api.JKindApi)8 JKindException (jkind.JKindException)5 JKindResult (jkind.api.results.JKindResult)5 Program (jkind.lustre.Program)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)4 ConsistencyResult (com.rockwellcollins.atc.agree.analysis.ConsistencyResult)3 AgreeProgram (com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram)3 JRealizabilityApi (jkind.api.JRealizabilityApi)3 JRealizabilityResult (jkind.api.results.JRealizabilityResult)3 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)2 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)2 PartInitException (org.eclipse.ui.PartInitException)2 TcgRenaming (com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming)1 TestSuite (com.rockwellcollins.atc.tcg.suite.TestSuite)1 SimulationProgram (edu.uah.rsesc.aadlsimulator.agree.SimulationProgram)1 SimulationProperty (edu.uah.rsesc.aadlsimulator.agree.SimulationProperty)1 FTResolveVisitor (edu.umn.cs.crisys.safety.analysis.ast.visitors.FTResolveVisitor)1 PrintUtils (edu.umn.cs.crisys.safety.analysis.ast.visitors.PrintUtils)1