Search in sources :

Example 1 with ITraceWindow

use of edu.cmu.cs.hcii.cogtool.ui.Interaction.ITraceWindow in project cogtool by cogtool.

the class ProjectController method displayTraces.

protected void displayTraces(AUndertaking task, Design design) {
    if (task.isTaskGroup()) {
        Iterator<AUndertaking> allSubtasks = ((TaskGroup) task).getUndertakings().iterator();
        while (allSubtasks.hasNext()) {
            displayTraces(allSubtasks.next(), design);
        }
    } else {
        TaskApplication taskApp = project.getTaskApplication(task, design);
        if (taskApp != null) {
            StringBuilder labelText = new StringBuilder();
            Iterator<CognitiveModelGenerator> modelGens = taskApp.getModelGenerators();
            while (modelGens.hasNext()) {
                CognitiveModelGenerator modelGen = modelGens.next();
                Iterator<IPredictionAlgo> computeAlgs = taskApp.getPredictionAlgs(modelGen);
                while (computeAlgs.hasNext()) {
                    IPredictionAlgo computeAlg = computeAlgs.next();
                    APredictionResult result = taskApp.getResult(modelGen, computeAlg);
                    int resultState = result.getResultState();
                    if ((result != null) && ((resultState == APredictionResult.IS_COMPUTED) || (resultState == APredictionResult.COMPUTE_FAILED))) {
                        labelText.delete(0, labelText.length());
                        labelText.append(tracesWindowLabel);
                        labelText.append(": ");
                        labelText.append(project.getName());
                        labelText.append(" > ");
                        labelText.append(design.getName());
                        labelText.append(" > ");
                        labelText.append(task.getName());
                        String labelStr = labelText.toString();
                        ITraceWindow traceWin = interaction.createTraceWindow(labelStr + (OSUtils.MACOSX ? "" : UI.WINDOW_TITLE), null, labelStr);
                        traceWin.appendOutputLines(result.getTraceLines());
                        traceWin.scrollToTop();
                        traceWin.appendErrorLines(result.getErrorLines());
                        traceWin.scrollToTop();
                    }
                }
            }
        }
    }
}
Also used : IPredictionAlgo(edu.cmu.cs.hcii.cogtool.model.IPredictionAlgo) ITraceWindow(edu.cmu.cs.hcii.cogtool.ui.Interaction.ITraceWindow) AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking) APredictionResult(edu.cmu.cs.hcii.cogtool.model.APredictionResult) TaskApplication(edu.cmu.cs.hcii.cogtool.model.TaskApplication) CognitiveModelGenerator(edu.cmu.cs.hcii.cogtool.model.CognitiveModelGenerator) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint)

Example 2 with ITraceWindow

use of edu.cmu.cs.hcii.cogtool.ui.Interaction.ITraceWindow in project cogtool by cogtool.

the class SNIFACTCmd method computeInBackground.

public static SNIFACTExecContext computeInBackground(Project project, Design design, Interaction interaction, TaskGroup group, SNIFACTParameters parms) {
    isComputing = true;
    try {
        SNIFACTAnalysisWorkThread workThread = new SNIFACTAnalysisWorkThread(SNIFACTPredictionAlgo.ONLY, project, design, null, interaction, group, parms);
        if (SNIFACTPredictionAlgo.exportCTEModelFile != null) {
            return null;
        }
        ITraceWindow traceWin = interaction.createTraceWindow("Computation trace", workThread, "Trace output: stdout (top) and stderr (bottom)");
        workThread.setTraceWindow(traceWin);
        ThreadManager.startNewThread(workThread);
        return workThread.getExecContext();
    } catch (IPredictionAlgo.ComputationException ex) {
        throw new RcvrComputationException(ex);
    } catch (IllegalStateException ex) {
        throw new RcvrIllegalStateException(ex);
    } catch (UnsupportedOperationException ex) {
        throw new RcvrUnimplementedFnException(ex);
    } catch (Exception ex) {
        throw new RcvrComputationException(ex);
    }
}
Also used : RcvrIllegalStateException(edu.cmu.cs.hcii.cogtool.util.RcvrIllegalStateException) IPredictionAlgo(edu.cmu.cs.hcii.cogtool.model.IPredictionAlgo) ITraceWindow(edu.cmu.cs.hcii.cogtool.ui.Interaction.ITraceWindow) RcvrIllegalStateException(edu.cmu.cs.hcii.cogtool.util.RcvrIllegalStateException) RcvrUnimplementedFnException(edu.cmu.cs.hcii.cogtool.util.RcvrUnimplementedFnException) RcvrComputationException(edu.cmu.cs.hcii.cogtool.util.RcvrComputationException) RcvrComputationException(edu.cmu.cs.hcii.cogtool.util.RcvrComputationException) RcvrUnimplementedFnException(edu.cmu.cs.hcii.cogtool.util.RcvrUnimplementedFnException) RcvrIllegalStateException(edu.cmu.cs.hcii.cogtool.util.RcvrIllegalStateException)

