1 package Analysis.Scheduling;
3 import java.util.Iterator;
5 import Analysis.TaskStateAnalysis.*;
9 /* Edge *****************/
10 public class ScheduleEdge extends Edge {
12 public final static int NEWEDGE = 0;
13 public final static int TRANSEDGE = 1;
17 protected static int nodeID=0;
19 protected String label;
20 protected final FlagState fstate;
21 protected int type; // 0--new edge: indicate creating new objects
22 // 1--transmit edge: indicate transimitting an existing object
24 protected FlagState targetFState;
26 private ClassNode sourceCNode;
27 private ClassNode targetCNode;
29 private double probability;
30 private long transTime;
31 private long listExeTime;
36 private boolean isclone;
41 public ScheduleEdge(ScheduleNode target,
47 this.uid = ScheduleEdge.nodeID++;
50 this.targetFState = null;
51 this.sourceCNode = null;
52 this.targetCNode = null;
56 this.probability = 100;
58 this.listExeTime = -1;
63 public boolean isclone() {
67 public void setIsclone(boolean isclone) {
68 this.isclone = isclone;
71 public void setTarget(GraphNode sn) {
75 public int getType() {
79 public String getLabel() {
80 String completeLabel = label;
81 if(ScheduleEdge.NEWEDGE == this.type) {
82 completeLabel += ":" + Integer.toString(this.newRate);
84 completeLabel += ":(" + Double.toString(this.probability) + "%)" + ":[" + Long.toString(this.transTime) + "]";
88 public FlagState getFstate() {
92 public FEdge getFEdge() {
96 public void setFEdge(FEdge fEdge) {
100 public FlagState getSourceFState() {
101 if(this.fedge == null) {
104 return (FlagState) this.fedge.getTarget();
107 public void setTargetFState(FlagState targetFState) {
108 this.targetFState = targetFState;
111 public FlagState getTargetFState() {
112 return this.targetFState;
115 public double getProbability() {
116 return this.probability;
119 public int getNewRate() {
123 public ClassNode getSourceCNode() {
124 return this.sourceCNode;
127 public void setSourceCNode(ClassNode sourceCNode) {
128 this.sourceCNode = sourceCNode;
131 public ClassNode getTargetCNode() {
132 return this.targetCNode;
135 public void setTargetCNode(ClassNode targetCNode) {
136 this.targetCNode = targetCNode;
137 this.transTime = targetCNode.getTransTime();
140 public boolean equals(Object o) {
141 if (o instanceof ScheduleEdge) {
142 ScheduleEdge e=(ScheduleEdge)o;
143 if(e.gid == this.gid) {
144 if(e.uid != this.uid) {
148 if ((e.label.equals(label))&&
149 (e.target.equals(target))&&
150 (e.source.equals(source)) &&
151 (e.fstate.equals(fstate)) &&
152 (e.sourceCNode.equals(sourceCNode)) &&
153 (e.targetCNode.equals(targetCNode)) &&
154 (e.newRate == newRate) &&
155 (e.probability == probability) &&
157 (e.transTime == transTime) &&
158 (e.listExeTime == listExeTime))
159 if(e.targetFState != null) {
160 if(!e.targetFState.equals(targetFState)) {
163 } else if(this.targetFState != null) {
166 if(e.fedge != null) {
167 return e.fedge.equals(fedge);
168 } else if(this.fedge == null) {
175 public int hashCode() {
176 int hashcode = gid^uid^label.hashCode()^target.hashCode()^source.hashCode()^fstate.hashCode()^
177 sourceCNode.hashCode()^targetCNode.hashCode()^newRate^(int)probability^
178 type^(int)transTime^(int)listExeTime;
179 if(targetFState != null) {
180 hashcode ^= targetFState.hashCode();
183 hashcode ^= fedge.hashCode();
188 public void setProbability(double prob) {
189 this.probability = prob;
192 public void setNewRate(int nr) {
196 public long getTransTime() {
197 return this.transTime;
200 public void setTransTime(long transTime) {
201 this.transTime = transTime;
204 public long getListExeTime() {
205 if(listExeTime == -1) {
206 // calculate the lisExeTime
207 listExeTime = ((ScheduleNode) this.getTarget()).getExeTime() + this.getTransTime() * this.getNewRate();
208 Iterator it_edges = this.getTarget().edges();
210 if(it_edges.hasNext()) {
211 temp = ((ScheduleEdge)it_edges.next()).getListExeTime();
213 while(it_edges.hasNext()) {
214 long tetime = ((ScheduleEdge)it_edges.next()).getListExeTime();
221 return this.listExeTime;
224 public void resetListExeTime() {
225 this.listExeTime = -1;