Skip to content

Add dictionary datatype #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.sensingkit.sensingkitlib.SKSensorType;

import java.util.HashMap;
import java.util.Locale;


Expand Down Expand Up @@ -79,6 +80,30 @@ public String getDataInCSV() {
return String.format(Locale.US, "%d,%f,%f,%f", this.timestamp, this.x, this.y, this.z);
}

/**
* Get the accelerator measurements in dictionary format
*
* @return Dictionary containing the time stamp and accelerometer measurements in dictionary format:
* sensor type, sensor type in string, timeIntervalSince1970, accelerometer in x,y,z
*/
@Override
public HashMap getDataInDict() {
HashMap multiMap = new HashMap<>();
HashMap<String,Float> accelerationMap = new HashMap<>();

multiMap.put("sensorType",this.getSensorType());
multiMap.put("sensorTypeString",this.getSensorType().toString());
multiMap.put("timestamp",this.timestamp);

accelerationMap.put("x",this.x);
accelerationMap.put("y",this.y);
accelerationMap.put("z",this.z);

multiMap.put("acceleration",accelerationMap);

return multiMap;
}

/**
* Get the X-axis acceleromator measurement
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.sensingkit.sensingkitlib.SKSensorType;

import java.util.HashMap;
import java.util.Locale;

/**
Expand Down Expand Up @@ -70,6 +71,24 @@ public String getDataInCSV() {
return String.format(Locale.US, "%d,%f", this.timestamp, this.temperature);
}

/**
* Get the Ambient Temperature sensor data in dictionary format
*
* @return Dictionary containing the ambient temperature in dictionary format:
* sensor type, sensor type in string, timeIntervalSince1970, temperature
*/
@Override
public HashMap getDataInDict() {
HashMap multiMap = new HashMap<>();

multiMap.put("sensorType",this.getSensorType());
multiMap.put("sensorTypeString",this.getSensorType().toString());
multiMap.put("timestamp",this.timestamp);
multiMap.put("temperature",this.temperature);

return multiMap;
}

/**
* Get only the Ambient Temperature
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.sensingkit.sensingkitlib.SKSensorType;

import java.util.HashMap;
import java.util.Locale;

/**
Expand Down Expand Up @@ -69,6 +70,24 @@ public String getDataInCSV() {
return String.format(Locale.US, "%d,%d", this.timestamp, this.level);
}

/**
* Get the audio level measurement in dictionary format
*
* @return Dictionary containing the timestamp and audio level measurements in dictionary format:
* sensor type, sensor type in string, timeIntervalSince1970, level
*/
@Override
public HashMap getDataInDict() {
HashMap multiMap = new HashMap<>();

multiMap.put("sensorType",this.getSensorType());
multiMap.put("sensorTypeString",this.getSensorType().toString());
multiMap.put("timestamp",this.timestamp);
multiMap.put("audioLevel",this.level);

return multiMap;
}

/**
* Get the audio level only
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.sensingkit.sensingkitlib.SKSensorType;

import java.util.HashMap;
import java.util.Locale;

/**
Expand Down Expand Up @@ -70,6 +71,24 @@ public String getDataInCSV() {
return String.format(Locale.US, "%d,%f", this.timestamp, this.pressure);
}

/**
* Get the Barometer sensor data in dictionary format
*
* @return Dictionary containing the barometer data in dictionary format:
* sensor type, sensor type in string, timeIntervalSince1970, pressure
*/
@Override
public HashMap getDataInDict() {
HashMap multiMap = new HashMap<>();

multiMap.put("sensorType",this.getSensorType());
multiMap.put("sensorTypeString",this.getSensorType().toString());
multiMap.put("timestamp",this.timestamp);
multiMap.put("pressure",this.pressure);

return multiMap;
}

