|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.android.activityminer.logic.util.AbstractActivatableComponentImpl
org.android.activityminer.logic.devices.AbstractAccelerometerDataSource
public abstract class AbstractAccelerometerDataSource
Base class for the accelerometer data source.
Nested Class Summary | |
---|---|
private class |
AbstractAccelerometerDataSource.RawAccelerationListener
The raw acceleration listener. |
Field Summary | |
---|---|
protected AccelerometerDataCache |
cache
The data cache to hold samples for scan access. |
protected Context |
context
The Android context |
protected double[] |
currentData
The most recent sample data (linear axis accelerations and force of gravity components) |
protected Object |
currentDataLock
lock for access to the current sample data |
protected double[] |
currentFilterData
The most recent smoothed sample data |
protected LowPassFilter |
filter
The low pass filter to suppress higher frequencies |
private SensorEventListener |
rawAccListener
The sensor event listener for the raw acceleration event |
private Sensor |
rawAccSensor
The corresponding Android sensor for raw acceleration |
protected AtomicLong |
sampleCount
The current sample count ( since last start ). |
private ScreenOnOffBroadcastReceiver |
screenStateChangeReceiver
A broadcast receiver for screen state changes. |
protected int |
sensorRate
The sensor rate |
protected AtomicLong |
startRefTime
The time stamp of the first sensor event in nanoseconds. |
protected AtomicLong |
startTs
The time stamp of the last start in milliseconds. |
private AtomicLong |
stopTs
The current time stamp in milliseconds. |
Constructor Summary | |
---|---|
AbstractAccelerometerDataSource(Context context,
FrequencyTypes fType,
LowPassFilter filter)
Constructor |
Method Summary | |
---|---|
long |
getAverageSampleDistance()
Getter for the average sample distance in milliseconds. |
boolean |
hasObservers()
|
void |
notify(SampleGapErrorEvent data)
|
protected void |
onActivationStateChange(boolean active)
Handler for activation state changes |
void |
onDestroy()
This method is for cleanup in case of termination. |
void |
onEvent(ObservableEventSource<? extends ScreenChangeEvent> eventSource,
ScreenChangeEvent observedEvent)
|
abstract void |
onSensorEventRawAcc(SensorEvent event)
Handler for sensor events of the raw acceleration sensor |
void |
registerEventObserver(EventObserver<? extends SampleGapErrorEvent> observer)
|
protected void |
registerListener(Context context)
Does register the sensor listeners for the device type |
void |
removeAllObservers()
|
void |
setFilter(LowPassFilter filter)
Setter for the smoothing filter ( Access is only allowed if the device is not activate ). |
AccelerometerData |
takeSample(Long ts)
Getter for the current sample |
void |
unregisterEventObserver(EventObserver<? extends SampleGapErrorEvent> observer)
|
protected void |
unregisterListener(Context context)
Does unregister the sensor listener for the device type |
void |
updateFilterConfiguration(RuntimeConfiguration config)
Method to update the accelerometer filter configuration ( Access is only allowed if the device is not activate ). |
Methods inherited from class org.android.activityminer.logic.util.AbstractActivatableComponentImpl |
---|
isActive, setActivationState |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Context context
private final SensorEventListener rawAccListener
private final Sensor rawAccSensor
protected final double[] currentData
protected double[] currentFilterData
private final AtomicLong stopTs
protected final AtomicLong startTs
protected final AtomicLong startRefTime
protected final AtomicLong sampleCount
private final ScreenOnOffBroadcastReceiver screenStateChangeReceiver
protected final Object currentDataLock
protected final int sensorRate
protected final AccelerometerDataCache cache
protected LowPassFilter filter
Constructor Detail |
---|
public AbstractAccelerometerDataSource(Context context, FrequencyTypes fType, LowPassFilter filter)
context
- the application contextfType
- the sample frequency typefilter
- the filter to cut of higher frequenciesMethod Detail |
---|
protected void registerListener(Context context)
context
- the contextprotected void unregisterListener(Context context)
context
- the contextpublic abstract void onSensorEventRawAcc(SensorEvent event)
event
- the sensor eventpublic AccelerometerData takeSample(Long ts)
SensorDataSource
takeSample
in interface SensorDataSource<AccelerometerData>
ts
- the requested time stamp
public void onEvent(ObservableEventSource<? extends ScreenChangeEvent> eventSource, ScreenChangeEvent observedEvent)
onEvent
in interface EventObserver<ScreenChangeEvent>
protected void onActivationStateChange(boolean active)
AbstractActivatableComponentImpl
onActivationStateChange
in class AbstractActivatableComponentImpl
active
- the new activation statepublic final long getAverageSampleDistance()
public final void setFilter(LowPassFilter filter) throws AccessControlException
filter
- the filter to set
AccessControlException
- if activepublic final void updateFilterConfiguration(RuntimeConfiguration config) throws AccessControlException
config
- the current configuration
AccessControlException
- if activepublic final void onDestroy()
SensorDataSource
onDestroy
in interface SensorDataSource<AccelerometerData>
public void registerEventObserver(EventObserver<? extends SampleGapErrorEvent> observer)
registerEventObserver
in interface ObserverRegistration<SampleGapErrorEvent>
public void unregisterEventObserver(EventObserver<? extends SampleGapErrorEvent> observer)
unregisterEventObserver
in interface ObserverRegistration<SampleGapErrorEvent>
public void removeAllObservers()
removeAllObservers
in interface ObserverRegistration<SampleGapErrorEvent>
public void notify(SampleGapErrorEvent data)
notify
in interface ObservableEventSource<SampleGapErrorEvent>
public boolean hasObservers()
hasObservers
in interface ObservableEventSource<SampleGapErrorEvent>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |