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 int probability;
30 private int transTime;
31 private int listExeTime;
36 private boolean isclone;
41 public ScheduleEdge(ScheduleNode target, String label, FlagState fstate, int type, int gid) {
43 this.uid = ScheduleEdge.nodeID++;
46 this.targetFState = null;
47 this.sourceCNode = null;
48 this.targetCNode = null;
52 this.probability = 100;
54 this.listExeTime = -1;
59 public boolean isclone() {
63 public void setIsclone(boolean isclone) {
64 this.isclone = isclone;
67 public void setTarget(GraphNode sn) {
71 public int getType() {
75 public String getLabel() {
76 String completeLabel = label;
77 if(ScheduleEdge.NEWEDGE == this.type) {
78 completeLabel += ":" + Integer.toString(this.newRate);
80 completeLabel += ":(" + Integer.toString(this.probability) + "%)" + ":[" + Integer.toString(this.transTime) + "]";
84 public FlagState getFstate() {
88 public FEdge getFEdge() {
92 public void setFEdge(FEdge fEdge) {
96 public FlagState getSourceFState() {
97 if(this.fedge == null) {
100 return (FlagState)this.fedge.getTarget();
103 public void setTargetFState(FlagState targetFState) {
104 this.targetFState = targetFState;
107 public FlagState getTargetFState() {
108 return this.targetFState;
111 public int getProbability() {
112 return this.probability;
115 public int getNewRate() {
119 public ClassNode getSourceCNode() {
120 return this.sourceCNode;
123 public void setSourceCNode(ClassNode sourceCNode) {
124 this.sourceCNode = sourceCNode;
127 public ClassNode getTargetCNode() {
128 return this.targetCNode;
131 public void setTargetCNode(ClassNode targetCNode) {
132 this.targetCNode = targetCNode;
133 this.transTime = targetCNode.getTransTime();
136 public boolean equals(Object o) {
137 if (o instanceof ScheduleEdge) {
138 ScheduleEdge e=(ScheduleEdge)o;
139 if(e.gid == this.gid) {
140 if(e.uid != this.uid) {
144 if ((e.label.equals(label))&&
145 (e.target.equals(target))&&
146 (e.source.equals(source)) &&
147 (e.fstate.equals(fstate)) &&
148 (e.sourceCNode.equals(sourceCNode)) &&
149 (e.targetCNode.equals(targetCNode)) &&
150 (e.newRate == newRate) &&
151 (e.probability == probability) &&
153 (e.transTime == transTime) &&
154 (e.listExeTime == listExeTime))
155 if(e.targetFState != null) {
156 if(!e.targetFState.equals(targetFState)) {
159 } else if(this.targetFState != null) {
162 if(e.fedge != null) {
163 return e.fedge.equals(fedge);
164 } else if(this.fedge == null) {
171 public int hashCode(){
172 int hashcode = gid^uid^label.hashCode()^target.hashCode()^source.hashCode()^fstate.hashCode()^
173 sourceCNode.hashCode()^targetCNode.hashCode()^newRate^probability^
174 type^transTime^listExeTime;
175 if(targetFState != null) {
176 hashcode ^= targetFState.hashCode();
179 hashcode ^= fedge.hashCode();
184 public void setProbability(int prob) {
185 this.probability = prob;
188 public void setNewRate(int nr) {
192 public int getTransTime() {
193 return this.transTime;
196 public void setTransTime(int transTime) {
197 this.transTime = transTime;
200 public int getListExeTime() {
201 if(listExeTime == -1) {
202 // calculate the lisExeTime
203 listExeTime = ((ScheduleNode)this.getTarget()).getExeTime() + this.getTransTime() * this.getNewRate();
204 Iterator it_edges = this.getTarget().edges();
206 if(it_edges.hasNext()) {
207 temp = ((ScheduleEdge)it_edges.next()).getListExeTime();
209 while(it_edges.hasNext()) {
210 int tetime = ((ScheduleEdge)it_edges.next()).getListExeTime();
217 return this.listExeTime;
220 public void resetListExeTime() {
221 this.listExeTime = -1;