hmi.elckerlyc.animationengine.motionunit
Class TimedMotionUnit

java.lang.Object
  extended by hmi.elckerlyc.planunit.AbstractPlanUnit
      extended by hmi.elckerlyc.animationengine.motionunit.TimedMotionUnit
All Implemented Interfaces:
PlanUnit
Direct Known Subclasses:
GazeTMU, PhysicalTMU, PointingTMU, TransitionTMU

public class TimedMotionUnit
extends AbstractPlanUnit

When you do not set an end time peg, 'UNKNNOWN' is assumed. This leads to the motionunit being timed as starttime..starttime+getpreferredduration When you do not set a start time peg, the animation cannot be played

Author:
welberge

Field Summary
private  org.slf4j.Logger logger
           
private  MotionUnit mu
           
protected  ArrayList<KeyPosition> progressHandled
           
private  PlanUnitTimeManager puTimeManager
           
 
Fields inherited from class hmi.elckerlyc.planunit.AbstractPlanUnit
bmlBlockPeg
 
Constructor Summary
TimedMotionUnit(BMLBlockPeg bmlBlockPeg, String i, String bmlId, MotionUnit m)
          Constructor
 
Method Summary
 List<String> getAvailableSyncs()
          Get the list of sync ids that can be used in this behavior.
 double getEndTime()
          Get the global end time of the PlanUnit, TimePeg.VALUEUNKNOWN if not known (yet)
 KeyPosition getKeyPosition(String kid)
           
 KeyPosition getKeyPosition(TimePeg sp)
           
 MotionUnit getMotionUnit()
           
 double getNextPegTime(String pid)
           
 Map<KeyPosition,TimePeg> getPegs()
           
 TimedMotionUnit getPredictor(VJoint vPredict)
          Gets a predictor for this timed motion unit, returns null if no predictor can be made
 double getPreferedDuration()
          0 is unknown/persistent
 double getPrevPegTime(String pid)
           
 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
 double getStartTime()
          Get the global start time of the PlanUnit, TimePeg.VALUEUNKNOWN if not known (yet)
 double getTime(String pid)
          Get the global time of sync syncId of the PlanUnit, TimePeg.VALUEUNKNOWN if not known (yet)
 TimePeg getTimePeg(String pid)
          null is not set
 boolean hasValidTiming()
          Checks if the timing of this plan unit is 'valid' (e.g. stuff like start is earlier than end, but also planunit specific stuff like biomechanically possible timing).
protected  void playUnit(double time)
           
 void resetUnit()
           
 void resolveDefaultBMLKeyPositions()
          Fills out default BML keypositions that are not yet in the TimedMotionUnit.
private  void sendProgress(double t, double time)
          Send progress feedback for all key positions passed at canonical time t.
 void setParameterValue(String paramId, float value)
          Sets a parameter value
 void setParameterValue(String paramId, String value)
          Sets a parameter value
 void setTimePeg(KeyPosition kp, TimePeg sp)
           
 void setTimePeg(String kid, TimePeg sp)
          Assigns a TimePeg to a sync in the PlanUnit
 void stopUnit(double time)
           
 
Methods inherited from class hmi.elckerlyc.planunit.AbstractPlanUnit
addFeedbackListener, feedback, getBMLBlockPeg, getBMLId, getId, getState, isDone, isLurking, isPlaying, isSubUnit, play, reset, setState, setSubUnit, start, startUnit, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private org.slf4j.Logger logger

mu

private final MotionUnit mu

progressHandled

protected ArrayList<KeyPosition> progressHandled

puTimeManager

private final PlanUnitTimeManager puTimeManager
Constructor Detail

TimedMotionUnit

public TimedMotionUnit(BMLBlockPeg bmlBlockPeg,
                       String i,
                       String bmlId,
                       MotionUnit m)
Constructor

Parameters:
bmlBlockPeg -
i - behaviour id
bmlId - BML block id
m - motion unit
Method Detail

hasValidTiming

public boolean hasValidTiming()
Description copied from interface: PlanUnit
Checks if the timing of this plan unit is 'valid' (e.g. stuff like start is earlier than end, but also planunit specific stuff like biomechanically possible timing).

Returns:
true if valid

getPegs

public Map<KeyPosition,TimePeg> getPegs()

getKeyPosition

public KeyPosition getKeyPosition(TimePeg sp)

getPrevPegTime

public double getPrevPegTime(String pid)

getNextPegTime

public double getNextPegTime(String pid)

getTime

public double getTime(String pid)
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
Overrides:
getTime in class AbstractPlanUnit

getTimePeg

public TimePeg getTimePeg(String pid)
Description copied from interface: PlanUnit
null is not set


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
Overrides:
getRelativeTime in class AbstractPlanUnit
Returns:
relative time in range [0..1]
Throws:
RelativeSyncNotFoundException

getEndTime

public double getEndTime()
Description copied from interface: PlanUnit
Get the global end time of the PlanUnit, TimePeg.VALUEUNKNOWN if not known (yet)


setTimePeg

public void setTimePeg(String kid,
                       TimePeg sp)
Description copied from interface: PlanUnit
Assigns a TimePeg to a sync in the PlanUnit


setTimePeg

public void setTimePeg(KeyPosition kp,
                       TimePeg sp)

getStartTime

public double getStartTime()
Description copied from interface: PlanUnit
Get the global start time of the PlanUnit, TimePeg.VALUEUNKNOWN if not known (yet)


getPredictor

public TimedMotionUnit getPredictor(VJoint vPredict)
Gets a predictor for this timed motion unit, returns null if no predictor can be made

Parameters:
vPredict - VJoint the predictor acts on
Returns:
the predictor

resolveDefaultBMLKeyPositions

public void resolveDefaultBMLKeyPositions()
Fills out default BML keypositions that are not yet in the TimedMotionUnit. Conventions: missing ready => ready = start = 0; missing relax => relax = end = 1; missing stroke_start => stroke_start = ready missing stroke_end => stroke_end = relax missing stroke => stroke = stroke_start


getKeyPosition

public KeyPosition getKeyPosition(String kid)

sendProgress

private void sendProgress(double t,
                          double time)
Send progress feedback for all key positions passed at canonical time t.

Parameters:
t - canonical time 0 <= t <=1
time - time since start of BML execution

playUnit

protected void playUnit(double time)
                 throws TMUPlayException
Specified by:
playUnit in class AbstractPlanUnit
Throws:
TMUPlayException

stopUnit

public void stopUnit(double time)
Specified by:
stopUnit in class AbstractPlanUnit

resetUnit

public void resetUnit()
Overrides:
resetUnit in class AbstractPlanUnit

getMotionUnit

public MotionUnit getMotionUnit()
Returns:
the encapsulated motion unit

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
Overrides:
getReplacementGroup in class AbstractPlanUnit

getPreferedDuration

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

Specified by:
getPreferedDuration in interface PlanUnit
Overrides:
getPreferedDuration in class AbstractPlanUnit

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
Overrides:
getAvailableSyncs in class AbstractPlanUnit

setParameterValue

public void setParameterValue(String paramId,
                              String value)
Description copied from interface: PlanUnit
Sets a parameter value


setParameterValue

public void setParameterValue(String paramId,
                              float value)
Description copied from interface: PlanUnit
Sets a parameter value