Blame view
BRIC/src/CREATOR_CONDICTIONS_RULES/CreatorChannelFunctionUnary.java
3.16 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 |
/* * 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 */ class CreatorChannelFunctionUnary { private Instance instance; private String creatorChannel = ""; private LinkedList<String> prot_imp_getChannel; //string com definição de pro_imp e seu canal private LinkedList<Protocols> prot; private LinkedList<String> nomecanal; private String eventoprotocol1 = ""; private String eventoprotocol2 = ""; public CreatorChannelFunctionUnary(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(".", "_")); //nomeando protocolos para função GET_CHANNEL prot_imp_getChannel = new LinkedList<>(); prot_imp_getChannel.add("PROT_IMP_" + instance.getName() + "_" + nomecanal.get(0)); prot_imp_getChannel.add("PROT_IMP_" + instance.getName() + "_" + nomecanal.get(1)); //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 creatorChannelFunction() { // CHANNELS, INPUTS AND OUTPUTS int cont = 0; //channels creatorChannel = creatorChannel + " GET_CHANNELS(P) ="; creatorChannel = creatorChannel + " \t let f ="; creatorChannel = creatorChannel + " \t < "; creatorChannel = creatorChannel + "\t(" + instance.getName() + ", { "; for (int j = 0; j < instance.getChannel().size(); j++) { if (j == instance.getChannel().size() - 1) { creatorChannel = creatorChannel + instance.getChannel().get(j).getName(); } else { creatorChannel = creatorChannel + instance.getChannel().get(j).getName() + ","; } } cont++; creatorChannel = creatorChannel + " }),"; creatorChannel = creatorChannel + " "; creatorChannel = creatorChannel + "\t"; //definição dos canais dos protocolos //EX: PROT_IMP_<contract>_<channel> = {<channel>} creatorChannel = creatorChannel + "(" + prot_imp_getChannel.get(0) + ",{" + eventoprotocol1 + "}),"; creatorChannel = creatorChannel + " \t"; creatorChannel = creatorChannel + "(" + prot_imp_getChannel.get(1) + ",{" + eventoprotocol2 + "})"; creatorChannel = creatorChannel + " \t > "; creatorChannel = creatorChannel + " \t within apply(f,P )"; return creatorChannel; } } |