/**
* Get the Air Pressure measurement along
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import org.sensingkit.sensingkitlib.SKSensorType;

import java.util.HashMap;
import java.util.Locale;

import static android.os.BatteryManager.*;
Expand Down Expand Up @@ -98,12 +99,41 @@ public static String csvHeader() {
* status string ("charging", "discharging", "full", "not charging", "unknown" or "unsupported"),
* health string ("cold", "dead", "good", "over heat", "over voltage", "unknown", "failure" or "unsupported")
*/

@Override
public String getDataInCSV() {
return String.format(Locale.US, "%d,%f,%d,%d,%s,%s,%s", this.timestamp, this.getLevelRatio(), this.temperature, this.voltage, getPluggedString(), getBatteryStatusString(), getBatteryHealthString());
}

/**
* Get the battery properties in dictionary format
*
* @return Dictionary containing the battery properties in dictionary format:
* sensor type, sensor type in string, timeIntervalSince1970,charge,temperature,voltage,
* plugged string ("usb", "ac", "wireless" or "unknown"),
* status string ("charging", "discharging", "full", "not charging", "unknown" or "unsupported"),
* health string ("cold", "dead", "good", "over heat", "over voltage", "unknown", "failure" or "unsupported")
*/
@Override
public HashMap getDataInDict() {
HashMap multiMap = new HashMap<>();
HashMap batteryMap = new HashMap<>();

multiMap.put("sensorType",this.getSensorType());
multiMap.put("sensorTypeString",this.getSensorType().toString());
multiMap.put("timestamp",this.timestamp);

batteryMap.put("charge",this.getLevelRatio());
batteryMap.put("temperature",this.temperature);
batteryMap.put("voltage",this.voltage);
batteryMap.put("plugged",getPluggedString());
batteryMap.put("status",getBatteryStatusString());
batteryMap.put("health",getBatteryHealthString());

multiMap.put("battery",batteryMap);

return multiMap;
}

/**
* Get the battery charge
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.sensingkit.sensingkitlib.SKSensorType;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;

/**
Expand Down Expand Up @@ -85,6 +86,27 @@ public String getDataInCSV() {
return stringBuilder.toString();
}

/**
* Get the data for all Beacon devices in dictionary format
*
* @return Dictionary formatted as follows: timeIntervalSince1970, device1 data, device2 data,,,
*/
@Override
public HashMap getDataInDict() {

HashMap allBeaconProximityMap = new HashMap();

// Add deviceData
int i = 1;
for (SKBeaconProximityData deviceData : mDevices) {
allBeaconProximityMap.put("deviceNo" + i++, deviceData.getDataInDict());
}

// Return in HashMap
return(allBeaconProximityMap);
}


/**
* Get Beacon device data
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.altbeacon.beacon.Identifier;
import org.sensingkit.sensingkitlib.SKSensorType;

import java.util.HashMap;
import java.util.Locale;

public class SKBeaconProximityData extends SKAbstractData {
Expand All @@ -50,14 +51,50 @@ public static String csvHeader() {
return "timeIntervalSince1970,beaconType,manufacturer,id1,id2,id3,rssi,txPower,distance";
}

/**
* Get the Beacon Proximity sensor data in csv format
*
* @return String containing the Beacon Proximity sensor data in csv format:
* sensor type, sensor type in string, timeIntervalSince1970, beaconType, manufacturer, id1,id2,id3,rssi,txPower,distance
*/
@Override
public String getDataInCSV() {
return String.format(Locale.US, "%d,%d,%d,%s,%d,%d,%d,%d,%f",
this.timestamp, this.getBeaconTypeCode(), this.getManufacturer(),
this.getId1().toString(), this.getId2().toInt(), this.getId3().toInt(),
this.getRssi(), this.getTxPower(), this.getDistance() );
this.getRssi(), this.getTxPower(), this.getDistance());
}

