|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSensorDriver
public class SensorDriver
Field Summary | |
---|---|
static int |
numSamples
Total number of samples to take |
static int |
sampleInterval
Interval between samples (note that there is also other overhead that extends this delay) |
Constructor Summary | |
---|---|
SensorDriver()
|
Method Summary | ||
---|---|---|
static void |
displayConditionalStats(java.util.ArrayList<FinchSensor> list)
Given an ArrayList of FinchSensors, report the statistics for for both the Acceleration Magnitude and for the Z component of Acceleration |
|
static void |
displayStats(java.util.List<FinchSensor> log,
SensorComparator comp)
For the given sensor channel (as indicated by comp), display: The mean value of this sensor channel the entire sensor sample for the minimum, median and maximum channel values |
|
static void |
getSamples(finch.Finch myFinch,
int num,
int interval,
java.util.Map<java.lang.Long,FinchSensor> map)
Take a specified number of FinchSensor samples and place them into a map. |
|
static void |
main(java.lang.String[] args)
Create several Maps of FinchSensor objects. |
|
static double |
mean(java.util.List<FinchSensor> log,
SensorComparator comp)
Compute the mean value of a some sensor value across a set of FinchSensors. |
|
static FinchSensor |
median(java.util.List<FinchSensor> log)
Return the sensor sample that is the median value of the key used to sort a set. |
|
static void |
queryTest(java.util.ArrayList<FinchSensor> list,
java.lang.Long[] keys)
Given an ArrayList of FinchSensors and an array of sample times to query, measure the amount of time (in ms) that is required to query all of the keys. |
|
static void |
queryTest(java.util.Map<java.lang.Long,FinchSensor> map,
java.lang.Long[] keys)
Given a map and an array of keys, measure the amount of time (in ms) that is required to query all of the keys. |
|
static java.util.TreeMap<java.lang.Integer,java.util.ArrayList<FinchSensor>> |
reKey(java.util.Map<java.lang.Long,FinchSensor> map)
Given an existing map that is keyed by sample time (a Long) and stores FinchSensor values, generate a new map in which the same set of values are stored, but are keyed by the left light sensor value (an Integer). |
|
static
|
reportSamples(java.util.Map<T,E> map)
Report a set of samples that have been stored in the map. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int numSamples
public static final int sampleInterval
Constructor Detail |
---|
public SensorDriver()
Method Detail |
---|
public static void getSamples(finch.Finch myFinch, int num, int interval, java.util.Map<java.lang.Long,FinchSensor> map)
myFinch
- A reference to a valid Finch object or nullnum
- Number of samples to takeinterval
- Interval in ms between samples (note that this
does not take into account the time required
to take a sample.map
- The map in which to insert the samples. This map
is keyed by the time of the sample
public static <T,E> void reportSamples(java.util.Map<T,E> map)
map
- Some map
public static void queryTest(java.util.Map<java.lang.Long,FinchSensor> map, java.lang.Long[] keys)
map
- A map from sample time (Long) to FinchSensorkeys
- An array of keys to access during the test (sample times)
public static void queryTest(java.util.ArrayList<FinchSensor> list, java.lang.Long[] keys)
list
- An ArrayList of FinchSensor objectskeys
- An array of keys to access during the test (sample times)
public static java.util.TreeMap<java.lang.Integer,java.util.ArrayList<FinchSensor>> reKey(java.util.Map<java.lang.Long,FinchSensor> map)
map
- A map from sample times (Long) to a FinchSensor object
public static double mean(java.util.List<FinchSensor> log, SensorComparator comp)
log
- A set of FinchSensorscomp
- A SensorComparator that specifies the key
Algorithm: Return the sum of the channel values divided by the number of samples.
public static FinchSensor median(java.util.List<FinchSensor> log)
log
- A set of FinchSensors, already sorted by some key
Algorithm:
The median sample is the middle one given that the set has already been
ordered.
public static void displayStats(java.util.List<FinchSensor> log, SensorComparator comp)
log
- A valid list of Finch sensor samplescomp
- The sensor channel on which to organize the list
Algorithm:
1. Sort the elements of log according to comp
2. Report the mean of the sensor value
3. Given the ordering of the sorted list, we can pull out the min, median
and max sensor samples by extracting the first, middle and last elements
in the list.
public static void displayConditionalStats(java.util.ArrayList<FinchSensor> list)
list
- ArrayList of FinchSensor objects over which to compute
the statistics
public static void main(java.lang.String[] args)
args
- Are ignored
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |