~workcraft/workcraft/2.0

« back to all changes in this revision

Viewing changes to Workcraft/src/org/workcraft/plugins/interop/Unfolder.java

  • Committer: Arseniy Alekseyev
  • Date: 2010-10-18 11:14:57 UTC
  • mfrom: (471.1.17 Workcraft)
  • Revision ID: rotsor@gmail.com-20101018111457-0o4t6lj1oh7upfx1
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.workcraft.plugins.interop;
2
 
 
3
 
import java.io.File;
4
 
import java.io.IOException;
5
 
 
6
 
import org.workcraft.plugins.shared.tasks.ExternalProcessResult;
7
 
import org.workcraft.plugins.shared.tasks.PunfTask;
8
 
import org.workcraft.tasks.Result;
9
 
import org.workcraft.tasks.TaskManager;
10
 
import org.workcraft.tasks.Result.Outcome;
11
 
 
12
 
// TODO: Merge with new Punf wrappers and remove this class
13
 
public class Unfolder {
14
 
        public static void makeUnfolding(TaskManager taskManager, File original, File unfolding) throws IOException
15
 
        {
16
 
                PunfTask task = new PunfTask(original.getAbsolutePath(), unfolding.getAbsolutePath());
17
 
                
18
 
                Result<? extends ExternalProcessResult> res = taskManager.execute(task, "Unfolding the Balsa circuit STG");
19
 
                
20
 
                System.out.println("Unfolding output: ");
21
 
                System.out.write(res.getReturnValue().getOutput());System.out.println();System.out.println("----------------------------------------");
22
 
                
23
 
                byte[] errors = res.getReturnValue().getErrors();
24
 
 
25
 
                if(errors.length > 0)
26
 
                {
27
 
                        System.out.println("Unfolding errors stream: ");
28
 
                        System.out.write(errors);System.out.println();System.out.println("----------------------------------------");
29
 
                }
30
 
 
31
 
                Outcome outcome = res.getOutcome();
32
 
                switch(outcome)
33
 
                {
34
 
                case CANCELLED:
35
 
                        throw new RuntimeException("Unfolding operation cancelled by user");
36
 
                case FINISHED:
37
 
                        return;
38
 
                case FAILED:
39
 
                        throw new RuntimeException("Punf failed: " + new String(res.getReturnValue().getErrors()), res.getCause());
40
 
                }
41
 
        }
42
 
}