Add directory and codes for task scheduling
[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         return (FlagState)this.fedge.getTarget();
69     }
70     
71     public void setTargetFState(FlagState targetFState) {
72         this.targetFState = targetFState;
73     }
74     
75     public FlagState getTargetFState() {
76         return this.targetFState;
77     }
78     
79     public int getProbability() {
80         return this.probability;
81     }
82     
83     public int getNewRate() {
84         return this.newRate;
85     }
86     
87     public ClassNode getSourceCNode() {
88         return this.sourceCNode;
89     }
90     
91     public void setSourceCNode(ClassNode sourceCNode) {
92         this.sourceCNode = sourceCNode;
93     }
94     
95     public ClassNode getTargetCNode() {
96         return this.targetCNode;
97     }
98     
99     public void setTargetCNode(ClassNode targetCNode) {
100         this.targetCNode = targetCNode;
101     }
102
103    /* public int getIndex() {
104         return parameterindex;
105     }*/
106         
107     public boolean equals(Object o) {
108         if (o instanceof ScheduleEdge) {
109             ScheduleEdge e=(ScheduleEdge)o;
110             if ((e.label.equals(label))&&
111                 (e.target.equals(target))&&
112                 (e.td.equals(td)) && 
113                 (e.cd.equals(cd)) && 
114                 (e.fedge.equals(fedge)) && 
115                 (e.targetFState.equals(targetFState)) && 
116                 (e.sourceCNode.equals(sourceCNode)) &&
117                 (e.targetCNode.equals(targetCNode)) &&
118                 (e.newRate == newRate) && 
119                 (e.probability == probability)/*&&
120                 e.getIndex()==parameterindex*/)
121                 return true;
122         }
123         return false;
124     }
125     
126     public void setProbability(int prob) {
127         this.probability = prob;
128     }
129     
130     public void setNewRate(int nr) {
131         this.newRate = nr;
132     }
133 }