SketchAggSensor.sensor
Class Sensor

public class Sensor
implements SensorInterface
Field Detail

MAX_READING

public static final int MAX_READING
Specifies sensor range [0 ... MAX_READING]

NUM_SENSORS

static final int NUM_SENSORS
How many sensor-devices are available ?

QUERY_FIELD

public static final int QUERY_FIELD
Field to aggregate on

RANDOM_DIST

public static final int RANDOM_DIST
Randomly, uniformly selected

NORMAL_DIST

public static final int NORMAL_DIST
Selected from a normal with specified mean, variance

GEOGRAPHIC_DIST

public static final int GEOGRAPHIC_DIST
Selected from a gradient

NINETY_TEN_DIST

public static final int NINETY_TEN_DIST
Selected from a highly-skewed distribution where 90% of values are in the range [middle - range/2 ... middle + range/2]

MAX_EPOCHS

public static int MAX_EPOCHS
Number of epochs after hearing intial request-to-aggrgeate that the sensor should wait before forwarding its value

x

protected int x
The x and y coordinates of this sensor

y

protected int y
The x and y coordinates of this sensor

top

protected Topology top
The topology where this sensor lives

id

protected int id
The id of this sensor

reading

protected int[] reading
Readings for this sensor -- note that these are fixed over the lifetime of the device, generally

Constructor Detail

Sensor

public Sensor(Topology t,
              int id,
              int dist)
Constructor
Parameters:
t - The topology used to radiate messages for this sensor
id - The id of this sensor
dist - The value-distribution used to generate readings for this sensor

Method Detail

inverseNormal

double inverseNormal(double p)
Given a probablity p, return the value of an inverse normal function at p centered around MEAN with variance STD_DEV^2.

getId

public int getId()
Returns:
the id of this sensor

getX

public int getX()
Returns:
the current x location of this sensor

getY

public int getY()
Returns:
the current y location of this sensor

setX

public void setX(int x)
Set the x location of the sensor

setY

public void setY(int y)
Set the y locaiton of the sensor

receiveMessage

public void receiveMessage(Message m)
Notify this sensor that it received a message

sendMessage

public void sendMessage(Message m)
Send a message on behalf of this sensor

prepareMessage

public void prepareMessage(Message m)
Allow the sensor to modify a message that is about to be sent

setTime

public void setTime(int time)
Set the time

getTime

public int getTime()
Return the last time this sensor's setTime() method was invoked

getReading

public int getReading(int sensorType)
Return the reading of sensor-device sensorType

msgCount

public int msgCount()
Return the number of messages this sensor has heard

sentCount

public int sentCount()
Return the number of messages this sensor has sent

setDisabled

public void setDisabled(boolean disabled)
Disabled sensors don't forward messages for their children

isDisabled

public boolean isDisabled()
Returns:
true iff this sensor is disabled

setNoParticipate

public void setNoParticipate(boolean disabled)
Not participating sensors do forward messages, but don't include thier own aggs