|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
com.drismo.logic.QualityRater
public class QualityRater
Handles quality rating and distributing updates to all the registered listeners.
QualityListener
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private java.util.LinkedList<AccelerationObject> |
accelerationObjectList
|
private static float |
CONST_POINTS
Used to calculate a delta score based on the constant force the vehicle is exposed to, over a short period of time (MAX_LIST_LENGTH_MS). |
private int |
currentRating
|
private static float |
DIFF_POINTS
Used to calculate a delta score based on changes in the force the vehicle is exposed to, over a short period of time (MAX_LIST_LENGTH_MS). |
private boolean |
isRating
|
private static int |
MAX_LIST_LENGTH_MS
|
private static float |
MOTION_THRESHOLD
|
private java.util.ArrayList<QualityListener> |
qualityListeners
|
private static float[] |
THRESHOLD_BAD
|
private static float[] |
THRESHOLD_UGLY
|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
QualityRater()
Constructs the accelerationObjectList. |
Method Summary | |
---|---|
float |
calculateDeltaScore(float outcome,
float points)
This is used to calculate a score relative to the current score and quality. |
private void |
evaluate()
Evaluate the new quality rating by adding the sum of each delta score (calculated by evaluating changes and constant force measured by each vector). |
float |
getDeltaScore(float vector,
float badThres,
float uglyThres,
float points)
Get delta score based on the current state given. |
void |
onFilteredAccelerationChange(float[] filteredVectors,
float[] RotatedVectors)
On each entry an AccelerationObject (containing the vectors and timestamp) is added to the accelerationObjectList , and deletes all the objects that are older
than MAX_LIST_LENGTH_MS . |
void |
registerQualityListener(QualityListener listener)
Adds a quality listener and starts the thread if it is the first listener added to the list. |
void |
run()
Evaluates the driving quality and updates all the listeners. |
void |
unregisterQualityListener(QualityListener listener)
Removes the specified quality listener and stops the thread if the listener list is empty. |
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 |
---|
private static final int MAX_LIST_LENGTH_MS
private static final float DIFF_POINTS
private static final float CONST_POINTS
private static final float[] THRESHOLD_BAD
private static final float[] THRESHOLD_UGLY
private static final float MOTION_THRESHOLD
private int currentRating
private volatile java.util.ArrayList<QualityListener> qualityListeners
private final java.util.LinkedList<AccelerationObject> accelerationObjectList
private boolean isRating
Constructor Detail |
---|
public QualityRater()
Method Detail |
---|
public void registerQualityListener(QualityListener listener)
listener
- The listener to add.public void unregisterQualityListener(QualityListener listener)
listener
- The given listener to stopMonitoring.public void onFilteredAccelerationChange(float[] filteredVectors, float[] RotatedVectors)
accelerationObjectList
, and deletes all the objects that are older
than MAX_LIST_LENGTH_MS
.
onFilteredAccelerationChange
in interface FilteredAccelerationListener
filteredVectors
- Not used here.RotatedVectors
- This is added as the vectors in the AccelerationObject
AccelerationObject
,
MAX_LIST_LENGTH_MS
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
evaluate()
,
QualityListener.onQualityUpdate(int)
private void evaluate()
public float getDeltaScore(float vector, float badThres, float uglyThres, float points)
vector
- Current acceleration vector, can be either Good, the bad or the ugly.badThres
- Threshold relative to the given vector, representing bad sectors.uglyThres
- Threshold relative to the given vector, representing ugly sectors.points
- unit used to calculate the delta currentRating.
public final float calculateDeltaScore(float outcome, float points)
outcome
- this is the outcome of the current driving quality.points
- unit used to calculate the delta score.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |