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;
14 public final static int ASSOCEDGE = 2;
18 protected static int nodeID=0;
20 protected String label;
21 protected final FlagState fstate;
22 protected int type; // 0--new edge: indicate creating new objects
23 // 1--transmit edge: indicate transimitting an existing object
24 // 2-- associate edge: indicate association with another object in that they are both parameters of one task
26 protected FlagState targetFState; // associate edge's targetFState is always null
28 private ClassNode sourceCNode;
29 private ClassNode targetCNode;
31 private int probability;
32 private int transTime;
33 private int listExeTime;
38 private boolean isclone;
43 public ScheduleEdge(ScheduleNode target, String label, FlagState fstate, int type, int gid) {
45 this.uid = ScheduleEdge.nodeID++;
48 this.targetFState = null;
49 this.sourceCNode = null;
50 this.targetCNode = null;
54 this.probability = 100;
56 this.listExeTime = -1;
61 public boolean isclone() {
65 public void setIsclone(boolean isclone) {
66 this.isclone = isclone;
69 public void setTarget(GraphNode sn) {
73 public int getType() {
77 public String getLabel() {
78 String completeLabel = label;
79 if(ScheduleEdge.NEWEDGE == this.type) {
80 completeLabel += ":" + Integer.toString(this.newRate);
82 completeLabel += ":(" + Integer.toString(this.probability) + "%)" + ":[" + Integer.toString(this.transTime) + "]";
86 public FlagState getFstate() {
90 public FEdge getFEdge() {
94 public void setFEdge(FEdge fEdge) {
98 public FlagState getSourceFState() {
99 if(this.fedge == null) {
102 return (FlagState)this.fedge.getTarget();
105 public void setTargetFState(FlagState targetFState) {
106 this.targetFState = targetFState;
109 public FlagState getTargetFState() {
110 return this.targetFState;
113 public int getProbability() {
114 return this.probability;
117 public int getNewRate() {
121 public ClassNode getSourceCNode() {
122 return this.sourceCNode;
125 public void setSourceCNode(ClassNode sourceCNode) {
126 this.sourceCNode = sourceCNode;
129 public ClassNode getTargetCNode() {
130 return this.targetCNode;
133 public void setTargetCNode(ClassNode targetCNode) {
134 this.targetCNode = targetCNode;
135 //this.targetCNode.getInedgeVector().addElement(this);
136 this.transTime = targetCNode.getTransTime();
139 public boolean equals(Object o) {
140 if (o instanceof ScheduleEdge) {
141 ScheduleEdge e=(ScheduleEdge)o;
142 if(e.gid == this.gid) {
143 if(e.uid != this.uid) {
147 if ((e.label.equals(label))&&
148 (e.target.equals(target))&&
149 (e.source.equals(source)) &&
150 (e.fstate.equals(fstate)) &&
151 (e.sourceCNode.equals(sourceCNode)) &&
152 (e.targetCNode.equals(targetCNode)) &&
153 (e.newRate == newRate) &&
154 (e.probability == probability) &&
156 (e.transTime == transTime) &&
157 (e.listExeTime == listExeTime))
158 if(e.targetFState != null) {
159 if(!e.targetFState.equals(targetFState)) {
162 } else if(this.targetFState != null) {
165 if(e.fedge != null) {
166 return e.fedge.equals(fedge);
167 } else if(this.fedge == null) {
174 public int hashCode(){
175 int hashcode = gid^uid^label.hashCode()^target.hashCode()^source.hashCode()^fstate.hashCode()^
176 sourceCNode.hashCode()^targetCNode.hashCode()^newRate^probability^
177 type^transTime^listExeTime;
178 if(targetFState != null) {
179 hashcode ^= targetFState.hashCode();
182 hashcode ^= fedge.hashCode();
187 public void setProbability(int prob) {
188 this.probability = prob;
191 public void setNewRate(int nr) {
195 public int getTransTime() {
196 return this.transTime;
199 public void setTransTime(int transTime) {
200 this.transTime = transTime;
203 public int getListExeTime() {
204 if(listExeTime == -1) {
205 // calculate the lisExeTime
206 listExeTime = ((ScheduleNode)this.getTarget()).getExeTime() + this.getTransTime() * this.getNewRate();
207 Iterator it_edges = this.getTarget().edges();
209 if(it_edges.hasNext()) {
210 temp = ((ScheduleEdge)it_edges.next()).getListExeTime();
212 while(it_edges.hasNext()) {
213 int tetime = ((ScheduleEdge)it_edges.next()).getListExeTime();
220 return this.listExeTime;
223 public void resetListExeTime() {
224 this.listExeTime = -1;