/* * 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 CreatorCondictionDesacopledChannels { private Instance instance; private LinkedList prot; private String desacop = ""; private LinkedList prot_imp; private CreatorNamesOfProcessCSP creatNamePcsp; private LinkedList inst; private String eventoprotocol1 = ""; private String eventoprotocol2 = ""; public CreatorCondictionDesacopledChannels(Instance i, LinkedList listProtocols) { instance = i; inst = new LinkedList<>(); inst.add(i); prot = listProtocols; creatNamePcsp = new CreatorNamesOfProcessCSP(inst, prot); //prot_imp.add("PROT_IMP_" + i.getName() + "_" + i.getChannel().get(0).getName()); //prot_imp.add("PROT_IMP_" + i.getName() + "_" + i.getChannel().get(1).getName()); //pegando o nome do evento que passei por paramentro no protocolo int pr1, pr2, pr3, pr4; pr1 = listProtocols.get(0).getProtocol().indexOf("("); pr2 = listProtocols.get(0).getProtocol().lastIndexOf(")"); eventoprotocol1 = listProtocols.get(0).getProtocol().substring(pr1 + 1, pr2); pr3 = listProtocols.get(1).getProtocol().indexOf("("); pr4 = listProtocols.get(1).getProtocol().lastIndexOf(")"); eventoprotocol2 = listProtocols.get(1).getProtocol().substring(pr3 + 1, pr4); } public String condictionDesacopledChannels() { /*desacop = desacop + "assert INTER_PROT_IMP(" + prot_imp.get(0) + ", {" + prot.get(0).getCanal().getName() + ", " + prot.get(1).getCanal().getName() + "}) [F= PROJECTION(" + instance.getName() + ", {" + prot.get(0).getCanal().getName() + ", " + prot.get(1).getCanal().getName() + "})"; desacop = desacop + "\n\n"; desacop = desacop + "assert PROJECTION(" + instance.getName() + ", {" + prot.get(0).getCanal().getName() + ", " + prot.get(1).getCanal().getName() + "}) [FD= INTER_PROT_IMP(" + prot_imp.get(0) + ", {" + prot.get(0).getCanal().getName() + ", " + prot.get(1).getCanal().getName() + "})"; */ prot_imp = creatNamePcsp.CreatorProt_Name_Unary(); desacop = desacop + "assert " + prot_imp.get(0) + " ||| " + prot_imp.get(1) + " [F= PROJECTION(" + instance.getName() + ", {" + eventoprotocol1 + ", " + eventoprotocol2 + "})"; desacop = desacop + "\n\n"; desacop = desacop + "assert PROJECTION(" + instance.getName() + ", {" + eventoprotocol1 + ", " + eventoprotocol2 + "}) [FD= " + prot_imp.get(0) + " ||| " + prot_imp.get(1); desacop = desacop + "\n"; return desacop; } }