|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjade.core.behaviours.Behaviour
jade.core.behaviours.CompositeBehaviour
jade.core.behaviours.DistilledStateChartBehaviour
public class DistilledStateChartBehaviour
DistilledStateChartBehaviour: a DSC using behaviours as states.
It is a CompositeBehaviour
that executes its children
behaviours according to a DSC defined by the user. More specifically
each child represents a state in the DSC.
The class provides methods to add states (sub-behaviours) and
transitions that defines how sub-behaviours will be scheduled.
At a minimum, the following steps are needed in order to properly
define a DistilledStateChartBehaviour
:
addInitialState
;
addFinalState
;
addState
;
addTransition
;
Nested Class Summary |
---|
Nested classes/interfaces inherited from class jade.core.behaviours.Behaviour |
---|
jade.core.behaviours.Behaviour.RunnableChangedEvent |
Field Summary |
---|
Fields inherited from class jade.core.behaviours.CompositeBehaviour |
---|
currentExecuted |
Fields inherited from class jade.core.behaviours.Behaviour |
---|
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING |
Constructor Summary | |
---|---|
DistilledStateChartBehaviour()
Default constructor, does not set the owner agent. |
|
DistilledStateChartBehaviour(jade.core.Agent anAgent)
This constructor sets the owner agent. |
|
DistilledStateChartBehaviour(jade.core.Agent anAgent,
java.lang.String aName)
This constructor sets the owner agent and name of the behaviour (state). |
|
DistilledStateChartBehaviour(jade.core.Agent anAgent,
java.lang.String aName,
boolean aPutback)
This constructor sets the owner agent, name and sets the putback mode. |
|
DistilledStateChartBehaviour(jade.core.Agent anAgent,
java.lang.String aName,
jade.lang.acl.MessageTemplate aTemplate)
This constructor sets the owner agent, name and MessageTemplate. |
|
DistilledStateChartBehaviour(jade.core.Agent anAgent,
java.lang.String aName,
jade.lang.acl.MessageTemplate aTemplate,
boolean aPutback)
This constructor sets the owner agent, name, MessageTemplate and the putback mode. |
Method Summary | |
---|---|
void |
addFinalState(jade.core.behaviours.Behaviour state)
Add a Behaviour as a final state of this DistilledStateChartBehaviour . |
void |
addInitialState(jade.core.behaviours.Behaviour state)
Add a Behaviour as the initial state of this DistilledStateChartBehaviour . |
void |
addInitialState(int history)
Add a history state as the initial state of this DistilledStateChartBehaviour . |
void |
addState(jade.core.behaviours.Behaviour state)
Add a Behaviour as a state of this DistilledStateChartBehaviour . |
void |
addTransition(DistilledStateChartTransition trans)
Adds the argument transition to the list of transitions in the root DistilledStateChartBehaviour . |
void |
addTransition(DistilledStateChartTransition trans,
jade.core.behaviours.Behaviour source)
Adds the argument transition to the list of transitions in the root DistilledStateChartBehaviour . |
protected boolean |
checkTermination(boolean currentDone,
int currentResult)
Check whether this DistilledStateChartBehaviour must terminate. |
boolean |
containsState(jade.core.behaviours.Behaviour b)
Determines if the given state is already associated with this state. |
boolean |
containsTransition(DistilledStateChartTransition aTransition,
jade.core.behaviours.Behaviour source)
Determines if the given transition is already added. |
static DistilledStateChartBehaviour |
createRootForDSCTemplate(DistilledStateChartBehaviour dsc)
This method creates the root DistilledStateChartBehaviour using the DistilledStateChartBehaviour passed as parameter, in agreement to the DSC template with initial deep history state. |
void |
defaultDeepHistoryEntranceAction()
This method is normally overridden and indicates the action related to the Default Deep History Entrance of the DSC. |
void |
defaultShallowHistoryEntranceAction()
This method is normally overridden and indicates the action related to the Default Shallow History Entrance of the DSC. |
jade.util.leap.Collection |
getChildren()
Return a Collection view of the children behaviours of this DistilledStateChartBehaviour . |
protected jade.core.behaviours.Behaviour |
getCurrent()
Get the current child. |
jade.core.behaviours.Behaviour |
getDefaultDeepHistoryEntrance()
Get Default Deep History Entrance of this DistilledStateChartBehaviour . |
jade.core.behaviours.Behaviour |
getDefaultShallowHistoryEntrance()
Get Default Shallow History Entrance of this DistilledStateChartBehaviour . |
jade.core.behaviours.Behaviour |
getFinalState(int index)
Returns the final state at the given index. |
int |
getFinalStateCount()
Returns the number of final states associated with this DistilledStateChartBehaviour . |
jade.util.leap.Iterator |
getFinalStates()
Returns the final states assocated with this DistilledStateChartBehaviour . |
java.lang.Object |
getInitialState()
Returns the initial state of this DistilledStateChartBehaviour
(the initial state returned is a Behaviour or an Integer that represents an history state
of type DistilledStateChartTransition.SHALLOW_HISTORY or DistilledStateChartTransition.DEEP_HISTORY). |
int |
getLastExitValue()
Get the exit value of the last executed state. |
jade.lang.acl.MessageTemplate |
getMainTemplate()
Get the MessageTemplate. |
jade.core.behaviours.CompositeBehaviour |
getParent()
Returns the parent behaviour of this behaviour. |
boolean |
getPutback()
Get the putback mode. |
int |
getStateCount()
Returns the number of states contained within this state. |
jade.util.leap.Collection |
getStatesWithTransitions()
Returns the collection of only the transitions that I know about (this method has to work in this way! |
DistilledStateChartTransition |
getTransition(int index,
jade.core.behaviours.Behaviour source)
Returns the transition at the given index. |
int |
getTransitionCount(jade.core.behaviours.Behaviour source)
Returns the number of transitions with the given source state. |
jade.util.leap.Iterator |
getTransitions(jade.core.behaviours.Behaviour source)
Return an Iterator of the transitions with the given source state. |
jade.core.behaviours.Behaviour |
getTransitionSource(DistilledStateChartTransition t)
Returns the source behaviour of the given transition. |
jade.core.behaviours.Behaviour |
getWrappedState(jade.core.behaviours.Behaviour aState)
Helper to extract the wrapped state of the argument. |
protected void |
handle(jade.core.behaviours.Behaviour.RunnableChangedEvent rce)
Handle block/restart notifications. |
void |
initialAction()
This method is normally overridden and indicates the action related to the initial state of the DSC to execute when we enter the DSC and we have to leave again from the initial state (it represents the existing action on the transition that connects the black circle to the initial state in the DSC). |
int |
onEnd()
"onEnd" method for this DSC. |
void |
onStart()
"onStart" method for this DSC. |
void |
removeAllTransitions()
Remove all the transitions. |
void |
removeInitialStateHistory()
Delete the initial history state (H or H*) from this DSC. |
void |
removeState(jade.core.behaviours.Behaviour state)
Delete the argument state from this DSC. |
void |
removeTransition(DistilledStateChartTransition aTransition)
Remove the argument transition from the set of known transitions by calling the specific removeTransition on this behaviour. |
void |
removeTransition(DistilledStateChartTransition aTransition,
jade.core.behaviours.Behaviour source)
Remove the argument transition from the set of known transitions. |
void |
reset()
Reset this DistilledStateChartBehaviour . |
protected void |
scheduleFirst()
Prepare the first child for execution. |
protected void |
scheduleNext(boolean currentDone,
int currentResult)
This method schedules the next child to be executed. |
void |
setAgent(jade.core.Agent a)
Overridden from the base class to make sure that the Wrapper objects have their agent pointers set as well. |
protected void |
setCurrent(jade.core.behaviours.Behaviour state)
Establish who is the current state. |
void |
setDefaultDeepHistoryEntrance(jade.core.behaviours.Behaviour state)
Set Default Deep History Entrance of this DistilledStateChartBehaviour . |
void |
setDefaultShallowHistoryEntrance(jade.core.behaviours.Behaviour state)
Set Default Shallow History Entrance of this DistilledStateChartBehaviour . |
void |
setMainTemplate(jade.lang.acl.MessageTemplate aTemplate)
To set the MessageTemplate. |
void |
setPutback(boolean aPutback)
To set the putback mode. |
Methods inherited from class jade.core.behaviours.CompositeBehaviour |
---|
action, done, handleBlockEvent, handleRestartEvent, registerAsChild, resetChildren |
Methods inherited from class jade.core.behaviours.Behaviour |
---|
actionWrapper, block, block, getBehaviourName, getDataStore, getExecutionState, getRestartCounter, isRunnable, restart, root, setBehaviourName, setDataStore, setExecutionState |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DistilledStateChartBehaviour()
public DistilledStateChartBehaviour(jade.core.Agent anAgent)
anAgent
- the agent this behaviour belongs to.public DistilledStateChartBehaviour(jade.core.Agent anAgent, java.lang.String aName)
anAgent
- the agent this behaviour belongs to.aName
- the name of the behaviour.public DistilledStateChartBehaviour(jade.core.Agent anAgent, java.lang.String aName, jade.lang.acl.MessageTemplate aTemplate)
anAgent
- the agent this behaviour belongs to.aName
- the name of the behaviour.aTemplate
- the main templatepublic DistilledStateChartBehaviour(jade.core.Agent anAgent, java.lang.String aName, boolean aPutback)
anAgent
- the agent this behaviour belongs to.aName
- the name of the behaviour.aPutback
- the putback modepublic DistilledStateChartBehaviour(jade.core.Agent anAgent, java.lang.String aName, jade.lang.acl.MessageTemplate aTemplate, boolean aPutback)
anAgent
- the agent this behaviour belongs to.aName
- the name of the behaviour.aTemplate
- the main templateaPutback
- the putback modeMethod Detail |
---|
public void setPutback(boolean aPutback)
aPutback
- boolean to set the putback modepublic void setMainTemplate(jade.lang.acl.MessageTemplate aTemplate)
aTemplate
- the filtering MessageTemplatepublic boolean getPutback()
public jade.lang.acl.MessageTemplate getMainTemplate()
public jade.core.behaviours.CompositeBehaviour getParent()
getParent
in class jade.core.behaviours.Behaviour
public void addState(jade.core.behaviours.Behaviour state)
Behaviour
as a state of this DistilledStateChartBehaviour
.
When the DSC reaches this state the added Behaviour
will be
executed. If the added state is a DistilledStateChartBehaviour, then we check to see if it
has any transitions and take them out of the state and put them into our own DSC parent.
state
- The Behaviour
representing the statepublic boolean containsState(jade.core.behaviours.Behaviour b)
b
- Tests to see if this argument is a state inside of me.
public int getStateCount()
public void addInitialState(jade.core.behaviours.Behaviour state)
Behaviour
as the initial state of this DistilledStateChartBehaviour
.
state
- The Behaviour
representing the statepublic void addInitialState(int history)
DistilledStateChartBehaviour
.
history
- The history type: DistilledStateChartTransition.SHALLOW_HISTORY or DistilledStateChartTransition.DEEP_HISTORYpublic java.lang.Object getInitialState()
DistilledStateChartBehaviour
(the initial state returned is a Behaviour or an Integer that represents an history state
of type DistilledStateChartTransition.SHALLOW_HISTORY or DistilledStateChartTransition.DEEP_HISTORY).
public void addFinalState(jade.core.behaviours.Behaviour state)
Behaviour
as a final state of this DistilledStateChartBehaviour
.
When the DSC reaches this state
the added Behaviour
will be executed and,
when completed, the DistilledStateChartBehaviour
will terminate too.
state
- The Behaviour
representing the statepublic jade.util.leap.Iterator getFinalStates()
DistilledStateChartBehaviour
.
public int getFinalStateCount()
DistilledStateChartBehaviour
.
public jade.core.behaviours.Behaviour getFinalState(int index)
index
- The index of one of the final states in this DSC.
public void removeState(jade.core.behaviours.Behaviour state)
state
- the behaviour to delete.
java.lang.RuntimeException
- if the state that we attempt to remove is not defined in the DSC.public void removeInitialStateHistory()
public void addTransition(DistilledStateChartTransition trans)
DistilledStateChartBehaviour
.
Calls "addTransition" with the "this" as the state argument.
trans
- the transition that we are adding.public void addTransition(DistilledStateChartTransition trans, jade.core.behaviours.Behaviour source)
DistilledStateChartBehaviour
.
trans
- the transition that we are addingsource
- the source of the transitionpublic boolean containsTransition(DistilledStateChartTransition aTransition, jade.core.behaviours.Behaviour source)
aTransition
- Tests to see if this argument is a transition already added.source
- source of the transition.
public void removeTransition(DistilledStateChartTransition aTransition)
aTransition
- the transition to remove.
java.lang.RuntimeException
- is thrown if the argument transition isn't in the set of transitions.public void removeTransition(DistilledStateChartTransition aTransition, jade.core.behaviours.Behaviour source)
aTransition
- the transition to remove.source
- The source state that may have the transition.
java.lang.RuntimeException
- is thrown if the argument transition isn't in the set of transitions.public void removeAllTransitions()
public int getLastExitValue()
protected void scheduleFirst()
scheduleFirst
in class jade.core.behaviours.CompositeBehaviour
CompositeBehaviour.scheduleFirst()
protected void scheduleNext(boolean currentDone, int currentResult)
scheduleNext
in class jade.core.behaviours.CompositeBehaviour
currentDone
- a flag indicating whether the just executed
child has completed or not.currentResult
- the termination value (as returned by
onEnd()
) of the just executed child in the case this
child has completed (otherwise this parameter is meaningless)CompositeBehaviour.scheduleNext(boolean, int)
public void initialAction()
public void defaultShallowHistoryEntranceAction()
public void defaultDeepHistoryEntranceAction()
public static DistilledStateChartBehaviour createRootForDSCTemplate(DistilledStateChartBehaviour dsc)
protected boolean checkTermination(boolean currentDone, int currentResult)
DistilledStateChartBehaviour
must terminate.
Note: this happens only when the last child is done and it is a final state.
checkTermination
in class jade.core.behaviours.CompositeBehaviour
currentDone
- tells if the behaviour that just ran set its done flag to true.currentResult
- is the result that the behaviour that just ran returned.
CompositeBehaviour.checkTermination(boolean, int)
public jade.core.behaviours.Behaviour getWrappedState(jade.core.behaviours.Behaviour aState)
aState
- the state that we are looking up.
protected jade.core.behaviours.Behaviour getCurrent()
getCurrent
in class jade.core.behaviours.CompositeBehaviour
CompositeBehaviour.getCurrent()
protected void setCurrent(jade.core.behaviours.Behaviour state)
state
- The state to set the current to.public jade.core.behaviours.Behaviour getDefaultShallowHistoryEntrance()
DistilledStateChartBehaviour
.
public void setDefaultShallowHistoryEntrance(jade.core.behaviours.Behaviour state)
DistilledStateChartBehaviour
.
state
- Behaviour that represents Default Shallow History Entrance.public jade.core.behaviours.Behaviour getDefaultDeepHistoryEntrance()
DistilledStateChartBehaviour
.
public void setDefaultDeepHistoryEntrance(jade.core.behaviours.Behaviour state)
DistilledStateChartBehaviour
.
state
- Behaviour that represents Default Deep History Entrance.public jade.util.leap.Collection getChildren()
DistilledStateChartBehaviour
.
getChildren
in class jade.core.behaviours.CompositeBehaviour
CompositeBehaviour.getChildren()
public jade.util.leap.Iterator getTransitions(jade.core.behaviours.Behaviour source)
source
- The source state of the transitions.
public jade.core.behaviours.Behaviour getTransitionSource(DistilledStateChartTransition t)
public int getTransitionCount(jade.core.behaviours.Behaviour source)
source
- The source state of the transitions.
public DistilledStateChartTransition getTransition(int index, jade.core.behaviours.Behaviour source)
index
- The index of the transition that we are looking up.source
- The source state of the transition.
public jade.util.leap.Collection getStatesWithTransitions()
public void reset()
DistilledStateChartBehaviour
.
reset
in class jade.core.behaviours.CompositeBehaviour
public void setAgent(jade.core.Agent a)
setAgent
in class jade.core.behaviours.CompositeBehaviour
a
- The agent that you are setting for this behaviour.protected void handle(jade.core.behaviours.Behaviour.RunnableChangedEvent rce)
DistilledStateChartBehaviour
is blocked only when
its currently active child is blocked, and becomes ready again
when its current child is ready. This method takes care of the
various possibilities.
handle
in class jade.core.behaviours.Behaviour
rce
- The event to handle.public int onEnd()
onEnd
in class jade.core.behaviours.Behaviour
public void onStart()
onStart
in class jade.core.behaviours.Behaviour
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |