org.android.activityminer.app.util
Class MaximumSampleFrequencyDeterminationTask

Package class diagram package MaximumSampleFrequencyDeterminationTask
java.lang.Object
  extended by android.os.AsyncTask<Void,Integer,Long>
      extended by org.android.activityminer.app.util.MaximumSampleFrequencyDeterminationTask
All Implemented Interfaces:
EventObserver<SensorObservationCutout<SensorObservationDimensions,Double>>

public class MaximumSampleFrequencyDeterminationTask
extends AsyncTask<Void,Integer,Long>
implements EventObserver<SensorObservationCutout<SensorObservationDimensions,Double>>

The asynchronous task for determination of the maximum sample frequency.


Nested Class Summary
 
Nested classes/interfaces inherited from class android.os.AsyncTask
AsyncTask.Status
 
Field Summary
private  AbstractAccelerometerDataSource accelerometerDevice
          The accelerometer device.
private  long bestRate
          The old frequency value.
private  RuntimeConfiguration config
          The runtime configuration to use.
private  Context context
          The activity context.
private  GenericObservableCutoutCreator<SensorObservationDimensions,Double> cutoutCreator
          The cut-out creator.
private  List<SensorObservationCutout<SensorObservationDimensions,Double>> cutoutList
          The list to hold the observed cut-outs.
private  DeviceManager deviceManager
          The device manager
private  EventObserver<TaskFinishedEvent> finishedObserver
          The finished observer to be notified for success.
private  ProgressDialog progressDialog
          The progress dialog.
private  ObservableSensorScanner<SensorObservationDimensions,Double> sensorScanner
          The sensor scanner to use.
private static int TEST_REPEATION_COUNT
          The count of repetitive test runs, where the maximum sample frequency is averaged for.
 
Fields inherited from class android.os.AsyncTask
SERIAL_EXECUTOR, THREAD_POOL_EXECUTOR
 
Constructor Summary
private MaximumSampleFrequencyDeterminationTask(Context context, RuntimeConfiguration config, EventObserver<TaskFinishedEvent> finishedObserver, DeviceManager deviceManager)
          Constructor
 
Method Summary
static void createAndRunTask(Context context, RuntimeConfiguration config, EventObserver<TaskFinishedEvent> finishedObserver)
          Does create and execute a the asynchronous task in the given context.
protected  Long doInBackground(Void... params)
           
 void execute()
          An execution wrapper.
private  void notify(boolean success)
          Notification method.
private  void notifyForResult(long result)
          Does notify the user about the result.
 void onEvent(ObservableEventSource<? extends SensorObservationCutout<SensorObservationDimensions,Double>> eventSource, SensorObservationCutout<SensorObservationDimensions,Double> observedEvent)
           
protected  void onPostExecute(Long result)
           
protected  void onPreExecute()
           
private  void saveResult(long sampleRate)
          Does save the resulting sample rate to the preferences.
 
Methods inherited from class android.os.AsyncTask
cancel, execute, execute, executeOnExecutor, get, get, getStatus, isCancelled, onCancelled, onCancelled, onProgressUpdate, publishProgress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEST_REPEATION_COUNT

private static final int TEST_REPEATION_COUNT
The count of repetitive test runs, where the maximum sample frequency is averaged for.

See Also:
Constant Field Values

progressDialog

private ProgressDialog progressDialog
The progress dialog.


context

private final Context context
The activity context.


config

private final RuntimeConfiguration config
The runtime configuration to use.


finishedObserver

private final EventObserver<TaskFinishedEvent> finishedObserver
The finished observer to be notified for success.


sensorScanner

private ObservableSensorScanner<SensorObservationDimensions,Double> sensorScanner
The sensor scanner to use.


cutoutCreator

private final GenericObservableCutoutCreator<SensorObservationDimensions,Double> cutoutCreator
The cut-out creator.


cutoutList

private final List<SensorObservationCutout<SensorObservationDimensions,Double>> cutoutList
The list to hold the observed cut-outs.


bestRate

private long bestRate
The old frequency value.


accelerometerDevice

private AbstractAccelerometerDataSource accelerometerDevice
The accelerometer device.


deviceManager

private final DeviceManager deviceManager
The device manager

Constructor Detail

MaximumSampleFrequencyDeterminationTask

private MaximumSampleFrequencyDeterminationTask(Context context,
                                                RuntimeConfiguration config,
                                                EventObserver<TaskFinishedEvent> finishedObserver,
                                                DeviceManager deviceManager)
Constructor

Parameters:
context - the application context
config - the runtime configuration
finishedObserver - the finished observer
deviceManager - the device manager to use
Method Detail

onPreExecute

protected final void onPreExecute()
Overrides:
onPreExecute in class AsyncTask<Void,Integer,Long>

onPostExecute

protected final void onPostExecute(Long result)
Overrides:
onPostExecute in class AsyncTask<Void,Integer,Long>

notifyForResult

private void notifyForResult(long result)
Does notify the user about the result.

Parameters:
result - the result

notify

private void notify(boolean success)
Notification method.

Parameters:
success - success state

saveResult

private final void saveResult(long sampleRate)
Does save the resulting sample rate to the preferences.

Parameters:
sampleRate - the sample rate

doInBackground

protected final Long doInBackground(Void... params)
Specified by:
doInBackground in class AsyncTask<Void,Integer,Long>

execute

public final void execute()
An execution wrapper.


createAndRunTask

public static final void createAndRunTask(Context context,
                                          RuntimeConfiguration config,
                                          EventObserver<TaskFinishedEvent> finishedObserver)
Does create and execute a the asynchronous task in the given context.

Parameters:
context - the context of the caller
config - the runtime configuration to use
finishedObserver - the finished event observer

onEvent

public void onEvent(ObservableEventSource<? extends SensorObservationCutout<SensorObservationDimensions,Double>> eventSource,
                    SensorObservationCutout<SensorObservationDimensions,Double> observedEvent)
Specified by:
onEvent in interface EventObserver<SensorObservationCutout<SensorObservationDimensions,Double>>