1 package Analysis.Scheduling;
2 import java.util.Iterator;
5 import Analysis.TaskStateAnalysis.*;
9 /* Edge *****************/
11 public class ScheduleEdge extends Edge {
15 private static int nodeID=0;
18 private final ClassDescriptor cd;
19 private boolean isNew = true;
21 private FlagState targetFState;
22 private ClassNode sourceCNode;
23 private ClassNode targetCNode;
25 private int probability;
26 private int transTime;
27 private int listExeTime;
35 public ScheduleEdge(ScheduleNode target, String label, ClassDescriptor cd, int gid) {
37 this.uid = ScheduleEdge.nodeID++;
40 this.targetFState = null;
41 this.sourceCNode = null;
42 this.targetCNode = null;
46 this.probability = 100;
48 this.listExeTime = -1;
51 public ScheduleEdge(ScheduleNode target, String label, ClassDescriptor cd, boolean isNew, int gid) {
53 this.uid = ScheduleEdge.nodeID++;
56 this.targetFState = null;
57 this.sourceCNode = null;
58 this.targetCNode = null;
62 this.probability = 100;
64 this.listExeTime = -1;
68 public void setTarget(GraphNode sn) {
72 public String getLabel() {
73 String completeLabel = label;
75 completeLabel += ":" + Integer.toString(this.newRate);
77 completeLabel += ":(" + Integer.toString(this.probability) + "%)" + ":[" + Integer.toString(this.transTime) + "]";
81 public ClassDescriptor getClassDescriptor() {
85 public boolean getIsNew() {
89 public FEdge getFEdge() {
93 public void setFEdge(FEdge fEdge) {
97 public FlagState getSourceFState() {
98 if(this.fedge == null) {
101 return (FlagState)this.fedge.getTarget();
104 public void setTargetFState(FlagState targetFState) {
105 this.targetFState = targetFState;
108 public FlagState getTargetFState() {
109 return this.targetFState;
112 public int getProbability() {
113 return this.probability;
116 public int getNewRate() {
120 public ClassNode getSourceCNode() {
121 return this.sourceCNode;
124 public void setSourceCNode(ClassNode sourceCNode) {
125 this.sourceCNode = sourceCNode;
128 public ClassNode getTargetCNode() {
129 return this.targetCNode;
132 public void setTargetCNode(ClassNode targetCNode) {
133 this.targetCNode = targetCNode;
134 this.transTime = targetCNode.getTransTime();
137 public boolean equals(Object o) {
138 if (o instanceof ScheduleEdge) {
139 ScheduleEdge e=(ScheduleEdge)o;
140 if(e.gid == this.gid) {
141 if(e.uid != this.uid) {
145 if ((e.label.equals(label))&&
146 (e.target.equals(target))&&
147 (e.source.equals(source)) &&
149 (e.sourceCNode.equals(sourceCNode)) &&
150 (e.targetCNode.equals(targetCNode)) &&
151 (e.newRate == newRate) &&
152 (e.probability == probability) &&
153 (e.isNew == isNew) &&
154 (e.transTime == transTime) &&
155 (e.listExeTime == listExeTime))
156 if(e.targetFState != null) {
157 if(!e.targetFState.equals(targetFState)) {
160 } else if(this.targetFState != null) {
163 if(e.fedge != null) {
164 return e.fedge.equals(fedge);
165 } else if(this.fedge == null) {
172 public int hashCode(){
173 int hashcode = gid^uid^label.hashCode()^target.hashCode()^source.hashCode()^cd.hashCode()^
174 sourceCNode.hashCode()^targetCNode.hashCode()^newRate^probability^
175 Boolean.toString(isNew).hashCode()^transTime^listExeTime;
176 if(targetFState != null) {
177 hashcode ^= targetFState.hashCode();
180 hashcode ^= fedge.hashCode();
185 public void setProbability(int prob) {
186 this.probability = prob;
189 public void setNewRate(int nr) {
193 public int getTransTime() {
194 return this.transTime;
197 public void setTransTime(int transTime) {
198 this.transTime = transTime;
201 public int getListExeTime() {
202 if(listExeTime == -1) {
203 // calculate the lisExeTime
204 listExeTime = ((ScheduleNode)this.getTarget()).getExeTime() + this.getTransTime() * this.getNewRate();
205 Iterator it_edges = this.getTarget().edges();
207 if(it_edges.hasNext()) {
208 temp = ((ScheduleEdge)it_edges.next()).getListExeTime();
210 while(it_edges.hasNext()) {
211 int tetime = ((ScheduleEdge)it_edges.next()).getListExeTime();
218 return this.listExeTime;
221 public void resetListExeTime() {
222 this.listExeTime = -1;