Blame view

BRIC/src/CSP_ANALYSE/ReadFileCSP.java 1.98 KB
eeb5cac08   Madiel de Souza Conserva Filho   first
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
  /*
   * To change this template, choose Tools | Templates
   * and open the template in the editor.
   */
  package CSP_ANALYSE;
  
  import LOGIC.Contract;
  import java.io.BufferedReader;
  import java.io.File;
  import java.io.FileReader;
  import java.io.FileWriter;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import javax.swing.JOptionPane;
  
  /**
   *
   * @author sarah
   */
  public class ReadFileCSP {
  
      private Contract contract;
      private double temp;
      
      public ReadFileCSP(Contract c) {
          contract = c;
      }
  
      public double getTemp() {
          return temp;
      }
  
      public void setTemp(double t) {
          this.temp = t;
      }
  
      public void saidaFDR() {
  
          setTemp(System.currentTimeMillis());
          
          FileWriter saida = null;
  
          File pegarpath = new File("path.txt");
          if (!pegarpath.exists()) {
              System.exit(-1);
          }
          try {
              //parte que pega o caminho fdr
              String path;
              BufferedReader pegarResultado = new BufferedReader(new FileReader(pegarpath));
              path = pegarResultado.readLine();
              //
              saida = new FileWriter(new File("fdrLog/"+contract.getName()+"_saida_"+getTemp()+".log"));
  
              PrintWriter d = new PrintWriter(saida);
              d.flush();
  
              String line;
              Process p = Runtime.getRuntime().exec(path + "./fdr2 batch -trace cspFiles/"+contract.getName()+".csp");
  
              BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
              //para pegar a mensagem que foi tipada corretamente
              while ((line = in.readLine()) != null) {
  
                  d.write(line + "
  ");
  
              }
  
              in.close();
              saida.close();
              d.close();
              p.waitFor();
              java.lang.System.out.println("Done.");
          } catch (Exception e) {
              e.printStackTrace();
              JOptionPane.showMessageDialog(null, "The path of FDR undefined");
          }
  
      }
  }