1 package Analysis.Scheduling;
2 import java.util.Iterator;
5 import Analysis.TaskStateAnalysis.*;
9 /* Edge *****************/
11 public class ScheduleEdge extends Edge {
14 private final ClassDescriptor cd;
15 private boolean isNew = true;
17 private FlagState targetFState;
18 private ClassNode sourceCNode;
19 private ClassNode targetCNode;
21 private int probability;
22 private int transTime;
23 private int listExeTime;
31 public ScheduleEdge(ScheduleNode target, String label, ClassDescriptor cd) {
34 this.targetFState = null;
35 this.sourceCNode = null;
36 this.targetCNode = null;
40 this.probability = 100;
42 this.listExeTime = -1;
45 public ScheduleEdge(ScheduleNode target, String label, ClassDescriptor cd, boolean isNew) {
48 this.targetFState = null;
49 this.sourceCNode = null;
50 this.targetCNode = null;
54 this.probability = 100;
56 this.listExeTime = -1;
60 public void setTarget(GraphNode sn) {
64 public String getLabel() {
65 String completeLabel = label;
67 completeLabel += ":" + Integer.toString(this.newRate);
69 completeLabel += ":(" + Integer.toString(this.probability) + "%)" + ":[" + Integer.toString(this.transTime) + "]";
73 public int hashCode(){
74 return target.hashCode()^label.hashCode();
77 public ClassDescriptor getClassDescriptor() {
81 public boolean getIsNew() {
85 public FEdge getFEdge() {
89 public void setFEdge(FEdge fEdge) {
93 public FlagState getSourceFState() {
94 if(this.fedge == null) {
97 return (FlagState)this.fedge.getTarget();
100 public void setTargetFState(FlagState targetFState) {
101 this.targetFState = targetFState;
104 public FlagState getTargetFState() {
105 return this.targetFState;
108 public int getProbability() {
109 return this.probability;
112 public int getNewRate() {
116 public ClassNode getSourceCNode() {
117 return this.sourceCNode;
120 public void setSourceCNode(ClassNode sourceCNode) {
121 this.sourceCNode = sourceCNode;
124 public ClassNode getTargetCNode() {
125 return this.targetCNode;
128 public void setTargetCNode(ClassNode targetCNode) {
129 this.targetCNode = targetCNode;
130 this.transTime = targetCNode.getTransTime();
133 public boolean equals(Object o) {
134 if (o instanceof ScheduleEdge) {
135 ScheduleEdge e=(ScheduleEdge)o;
136 if ((e.label.equals(label))&&
137 (e.target.equals(target))&&
138 (e.source.equals(source)) &&
140 (e.fedge.equals(fedge)) &&
141 (e.sourceCNode.equals(sourceCNode)) &&
142 (e.targetCNode.equals(targetCNode)) &&
143 (e.newRate == newRate) &&
144 (e.probability == probability) &&
145 (e.isNew == isNew) &&
146 (e.transTime == transTime) &&
147 (e.listExeTime == listExeTime))
148 if(e.targetFState != null) {
149 return e.targetFState.equals(targetFState);
150 } else if(this.targetFState == null) {
159 public void setProbability(int prob) {
160 this.probability = prob;
163 public void setNewRate(int nr) {
167 public int getTransTime() {
168 return this.transTime;
171 public void setTransTime(int transTime) {
172 this.transTime = transTime;
175 public int getListExeTime() {
176 if(listExeTime == -1) {
177 // calculate the lisExeTime
178 listExeTime = ((ScheduleNode)this.getTarget()).getExeTime() + this.getTransTime() * this.getNewRate();
179 Iterator it_edges = this.getTarget().edges();
181 if(it_edges.hasNext()) {
182 temp = ((ScheduleEdge)it_edges.next()).getListExeTime();
184 while(it_edges.hasNext()) {
185 int tetime = ((ScheduleEdge)it_edges.next()).getListExeTime();
192 return this.listExeTime;
195 public void resetListExeTime() {
196 this.listExeTime = -1;