Search in sources :

Example 6 with JRealizabilityResult

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

the class VerifyHandler method doAnalysis.

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;
                }
            }
            try {
                activateTerminateHandlers(globalMonitor);
                KindApi api = PreferencesUtil.getKindApi();
                KindApi consistApi = PreferencesUtil.getConsistencyApi();
                JRealizabilityApi realApi = PreferencesUtil.getJRealizabilityApi();
                while (!queue.isEmpty() && !globalMonitor.isCanceled()) {
                    JKindResult result = queue.peek();
                    NullProgressMonitor subMonitor = new NullProgressMonitor();
                    monitorRef.set(subMonitor);
                    Program program = linker.getProgram(result);
                    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);
                        // System.out.println("******** JKind Output ********");
                        // System.out.println(result.getText());
                        // System.out.println("******** Agree Lustre ********");
                        // System.out.println(program);
                        String errStr = e.getMessage();
                        int l = Math.min(errStr.length(), 300);
                        System.out.println(e.getMessage().substring(0, l));
                        // >>>>>>> origin/develop
                        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();
                }
            } finally {
                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) 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 7 with JRealizabilityResult

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

the class TestCaseGeneratorResultLabelProvider method getText.

@Override
public String getText(Object element) {
    if (element instanceof PropertyResult) {
        PropertyResult pr = (PropertyResult) element;
        switch(column) {
            case PROPERTY:
                if (pr.getName().equals(Util.REALIZABLE)) {
                    return pr.getParent().getName();
                } else {
                    return pr.getName();
                }
            case RESULT:
                Status tcgStatus = StatusToTcgStatus.get(pr.getStatus());
                String tcgStatusString = TcgStatusToTcgStatusString.get(tcgStatus);
                switch(tcgStatus) {
                    case WAITING:
                        return tcgStatusString;
                    case WORKING:
                        return tcgStatusString + "..." + getProgress(pr) + " (" + pr.getElapsed() + "s)";
                    default:
                        return getFinalStatus(pr) + " (" + pr.getElapsed() + "s)";
                }
        }
    } else if (element instanceof JRealizabilityResult) {
        JRealizabilityResult result = (JRealizabilityResult) element;
        return getText(result.getPropertyResult());
    } else if (element instanceof AnalysisResult) {
        AnalysisResult result = (AnalysisResult) element;
        switch(column) {
            case PROPERTY:
                return result.getName();
            case RESULT:
                return TcgResultsUtil.getMultiStatus(result).toString();
        }
    }
    return "";
}
Also used : Status(jkind.api.results.Status) JRealizabilityResult(jkind.api.results.JRealizabilityResult) PropertyResult(jkind.api.results.PropertyResult) AnalysisResult(jkind.api.results.AnalysisResult)

Aggregations

JRealizabilityResult (jkind.api.results.JRealizabilityResult)7 ConsistencyResult (com.rockwellcollins.atc.agree.analysis.ConsistencyResult)6 JKindResult (jkind.api.results.JKindResult)6 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)5 AgreeProgram (com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram)4 JKindException (jkind.JKindException)4 JKindApi (jkind.api.JKindApi)4 JRealizabilityApi (jkind.api.JRealizabilityApi)4 KindApi (jkind.api.KindApi)4 Program (jkind.lustre.Program)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 AgreeLayout (com.rockwellcollins.atc.agree.analysis.AgreeLayout)3 AgreeRenaming (com.rockwellcollins.atc.agree.analysis.AgreeRenaming)3 AgreeAutomater (com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater)3 AgreeAutomaterRegistry (com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry)3 ArrayList (java.util.ArrayList)3 Node (jkind.lustre.Node)3 PartInitException (org.eclipse.ui.PartInitException)3 ComponentImplementation (org.osate.aadl2.ComponentImplementation)3 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)2