hmi.elckerlyc.planunit
Class AbstractPlanUnit

java.lang.Object
  extended by hmi.elckerlyc.planunit.AbstractPlanUnit
All Implemented Interfaces:
PlanUnit
Direct Known Subclasses:
AbstractSpeechUnit, AudioUnit, InterruptUnit, TimedFaceUnit, TimedMotionUnit, WaitUnit

public abstract class AbstractPlanUnit
extends Object
implements PlanUnit


Field Summary
private  List<String> availableSyncs
           
private  String bmlBlockId
           
protected  BMLBlockPeg bmlBlockPeg
           
private  ArrayList<BMLFeedbackListener> feedbackListeners
           
private  String id
           
private static org.slf4j.Logger logger
           
private  PlanUnitState state
           
private  boolean subUnit
           
 
Constructor Summary
AbstractPlanUnit(BMLBlockPeg bmlPeg, String i, String bmlId)
           
AbstractPlanUnit(BMLBlockPeg bmlPeg, String i, String bmlId, boolean sub)
           
 
Method Summary
 void addFeedbackListener(BMLFeedbackListener fb)
          Adds a feedback listener
 void feedback(BMLSyncPointProgressFeedback fb)
          Send feedback to all feedback listeners
 List<String> getAvailableSyncs()
          Get the list of sync ids that can be used in this behavior.
 BMLBlockPeg getBMLBlockPeg()
          Get the BML block to which this PlanUnit belongs
 String getBMLId()
          Get the BML block id of the PlanUnit
 String getId()
          Get the behaviour id of the PlanUnit
 double getPreferedDuration()
          0 is unknown/persistent
 double getRelativeTime(String syncId)
          Get the relative timing of this sync id Implementing classes should at least provide valid relative times for the BML sync points
 String getReplacementGroup()
          Get the PlanUnit replacement group (=typically the BML behavior) Used to determine the currently active persistent PlanUnit for this group in the player Only one group is active at a time null is none
 PlanUnitState getState()
          Get the plan unit state
 double getTime(String syncId)
          Get the global time of sync syncId of the PlanUnit, TimePeg.VALUEUNKNOWN if not known (yet)
 boolean isDone()
          State is done?
 boolean isLurking()
          State is lurking?
 boolean isPlaying()
          In PlanUnitState.IN_EXEC or PlanUnitState.SUBSIDING
 boolean isSubUnit()
          Return true if this unit is a subunit of another planunit (e.g. a visime or speech-related timed motion unit)
 void play(double time)
          Plays the unit at global time time.
protected abstract  void playUnit(double time)
           
 void reset()
          Resets the plan unit.
protected  void resetUnit()
           
 void setState(PlanUnitState newState)
          Set the plan unit state
 void setSubUnit(boolean sub)
           
 void start(double time)
          Starts the Plan unit, is called only once before the first play is called.
protected  void startUnit(double time)
          Starts the PlanUnit, is only called once at start
 void stop(double time)
          Stop the Plan unit.
protected abstract  void stopUnit(double time)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface hmi.elckerlyc.planunit.PlanUnit
getEndTime, getStartTime, getTimePeg, hasValidTiming, setParameterValue, setParameterValue, setTimePeg
 

Field Detail

bmlBlockPeg

protected final BMLBlockPeg bmlBlockPeg

subUnit

private boolean subUnit

id

private final String id

bmlBlockId

private final String bmlBlockId

feedbackListeners

private final ArrayList<BMLFeedbackListener> feedbackListeners

logger

private static org.slf4j.Logger logger

availableSyncs

private final List<String> availableSyncs

state

private PlanUnitState state
Constructor Detail

AbstractPlanUnit

public AbstractPlanUnit(BMLBlockPeg bmlPeg,
                        String i,
                        String bmlId,
                        boolean sub)

AbstractPlanUnit

public AbstractPlanUnit(BMLBlockPeg bmlPeg,
                        String i,
                        String bmlId)
Method Detail

setSubUnit

public void setSubUnit(boolean sub)

playUnit

protected abstract void playUnit(double time)
                          throws PlayException
Throws:
PlayException

stopUnit

protected abstract void stopUnit(double time)
                          throws PlayException
Throws:
PlayException

startUnit

protected void startUnit(double time)
                  throws PlayException
Starts the PlanUnit, is only called once at start

Parameters:
time - global start time
Throws:
PlayException

