Package com.opencloud.sce.fsmtool
Interface StateMachine<InputType extends Enum<?>,ReturnCodeType extends Enum<?>>
-
public interface StateMachine<InputType extends Enum<?>,ReturnCodeType extends Enum<?>>
Interface for a finite state machine generated POJO class.When an input is received the receivedInput() method is called. The state machine implementation will execute all input, exit and entry actions which are defined in the FSM. If multiple inputs need to be set/unset, or if inputs must be set/unset during action actions then the setInput() and unsetInput() methods should be used.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description List<?>
getActionDictionary()
Returns a array containing all of the action names in the action dictionary in index orderEnum<?>
getCurrentState()
Query the current state of the state machine.String
getDescription()
Enum<?>
getInitialState()
List<?>
getInputDictionary()
Returns a array containing all of the input names in the input dictionary in index orderString
getName()
Enum<?>
getState(int stateId)
Return the name of a stateList<?>
getStates()
Return a set of state names for the state machine.Enum<?>
lookupAction(int actionId)
Return the name of the action from the action dictionaryEnum<?>
lookupInput(int inputId)
Return the name of the input from the input dictionaryReturnCodeType
receivedInput(InputType input, Object event, Object channel)
Notify the state machine that an input has arrived and process it.void
setInput(InputType input)
Used prior to a receivedInput call to set additional inputs.void
unsetInput(InputType input)
Used prior to a receivedInput call to unset inputs.
-
-
-
Method Detail
-
receivedInput
ReturnCodeType receivedInput(InputType input, Object event, Object channel) throws Exception
Notify the state machine that an input has arrived and process it. All actions will be processed before this method returns- Parameters:
input
- input to set in the input register of the state machine- Returns:
- number of transitions or -1 if there was an error
- Throws:
Exception
-
setInput
void setInput(InputType input)
Used prior to a receivedInput call to set additional inputs. Can also be used in actions to set inputs.- Parameters:
input
- input to set in the input register
-
unsetInput
void unsetInput(InputType input)
Used prior to a receivedInput call to unset inputs. Can also be used in action actions to unset inputs.- Parameters:
input
- input to unset in the input register
-
getCurrentState
Enum<?> getCurrentState()
Query the current state of the state machine.- Returns:
- the current state of the state machine
-
getStates
List<?> getStates()
Return a set of state names for the state machine.- Returns:
- set of state names
-
getState
Enum<?> getState(int stateId)
Return the name of a state- Parameters:
stateId
- state- Returns:
- state name
-
getName
String getName()
- Returns:
- name of the state machine
-
getDescription
String getDescription()
- Returns:
- description of the state machine
-
getInitialState
Enum<?> getInitialState()
- Returns:
- the initial state of the state machine
-
lookupAction
Enum<?> lookupAction(int actionId) throws StateMachineException
Return the name of the action from the action dictionary- Parameters:
actionId
- id of the action- Returns:
- name of action
- Throws:
StateMachineException
- when the action id does not exist
-
lookupInput
Enum<?> lookupInput(int inputId) throws StateMachineException
Return the name of the input from the input dictionary- Parameters:
inputId
- id of the input- Returns:
- name of input
- Throws:
StateMachineException
- when the input id does not exist
-
getActionDictionary
List<?> getActionDictionary()
Returns a array containing all of the action names in the action dictionary in index order- Returns:
- action dictionary as an array of action names
-
getInputDictionary
List<?> getInputDictionary()
Returns a array containing all of the input names in the input dictionary in index order- Returns:
- input dictionary as an array of input names
-
-