Blame view
BRIC/src/RULES/CreatorRuleReflexiveComposition.java
5.97 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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package RULES; import CREATOR_CONDICTIONS_RULES.CreatorBinaryRules; import CREATOR_CONDICTIONS_RULES.CreatorBinaryRules; import CREATOR_CONDICTIONS_RULES.CreatorCondictionDesacopledChannels; import CREATOR_CONDICTIONS_RULES.CreatorConditionAuto_Injection_Compatible; import CREATOR_CONDICTIONS_RULES.CreatorConditionD3; import CREATOR_CONDICTIONS_RULES.CreatorCondition_D1_D2; import CREATOR_CONDICTIONS_RULES.CreatorCondition_D4; import CREATOR_CONDICTIONS_RULES.CreatorCondition_D5; import CREATOR_CONDICTIONS_RULES.CreatorCondition_D6; import CREATOR_CONDICTIONS_RULES.CreatorCondition_D7; import CREATOR_CONDICTIONS_RULES.CreatorProtocol; import CREATOR_CONDICTIONS_RULES.CreatorUnaryRule; import LOGIC.Contract; import LOGIC.Instance; import LOGIC.ObjectList; import LOGIC.Protocols; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.LinkedList; /** * * @author forall */ public class CreatorRuleReflexiveComposition { private LinkedList<Instance> instance = null; private CreatorUnaryRule rule; private Contract c; private CreatorProtocol createP; private LinkedList<Protocols> protChannel; private CreatorCondition_D1_D2 d1; private CreatorCondition_D1_D2 d2; private CreatorConditionD3 d3; private CreatorCondition_D4 condition_d4; private CreatorCondition_D5 condition_D5; private CreatorCondition_D6 condition_D6; private CreatorCondition_D7 condition_D7; private CreatorConditionAuto_Injection_Compatible injection; private String eventoprotocol1 = ""; private String eventoprotocol2 = ""; public CreatorRuleReflexiveComposition( LinkedList<Instance> i, LinkedList<Protocols> listProtocols, ObjectList lt) { instance = new LinkedList<>(); instance.addAll(i); rule = new CreatorUnaryRule(i.get(0), lt, listProtocols); c = new Contract(); c.setName("RuleReflexiveOf" + instance.get(0).getName()); protChannel = listProtocols; createP = new CreatorProtocol(instance, listProtocols); rule.setPegaComposicao(instance.get(0).getName() + "_FEED"); //enviando sepado prq na regra de feedback recebe apenas 1 d1 = new CreatorCondition_D1_D2(instance.get(0), listProtocols.get(0)); d2 = new CreatorCondition_D1_D2(instance.get(0), listProtocols.get(1)); d3 = new CreatorConditionD3(instance, listProtocols); condition_d4 = new CreatorCondition_D4(instance, listProtocols); condition_D5 = new CreatorCondition_D5(instance, listProtocols); condition_D6 = new CreatorCondition_D6(instance, listProtocols); condition_D7 = new CreatorCondition_D7(instance, listProtocols); injection = new CreatorConditionAuto_Injection_Compatible(instance.get(0), listProtocols); //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 void creatorRule() { rule.creatorUnaryCSP(); //definindo functions inputc e outputc para verificação de self-injection rule.setRule(rule.getRule() + " "); rule.setRule(rule.getRule() + "outputsC(c,P) = inter(outputs(P),{|c|})"); rule.setRule(rule.getRule() + " "); rule.setRule(rule.getRule() + "inputsC(c,P) = inter(inputs(P),{|c|})"); rule.setRule(rule.getRule() + " "); rule.setRule(rule.getRule()+ createP.creatorProtocol_and_DualProtocol()); //rule.setPegaComposicao("ResultComposition"); rule.setRule(rule.getRule() + " "); rule.setRule(rule.getRule() + "--REFLEXIVE COMPOSITION"); rule.setRule(rule.getRule() + " "); //implementação da regra rule.setRule(rule.getRule() + rule.getPegaComposicao() + " = "); rule.setRule(rule.getRule() + "REF("); rule.setRule(rule.getRule() + instance.get(0).getName() + ", "); rule.setRule(rule.getRule() + eventoprotocol1 + ", "); rule.setRule(rule.getRule() + eventoprotocol2 + ")"); rule.setRule(rule.getRule() + " "); //rule.setRule(rule.getRule() + "assert "); //rule.setRule(rule.getRule() + rule.getPegaComposicao() + ":[deadlock free[FD]]"); rule.setRule(rule.getRule()+ d1.implementation_Condition_D1()); rule.setRule(rule.getRule()+ d2.implementation_Condition_D1()); rule.setRule(rule.getRule()+ condition_d4.implementationCondiction_D4()); rule.setRule(rule.getRule()+ condition_D5.implementationCondiction_D5()); rule.setRule(rule.getRule()+ condition_D6.implementationCondition_D6_1()); rule.setRule(rule.getRule()+ condition_D6.implementationCondition_D6_2()); rule.setRule(rule.getRule()+ condition_D7.implementationCondition_D7()); rule.setRule(rule.getRule() + injection.condictionAuto_Injection_Compatible()); FileWriter rule2 = null; try { rule2 = new FileWriter(new File("cspFiles/" + c.getName() + ".csp")); PrintWriter p = new PrintWriter(rule2); p.flush(); // escreve no arquivo os tipos e canais que estão na string 'csp, em seguida escreve uma string com o // comportamento que é recebido do comtrato p.write(rule.getRule()); rule2.close(); p.close(); } catch (IOException ex) { //Logger.getLogger(instance.getName()).log(Level.SEVERE, null, ex); } } } |