frog.plugin.spot.onspot
Class FilterManager

java.lang.Object
  extended by java.lang.Thread
      extended by frog.plugin.spot.onspot.FilterManager
All Implemented Interfaces:
Frog_Spot_Constants, Killable, Runnable

public class FilterManager
extends Thread
implements Frog_Spot_Constants, Killable

Manages all filtering on the SPOT. Multiple Filters can be active at a time. The purpose of this thread is to apply all active filters to a given acceleration sample, remove an sample that a filter has deemed unnecessary and hands the resulting, presumably smaller, list of samples to the ConnectionManager which will then send these samples to the host.

Author:
Team Better Recognize

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static Class[] availFilters
          List of filters that can be instantiated and used by the FilterManager.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface frog.plugin.spot.Frog_Spot_Constants
CORRUPT_DATA, END_OF_DATA, INT_CORRUPT_DATA, INT_END_OF_DATA, MSG_ACK, MSG_ADD_FILTER, MSG_ALIVE, MSG_DISCONNECT, MSG_DISCOVER, MSG_END_OF_DATA, MSG_ERROR, MSG_GESTURE, MSG_REMOVE_FILTERS, MSG_RESEND, MSG_SAMPLE_RATE, PORT_BCAST, PORT_MAX, PORT_REPLY, PORT_START, SPOT1, SPOT1_PORT, SPOT2, SPOT2_PORT, SPOT3, SPOT3_PORT, SPOT4, SPOT4_PORT, SPOT5, SPOT5_PORT, SPOT6, SPOT6_PORT, SPOT7, SPOT7_PORT, SPOT8, SPOT8_PORT, SPOTB1, SPOTB1_PORT, SPOTB2, SPOTB2_PORT, SPOTB3, SPOTB3_PORT, SPOTB4, SPOTB4_PORT
 
Constructor Summary
FilterManager(FrogSpot frog)
          Creates the FilterManager with a permanent reference back to the FrogSpot for quick access to its facilities.
 
Method Summary
 void addFilter(byte index, String param)
          Adds a new instance of a Filter to the list of active filters.
 void giveGesture(Queue gesture)
          Used by the AccelManager to add a new set of accelerations to the FilterManager's job queue.
 void kill()
          Attempt to unconditionally stop all threads and release all resources.
 void removeFilters()
          Clears all active filters in this FilterManager.
 void run()
          Constantly loops through a job queue of acceleration data applying all active filters.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

availFilters

public static final Class[] availFilters
List of filters that can be instantiated and used by the FilterManager. If future Filters are written, they should be added to this list. The index of a given class is used by MSG_ADD_FILTER in the ConnectionManager to add additional filters to the FilterManager's activeFilter list.

Constructor Detail

FilterManager

public FilterManager(FrogSpot frog)
Creates the FilterManager with a permanent reference back to the FrogSpot for quick access to its facilities.

Parameters:
frog - reference to the FrogSpot object
Method Detail

addFilter

public void addFilter(byte index,
                      String param)
Adds a new instance of a Filter to the list of active filters. A new filter is added by its index on the array of availFilters and a given parameter String to dictate the Filter's behavior.

Parameters:
index - position of this filter in the availFilters array
param - a comma separated string of options for the Filter

giveGesture

public void giveGesture(Queue gesture)
Used by the AccelManager to add a new set of accelerations to the FilterManager's job queue. The AccelManager hands this queue over before the user is even done with the gesture so processing can take place as the gesture is being made.

Parameters:
gesture - the gesture (currently in progress) to be filtered

kill

public void kill()
Description copied from interface: Killable
Attempt to unconditionally stop all threads and release all resources.

Specified by:
kill in interface Killable

removeFilters

public void removeFilters()
Clears all active filters in this FilterManager. This is used to wipe the slate clean so that new filters can be used instead.


run

public void run()
Constantly loops through a job queue of acceleration data applying all active filters.

Specified by:
run in interface Runnable
Overrides:
run in class Thread