|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
org.placelab.stumbler.StumblerFunnel
StumblerFunnel manages and collates Measurements from multiple Spotters.
The StumblerFunnel, with the use of SpotterExtension objects, can be configured to
allow for virtually any type of stumbling semantics. Examples of real and
potential uses are given below.
Trigger, Independent, and Dependent Spotters
PeriodicScannable.setPeriodicScanInterval(long)). When they update, they cause
all Dependent Spotters to be queried for their latest updates (whether this
triggers an actual scan of the environment or just gets the latest update
from the dependent spotter depends on the configuration of the Spotter Extension
for that dependent spotter). When the StumblerFunnel is started, all Trigger
Spotters will have their startScanning() methods called, so they should not be
started prior to providing them to the StumblerFunnel.
SpotterExtension.getLatestMeasurement() which should return quickly.
Note that the StumblerFunnel does not start Dependent Spotters, so if you intend
to have them run asynchronously you will have to use SpotterExtension.startScanning()
yourself.
Timeout
If you specify a positive timeout, if the registered Trigger spotters do not produce
Measurements by the timeout period (or if there are no Trigger spotters) all Dependent
Spotters will have their latest Measurements collected and pushed through to
StumblerFunnelUpdateListeners at that time. Negative timeouts will make it such
that a Trigger Spotter must update in order for Measurements to be collected from
any Dependent spotters.
Examples of StumblerFunnel configurations
"Straight-line stumbler": This type of Stumbler doesn't have any dependent spotters.
This is if you just want updates to come in as the spotters make them available.
StumblerFunnel f = new StumblerFunnel(-1);
WiFiSpotter wifi = new WiFiSpotter(250); // wifi will produce updates every 250 ms
NMEAGPSSpotter gps = SerialGPSSpotter.newSpotter(); // gps will produce updates as fast as the hardware allows
SpotterExtension wifiExt = new SpotterExtension(wifi, true, -1);
SpotterExtension gpsExt = new SpotterExtension(gps, false, SpotterExtension.GPS_STALE_TIME);
f.addIndependentSpotter(wifiExt);
f.addIndependentSpotter(gpsExt);
f.addUpdateListener(new LogWriter());
f.start();
"Place Lab Stumbler": This is (a simplification) of the default config used by PlacelabStumbler.
The idea is to place WiFi as accurately as possible, so WiFi should be collected when GPS Measurements
come in. Running WiFi fast and independent of the GPS as above will probably see more APs, but
it won't produce logs that are as accurate as this method.
StumblerFunnel f = new StumblerFunnel(-1); // you might specify 2000 or something here to get something when GPS isn't active
WiFiSpotter wifi = new WiFiSpotter();
NMEAGPSSpotter gps = SerialGPSSpotter.newSpotter();
SpotterExtension wifiExt = new SpotterExtension(wifi, true, -1);
SpotterExtension gpsExt = new SpotterExtension(gps, false, SpotterExtension.GPS_STALE_TIME);
f.addDependentSpotter(wifiExt);
f.addTriggerSpotter(gpsExt);
f.addUpdateListener(new AudioNotifier());
f.start();
Listeners to StumblerFunnel will get notifications containing the measurements for
the StumblerSpotters as they are available according to the rules outlined above
The StumblerFunnel begins its funneling operations after start() is called and
runs these in a new thread. This means that stumblerUpdated notifications will
not come back in the same thread as which start() was called. If this won't work
for you, you can use start(EventSystem evs) and callbacks will be delivered by
the given EventSystem.
Finally, note that the update Hashtable is keyed by the Spotters, not the SpotterExtensions.
| Nested Class Summary | |
protected class |
StumblerFunnel.Timeout
|
| Field Summary | |
protected HashtableSet |
dependentSpotters
|
protected boolean |
doUpdate
|
protected EventSystem |
eventSystem
|
protected HashtableSet |
independentSpotters
|
protected HashtableSet |
shutdowns
|
protected boolean |
shuttingDown
|
protected boolean |
suspend
|
protected StumblerFunnel.Timeout |
timeout
|
protected boolean |
timeoutFired
|
protected HashtableSet |
triggerSpotters
|
protected HashtableSet |
updateListeners
|
protected java.util.Vector |
updateSenderMeasurements
|
protected java.util.Vector |
updateSenders
|
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
StumblerFunnel()
Create a StumblerFunnel with default timeout, as set in placelab.StumblerFunnel.timeout system property or 2000 ms if not set |
|
StumblerFunnel(long timeout)
Create a new StumblerFunnel. |
|
| Method Summary | |
void |
addDependentSpotter(SpotterExtension spotter)
Adds a spotter to be watched by the StumblerFunnel. |
void |
addIndependentSpotter(SpotterExtension spotter)
Adds a spotter to be watched by the StumblerFunnel. |
void |
addShutdownListener(ShutdownListener listener)
Register to be notified when the StumblerFunnel has been signaled to shutdown. |
void |
addTriggerSpotter(SpotterExtension spotter)
Adds a spotter to be watched by the StumblerFunnel. |
void |
addUpdateListener(StumblerFunnelUpdateListener sul)
Register to be notified after the pulse with the latest Measurements from all the spotters |
void |
gotMeasurement(Spotter sender,
Measurement measurement)
|
boolean |
isSuspended()
|
protected void |
notifyUpdate(java.util.Hashtable response)
|
protected void |
pulse()
|
void |
removeShutdownListener(ShutdownListener listener)
|
void |
removeSpotter(SpotterExtension remove)
Remove a SpotterExtension of any type from the StumblerFunnel |
void |
removeUpdateListener(StumblerFunnelUpdateListener sul)
|
void |
resumeListen()
|
void |
run()
|
void |
shutdown()
|
void |
spotterExceptionThrown(Spotter s,
SpotterException ex)
|
void |
start(EventSystem evs)
|
protected void |
startIndependentSpotters()
|
protected void |
startTriggerSpotters()
|
void |
suspendListen()
|
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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 |
protected HashtableSet dependentSpotters
protected HashtableSet triggerSpotters
protected HashtableSet independentSpotters
protected HashtableSet shutdowns
protected HashtableSet updateListeners
protected boolean shuttingDown
protected boolean suspend
protected boolean doUpdate
protected EventSystem eventSystem
protected StumblerFunnel.Timeout timeout
protected volatile boolean timeoutFired
protected java.util.Vector updateSenders
protected java.util.Vector updateSenderMeasurements
| Constructor Detail |
public StumblerFunnel()
public StumblerFunnel(long timeout)
| Method Detail |
public void start(EventSystem evs)
public void run()
run in interface java.lang.Runnableprotected void startTriggerSpotters()
protected void startIndependentSpotters()
public void addDependentSpotter(SpotterExtension spotter)
spotter - to be added to the StumblerFunnelpublic void addTriggerSpotter(SpotterExtension spotter)
spotter - to be added to the StumblerFunnelpublic void addIndependentSpotter(SpotterExtension spotter)
public void removeSpotter(SpotterExtension remove)
remove - the spotter (and) extension to be removedpublic void addUpdateListener(StumblerFunnelUpdateListener sul)
public void addShutdownListener(ShutdownListener listener)
public void removeUpdateListener(StumblerFunnelUpdateListener sul)
public void removeShutdownListener(ShutdownListener listener)
protected void pulse()
protected void notifyUpdate(java.util.Hashtable response)
public void gotMeasurement(Spotter sender,
Measurement measurement)
gotMeasurement in interface SpotterListenerpublic void suspendListen()
public boolean isSuspended()
public void resumeListen()
public void shutdown()
public void spotterExceptionThrown(Spotter s,
SpotterException ex)
spotterExceptionThrown in interface SpotterListener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||