Skip to content
This repository was archived by the owner on May 22, 2021. It is now read-only.

Commit 26817b8

Browse files
committed
Update
1 parent 0eea377 commit 26817b8

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

src/main/java/stateMachine/AbstractStateMachine.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,16 @@ public void connectToEvent(String eventName, Callable callable){
5252
}
5353
}
5454
}
55+
56+
public void linkStates(){
57+
for(State state: this.stateList){
58+
for(Transition transition : state.getTransitions()){
59+
for(State state1 : this.stateList){
60+
if(transition.to().getId().equals(state1.getId())){
61+
transition.setTo(state1);
62+
}
63+
}
64+
}
65+
}
66+
}
5567
}

src/main/java/stateMachine/Caller.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public class Caller implements Callable {
1313
Object[] args;
1414

1515
public Caller(){
16-
1716
}
1817

1918
public Caller(Object calledObject, Method calledMethod){

src/main/java/stateMachine/GStateMachine.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@
44
**/
55
public class GStateMachine extends AbstractStateMachine{
66
public GStateMachine(){
7+
super();
8+
super.stateList.add( new State().setId("State_1").setIsInit(false).addTransition(new Transition().setTo(new State("State_2")).addTriggerEvent("Transition_9")));
9+
super.stateList.add( new State().setId("State_2").setIsInit(false).addOnEntry(new Event("aezge").addCallable(new EventSender("aezge", this))).addOnExit(new Event("zerzer").addCallable(new EventSender("zerzer", this))));
10+
super.stateList.add( new State().setId("State_4").setIsInit(false));
11+
super.linkStates();
12+
super.init();
713
}}

src/main/java/stateMachine/State.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,8 @@ public void connectToEvent(String eventName, Callable callable){}
9898

9999
//TODO
100100
public boolean hasSentEvent(String name){return false;}
101+
102+
public List<Transition> getTransitions() {
103+
return this.transitions;
104+
}
101105
}

0 commit comments

Comments
 (0)