forked from kevin.shehu/GGD
FIX : Sensor reading
NEW : Idea for Rule Engine
This commit is contained in:
@@ -22,7 +22,7 @@ public class ApiCall {
|
||||
UserCredentials userCredentials = new UserCredentials();
|
||||
final String username = userCredentials.getUsername();
|
||||
final String password = userCredentials.getPassword();
|
||||
final String homeRoot = userCredentials.getHomeRoot();
|
||||
final String homeRoot = UserCredentials.getHomeRoot();
|
||||
String outputToken;
|
||||
WriteFile writingIntoFile = new WriteFile();
|
||||
Date now; // to display current time
|
||||
@@ -46,15 +46,28 @@ public class ApiCall {
|
||||
ReadSensors4Partner readSensors4Partner = new ReadSensors4Partner();
|
||||
ArrayList<String> outputValue = (readSensors4Partner.FetchSensor4Box("Germes", token));
|
||||
for(int i=0;i<outputValue.size();i++){
|
||||
JSONArray jsonArray = new JSONArray(outputValue.get(i));
|
||||
for(int j=0; j<jsonArray.length(); j++){
|
||||
JSONObject jsonobject = jsonArray.getJSONObject(j);
|
||||
double value = jsonobject.getDouble("value");
|
||||
String sensorTag = jsonobject.getString("sensorTag");
|
||||
String sensorId = jsonobject.getString("sensorId");
|
||||
String deviceId = jsonobject.getString("deviceId");
|
||||
Device device;
|
||||
JSONArray sensorDatas = new JSONArray(outputValue.get(i));
|
||||
|
||||
finalOutput.put(sensorTag, new SensorData(deviceId, value,sensorId));
|
||||
for(int j=0; j<sensorDatas.length(); j++) { //15
|
||||
JSONObject sensorData = sensorDatas.getJSONObject(j);
|
||||
|
||||
String deviceId = sensorData.getString("deviceId");
|
||||
|
||||
double value = sensorData.getDouble("value");
|
||||
String sensorTag = sensorData.getString("sensorTag");
|
||||
String sensorId = sensorData.getString("sensorId");
|
||||
|
||||
SensorData sd = new SensorData(sensorId, value, sensorTag);
|
||||
|
||||
if(devices.containsKey(deviceId)) {
|
||||
device = devices.get(deviceId);
|
||||
device.addSensorData(sd);
|
||||
} else {
|
||||
device = new Device(deviceId);
|
||||
device.addSensorData(sd);
|
||||
devices.put(deviceId, device);
|
||||
}
|
||||
}
|
||||
}
|
||||
return finalOutput;
|
||||
|
||||
Reference in New Issue
Block a user