edu.cmu.emulator.world
Class RSALInfo

java.lang.Object
  extended by edu.cmu.emulator.listener.ListenerInfo
      extended by edu.cmu.emulator.world.RSALInfo

public class RSALInfo
extends ListenerInfo

Holds information about each listener registered to the RelSpatialAttribute. Keeps track of the previous time at which the listener was invoked and also performs the necessary calculations to check if the listener should be invoked or not based on the listener's invocation frequency.

Invocations may also occur due to a change in some magnitude, such as movement distance that the listener is interested in.

See Also:

Field Summary
static int ABSOLUTE
           
private static boolean debug
           
private static boolean debugListeners
           
static long NO_INTERVAL
           
static double NO_MAGNITUDE
           
protected  Object prevAbsValue
           
protected  Object prevRelValue
           
protected  long prevTime
           
static int RELATIVE
           
protected  long triggerIntervalMillis
           
protected  double triggerMagnitude
           
protected  boolean triggerOnAbsoluteChange
           
protected  boolean triggerOnRelativeChange
           
 
Fields inherited from class edu.cmu.emulator.listener.ListenerInfo
DEDICATED_THREAD, GROUP_THREAD, listener, NO_THREAD, threadMode
 
Constructor Summary
RSALInfo(RSAListener listener)
           
RSALInfo(RSAListener listener, int threadMode)
           
 
Method Summary
 Object checkForTrigger(Object source, long timeMillis, Object relValue)
          may be called from multiple threads, so writing state should be avoided
 void doUpdate(Object source, long timeMillis, Object updateValue)
           
 long getTriggerIntervalMillis()
           
 double getTriggerMagnitude()
           
 void setTriggerInterval(double triggerIntervalSecs)
           
 void setTriggerInterval(long triggerIntervalMillis)
           
 void setTriggerMagnitude(double triggerMagnitude, int relAbsMode)
           
protected  boolean triggerIntervalExceeded(long timeMillis)
           
protected  boolean triggerMagnitudeExceeded(long magnitude)
           
 boolean triggerOnAbsolute()
           
 boolean triggerOnRelative()
           
 
Methods inherited from class edu.cmu.emulator.listener.ListenerInfo
getListener, getThreadMode, setThreadMode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

triggerIntervalMillis

protected long triggerIntervalMillis

prevRelValue

protected Object prevRelValue

prevAbsValue

protected Object prevAbsValue

prevTime

protected long prevTime

triggerMagnitude

protected double triggerMagnitude

triggerOnRelativeChange

protected boolean triggerOnRelativeChange

triggerOnAbsoluteChange

protected boolean triggerOnAbsoluteChange

NO_INTERVAL

public static final long NO_INTERVAL
See Also:
Constant Field Values

NO_MAGNITUDE

public static final double NO_MAGNITUDE
See Also:
Constant Field Values

RELATIVE

public static final int RELATIVE
See Also:
Constant Field Values

ABSOLUTE

public static final int ABSOLUTE
See Also:
Constant Field Values

debug

private static final boolean debug
See Also:
Constant Field Values

debugListeners

private static final boolean debugListeners
See Also:
Constant Field Values
Constructor Detail

RSALInfo

public RSALInfo(RSAListener listener)

RSALInfo

public RSALInfo(RSAListener listener,
                int threadMode)
Method Detail

triggerOnAbsolute

public boolean triggerOnAbsolute()

triggerOnRelative

public boolean triggerOnRelative()

setTriggerInterval

public void setTriggerInterval(double triggerIntervalSecs)

setTriggerInterval

public void setTriggerInterval(long triggerIntervalMillis)

getTriggerIntervalMillis

public long getTriggerIntervalMillis()

setTriggerMagnitude

public void setTriggerMagnitude(double triggerMagnitude,
                                int relAbsMode)

getTriggerMagnitude

public double getTriggerMagnitude()

triggerIntervalExceeded

protected boolean triggerIntervalExceeded(long timeMillis)

triggerMagnitudeExceeded

protected boolean triggerMagnitudeExceeded(long magnitude)

checkForTrigger

public Object checkForTrigger(Object source,
                              long timeMillis,
                              Object relValue)
Description copied from class: ListenerInfo
may be called from multiple threads, so writing state should be avoided

Overrides:
checkForTrigger in class ListenerInfo

doUpdate

public void doUpdate(Object source,
                     long timeMillis,
                     Object updateValue)
Specified by:
doUpdate in class ListenerInfo


Copyright © 2013. All Rights Reserved.