Research Article

Gathering Contextual Data with Power Information Using Smartphones in Internet of Everything

Pseudocode 1

Pseudocode of PowerIpsum process.
STEP #  pseudocode
1 int numberOfAttributes; //total number of attributes
2 double sensorData[numberOfAttributes]; //array for sensor data
3 URL weatherURL;
4 URL mapURL;
5 file contextFile;
6 procedure init() {
7  mapURL = new URL(“https://developer.mapquest.com/);
8  weatherURL = new URL(“https://api.openweathermap.org”);
9  contextFile = new file(“contextualData.Txt”);
10 }
11 procedure powerIpsum (){
12  double timestampBefore = getCLK();
13  double avgCurrentBefore = getAverageCurrent();
14  double batteryLevelBefore = getBatteryLevel();
15  for (int i =0; i < numberOfAttributes; i++) {
16   sensorData[i] = attributeValue; //value of attribute
17  }
18  HttpURLConnection con1 = weatherURL.openConnection();
19  string weatherRep = con1.setRequestMethod(“GET”, lat, long);
20  HttpURLConnection con2 = mapURL.openConnection();
21  string mapRep = con2.setRequestMethod(“GET”, lat, long);
22  double timestampAfter = getCLK();
23  double avgCurrentAfter = getAverageCurrent();
24  double batteryLevelAfter = getBatteryLevel();
25  string activityLabel = inputUserLabel(); //user types data
26  contextFile.Append(timestampBefore, avgCurrentbefore, batterylevelbefore, sensordata[], weatherRep, mapRep, timestampAfter, avgCurrentafter, batteryLevelafter, activityLabel, “endLine”);
27 }