Blame view

BRIC/src/CSP_ANALYSE/AnalyseFDR.java 9.42 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
  /*
   * To change this template, choose Tools | Templates
   * and open the template in the editor.
   */
  package CSP_ANALYSE;
  
  import CSP_CREATOR.CreatorContract;
  import CSP_CREATOR.CreatorInstance;
  import LOGIC.Contract;
  import LOGIC.Instance;
  import LOGIC.ObjectList;
  import java.io.BufferedReader;
  import java.io.File;
  import java.io.FileReader;
  import java.io.InputStreamReader;
  import java.util.ArrayList;
  import javax.swing.JOptionPane;
  
  /**
   *
   * @author forall
   */
  public class AnalyseFDR {
  
      private Contract contract;
      private ArrayList<FDRResult> resultadoFDR;
      private ArrayList<FDRResult> strongOutputDChannel;
      private CreatorContract creatC;
      private CreatorInstance creatI;
      private String strongOchannel = "";
      private ReadFileCSP readF;
      private ReturnMensageFDR mensagemFdr;
  
      public AnalyseFDR(Contract c, ObjectList l) {
          contract = c;
          resultadoFDR = new ArrayList<>();
          strongOutputDChannel = new ArrayList<>();
          creatC = new CreatorContract(c, l);
          readF = new ReadFileCSP(c);
          mensagemFdr = new ReturnMensageFDR(c);
      }
  
      public ArrayList<FDRResult> takeResultIOProcess() {
  
          readF.saidaFDR();
          // vai ler o arquivo saidaFDR.log verificando as condições de IOProcess
          File pegarSaida = new File("fdrLog/"+contract.getName()+"_saida_"+readF.getTemp()+".log");
          if (!pegarSaida.exists()) {
              System.exit(-1);
          }
          try {
  
              BufferedReader pegarResultado = new BufferedReader(new FileReader(pegarSaida));
              String line = "";
              while ((line = pegarResultado.readLine()) != null) {
  
                  if (line == null) {
                      FDRResult retorno = new FDRResult();
                      retorno.setMensagem("O arquivo CSP está com erro");
                      retorno.setResultado(false);
                      resultadoFDR.add(retorno);
  
                  } else if (line.equals("Checking Test(inter(inputs(" + contract.getName() + "),outputs(" + contract.getName() + ")) == {}) [T= ERROR")) {
                      line = pegarResultado.readLine();
                      if (line == null) {
                          FDRResult retorno = new FDRResult();
                          retorno.setMensagem("O arquivo CSP está com erro");
                          retorno.setResultado(false);
                          resultadoFDR.add(retorno);
                      } else {
                          FDRResult retorno = new FDRResult();
                          if (line.equals("true") || line.equals("xtrue")) {
  
                              retorno.setMensagem("Contract's Channels are I/O Channel");
                              retorno.setResultado(true);
                              resultadoFDR.add(retorno);
                          } else {
  
                              retorno.setMensagem("Contract's Channels aren't I/O Channel");
                              retorno.setResultado(false);
                              resultadoFDR.add(retorno);
                          }
                      }
  
                  } else if (line.equals("Checking HideAll(" + contract.getName() + ") :[divergence free [FD]]")) {
                      line = pegarResultado.readLine();
                      if (line == null) {
                          FDRResult retorno = new FDRResult();
                          retorno.setMensagem("O arquivo CSP está com erro");
                          retorno.setResultado(false);
                          resultadoFDR.add(retorno);
                      } else {
                          FDRResult retorno = new FDRResult();
                          if (line.equals("true") || line.equals("xtrue")) {
  
                              retorno.setMensagem("The Contract's behavior has Infinite Traces");
                              retorno.setResultado(true);
                              resultadoFDR.add(retorno);
                          } else {
  
                              retorno.setMensagem("The Contract's behavior doesn't have Infinite Traces");
                              retorno.setResultado(false);
                              resultadoFDR.add(retorno);
                          }
                      }
                  } else if (line.equals("Checking " + contract.getName() + " :[divergence free [FD]]")) {
                      line = pegarResultado.readLine();
                      if (line == null) {
                          FDRResult retorno = new FDRResult();
                          retorno.setMensagem("O arquivo CSP está com erro");
                          retorno.setResultado(false);
                          resultadoFDR.add(retorno);
                      } else {
                          FDRResult retorno = new FDRResult();
                          if (line.equals("true") || line.equals("xtrue")) {
  
                              retorno.setMensagem("The Contract's behavior is Divergence Free");
                              retorno.setResultado(true);
                              resultadoFDR.add(retorno);
  
                          } else {
  
                              retorno.setMensagem("The Contract's behavior isn't Divergence Free");
                              retorno.setResultado(false);
                              resultadoFDR.add(retorno);
                          }
                      }
                  } else if (line.equals("Checking LHS_InputDet(" + contract.getName() + ") [F= RHS_InputDet(" + contract.getName() + ")")) {
                      line = pegarResultado.readLine();
                      if (line == null) {
                          FDRResult retorno = new FDRResult();
                          retorno.setMensagem("O arquivo CSP está com erro");
                          retorno.setResultado(false);
                          resultadoFDR.add(retorno);
                      } else {
                          FDRResult retorno = new FDRResult();
                          if (line.equals("true") || line.equals("xtrue")) {
  
                              retorno.setMensagem("The Contract's behavior is input Deterministic");
                              retorno.setResultado(true);
                              resultadoFDR.add(retorno);
                          } else {
  
                              retorno.setMensagem("The Contract's behavior isn't input Deterministic");
                              retorno.setResultado(false);
                              resultadoFDR.add(retorno);
                          }
                      }
                  } else if (line.equals("Checking LHS_OutputDec_A(" + contract.getName() + ") [F= RHS_OutputDec_A(" + contract.getName() + ")")) {
                      line = pegarResultado.readLine();
                      if (line == null) {
                          FDRResult r = new FDRResult();
                          r.setMensagem("O arquivo CSP está com erro");
                          r.setResultado(false);
                          strongOutputDChannel.add(r);
                      } else {
  
                          FDRResult r = new FDRResult();
                          if (line.equals("true") || line.equals("xtrue")) {
  
                              r.setMensagem("The Contract's behavior is output decisive");
                              r.setResultado(true);
                              strongOutputDChannel.add(r);
                          } else {
  
                              r.setMensagem("The Contract's behavior isn't output decisive");
                              r.setResultado(false);
                              strongOutputDChannel.add(r);
                          }
                      }
  
                  } else if (line.contains("Checking LHS_OutputDec_B(")) {
  
                      line = pegarResultado.readLine();
                      if (line == null) {
                          FDRResult r = new FDRResult();
                          r.setMensagem("O arquivo CSP está com erro");
                          r.setResultado(false);
                          strongOutputDChannel.add(r);
                      } else {
                          FDRResult r = new FDRResult();
  
                          if (line.equals("true") || line.equals("xtrue")) {
  
                              r.setMensagem("The Contract is output decisive in channels");
                              r.setResultado(true);
                              strongOutputDChannel.add(r);
  
                          } else {
  
                              r.setMensagem("The Contract NOT is output decisive in channels");
                              r.setResultado(false);
                              strongOutputDChannel.add(r);
                          }
                      }
                  }
              }
  
  
          } catch (Exception e) {
              e.printStackTrace();
              JOptionPane.showMessageDialog(null, "error occurred in checking IO / Process");
          }
          resultadoFDR.add(StrongOutputIsTrue());
          //returnMensagefdr();
          resultadoFDR.add(mensagemFdr.returnMensagefdr());
         
          return resultadoFDR;
  
      }
  
      public FDRResult StrongOutputIsTrue() {
          FDRResult retorno = new FDRResult();
          for (int i = 0; i < strongOutputDChannel.size(); i++) {
              if ((!strongOutputDChannel.get(i).getResultado())) {
                  retorno.setMensagem("The Contract is NOT output decisive");
                  retorno.setResultado(false);
                  //resultadoFDR.add(retorno);
              } else {
                  retorno.setMensagem("The Contract is output decisive");
                  retorno.setResultado(true);
                  //resultadoFDR.add(retorno);
              }
          }
  
          //retorna o resultado do strongOutputDecisiviness
          return retorno;
      }
      
     
  }