CreatorUnaryRule.java 3.2 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
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package CREATOR_CONDICTIONS_RULES;

import CSP_CREATOR.CreatorTypesAndChannels;
import LOGIC.Channel;
import LOGIC.Instance;
import LOGIC.ObjectList;
import LOGIC.Protocols;
import java.util.LinkedList;

/**
*
* @author sarah
*/
public class CreatorUnaryRule {
private String rule;
private String pegaComposicao;
private LinkedList<Instance> instance;
private ObjectList obl;
private CreatorTypesAndChannels typechannels;
private CreatorRenameFunction renameFunction;
private CreatorChannelFunctionUnary channelFunction;
private CreatorInputFunctionUnary inputFunction;
private CreatorOutputFunctionUnary outputFunction;
public CreatorUnaryRule(Instance i, ObjectList ob, LinkedList<Protocols> p) {
instance = new LinkedList<>();
instance.add(i);

obl = ob;
typechannels = new CreatorTypesAndChannels(ob);
typechannels.creatorTypesChannels();
renameFunction = new CreatorRenameFunction(instance);
channelFunction = new CreatorChannelFunctionUnary(i, p);
inputFunction = new CreatorInputFunctionUnary(i,p);//Vai receber mais alguma coisa
outputFunction = new CreatorOutputFunctionUnary(i,p);
}

public String getRule() {
return rule;
}

public void setRule(String rule) {
this.rule = rule;
}

public String getPegaComposicao() {
return pegaComposicao;
}

public void setPegaComposicao(String pegaComposicao) {
this.pegaComposicao = pegaComposicao;
}

public void creatorUnaryCSP() {

setRule("");
setRule(getRule() + "include \"sequence_aux.csp\" \ninclude \"function_aux.csp\" \n"
+ "include \"auxiliar.csp\" \ninclude \"rules.csp\"");

setRule(getRule() + typechannels.getTypeChannel());
//não preciso de types e channels de contrato, pois estou declarando todos os tipos e canais do ObjectList
//no caso, todo canal q eu criar vai possuir algum tipo e canal dessa lista.

setRule(getRule() + "\n\n");
//comportamento
setRule(getRule() + instance.get(0).getContrato().getBehavior());

setRule(getRule() + "\n\n");
setRule(getRule() + "\n" + obl.getProcessosAuxiliares() + "\n\n");

//creatorRenameFunction();
setRule(getRule() + renameFunction.creatorRenameFunction());
//creatorChannelFunction();
setRule(getRule() + channelFunction.creatorChannelFunction());
// creatorInputFunction();
setRule(getRule() + inputFunction.creatorInputFunction());
//creatorOutputFunction();
setRule(getRule() + outputFunction.creatorOutputFunction());
}
public void channelInstanciation(Channel Canal) {

setRule(getRule() + "\nchannel " + Canal.getName() + " : ");
for (int i = 0; i < Canal.getType().size(); i++) {
if (i == Canal.getType().size() - 1) {
setRule(getRule() + Canal.getType().get(i).getNome());
} else {
setRule(getRule() + Canal.getType().get(i).getNome() + ".");
}
}
}
}