Skip to content

Commit

Permalink
updated fsm
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick committed Apr 2, 2024
1 parent e895087 commit 3964a1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
14 changes: 4 additions & 10 deletions src/main/java/org/myrobotlab/service/FiniteStateMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ public void fire(String event) {
stateMachine.send(event);
current = stateMachine.getCurrent();

log.info("fired event ({}) -> ({}) moves to ({})", event, last == null ? null : last.getName(), current == null ? null : current.getName());
log.info("fired event ({}) -> ({}) moves to ({})", event, last == null ? null : last.getName(),
current == null ? null : current.getName());

if (last != null && !last.equals(current)) {
StateChange stateChange = new StateChange(current.getName(), event);
Expand Down Expand Up @@ -254,13 +255,6 @@ public StateChange publishStateChange(StateChange stateChange) {
return stateChange;
}

@Override
public FiniteStateMachineConfig getConfig() {
super.getConfig();
config.current = getState();
return config;
}

@Override
public FiniteStateMachineConfig apply(FiniteStateMachineConfig c) {
super.apply(c);
Expand All @@ -280,8 +274,8 @@ public FiniteStateMachineConfig apply(FiniteStateMachineConfig c) {
}

// setCurrent
if (c.current != null) {
setCurrent(c.current);
if (c.start != null) {
setCurrent(c.start);
}

return c;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Transition(String from, String event, String to) {

public List<Transition> transitions = new ArrayList<>();

public String current = null;
public String start = null;


}

0 comments on commit 3964a1a

Please sign in to comment.