From: yeom Date: Sat, 1 Oct 2011 00:18:01 +0000 (+0000) Subject: add input sensor data file X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=0e648e45866f1a258cffb8147d5bde92420fdbde;p=IRC.git add input sensor data file --- diff --git a/Robust/src/Benchmarks/SSJava/JavaNator/RobotMain.java b/Robust/src/Benchmarks/SSJava/JavaNator/RobotMain.java index 381e10cd..84dd7e7a 100644 --- a/Robust/src/Benchmarks/SSJava/JavaNator/RobotMain.java +++ b/Robust/src/Benchmarks/SSJava/JavaNator/RobotMain.java @@ -26,7 +26,7 @@ public class RobotMain { private static boolean DEBUG1 = true; - private static boolean DEBUG = false; + private static boolean DEBUG = true; private static final int OFF_MODE = 1; private static final int ON_MODE = 2; private static final int MANUAL_MODE = 1; @@ -116,9 +116,8 @@ public class RobotMain { // } if (DEBUG) { - // System.out.println("processIOCommand: Getting in opCode = " - // + Integer.toHexString((int) opCode) + " data = " + - // Integer.toHexString((int) data)); + System.out.println("processIOCommand: Default: opCode = " + Integer.toString((int) opCode) + + " data = " + Integer.toString((int) data)); } switch ((int) opCode) { case ON_OFF: @@ -235,6 +234,7 @@ public class RobotMain { */ public static void main(String args[]) { + TestSensorInput.init(); boolean active = true; /** * RealTime management of the robot behaviour based on sensors and commands @@ -273,17 +273,21 @@ public class RobotMain { int count = 0; - while (active && count < 10000) { + while (active && count < 100000) { try { - if (DEBUG) { - System.out.println("Main: Waiting for remote commands"); - } + // if (DEBUG) { + // System.out.println("Main: Waiting for remote commands"); + // } // try { // obj.wait(); // } catch (IllegalMonitorStateException ie) { // System.out.println("IllegalMonitorStateException caught in main loop"); // } currentCommand = TestSensorInput.getCommand(); + if (currentCommand == -1) { + break; + } + System.out.println("currentCommand="+currentCommand); processIOCommand(); // Nothing to do } catch (Exception e) { diff --git a/Robust/src/Benchmarks/SSJava/JavaNator/StrategyMgr.java b/Robust/src/Benchmarks/SSJava/JavaNator/StrategyMgr.java index c8d12f55..94df925a 100644 --- a/Robust/src/Benchmarks/SSJava/JavaNator/StrategyMgr.java +++ b/Robust/src/Benchmarks/SSJava/JavaNator/StrategyMgr.java @@ -33,7 +33,7 @@ public class StrategyMgr { // private boolean DEBUGL = false; // private boolean DEBUG = true; - private boolean DEBUG = false; + private boolean DEBUG = true; /** * Constructor - Invoke communication to remote application thread @@ -42,8 +42,6 @@ public class StrategyMgr { this.pwmControl = pwmManager.getPWMControl(); rand = new Random(); } - - void processSonars(byte sonarSensors) { @@ -149,10 +147,7 @@ public class StrategyMgr { } catch (InterruptedException ie) { } } - - // TODO - // lineSensorsMask = sm.getLineSensorsState(); - + lineSensorsMask = TestSensorInput.getCommand(); }// while loop } diff --git a/Robust/src/Benchmarks/SSJava/JavaNator/TestSensorInput.java b/Robust/src/Benchmarks/SSJava/JavaNator/TestSensorInput.java index 4ca1a31d..2f9319c3 100644 --- a/Robust/src/Benchmarks/SSJava/JavaNator/TestSensorInput.java +++ b/Robust/src/Benchmarks/SSJava/JavaNator/TestSensorInput.java @@ -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 index 00000000..5f5f63a4 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/JavaNator/input.dat @@ -0,0 +1,18 @@ +99 +99 +99 +99 +97 +97 +97 +97 +97 +68 +68 +96 +99 +99 +96 +99 + +