Package repast.simphony.statecharts
Class DefaultStateChart<T>
- java.lang.Object
-
- repast.simphony.statecharts.DefaultStateChart<T>
-
- All Implemented Interfaces:
StateChart<T>
public class DefaultStateChart<T> extends Object implements StateChart<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Transition<T>>
activeRegularTransitions
protected List<Transition<T>>
activeSelfTransitions
protected SimpleState<T>
currentSimpleState
protected List<Transition<T>>
regularTransitions
protected List<Transition<T>>
selfTransitions
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultStateChart(T agent)
Creates DefaultStateChart for the specified agent and sets whether or not the agent needs to be in a Context for the statechart to function.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateState(String stateID)
Activates the state (identified by a potentially non-unique ID) if it exists.void
activateState(AbstractState<T> state)
Activates the state if it exists.protected void
addRegularTransition(Transition<T> transition)
protected void
addSelfTransition(SelfTransition<T> transition)
protected void
addState(AbstractState<T> state)
void
begin(StateChartSimIntegrator integrator)
Begin state chart.void
followTransition(String transitionID)
Follow the transition (identified by a potentially non-unique ID) if valid.void
followTransition(Transition<T> transition)
Follow the transition if valid.T
getAgent()
Gets the agent associated with this StateChart.SimpleState<T>
getCurrentSimpleState()
Retrieve current state.List<AbstractState<T>>
getCurrentStates()
protected Parameters
getParams()
double
getPriority()
protected Queue<Object>
getQueue()
AbstractState<T>
getStateForUuid(String uuid)
Returns the state associated with the uuid or null if not found.Transition<T>
getTransitionForUuid(String uuid)
Returns the transition associated with the uuid or null if not found.protected TransitionResolutionStrategy
getTransitionResolutionStrategy()
String
getUuidForState(AbstractState<T> state)
protected void
putStateUuid(AbstractState<T> state, String uuid)
protected void
putTransitionUuid(Transition<T> transition, String uuid)
void
receiveMessage(Object message)
Receive a message into the statechart queue.protected void
registerEntryState(AbstractState<T> state)
void
registerStateChartListener(StateChartListener scl)
protected void
removeResolveTime(double nextTime)
void
removeStateChartListener(StateChartListener scl)
void
resolve()
protected void
scheduleResolveTime(double nextTime)
protected void
setPriority(double priority)
protected void
setStateUuidMap(Map<AbstractState<T>,String> stateUuidMap)
protected void
setTransitionResolutionStrategy(TransitionResolutionStrategy transitionResolutionStrategy)
protected void
setTransitionUuidMap(Map<Transition<T>,String> transitionUuidMap)
void
stop()
Stops this statechart.boolean
withinState(String id)
-
-
-
Field Detail
-
regularTransitions
protected List<Transition<T>> regularTransitions
-
activeRegularTransitions
protected List<Transition<T>> activeRegularTransitions
-
selfTransitions
protected List<Transition<T>> selfTransitions
-
activeSelfTransitions
protected List<Transition<T>> activeSelfTransitions
-
currentSimpleState
protected SimpleState<T> currentSimpleState
-
-
Constructor Detail
-
DefaultStateChart
protected DefaultStateChart(T agent)
Creates DefaultStateChart for the specified agent and sets whether or not the agent needs to be in a Context for the statechart to function.- Parameters:
agent
-contextRequired
-
-
-
Method Detail
-
getTransitionResolutionStrategy
protected TransitionResolutionStrategy getTransitionResolutionStrategy()
-
setTransitionResolutionStrategy
protected void setTransitionResolutionStrategy(TransitionResolutionStrategy transitionResolutionStrategy)
-
setStateUuidMap
protected void setStateUuidMap(Map<AbstractState<T>,String> stateUuidMap)
-
putStateUuid
protected void putStateUuid(AbstractState<T> state, String uuid)
-
setTransitionUuidMap
protected void setTransitionUuidMap(Map<Transition<T>,String> transitionUuidMap)
-
putTransitionUuid
protected void putTransitionUuid(Transition<T> transition, String uuid)
-
registerEntryState
protected void registerEntryState(AbstractState<T> state)
-
begin
public void begin(StateChartSimIntegrator integrator)
Description copied from interface:StateChart
Begin state chart.- Specified by:
begin
in interfaceStateChart<T>
-
stop
public void stop()
Stops this statechart.- Specified by:
stop
in interfaceStateChart<T>
-
addState
protected void addState(AbstractState<T> state)
-
addRegularTransition
protected void addRegularTransition(Transition<T> transition)
-
addSelfTransition
protected void addSelfTransition(SelfTransition<T> transition)
-
getCurrentSimpleState
public SimpleState<T> getCurrentSimpleState()
Description copied from interface:StateChart
Retrieve current state.- Specified by:
getCurrentSimpleState
in interfaceStateChart<T>
- Returns:
-
resolve
public void resolve()
- Specified by:
resolve
in interfaceStateChart<T>
-
scheduleResolveTime
protected void scheduleResolveTime(double nextTime)
-
removeResolveTime
protected void removeResolveTime(double nextTime)
-
receiveMessage
public void receiveMessage(Object message)
Description copied from interface:StateChart
Receive a message into the statechart queue.- Specified by:
receiveMessage
in interfaceStateChart<T>
-
getPriority
public double getPriority()
- Specified by:
getPriority
in interfaceStateChart<T>
-
setPriority
protected void setPriority(double priority)
-
getAgent
public T getAgent()
Description copied from interface:StateChart
Gets the agent associated with this StateChart.- Specified by:
getAgent
in interfaceStateChart<T>
- Returns:
- the agent associated with this StateChart.
-
getParams
protected Parameters getParams()
-
withinState
public boolean withinState(String id)
- Specified by:
withinState
in interfaceStateChart<T>
-
getCurrentStates
public List<AbstractState<T>> getCurrentStates()
- Specified by:
getCurrentStates
in interfaceStateChart<T>
-
getUuidForState
public String getUuidForState(AbstractState<T> state)
- Specified by:
getUuidForState
in interfaceStateChart<T>
-
getStateForUuid
public AbstractState<T> getStateForUuid(String uuid)
Description copied from interface:StateChart
Returns the state associated with the uuid or null if not found.- Specified by:
getStateForUuid
in interfaceStateChart<T>
- Returns:
-
getTransitionForUuid
public Transition<T> getTransitionForUuid(String uuid)
Description copied from interface:StateChart
Returns the transition associated with the uuid or null if not found.- Specified by:
getTransitionForUuid
in interfaceStateChart<T>
- Returns:
-
registerStateChartListener
public void registerStateChartListener(StateChartListener scl)
- Specified by:
registerStateChartListener
in interfaceStateChart<T>
-
removeStateChartListener
public void removeStateChartListener(StateChartListener scl)
- Specified by:
removeStateChartListener
in interfaceStateChart<T>
-
activateState
public void activateState(AbstractState<T> state)
Description copied from interface:StateChart
Activates the state if it exists. Should be called when simulation is paused.- Specified by:
activateState
in interfaceStateChart<T>
- Parameters:
state
- the state to activate
-
activateState
public void activateState(String stateID)
Description copied from interface:StateChart
Activates the state (identified by a potentially non-unique ID) if it exists.- Specified by:
activateState
in interfaceStateChart<T>
- Parameters:
stateID
- the potentially non-unique ID of the state to activate
-
followTransition
public void followTransition(String transitionID)
Description copied from interface:StateChart
Follow the transition (identified by a potentially non-unique ID) if valid.- Specified by:
followTransition
in interfaceStateChart<T>
- Parameters:
transitionID
- the potentially non-unique ID of the transition to follow
-
followTransition
public void followTransition(Transition<T> transition)
Description copied from interface:StateChart
Follow the transition if valid. Should be called when simulation is paused.- Specified by:
followTransition
in interfaceStateChart<T>
- Parameters:
transition
- the transition to follow
-
-