Skip to content

Commit

Permalink
Added a 'type' attribute in sensors info.
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Cabé authored and Benjamin Cabé committed Oct 28, 2011
1 parent 03efc2a commit f551798
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
20 changes: 11 additions & 9 deletions simulator/src/Main.java
Expand Up @@ -128,20 +128,22 @@ public void run() {
private static void resetInfoCollection(DBCollection infoCollection) {
infoCollection.drop();

infoCollection.insert(new SensorInfo("CUBE_TEMPERATURE",
infoCollection.insert(new SensorInfo("CUBE_TEMPERATURE", "temperature",
"Temperature at the cube", "¡C"));
infoCollection.insert(new SensorInfo("CUBE_ILLUMINANCE",
"Ambient light level at the cube", "lux"));
infoCollection.insert(new SensorInfo("CUBE_ILLUMINANCE", "light",
"Ambient light level at the cube", "lx"));
infoCollection.insert(new SensorInfo("CUBE_HUMIDITY", "humidity",
"Humidity level at the cube", "%"));

infoCollection.insert(new SensorInfo("STATION1_TEMPERATURE",
"Temperature at station #1", "¡C"));
infoCollection.insert(new SensorInfo("STATION1_ILLUMINANCE",
"Ambient light level at station #1", "lux"));
"temperature", "Temperature at station #1", "¡C"));
infoCollection.insert(new SensorInfo("STATION1_ILLUMINANCE", "light",
"Ambient light level at station #1", "lx"));

infoCollection.insert(new SensorInfo("STATION2_TEMPERATURE",
"Temperature at station #2", "¡C"));
infoCollection.insert(new SensorInfo("STATION2_ILLUMINANCE",
"Ambient light level at station #2", "lux"));
"temperature", "Temperature at station #2", "¡C"));
infoCollection.insert(new SensorInfo("STATION2_ILLUMINANCE", "light",
"Ambient light level at station #2", "lx"));
}

private static void performMapReduce(DBCollection collection,
Expand Down
5 changes: 4 additions & 1 deletion simulator/src/SensorInfo.java
Expand Up @@ -12,18 +12,21 @@
@SuppressWarnings("serial")
public class SensorInfo extends BasicDBObject {
private static final String SENSOR_NAME_KEY = "sensor";
private static final String SENSOR_TYPE_KEY = "type";
private static final String SENSOR_DESCRIPTION_KEY = "description";
private static final String SENSOR_UNIT_KEY = "unit";

public SensorInfo(String name, String desc, String unit) {
public SensorInfo(String name, String type, String desc, String unit) {
this.put(SENSOR_NAME_KEY, name);
this.put(SENSOR_TYPE_KEY, type);
this.put(SENSOR_DESCRIPTION_KEY, desc);
this.put(SENSOR_UNIT_KEY, unit);
}

@Override
public String toString() {
return "SensorInfo: \"" + this.get(SENSOR_NAME_KEY) + "\" "
+ this.get(SENSOR_TYPE_KEY) + "\" "
+ this.get(SENSOR_DESCRIPTION_KEY) + "\" "
+ this.get(SENSOR_UNIT_KEY);
}
Expand Down

0 comments on commit f551798

Please sign in to comment.