-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessage.java
More file actions
66 lines (61 loc) · 1.62 KB
/
Message.java
File metadata and controls
66 lines (61 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
public class Message {
private int inid;
private int hopCount=0;
private int mcount=0;
private int phase=0;
private boolean state=true;// True equals out, false equals in
private boolean CWF=false;//clockwiseflag, true equals in
private boolean CCWF=false;
public Message(int id){
this.inid=id;
this.hopCount=(int)Math.pow(2, phase);
}
public Message(int id,int phase){
this.inid=id;
this.phase=phase;
}
public int GetMcount(){return mcount;}
public void SetMcount(){this.mcount+=1;}
public boolean GetState(){
return state;}
public int GetInid(){return inid;}
public void SetState(){
this.state=!state;}
public int GetHCount(){return hopCount;}
public void resetHCount(){
this.hopCount=(int)Math.pow(2, phase);}
public void setHCount(){
this.hopCount-=1;}
public void phaseIncrement(){phase+=1;
System.out.println("Message with id "+inid+" is now phase "+ phase);
}
public int Getphase(){return phase;}
public void reset(){
this.hopCount=(int)Math.pow(2, phase);
this.CCWF=false;
this.CWF=false;
}
public void setCWF(){
this.CWF=!CWF;}
public void setCCWF(){
this.CCWF=true;}
public boolean GetCWF(){return CWF;}
public boolean GetCCWF(){return CCWF;}
public void tostring(){
if(CCWF & CWF){
System.out.println("CCWF=True "+"True");}
else if(!CCWF & CWF){
System.out.println("CCWF=False "+"True");
}
else if(CCWF & !CWF){
System.out.println("CCWF=True "+"False");}
else{
System.out.println("CCWF=False "+"False");
}
}
public String MShowInfo(boolean F){
if(F){
return"<"+inid+", in, "+hopCount+", "+phase+">";}
else{return "<"+inid+", out, "+hopCount+", "+phase+">";}
}
}