Example 3 with ITraceWindow

use of edu.cmu.cs.hcii.cogtool.ui.Interaction.ITraceWindow in project cogtool by cogtool.

the class ComputePredictionCmd method computeInBackground.

/**
     * Perform the analysis in the background.  Set the result when done.
     */
public static APredictionResult computeInBackground(IPredictionAlgo computeAlg, Script s, Interaction interact) {
    try {
        DefaultAnalysisWorkThread workThread = new DefaultAnalysisWorkThread(computeAlg, s, null, interact);
        ITraceWindow traceWin = interact.createTraceWindow("Computation trace", workThread, "Trace output: stdout (top) and stderr (bottom)");
        workThread.setTraceWindow(traceWin);
        ThreadManager.startNewThread(workThread);
        return workThread.getResultProxy();
    } catch (IPredictionAlgo.ComputationException ex) {
        throw new RcvrComputationException(ex);
    } catch (IllegalStateException ex) {
        throw new RcvrIllegalStateException(ex);
    } catch (UnsupportedOperationException ex) {
        throw new RcvrUnimplementedFnException(ex);
    } catch (Exception ex) {
        throw new RcvrComputationException(ex);
    }
}
Also used : RcvrIllegalStateException(edu.cmu.cs.hcii.cogtool.util.RcvrIllegalStateException) IPredictionAlgo(edu.cmu.cs.hcii.cogtool.model.IPredictionAlgo) ITraceWindow(edu.cmu.cs.hcii.cogtool.ui.Interaction.ITraceWindow) RcvrIllegalStateException(edu.cmu.cs.hcii.cogtool.util.RcvrIllegalStateException) RcvrUnimplementedFnException(edu.cmu.cs.hcii.cogtool.util.RcvrUnimplementedFnException) RcvrComputationException(edu.cmu.cs.hcii.cogtool.util.RcvrComputationException) RcvrComputationException(edu.cmu.cs.hcii.cogtool.util.RcvrComputationException) RcvrParsingException(edu.cmu.cs.hcii.cogtool.util.RcvrParsingException) RcvrUnimplementedFnException(edu.cmu.cs.hcii.cogtool.util.RcvrUnimplementedFnException) RcvrIllegalStateException(edu.cmu.cs.hcii.cogtool.util.RcvrIllegalStateException)

Aggregations

IPredictionAlgo (edu.cmu.cs.hcii.cogtool.model.IPredictionAlgo)3 ITraceWindow (edu.cmu.cs.hcii.cogtool.ui.Interaction.ITraceWindow)3 RcvrComputationException (edu.cmu.cs.hcii.cogtool.util.RcvrComputationException)2 RcvrIllegalStateException (edu.cmu.cs.hcii.cogtool.util.RcvrIllegalStateException)2 RcvrUnimplementedFnException (edu.cmu.cs.hcii.cogtool.util.RcvrUnimplementedFnException)2 APredictionResult (edu.cmu.cs.hcii.cogtool.model.APredictionResult)1 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)1 CognitiveModelGenerator (edu.cmu.cs.hcii.cogtool.model.CognitiveModelGenerator)1 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)1 TaskApplication (edu.cmu.cs.hcii.cogtool.model.TaskApplication)1 RcvrParsingException (edu.cmu.cs.hcii.cogtool.util.RcvrParsingException)1