cz.cuni.amis.pogamut.sposh.elements
Class DriveCollection

Package class diagram package DriveCollection
java.lang.Object
  extended by cz.cuni.amis.pogamut.sposh.elements.PoshElement<THIS,PARENT>
      extended by cz.cuni.amis.pogamut.sposh.elements.PoshDummyElement<THIS,PARENT>
          extended by cz.cuni.amis.pogamut.sposh.elements.NamedLapElement<DriveCollection,PoshPlan>
              extended by cz.cuni.amis.pogamut.sposh.elements.DriveCollection

public final class DriveCollection
extends NamedLapElement<DriveCollection,PoshPlan>

This is root of POSH plan in execution sense. In source of POSH plan, this is leaf of root. Every POSH plan can have only one DriveCollection.

drive collection: this is the root of the POSH hierarchy, and on every POSH action-selection cycle, this reconsiders which goal the agent should be working on. This is how a BOD agent can respond rapidly to changes in the environment.

How does it work? Fact: Engine remembers which node of the drive it processed last time. When engine evaluates the drive, it starts evaluation in the place, where it left off in the last evaluation of drive. Engine evaluates the plan each tick, but it doesn't matter if drive was evaluated in previsous tick or 10000 ticks ago (e.g. trigger of the drive was unsatisfied for a long time), engine will take the state (state=path from the drive to some node in the drive tree) it was left off last time and goes from there, e.g. if drive was evaluating which action it should do, it will continue to do so, if drive was executing some action, it will continue in its execution.

By "will continue in..." is meant "will try to continue...", because in many cases, it will fail(the action will signal its failure ect.), but it doesn't matter, in such case the engine will traverse the drive's decision tree from the root. Originally it was supposed to enable quick switch to some action and go back to doing whatever the original drive was doing. Not sure about how useful it is.

Author:
HonzaH
See Also:
Competences are similar, but slightly different. There is a lot of confusion about how they differ from DC, so take a look.

Field Summary
static DataFlavor dataFlavor
          Data flavor of DC, used for drag and drop
static String dcName
          Property name for change of name.
 
Fields inherited from class cz.cuni.amis.pogamut.sposh.elements.PoshDummyElement
IDENT_PATTERN
 
Method Summary
 void addDrive(DriveElement drive)
          Add passed drive as the last drive of this DC and emit new it.
 void addDrive(int index, DriveElement drive)
           
 DataFlavor getDataFlavor()
          Get data flavour of posh plan element,used during DnD from palette to PoshScene.
 List<DriveElement> getDrives()
          Get list of all drives of this DC in correct order (drive with higest priority is first, drive with lowest priority is last).
 Trigger<DriveCollection> getGoal()
          Get goal of the DC.
 List<PoshElement> getChildDataNodes()
          Get all child nodes of the DC.
 String getName()
          Get name of the DC
 LapType getType()
          Get type of the element.
 boolean moveChild(int newIndex, PoshElement child)
          Move child to the @newIndex.
 void removeDrive(DriveElement drive)
          Remove drive from the drive collection.
 void setName(String newName)
          Change name of the DC and notify property listeners.
 String toString()
          Serialize DC into a parser readable form.
 
Methods inherited from class cz.cuni.amis.pogamut.sposh.elements.PoshDummyElement
getUnusedName, isUsedName, moveChildInList
 
Methods inherited from class cz.cuni.amis.pogamut.sposh.elements.PoshElement
addElementListener, emitChildDeleted, emitChildMove, emitChildNode, firePropertyChange, getElementListeners, getNumberOfChildInstances, getParent, getRootNode, isChildOfParent, removeElementListener, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dcName

public static final String dcName
Property name for change of name.

See Also:
Constant Field Values

dataFlavor

public static final DataFlavor dataFlavor
Data flavor of DC, used for drag and drop

Method Detail

addDrive

public void addDrive(DriveElement drive)
              throws DuplicateNameException
Add passed drive as the last drive of this DC and emit new it.

Parameters:
drive - drive to add
Throws:
DuplicateNameException

addDrive

public void addDrive(int index,
                     DriveElement drive)
              throws DuplicateNameException
Throws:
DuplicateNameException

getGoal

public Trigger<DriveCollection> getGoal()
Get goal of the DC. As long as goal is not satisfied, the DC will go on.

Returns:
goal of the DC

getDrives

public List<DriveElement> getDrives()
Get list of all drives of this DC in correct order (drive with higest priority is first, drive with lowest priority is last).

Returns:
unmodifiable list of drives.

toString

public String toString()
Serialize DC into a parser readable form. If goal is empty, don't include it. Example: (DC funbot (goal ((cz.cuni.HaveFun)(cz.cuni.Sing))) (drives ( (fun (trigger ((cz.cuni.IsAtParty)(cz.cuni.FriendsInSight)) ) cz.cuni.Enjoy ) (default cz.cuni.DoNothing) ) ) )

Overrides:
toString in class Object
Returns:
multi-line string that parser can read.

getChildDataNodes

public List<PoshElement> getChildDataNodes()
Get all child nodes of the DC. It consists of goal (at first place) and all drives of DC from second place forward (in correct order).

Specified by:
getChildDataNodes in class PoshElement<DriveCollection,PoshPlan>
Returns:
all children of this DC,

getName

public String getName()
Get name of the DC

Specified by:
getName in class NamedLapElement<DriveCollection,PoshPlan>
Returns:
name of the DC

setName

public void setName(String newName)
             throws InvalidNameException
Change name of the DC and notify property listeners.

Parameters:
newName - New name of the DC.
Throws:
InvalidNameException - throw if name is not valid (spaces, braces...)

moveChild

public boolean moveChild(int newIndex,
                         PoshElement child)
Description copied from class: PoshElement
Move child to the @newIndex. After child was moved (if it was moved), notify listeners.

Specified by:
moveChild in class PoshElement<DriveCollection,PoshPlan>
Returns:
if node succesfully moved

getDataFlavor

public DataFlavor getDataFlavor()
Description copied from class: PoshElement
Get data flavour of posh plan element,used during DnD from palette to PoshScene.

Specified by:
getDataFlavor in class PoshElement<DriveCollection,PoshPlan>
Returns:
dataFlavour of posh plan element, never null.

getType

public LapType getType()
Description copied from class: PoshElement
Get type of the element.

Specified by:
getType in class PoshElement<DriveCollection,PoshPlan>
Returns:
Type of element.

removeDrive

public void removeDrive(DriveElement drive)
Remove drive from the drive collection. If it is the last drive of DC, create new one before removing passed drive in order to have at least one drive in DC at all times.

Parameters:
drive - Drive to be removed.


Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.