Skip to content

Commit

Permalink
Added cancel event to the state machine.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernesto Corbellini committed Jan 18, 2016
1 parent 08885ce commit 1058131
Showing 1 changed file with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
/**
* State machine for the action client.
* @author Ernesto Corbellini [email protected]
* Comments:
* - The state returned on a transition is actually a vector of states that should be transitioned in sequence.
* TODO: change class name to ClientStateMachine
*/
*/
public class ClientStateMachine {
// Local class to hold the states
public static class ClientStates {
Expand All @@ -45,7 +42,6 @@ public static class ClientStates {
public final static int LOST = 8;
}

ActionGoal goal;
int latestGoalStatus;
int state;
int nextState;
Expand All @@ -61,14 +57,6 @@ public void ClientStateMachine()
//this.goal = actionGoal;
}

/*
* Compare two objects.
*/
public boolean equals(ClientStateMachine obj) {
//return actionGoal.goalId.id == obj.actionGoal.goalId.id;
return true;
}

public synchronized void setState(int state) {
this.state = state;
}
Expand Down Expand Up @@ -422,6 +410,25 @@ public Vector<Integer> getTransition(int goalStatus)
return stateList;
}

/**
* Cancel action goal. The goal can only be cancelled if its in certain
* states. If it can be cancelled the state will be changed to
* WAITING_FOR_CANCEL_ACK.
* @return True if the goal can be cancelled, false otherwise.
*/
public boolean cancel() {
bolean ret = false;
switch (stateMachine.getState()) {
case ClientStates.WAITING_FOR_GOAL_ACK:
case ClientStates.PENDING:
case ClientStates.ACTIVE:
this.state = ClientStates.WAITING_FOR_CANCEL_ACK;
ret = true;
break;
}
return ret;
}

public void markAsLost()
{
}
Expand Down

0 comments on commit 1058131

Please sign in to comment.