ch.tatool.core.element.handler.timeout
Class DefaultAdaptiveTimeoutHandler

java.lang.Object
  extended by ch.tatool.core.element.AbstractPropertyHolder
      extended by ch.tatool.core.element.NodeImpl
          extended by ch.tatool.core.element.handler.timeout.DefaultVisualTimeoutHandler
              extended by ch.tatool.core.element.handler.timeout.DefaultAdaptiveTimeoutHandler
All Implemented Interfaces:
AdaptiveTimeoutHandler, TimeoutHandler, PropertyHolder, Node, ExecutionPhaseListener

public class DefaultAdaptiveTimeoutHandler
extends DefaultVisualTimeoutHandler
implements AdaptiveTimeoutHandler

Timeout handler that individually adapts itself to the user by reducing and increasing the timeout duration. The interval of adaptation is given by the minDuration and maxDuration values. A level change resets the timeout duration.

Author:
Andre Locher

Field Summary
 
Fields inherited from class ch.tatool.core.element.handler.timeout.DefaultVisualTimeoutHandler
durationProperty, PROPERTY_DURATION, PROPERTY_REACTION_TIME, reactionTimeProperty, timer
 
Constructor Summary
DefaultAdaptiveTimeoutHandler()
           
 
Method Summary
 void adaptTimeoutDuration(ExecutionContext event)
          Individually adapts the timer.
 void decreaseTimeoutDuration(ExecutionContext event)
          Reduces the timer by the factor f with a minimum of minDuration
 float getFactor()
           
 double getInterpolatedValue(Long[] m, double percentile)
          Calculates the percentile of an array of longs.
 long getMaxTimerDuration()
           
 long getMinTimerDuration()
           
 double getPercentile()
           
 double getPercentile(Long[] m, double percentile)
          TODO: NOT USED ANYMORE?!
 long getSamplesDuration(ExecutionContext event)
          Gets the reaction time of the n last trials (n=maxSamples) and calculates the 3rd quartile
 int getTimerSampleSize()
           
 void increaseTimeoutDuration(ExecutionContext event)
          Increases the timer by the factor f with a maximum of maxDuration
 boolean isResetTimerDuration()
           
 void processExecutionPhase(ExecutionContext event)
           
 void resetTimeoutDuration(ExecutionContext event)
          Sets the duration of the timer to maxDuration
 void setFactor(float factor)
           
 void setMaxTimerDuration(long maxTimerDuration)
           
 void setMinTimerDuration(long minTimerDuration)
           
 void setPercentile(double percentile)
           
 void setResetTimerDuration(boolean resetTimerDuration)
           
 void setTimerSampleSize(int timerSampleSize)
           
 
Methods inherited from class ch.tatool.core.element.handler.timeout.DefaultVisualTimeoutHandler
cancelTimeout, getDefaultTimerDuration, getReactionTime, getTimerStartTimestamp, setDefaultTimerDuration, setReactionTime, startTimeout, timerElapsed
 
Methods inherited from class ch.tatool.core.element.NodeImpl
assignParent, assignParent, assignParents, getId, getLocalId, getParent, setId, setLocalId, setParent
 
Methods inherited from class ch.tatool.core.element.AbstractPropertyHolder
clearProperties, getKeys, getProperty, removeProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ch.tatool.core.element.handler.timeout.TimeoutHandler
cancelTimeout, getDefaultTimerDuration, setDefaultTimerDuration, startTimeout
 
Methods inherited from interface ch.tatool.element.Node
getParent, setParent
 
Methods inherited from interface ch.tatool.data.PropertyHolder
clearProperties, getId, getKeys, getProperty, removeProperty, setProperty
 

Constructor Detail

DefaultAdaptiveTimeoutHandler

public DefaultAdaptiveTimeoutHandler()
Method Detail

processExecutionPhase

public void processExecutionPhase(ExecutionContext event)
Specified by:
processExecutionPhase in interface ExecutionPhaseListener
Overrides:
processExecutionPhase in class DefaultVisualTimeoutHandler

adaptTimeoutDuration

public void adaptTimeoutDuration(ExecutionContext event)
Individually adapts the timer.

Specified by:
adaptTimeoutDuration in interface AdaptiveTimeoutHandler

getSamplesDuration

public long getSamplesDuration(ExecutionContext event)
Gets the reaction time of the n last trials (n=maxSamples) and calculates the 3rd quartile

Returns:
the 3rd quartile of the n last trials reaction times

resetTimeoutDuration

public void resetTimeoutDuration(ExecutionContext event)
Sets the duration of the timer to maxDuration

Specified by:
resetTimeoutDuration in interface AdaptiveTimeoutHandler

decreaseTimeoutDuration

public void decreaseTimeoutDuration(ExecutionContext event)
Reduces the timer by the factor f with a minimum of minDuration

Specified by:
decreaseTimeoutDuration in interface AdaptiveTimeoutHandler

increaseTimeoutDuration

public void increaseTimeoutDuration(ExecutionContext event)
Increases the timer by the factor f with a maximum of maxDuration

Specified by:
increaseTimeoutDuration in interface AdaptiveTimeoutHandler

getInterpolatedValue

public double getInterpolatedValue(Long[] m,
                                   double percentile)
Calculates the percentile of an array of longs.

Parameters:
m - has to be an ordered list
Returns:
the value

getPercentile

public double getPercentile(Long[] m,
                            double percentile)
TODO: NOT USED ANYMORE?!


getTimerSampleSize

public int getTimerSampleSize()

setTimerSampleSize

public void setTimerSampleSize(int timerSampleSize)

getPercentile

public double getPercentile()

setPercentile

public void setPercentile(double percentile)

getFactor

public float getFactor()

setFactor

public void setFactor(float factor)

getMinTimerDuration

public long getMinTimerDuration()

setMinTimerDuration

public void setMinTimerDuration(long minTimerDuration)

getMaxTimerDuration

public long getMaxTimerDuration()

setMaxTimerDuration

public void setMaxTimerDuration(long maxTimerDuration)

isResetTimerDuration

public boolean isResetTimerDuration()

setResetTimerDuration

public void setResetTimerDuration(boolean resetTimerDuration)


Copyright © 2012. All Rights Reserved.