1 package Analysis.Scheduling;
3 import java.util.Iterator;
6 import Analysis.TaskStateAnalysis.*;
10 /* Edge *****************/
12 public class ScheduleEdge extends Edge {
16 private static int nodeID=0;
19 //private final ClassDescriptor cd;
20 private final FlagState fstate;
21 private boolean isNew = true;
23 private FlagState targetFState;
24 private ClassNode sourceCNode;
25 private ClassNode targetCNode;
27 private int probability;
28 private int transTime;
29 private int listExeTime;
34 private boolean isclone;
39 public ScheduleEdge(ScheduleNode target, String label, /*ClassDescriptor cd,*/FlagState fstate, int gid) {
41 this.uid = ScheduleEdge.nodeID++;
44 this.targetFState = null;
45 this.sourceCNode = null;
46 this.targetCNode = null;
51 this.probability = 100;
53 this.listExeTime = -1;
57 public ScheduleEdge(ScheduleNode target, String label, /*ClassDescriptor cd,*/FlagState fstate, boolean isNew, int gid) {
59 this.uid = ScheduleEdge.nodeID++;
62 this.targetFState = null;
63 this.sourceCNode = null;
64 this.targetCNode = null;
69 this.probability = 100;
71 this.listExeTime = -1;
76 public boolean isclone() {
80 public void setIsclone(boolean isclone) {
81 this.isclone = isclone;
84 public void setTarget(GraphNode sn) {
88 public String getLabel() {
89 String completeLabel = label;
91 completeLabel += ":" + Integer.toString(this.newRate);
93 completeLabel += ":(" + Integer.toString(this.probability) + "%)" + ":[" + Integer.toString(this.transTime) + "]";
97 /*public ClassDescriptor getClassDescriptor() {
101 public FlagState getFstate() {
105 public boolean getIsNew() {
109 public FEdge getFEdge() {
113 public void setFEdge(FEdge fEdge) {
117 public FlagState getSourceFState() {
118 if(this.fedge == null) {
121 return (FlagState)this.fedge.getTarget();
124 public void setTargetFState(FlagState targetFState) {
125 this.targetFState = targetFState;
128 public FlagState getTargetFState() {
129 return this.targetFState;
132 public int getProbability() {
133 return this.probability;
136 public int getNewRate() {
140 public ClassNode getSourceCNode() {
141 return this.sourceCNode;
144 public void setSourceCNode(ClassNode sourceCNode) {
145 this.sourceCNode = sourceCNode;
148 public ClassNode getTargetCNode() {
149 return this.targetCNode;
152 public void setTargetCNode(ClassNode targetCNode) {
153 this.targetCNode = targetCNode;
154 this.transTime = targetCNode.getTransTime();
157 public boolean equals(Object o) {
158 if (o instanceof ScheduleEdge) {
159 ScheduleEdge e=(ScheduleEdge)o;
160 if(e.gid == this.gid) {
161 if(e.uid != this.uid) {
165 if ((e.label.equals(label))&&
166 (e.target.equals(target))&&
167 (e.source.equals(source)) &&
168 //(e.cd.equals(cd)) &&
169 (e.fstate.equals(fstate)) &&
170 (e.sourceCNode.equals(sourceCNode)) &&
171 (e.targetCNode.equals(targetCNode)) &&
172 (e.newRate == newRate) &&
173 (e.probability == probability) &&
174 (e.isNew == isNew) &&
175 (e.transTime == transTime) &&
176 (e.listExeTime == listExeTime))
177 if(e.targetFState != null) {
178 if(!e.targetFState.equals(targetFState)) {
181 } else if(this.targetFState != null) {
184 if(e.fedge != null) {
185 return e.fedge.equals(fedge);
186 } else if(this.fedge == null) {
193 public int hashCode(){
194 int hashcode = gid^uid^label.hashCode()^target.hashCode()^source.hashCode()^fstate.hashCode()^//cd.hashCode()^
195 sourceCNode.hashCode()^targetCNode.hashCode()^newRate^probability^
196 Boolean.toString(isNew).hashCode()^transTime^listExeTime;
197 if(targetFState != null) {
198 hashcode ^= targetFState.hashCode();
201 hashcode ^= fedge.hashCode();
206 public void setProbability(int prob) {
207 this.probability = prob;
210 public void setNewRate(int nr) {
214 public int getTransTime() {
215 return this.transTime;
218 public void setTransTime(int transTime) {
219 this.transTime = transTime;
222 public int getListExeTime() {
223 if(listExeTime == -1) {
224 // calculate the lisExeTime
225 listExeTime = ((ScheduleNode)this.getTarget()).getExeTime() + this.getTransTime() * this.getNewRate();
226 Iterator it_edges = this.getTarget().edges();
228 if(it_edges.hasNext()) {
229 temp = ((ScheduleEdge)it_edges.next()).getListExeTime();
231 while(it_edges.hasNext()) {
232 int tetime = ((ScheduleEdge)it_edges.next()).getListExeTime();
239 return this.listExeTime;
242 public void resetListExeTime() {
243 this.listExeTime = -1;