ae8f0d8553ef34883806707ab557394fd0df5b46.svn-base 4.87 KB
   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
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package CREATOR_CONDICTIONS_RULES;

import LOGIC.Instance;
import LOGIC.Protocols;
import java.util.LinkedList;

/**
*
* @author sarah
*/
public class CreatorOutputFunction {
private LinkedList<Instance> instance;
private String creatorFunction = "";
private LinkedList<String> prot_imp_outputs;
private LinkedList<Protocols> prot;
private LinkedList<String> pegarProtRIO;
private CreatorNamesOfProcessCSP creatNamePcsp;
public CreatorOutputFunction(LinkedList<Instance> i,LinkedList<Protocols> p){
this.instance = i;
this.prot = p;
pegarProtRIO = new LinkedList<>();
creatNamePcsp = new CreatorNamesOfProcessCSP(i, p);
prot_imp_outputs = new LinkedList<>();
//esse comportamento pode ser manual, pois a ferramenta recebe
//sempre dois componentes
prot_imp_outputs.add("PROT_IMP_"+ instance.get(0).getName() +
"_"+p.get(0).getCanal().getName());
prot_imp_outputs.add("PROT_IMP_"+ instance.get(1).getName() +
"_"+p.get(1).getCanal().getName());
//
prot_imp_outputs.add("PROT_IMP_"+instance.get(0).getName()+
"_"+p.get(0).getCanal().getName()+"_R_IO_"
+p.get(1).getCanal().getName());
prot_imp_outputs.add("PROT_IMP_"+instance.get(1).getName()+
"_"+p.get(1).getCanal().getName()+"_R_IO_"+
p.get(0).getCanal().getName());
//
prot_imp_outputs.add("DUAL_PROT_IMP_"+instance.get(0).getName()+
"_"+p.get(0).getCanal().getName()+"_R_IO_"+
p.get(1).getCanal().getName());
//
prot_imp_outputs.add("DUAL_PROT_IMP_"+instance.get(1).getName()+
"_"+p.get(1).getCanal().getName()+"_R_IO_"+
p.get(0).getCanal().getName());
}
public String creatorOutputFunction() {
pegarProtRIO = creatNamePcsp.CreatorProt_RIO();
int cont = 0;
//função outputs
creatorFunction = creatorFunction + "\n outputs( P ) = ";
creatorFunction = creatorFunction + "\n \t let f =\n\t < ";
for (Instance instance1 : instance) {// para cada objeto pertencente a lista inst, execute o que est[a logo a baixo
creatorFunction = creatorFunction + "\n\t ( " + instance1.getName() + ", {| ";
// coloca todos os canais de out associado com seus tipos. ex: {|c.1, c.2|}
for (int i = 0; i < instance1.getOut().size(); i++) {
if (i == instance1.getOut().size() - 1) {
creatorFunction = creatorFunction + instance1.getOut().get(i).getEvento();
} else {
creatorFunction = creatorFunction + instance1.getOut().get(i).getEvento() + ",";
}

}

//if (cont == instance.size() - 1) {
// creatorFunction = creatorFunction + " |})";
//} else {
creatorFunction = creatorFunction + " |}),";
//}
cont++;
}
creatorFunction = creatorFunction + "\n\t";
creatorFunction = creatorFunction + "("+ prot_imp_outputs.get(0)+","+
"outputs_PROT_IMP("
+instance.get(0).getName()+","+prot.get(0).getCanal().getName()+
")),";
creatorFunction = creatorFunction + "\n\n\t";
creatorFunction = creatorFunction + "("+ prot_imp_outputs.get(1)+","
+"outputs_PROT_IMP("
+instance.get(1).getName()+","+prot.get(1).getCanal().getName()+
")),";
creatorFunction = creatorFunction + "\n\n\t";
creatorFunction = creatorFunction + "("+ prot_imp_outputs.get(2)+","+
"outputs_R_IO("+instance.get(0).getName()
+","+prot.get(0).getCanal().getName()+","+
prot.get(1).getCanal().getName()+")),";
creatorFunction = creatorFunction + "\n\n\t";
creatorFunction = creatorFunction + "("+ prot_imp_outputs.get(3)+","
+"outputs_R_IO("+instance.get(0).getName()
+","+prot.get(1).getCanal().getName()+","+
prot.get(0).getCanal().getName()+")),";
creatorFunction = creatorFunction + "\n\n\t";
creatorFunction = creatorFunction + "("+ prot_imp_outputs.get(4)+
","+"inputs("+pegarProtRIO.get(0)+")),";
creatorFunction = creatorFunction + "\n\n\t";
creatorFunction = creatorFunction + "("+ prot_imp_outputs.get(5)+
","+"inputs("+pegarProtRIO.get(1)+"))";
creatorFunction = creatorFunction + "\n \t > \n";
creatorFunction = creatorFunction + "\n \t within apply(f, P )";
creatorFunction = creatorFunction + "\n\n";

return creatorFunction;
}
}