resetUnit

protected void resetUnit()

isSubUnit

public boolean isSubUnit()
Description copied from interface: PlanUnit
Return true if this unit is a subunit of another planunit (e.g. a visime or speech-related timed motion unit)

Specified by:
isSubUnit in interface PlanUnit

getReplacementGroup

public String getReplacementGroup()
Description copied from interface: PlanUnit
Get the PlanUnit replacement group (=typically the BML behavior) Used to determine the currently active persistent PlanUnit for this group in the player Only one group is active at a time null is none

Specified by:
getReplacementGroup in interface PlanUnit

play

public final void play(double time)
                throws PlayException
Description copied from interface: PlanUnit
Plays the unit at global time time. Is allowed to be a blocking call.

Specified by:
play in interface PlanUnit
Throws:
PlayException

reset

public final void reset()
Description copied from interface: PlanUnit
Resets the plan unit. That is: set the

Specified by:
reset in interface PlanUnit

stop

public final void stop(double time)
                throws PlayException
Description copied from interface: PlanUnit
Stop the Plan unit.

Specified by:
stop in interface PlanUnit
Parameters:
time - global time, used for feedback
Throws:
PlayException

start

public final void start(double time)
                 throws PlayException
Description copied from interface: PlanUnit
Starts the Plan unit, is called only once before the first play is called.

Specified by:
start in interface PlanUnit
Parameters:
time - global time, used for feedback
Throws:
PlayException

getBMLBlockPeg

public BMLBlockPeg getBMLBlockPeg()
Description copied from interface: PlanUnit
Get the BML block to which this PlanUnit belongs

Specified by:
getBMLBlockPeg in interface PlanUnit

getBMLId

public String getBMLId()
Description copied from interface: PlanUnit
Get the BML block id of the PlanUnit

Specified by:
getBMLId in interface PlanUnit

getId

public String getId()
Description copied from interface: PlanUnit
Get the behaviour id of the PlanUnit

Specified by:
getId in interface PlanUnit

feedback

public void feedback(BMLSyncPointProgressFeedback fb)
Description copied from interface: PlanUnit
Send feedback to all feedback listeners

Specified by:
feedback in interface PlanUnit
Parameters:
fb - feedback to send

addFeedbackListener

public void addFeedbackListener(BMLFeedbackListener fb)
Description copied from interface: PlanUnit
Adds a feedback listener

Specified by:
addFeedbackListener in interface PlanUnit
Parameters:
fb - feedback listener to add

setState

public void setState(PlanUnitState newState)
Description copied from interface: PlanUnit
Set the plan unit state

Specified by:
setState in interface PlanUnit

getState

public PlanUnitState getState()
Description copied from interface: PlanUnit
Get the plan unit state

Specified by:
getState in interface PlanUnit

isPlaying

public boolean isPlaying()
Description copied from interface: PlanUnit
In PlanUnitState.IN_EXEC or PlanUnitState.SUBSIDING

Specified by:
isPlaying in interface PlanUnit
Returns:

isLurking

public boolean isLurking()
Description copied from interface: PlanUnit
State is lurking?

Specified by:
isLurking in interface PlanUnit

isDone

public boolean isDone()
Description copied from interface: PlanUnit
State is done?

Specified by:
isDone in interface PlanUnit

getPreferedDuration

public double getPreferedDuration()
Description copied from interface: PlanUnit
0 is unknown/persistent

Specified by:
getPreferedDuration in interface PlanUnit

getRelativeTime

public double getRelativeTime(String syncId)
                       throws RelativeSyncNotFoundException
Description copied from interface: PlanUnit
Get the relative timing of this sync id Implementing classes should at least provide valid relative times for the BML sync points

Specified by:
getRelativeTime in interface PlanUnit
Returns:
relative time in range [0..1]
Throws:
RelativeSyncNotFoundException

getTime

public double getTime(String syncId)
Description copied from interface: PlanUnit
Get the global time of sync syncId of the PlanUnit, TimePeg.VALUEUNKNOWN if not known (yet)

Specified by:
getTime in interface PlanUnit

getAvailableSyncs

public List<String> getAvailableSyncs()
Description copied from interface: PlanUnit
Get the list of sync ids that can be used in this behavior. The list is ordered in relative time and maintains the BML order for BML syncIds. All BML syncs should be present in this list.

Specified by:
getAvailableSyncs in interface PlanUnit