Make the Scheduling codes can handle back edges in combined flag transition diagram...
[IRC.git] / Robust / src / Analysis / Scheduling / ScheduleEdge.java
1 package Analysis.Scheduling;
2 import IR.*;
3 import Analysis.TaskStateAnalysis.*;
4 import Util.Edge;
5
6 /* Edge *****************/
7
8 public class ScheduleEdge extends Edge {
9
10     private String label;
11     private final TaskDescriptor td;
12     private final ClassDescriptor cd;
13     private FEdge fedge;
14     private FlagState targetFState;
15     private ClassNode sourceCNode;
16     private ClassNode targetCNode;
17     private int newRate;
18     private int probability;
19     //private int parameterindex;
20     
21     /** Class Constructor
22      * 
23      */
24     public ScheduleEdge(ScheduleNode target, String label, TaskDescriptor td, ClassDescriptor cd/*, int parameterindex*/) {
25         super(target);
26         this.fedge = null;
27         this.targetFState = null;
28         this.sourceCNode = null;
29         this.targetCNode = null;
30         this.label = label;
31         this.td = td;
32         this.cd = cd;
33         this.newRate = 1;
34         this.probability = 100;
35         //this.parameterindex = parameterindex;
36     }
37     
38     public void setTarget(ScheduleNode sn) {
39         this.target = sn;
40     }
41     
42     public String getLabel() {
43         String completeLabel = label + ":" + Integer.toString(this.newRate) + ":(" + Integer.toString(this.probability) + ")";
44         return completeLabel;
45     }
46     
47     public int hashCode(){
48         return target.hashCode()^label.hashCode();
49     }
50
51     public TaskDescriptor getTask() {
52         return td;
53     }
54     
55     public ClassDescriptor getClassDescriptor() {
56         return cd;
57     }
58     
59     public FEdge getFEdge() {
60         return this.fedge;
61     }
62     
63     public void setFEdge(FEdge fEdge) {
64         this.fedge = fEdge;
65     }
66     
67     public FlagState getSourceFState() {
68         if(this.fedge == null) {
69             return null;
70         }
71         return (FlagState)this.fedge.getTarget();
72     }
73     
74     public void setTargetFState(FlagState targetFState) {
75         this.targetFState = targetFState;
76     }
77     
78     public FlagState getTargetFState() {
79         return this.targetFState;
80     }
81     
82     public int getProbability() {
83         return this.probability;
84     }
85     
86     public int getNewRate() {
87         return this.newRate;
88     }
89     
90     public ClassNode getSourceCNode() {
91         return this.sourceCNode;
92     }
93     
94     public void setSourceCNode(ClassNode sourceCNode) {
95         this.sourceCNode = sourceCNode;
96     }
97     
98     public ClassNode getTargetCNode() {
99         return this.targetCNode;
100     }
101     
102     public void setTargetCNode(ClassNode targetCNode) {
103         this.targetCNode = targetCNode;
104     }
105
106    /* public int getIndex() {
107         return parameterindex;
108     }*/
109         
110     public boolean equals(Object o) {
111         if (o instanceof ScheduleEdge) {
112             ScheduleEdge e=(ScheduleEdge)o;
113             if ((e.label.equals(label))&&
114                 (e.target.equals(target))&&
115                 (e.td.equals(td)) && 
116                 (e.cd.equals(cd)) && 
117                 (e.fedge.equals(fedge)) && 
118                 (e.targetFState.equals(targetFState)) && 
119                 (e.sourceCNode.equals(sourceCNode)) &&
120                 (e.targetCNode.equals(targetCNode)) &&
121                 (e.newRate == newRate) && 
122                 (e.probability == probability)/*&&
123                 e.getIndex()==parameterindex*/)
124                 return true;
125         }
126         return false;
127     }
128     
129     public void setProbability(int prob) {
130         this.probability = prob;
131     }
132     
133     public void setNewRate(int nr) {
134         this.newRate = nr;
135     }
136 }