Changes
authorAli Younis <ayounis@uci.edu>
Tue, 16 May 2017 05:04:47 +0000 (22:04 -0700)
committerAli Younis <ayounis@uci.edu>
Tue, 16 May 2017 05:04:47 +0000 (22:04 -0700)
version2/src/java/light_fan_embed_benchmark/Sensor.java [new file with mode: 0644]
version2/src/java/light_fan_embed_benchmark/Setup.java
version2/src/java/light_fan_embed_benchmark/WemoController.java
version2/src/java/light_fan_embed_benchmark/run3.bash

diff --git a/version2/src/java/light_fan_embed_benchmark/Sensor.java b/version2/src/java/light_fan_embed_benchmark/Sensor.java
new file mode 100644 (file)
index 0000000..fe03e1d
--- /dev/null
@@ -0,0 +1,87 @@
+import iotcloud.*;
+import java.util.*;
+import java.lang.*;
+import java.io.*;
+
+class Sensor {
+    public static void main(String[] args) throws Exception {
+
+
+        Table t1 = new Table("http://dc-6.calit2.uci.edu/test.iotcloud/", "reallysecret", 361, -1);
+        t1.rebuild();
+
+
+
+        String pingTimerKey = "sensorController";
+        IoTString ipingTimerKey = new IoTString(pingTimerKey);
+
+        String a1 = "sensor";
+        IoTString ia1 = new IoTString(a1);
+
+
+        System.out.println("Starting System");
+
+
+
+
+        while (true) {
+            try {
+
+
+
+                Runtime runTime = Runtime.getRuntime();
+                // Process proc = runTime.exec("/opt/vc/bin/vcgencmd measure_temp | tr -d 'temp=' |  tr -d \"'C\"");
+                Process proc = runTime.exec("/opt/vc/bin/vcgencmd measure_temp");
+                BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+                String line = null;
+                String dat = "";
+                while ((line = reader.readLine()) != null) {
+                    System.out.println(line);
+                    dat = line;
+                }
+                reader.close();
+
+
+
+                String pingTimer = Long.toString(System.currentTimeMillis());
+                IoTString ipingTimer = new IoTString(pingTimer);
+
+
+                IoTString senDat = new IoTString(dat);
+
+                t1.update();
+                t1.startTransaction();
+                t1.addKV(ipingTimerKey, ipingTimer);
+                t1.addKV(ia1, senDat);
+                t1.commitTransaction();
+
+
+
+
+
+
+
+
+
+
+
+
+                Thread.sleep(1000);
+
+            } catch (Error e) {
+                e.printStackTrace();
+
+                Runtime runTime = Runtime.getRuntime();
+                runTime.exec("gpio mode 4 out");
+
+
+                while (true) {
+                    runTime.exec("gpio write 4 1");
+                    Thread.sleep(500);
+                    runTime.exec("gpio write 4 0");
+                    Thread.sleep(500);
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
index 1fb86c89ab291fbc2af5d9d676f5807a0eb8faa6..a9ae0f2de513598304f11af6be4e149294850dc8 100644 (file)
@@ -24,6 +24,10 @@ class Setup {
         IoTString ib2 = new IoTString(b2);
 
 
+        String c1 = "sensor";
+        IoTString ic1 = new IoTString(c1);
+
+
         String pingTimerKey = "bulbController";
         IoTString ipingTimerKey = new IoTString(pingTimerKey);
 
@@ -32,6 +36,10 @@ class Setup {
         IoTString ipingTimerKey2 = new IoTString(pingTimerKey2);
 
 
+        String pingTimerKey3 = "sensorController";
+        IoTString ipingTimerKey3 = new IoTString(pingTimerKey3);
+
+
         t1.createNewKey(ia1, 321);
         t1.createNewKey(ia2, 321);
         t1.createNewKey(ia3, 321);
@@ -41,6 +49,10 @@ class Setup {
         t1.createNewKey(ib2, 351);
         t1.createNewKey(ipingTimerKey2, 351);
 
+
+        t1.createNewKey(ic1, 361);
+        t1.createNewKey(ipingTimerKey3, 361);
+
         t1.update();
     }
 }
\ No newline at end of file
index f19ac624b9817ebbf007d066f03fecfe7cdd5770..41117fda16bd972501348a4515d8257710ba1042 100644 (file)
@@ -8,12 +8,6 @@ class WemoController {
         Table t1 = new Table("http://dc-6.calit2.uci.edu/test.iotcloud/", "reallysecret", 351, -1);
         t1.rebuild();
 
-
-        String a = "fan";
-        IoTString ia = new IoTString(a);
-        t1.createNewKey(ia, 351);
-
-
         String a1 = "wemo1";
         String a2 = "wemo2";
 
index c12e81cb60e114cbaf2ec92fa3de891d4cf11185..0b71cec45a5dc57ef57b69d7fcd51c74fa352516 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-java -cp .:../iotcloud/bin WemoController
\ No newline at end of file
+java -cp .:../iotcloud/bin Sensor
\ No newline at end of file