CreatorCondictionDesacopledChannels.java 3.05 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
/*
* 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<Protocols> prot;
private String desacop = "";
private LinkedList<String> prot_imp;
private CreatorNamesOfProcessCSP creatNamePcsp;
private LinkedList<Instance> inst;
private String eventoprotocol1 = "";
private String eventoprotocol2 = "";
public CreatorCondictionDesacopledChannels(Instance i, LinkedList<Protocols> 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;
}
}