/**
* Get the Beacon Proximity sensor data in dictionary format
*
* @return Dictionary containing the Beacon Proximity sensor data in dictionary format:
* sensor type, sensor type in string, timeIntervalSince1970, beaconType, manufacturer, id1,id2,id3,rssi,txPower,distance
*/
@Override
public HashMap getDataInDict() {
HashMap multiMap = new HashMap<>();
HashMap beaconProximityMap = new HashMap<>();

multiMap.put("sensorType",this.getSensorType());
multiMap.put("sensorTypeString",this.getSensorType().toString());
multiMap.put("timestamp",this.timestamp);

beaconProximityMap.put("beaconType",this.getBeaconTypeCode());
beaconProximityMap.put("manufacturer",this.getManufacturer());
beaconProximityMap.put("id1",this.getId1().toString());
beaconProximityMap.put("id2",this.getId2().toInt());
beaconProximityMap.put("id3",this.getId3().toInt());
beaconProximityMap.put("rssi",this.getRssi());
beaconProximityMap.put("txPower",this.getTxPower());
beaconProximityMap.put("distance",this.getDistance());

multiMap.put("beaconProximity",beaconProximityMap);

return multiMap;
}


@SuppressWarnings("unused")
public int getBeaconTypeCode() {
return mBeacon.getBeaconTypeCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.sensingkit.sensingkitlib.SKSensorType;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;

/**
Expand Down Expand Up @@ -85,6 +86,26 @@ public String getDataInCSV() {
return stringBuilder.toString();
}

/**
* Get the data for all Bluetooth devices in dictionary format
*
* @return Dictionary formatted as follows: timestamp, device1 data, device2 data,,,
*/
@Override
public HashMap getDataInDict() {

HashMap allBluetoothMap = new HashMap();

// Add deviceData
int i = 1;
for (SKBluetoothData deviceData : mDevices) {
allBluetoothMap.put("deviceNo" + i++, deviceData.getDataInDict());
}

// Return in HashMap
return(allBluetoothMap);
}

/**
* Get Bluetooth device data
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.sensingkit.sensingkitlib.SKSensorType;

import java.util.HashMap;
import java.util.Locale;

/**
Expand Down Expand Up @@ -75,6 +76,32 @@ public String getDataInCSV() {
return String.format(Locale.US, "%d,%s,%s,%d", this.timestamp, this.name, this.address, this.rssi);
}


/**
* Get the Bluetooth data in dictionary format
*
* @return Dictionary containing the bluetooth data in dictionary format:
* sensor type, sensor type in string, timeIntervalSince1970, name,address,rssi
*/
@Override
public HashMap getDataInDict() {
HashMap multiMap = new HashMap<>();
HashMap blueToothMap = new HashMap<>();

multiMap.put("sensorType",this.getSensorType());
multiMap.put("sensorTypeString",this.getSensorType().toString());
multiMap.put("timestamp",this.timestamp);

blueToothMap.put("name",this.name);
blueToothMap.put("address",this.address);
blueToothMap.put("rssi",this.rssi);

multiMap.put("blueTooth",blueToothMap);

return(multiMap);
}


/**
* Get the Bluetooth device name
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.sensingkit.sensingkitlib.SKSensorType;

import java.util.HashMap;
import java.util.Locale;

/**
Expand Down Expand Up @@ -77,6 +78,30 @@ public String getDataInCSV() {
return String.format(Locale.US, "%d,%f,%f,%f", this.timestamp, this.x, this.y, this.z);
}

/**
* Get the Gravity sensor data in dictionary format
*
* @return Dictionary containing the Gravity sensor data in dictionary format:
* sensor type, sensor type in string, timeIntervalSince1970, x-axis, y-axis, z-axis
*/
@Override
public HashMap getDataInDict() {
HashMap multiMap = new HashMap<>();
HashMap<String,Float> gravityMap = new HashMap<>();

multiMap.put("sensorType",this.getSensorType());
multiMap.put("sensorTypeString",this.getSensorType().toString());
multiMap.put("timestamp",this.timestamp);

gravityMap.put("x",this.x);
gravityMap.put("y",this.y);
gravityMap.put("z",this.z);

multiMap.put("gravity",gravityMap);

return(multiMap);
}

/**
* Get the Gravity sensor X-axis value
*
Expand Down
Loading