|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
de.unikassel.android.sdcframework.util.AbstractWorkerThread
de.unikassel.android.sdcframework.util.AbstractEventDispatcherImpl<SensorObservation<D,T>,SensorObservationCutout<D,T>>
org.android.activityminer.logic.timeseries.GenericObservableCutoutCreator<D,T>
D
- the enumeration type for the dimensions of the sensor observationsT
- the data type for time series datapublic class GenericObservableCutoutCreator<D extends Enum<D> & Dimensions,T>
The generic observable cut-out creator is a worker thread, which
does asynchronously extract fixed size cut-out
from cached sensor observations
.
The sensor observations are received by observing an
ObservableEventSource for SensorObservation< D, T >
and will be stored in the queue first.
This queue is processed by a thread for cut-out extraction.
The position of the current cutOut for extraction may overlap by a
configurable
size with the previous one, but not more than 50%.
This component must be attached to a source of sensor observations,
which does implement the ObservableEventSource interface for the
type SensorObservation< D, T >
. To attach the sensor observations source, use the
attachSensorObservationSource(ObservableEventSource) method.
The
corresponding method to detach from a sample source is
detachSensorObservationSource(ObservableEventSource)
This component is observable for the resulting windows. To register for
cutOut observation implement the EventObserver
interface for the
SensorObservationCutout
and
register this observer to the event source of this
component (accessible by the AbstractEventDispatcherImpl.getEventSource() method}).
IMPORTANT: If you use this component, do not forget to call the
AbstractWorkerThread.doTerminate()
method to
finally kill this thread when done.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private ActivatableComponent |
activationDelegation
activatable component implementation to delegate to |
private Context |
context
The context. |
private SensorObservationCutout<D,T> |
current
The current cutOut. |
private AtomicLong |
currentCutOutLength
The current cut-out length in ms. |
private long |
currentFrameEndTime
The current cut-out end time. |
private SensorObservationCutout<D,T> |
last
Reference to the last unfinished cutOut. |
private SensorObservationCutout<D,T> |
next
The next cutOut. |
private long |
nextFrameStartTime
The next cut-out start time. |
private AtomicInteger |
observationCount
The total received observation count while active. |
private com.google.common.util.concurrent.AtomicDouble |
overlap
The overlap size in percent (0-1). |
private AtomicInteger |
overlapSize
The overlap size in milliseconds of continuous cut-outs. |
private AtomicLong |
startTs
The start time stamp for sample rate calculation |
private AtomicLong |
stopTs
The stop time stamp for sample rate calculation |
private AtomicLong |
windowSize
The size of the cut-outs (count of sensor observations ) to extract. |
Fields inherited from class de.unikassel.android.sdcframework.util.AbstractEventDispatcherImpl |
---|
collector |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
GenericObservableCutoutCreator(long windowSize,
int overlap,
Context context)
Constructor |
Method Summary | |
---|---|
void |
attachSensorObservationSource(ObservableEventSource<SensorObservation<D,T>> sensorObservationSource)
Method to attach a source for sensor observations. |
void |
detachSensorObservationSource(ObservableEventSource<SensorObservation<D,T>> sensorObservationSource)
Method to detach from a source for sensor observations. |
protected void |
doWork()
|
long |
getAvgSampleUpdateRate()
Getter for the average rate for received samples |
long |
getCurrentCutOutDuration()
Getter for the current cut-out duration (window length) |
SensorObservationCutout<D,T> |
getLastCutout()
If the processor is not active, this method will return the unfinished last cut-out with sensor observations. |
int |
getOverlapSize()
Getter for the overlap size |
int |
getQueuedObservationCount()
Getter for the remaining count of queued and unprocessed sensor observations. |
long |
getWindowSize()
Getter for the cutOut size |
boolean |
isActive()
Test method for the actiation state. |
protected SensorObservationCutout<D,T> |
newCutoutInstance()
Does create a new cut-out instance of the concrete type. |
void |
nextTimeStamp(long nextTs)
Method to handle the next incoming time stamp. |
protected void |
onActivationStateChange(boolean active)
Handler for activation state changes |
void |
setActivationState(boolean active)
Method to set the activation state of the component |
void |
setOverlap(double overlap)
Setter for the overlap in percent (0-1) |
void |
setWindowSize(int windowSize)
Setter for the cutOut size |
Methods inherited from class de.unikassel.android.sdcframework.util.AbstractEventDispatcherImpl |
---|
doCleanUp, getCollector, getEventSource, hasObservers, notify, registerEventObserver, removeAllObservers, unregisterEventObserver |
Methods inherited from class de.unikassel.android.sdcframework.util.AbstractWorkerThread |
---|
doTerminate, hasTerminated, isLogging, isWorking, logMessage, run, setLogging, start, startWork, stopWork |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, clone, 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, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface de.unikassel.android.sdcframework.util.facade.WorkerThread |
---|
doTerminate, hasTerminated, isLogging, isWorking, setLogging, startWork, stopWork |
Field Detail |
---|
private final ActivatableComponent activationDelegation
private final AtomicLong windowSize
private final com.google.common.util.concurrent.AtomicDouble overlap
private final AtomicInteger overlapSize
private SensorObservationCutout<D extends Enum<D> & Dimensions,T> current
private SensorObservationCutout<D extends Enum<D> & Dimensions,T> next
private SensorObservationCutout<D extends Enum<D> & Dimensions,T> last
private final AtomicLong startTs
private final AtomicLong stopTs
private final AtomicLong currentCutOutLength
private AtomicInteger observationCount
private long currentFrameEndTime
private long nextFrameStartTime
private final Context context
Constructor Detail |
---|
public GenericObservableCutoutCreator(long windowSize, int overlap, Context context) throws InvalidParameterException
windowSize
- the length (in milliseconds) of the window to move over the raw
time series stream and
to create a result type for.overlap
- the percentage of window overlap (in the range of 0 to 100) with
the
previous one when moved.context
- the context
InvalidParameterException
Method Detail |
---|
public final long getWindowSize()
public final void setWindowSize(int windowSize)
windowSize
- the cutOut size to setpublic final int getOverlapSize()
public final void setOverlap(double overlap)
overlap
- the overlap to setprotected SensorObservationCutout<D,T> newCutoutInstance()
protected final void onActivationStateChange(boolean active)
active
- the new activation statepublic final SensorObservationCutout<D,T> getLastCutout()
public final void setActivationState(boolean active)
ActivatableComponent
setActivationState
in interface ActivatableComponent
active
- the activation sate flagpublic final boolean isActive()
ActivatableComponent
isActive
in interface ActivatableComponent
protected final void doWork()
doWork
in class AbstractWorkerThread
public void nextTimeStamp(long nextTs)
nextTs
- the signaled next time stamppublic final int getQueuedObservationCount()
public final void attachSensorObservationSource(ObservableEventSource<SensorObservation<D,T>> sensorObservationSource)
sensorObservationSource
- the source for sensor observations to attach topublic final void detachSensorObservationSource(ObservableEventSource<SensorObservation<D,T>> sensorObservationSource)
sensorObservationSource
- the source for sensor observations to detach frompublic final long getAvgSampleUpdateRate()
public long getCurrentCutOutDuration()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |