/* * 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 prot_imp_getChannel; //string com definição de pro_imp e seu canal private LinkedList prot; public CreatorChannelFunctionUnary(Instance i, LinkedList p) { this.instance = i; this.prot = p; //nomeando protocolos para função GET_CHANNEL prot_imp_getChannel = new LinkedList<>(); prot_imp_getChannel.add("PROT_IMP_" + instance.getName() + "_" + p.get(0).getCanal().getName()); prot_imp_getChannel.add("PROT_IMP_" + instance.getName() + "_" + p.get(1).getCanal().getName()); } public String creatorChannelFunction() { // CHANNELS, INPUTS AND OUTPUTS int cont = 0; //channels creatorChannel = creatorChannel + "\nGET_CHANNELS(P) ="; creatorChannel = creatorChannel + "\n \t let f ="; creatorChannel = creatorChannel + "\n \t < \n"; 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 + "\n\n"; creatorChannel = creatorChannel + "\t"; //definição dos canais dos protocolos //EX: PROT_IMP__ = {} creatorChannel = creatorChannel + "(" + prot_imp_getChannel.get(0) + ",{" + prot.get(0).getCanal().getName() + "}),"; creatorChannel = creatorChannel + "\n\n\t"; creatorChannel = creatorChannel + "(" + prot_imp_getChannel.get(1) + ",{" + prot.get(1).getCanal().getName() + "})"; creatorChannel = creatorChannel + " \t > \n"; creatorChannel = creatorChannel + "\n \t within apply(f,P )"; return creatorChannel; } }