add input sensor data file
authoryeom <yeom>
Sat, 1 Oct 2011 00:18:01 +0000 (00:18 +0000)
committeryeom <yeom>
Sat, 1 Oct 2011 00:18:01 +0000 (00:18 +0000)
Robust/src/Benchmarks/SSJava/JavaNator/RobotMain.java
Robust/src/Benchmarks/SSJava/JavaNator/StrategyMgr.java
Robust/src/Benchmarks/SSJava/JavaNator/TestSensorInput.java
Robust/src/Benchmarks/SSJava/JavaNator/input.dat [new file with mode: 0644]

index 381e10cd59b75d40b269e0a8977d1647d7381f39..84dd7e7a134ca4ae32563f9f9c87413f0e592f6b 100644 (file)
@@ -26,7 +26,7 @@
 public class RobotMain {\r
 \r
   private static boolean DEBUG1 = true;\r
-  private static boolean DEBUG = false;\r
+  private static boolean DEBUG = true;\r
   private static final int OFF_MODE = 1;\r
   private static final int ON_MODE = 2;\r
   private static final int MANUAL_MODE = 1;\r
@@ -116,9 +116,8 @@ public class RobotMain {
     // }\r
 \r
     if (DEBUG) {\r
-      // System.out.println("processIOCommand: Getting in opCode = "\r
-      // + Integer.toHexString((int) opCode) + " data = " +\r
-      // Integer.toHexString((int) data));\r
+      System.out.println("processIOCommand: Default: opCode = " + Integer.toString((int) opCode)\r
+          + " data = " + Integer.toString((int) data));\r
     }\r
     switch ((int) opCode) {\r
     case ON_OFF:\r
@@ -235,6 +234,7 @@ public class RobotMain {
    */\r
   public static void main(String args[]) {\r
 \r
+    TestSensorInput.init();\r
     boolean active = true;\r
     /**\r
      * RealTime management of the robot behaviour based on sensors and commands\r
@@ -273,17 +273,21 @@ public class RobotMain {
 \r
     int count = 0;\r
 \r
-    while (active && count < 10000) {\r
+    while (active && count < 100000) {\r
       try {\r
-        if (DEBUG) {\r
-          System.out.println("Main: Waiting for remote commands");\r
-        }\r
+        // if (DEBUG) {\r
+        // System.out.println("Main: Waiting for remote commands");\r
+        // }\r
         // try {\r
         // obj.wait();\r
         // } catch (IllegalMonitorStateException ie) {\r
         // System.out.println("IllegalMonitorStateException caught in main loop");\r
         // }\r
         currentCommand = TestSensorInput.getCommand();\r
+        if (currentCommand == -1) {\r
+          break;\r
+        }\r
+        System.out.println("currentCommand="+currentCommand);\r
         processIOCommand();\r
         // Nothing to do\r
       } catch (Exception e) {\r
index c8d12f5544fbf317c9c80b97322b966ae789d845..94df925ab872abea6ab198f1e1611de005bb624b 100644 (file)
@@ -33,7 +33,7 @@ public class StrategyMgr {
   // private boolean DEBUGL = false;\r
 \r
   // private boolean DEBUG = true;\r
-  private boolean DEBUG = false;\r
+  private boolean DEBUG = true;\r
 \r
   /**\r
    * Constructor - Invoke communication to remote application thread\r
@@ -42,8 +42,6 @@ public class StrategyMgr {
     this.pwmControl = pwmManager.getPWMControl();\r
     rand = new Random();\r
   }\r
-  \r
-  \r
 \r
   void processSonars(byte sonarSensors) {\r
 \r
@@ -149,10 +147,7 @@ public class StrategyMgr {
         } catch (InterruptedException ie) {\r
         }\r
       }\r
-\r
-      // TODO\r
-      // lineSensorsMask = sm.getLineSensorsState();\r
-\r
+      lineSensorsMask = TestSensorInput.getCommand();\r
     }// while loop\r
   }\r
 \r
index 4ca1a31d7deaefdce6f886760da3819b351eef0c..2f9319c300a2efe971c9fe54dad39d0d0cd24b88 100644 (file)
@@ -1,14 +1,17 @@
 public class TestSensorInput {
 
-  FileInputStream inputFile;
+  private static FileInputStream inputFile;
 
-  public void init() {
+  public static void init() {
     inputFile = new FileInputStream("input.dat");
   }
 
   public static byte getCommand() {
-    // return Byte.parseInt(inputFile.readLine());
-    return 0;
+    String in = inputFile.readLine();
+    if (in == null) {
+      return (byte) -1;
+    }
+    return (byte) Integer.parseInt(in);
   }
 
 }
diff --git a/Robust/src/Benchmarks/SSJava/JavaNator/input.dat b/Robust/src/Benchmarks/SSJava/JavaNator/input.dat
new file mode 100644 (file)
index 0000000..5f5f63a
--- /dev/null
@@ -0,0 +1,18 @@
+99
+99
+99
+99
+97
+97
+97
+97
+97
+68
+68
+96
+99
+99
+96
+99
+
+