Blame view
BRIC/src/CREATOR_CONDICTIONS_RULES/CreatorInputFunction.java
5.5 KB
eeb5cac08
![]() |
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 |
/* * 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 */ //falta add mais coisas aqui public class CreatorInputFunction { private LinkedList<Instance> instance; private String creatorFunction = ""; private LinkedList<String> prot_imp_inputs; private LinkedList<Protocols> prot; private LinkedList<String> nomecanal; private String eventoprotocol1 = ""; private String eventoprotocol2 = ""; public CreatorInputFunction(LinkedList<Instance> i,LinkedList<Protocols> p){ this.instance = i; this.prot = p; nomecanal = new LinkedList<>(); nomecanal.add(p.get(0).getCanal().getName().replace(".","_")); nomecanal.add(p.get(1).getCanal().getName().replace(".","_")); prot_imp_inputs = new LinkedList<>(); //PROT_IMP prot_imp_inputs.add("PROT_IMP_"+ instance.get(0).getName() + "_"+nomecanal.get(0)); prot_imp_inputs.add("PROT_IMP_"+ instance.get(1).getName() + "_"+nomecanal.get(1)); //DUAL_PROT_IMP // prot_imp_inputs.add("DUAL_PROT_IMP_"+ instance.get(0).getName() + // "_"+p.get(0).getCanal().getName()); //prot_imp_inputs.add("DUAL_PROT_IMP_"+ instance.get(1).getName() + // "_"+p.get(1).getCanal().getName()); //PROT_IMP_RIO prot_imp_inputs.add("PROT_IMP_"+instance.get(0).getName()+"_"+ nomecanal.get(0)+"_R_IO_"+ nomecanal.get(1)); prot_imp_inputs.add("PROT_IMP_"+instance.get(1).getName()+"_"+ nomecanal.get(1)+"_R_IO_"+ nomecanal.get(0)); //DUAL_PROT_RIO prot_imp_inputs.add("DUAL_PROT_IMP_"+instance.get(0).getName()+"_"+ nomecanal.get(0)+"_R_IO_"+ nomecanal.get(1)); // prot_imp_inputs.add("DUAL_PROT_IMP_"+instance.get(1).getName()+"_"+ nomecanal.get(1)+"_R_IO_"+ nomecanal.get(0)); //pegando o nome do evento que passei por paramentro no protocolo int pr1, pr2, pr3, pr4; pr1 = p.get(0).getProtocol().indexOf("("); pr2 = p.get(0).getProtocol().lastIndexOf(")"); eventoprotocol1 = p.get(0).getProtocol().substring(pr1 + 1, pr2); pr3 = p.get(1).getProtocol().indexOf("("); pr4 = p.get(1).getProtocol().lastIndexOf(")"); eventoprotocol2 = p.get(1).getProtocol().substring(pr3 + 1, pr4); } public String creatorInputFunction() { int cont = 0; //função inputs creatorFunction = creatorFunction + " "; // verificação para o contrato creatorFunction = creatorFunction + " inputs( P ) = "; creatorFunction = creatorFunction + " \t let f = \t<"; for (Instance instance1 : instance) {// para cada objeto pertencente a lista inst, execute o que est[a logo a baixo creatorFunction = creatorFunction + " \t ( " + instance1.getName() + ", {| "; // coloca todos os canais de in associado com seus tipos. ex: {|c.1, c.2|} for (int i = 0; i < instance1.getIn().size(); i++) { if (i == instance1.getIn().size() - 1) { creatorFunction = creatorFunction + instance1.getIn().get(i).getEvento(); } else { creatorFunction = creatorFunction + instance1.getIn().get(i).getEvento() + ","; } } //if (cont == instance.size() - 1) { // creatorFunction = creatorFunction + " |})"; //} else { creatorFunction = creatorFunction + " |}),"; //} cont++; } creatorFunction = creatorFunction + " \t"; creatorFunction = creatorFunction + "("+ prot_imp_inputs.get(0)+"," +"inputs_PROT_IMP(" +instance.get(0).getName()+","+ eventoprotocol1+ ")),"; creatorFunction = creatorFunction + " \t"; creatorFunction = creatorFunction + "("+ prot_imp_inputs.get(1)+ ","+"inputs_PROT_IMP(" +instance.get(1).getName()+","+ eventoprotocol2+ ")),"; creatorFunction = creatorFunction + " \t"; creatorFunction = creatorFunction + "("+ prot_imp_inputs.get(2)+"," +"inputs_R_IO("+prot_imp_inputs.get(0) +","+eventoprotocol1+","+ eventoprotocol2+")),"; creatorFunction = creatorFunction + " \t"; creatorFunction = creatorFunction + "("+ prot_imp_inputs.get(3)+ ","+"inputs_R_IO("+prot_imp_inputs.get(1) +","+eventoprotocol2+","+ eventoprotocol1+")),"; creatorFunction = creatorFunction + " \t"; creatorFunction = creatorFunction + "("+ prot_imp_inputs.get(4)+","+ "outputs("+prot_imp_inputs.get(2)+")),"; creatorFunction = creatorFunction + " \t"; creatorFunction = creatorFunction + "("+ prot_imp_inputs.get(5)+ ","+"outputs("+prot_imp_inputs.get(3)+"))"; creatorFunction = creatorFunction + " \t > "; creatorFunction = creatorFunction + " \t within apply(f, P )"; creatorFunction = creatorFunction + " "; return creatorFunction; } } |