changes + add two more benchmarks without annotations
[IRC.git] / Robust / src / Benchmarks / SSJava / JavaNatorInfer / PWMControl.java
diff --git a/Robust/src/Benchmarks/SSJava/JavaNatorInfer/PWMControl.java b/Robust/src/Benchmarks/SSJava/JavaNatorInfer/PWMControl.java
new file mode 100644 (file)
index 0000000..05a1c56
--- /dev/null
@@ -0,0 +1,192 @@
+/*\r
+ * PWMControl.java\r
+ *\r
+ * Copyright (c) 1993-2002 Sun Microsystems, Inc. All Rights Reserved.\r
+ *\r
+ * This software is the confidential and proprietary information of Sun\r
+ * Microsystems, Inc. ("Confidential Information").  You shall not\r
+ * disclose such Confidential Information and shall use it only in\r
+ * accordance with the terms of the license agreement you entered into\r
+ * with Sun.\r
+ *\r
+ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF\r
+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED\r
+ * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\r
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR\r
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR\r
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.\r
+ */\r
+\r
+/**\r
+ * This class is the super class of all motor control classes. The class\r
+ * represent a generic interface to such class. In our case the motor controller\r
+ * require for 0 speed 1.5 ms out of 10-20ms cycle and a change between 1 to 2\r
+ * seconds for max reverse and forward speed. These values: 1, 1.5, 2 and 20 ms\r
+ * are thus this class specific\r
+ * \r
+ * @author Michael Gesundheit\r
+ * @version 1.0\r
+ */\r
+\r
+public abstract class PWMControl {\r
+\r
+  PWMManager pwmManager;\r
+  boolean DEBUG = false;\r
+  // boolean DEBUG = true;\r
+  static final byte PULSE_HIGH = 1;\r
+  static final byte PULSE_LOW = 0;\r
+  int highMask;\r
+  int m1HighMask;\r
+  int m2HighMask;\r
+  int lowMask;\r
+  int myOwnBit;\r
+  int myBitPos;\r
+  int m1BitPos;\r
+  int m2BitPos;\r
+  int speedFactor;\r
+  int agilityFactor;\r
+  boolean updateTime;\r
+  int pulseWidth;\r
+  Object obj;\r
+\r
+  int motorLeftUpTime = 150;\r
+  int motorRightUpTime = 150;\r
+  boolean manualMode = false;\r
+\r
+  PWMControl(PWMManager pwmMan, int motor1bit, int motor2bit) {\r
+    pwmManager = pwmMan; // This is papa\r
+    m1BitPos = 0x1 << motor1bit;\r
+    m2BitPos = 0x1 << motor2bit;\r
+    m1HighMask = 0x1 << motor1bit;\r
+    m2HighMask = 0x1 << motor2bit;\r
+    lowMask = 0x0;\r
+    obj = new Object();\r
+  }\r
+\r
+  public void setManualMode() {\r
+    if (DEBUG)\r
+      System.out.println("PWMContolr: setManualMode... ");\r
+//    synchronized (obj) {\r
+      if (manualMode == false) {\r
+        manualMode = true;\r
+      }\r
+//    }\r
+  }\r
+\r
+  public void setAutomatedMode() {\r
+    if (DEBUG)\r
+      System.out.println("PWMControl: setAutomatedMode... ");\r
+//    synchronized (obj) {\r
+      if (manualMode == true) {\r
+        System.out.println("PWMControl: wake me up... ");\r
+        manualMode = false;\r
+        // obj.notify();\r
+        System.out.println("PWMControl: wake me up...... tried!!!");\r
+      }\r
+//    }\r
+  }\r
+\r
+  /**\r
+   * OutPut value to motor control line\r
+   */\r
+  public void outToPortMLeft(byte value) {\r
+    /*\r
+     * System.out.println("PWMControl " + Integer.toString(myOwnBit) +\r
+     * //" bit position = 0x" + Integer.toHexString(myOwnBit) +\r
+     * " output value = 0x" + Integer.toHexString(value));\r
+     */\r
+    if (value == PULSE_HIGH) {\r
+      pwmManager.writeToPort(m1BitPos, m1HighMask);\r
+    } else {\r
+      pwmManager.writeToPort(m1BitPos, lowMask);\r
+    }\r
+  }\r
+\r
+  public void outToPortMRight(byte value) {\r
+    /*\r
+     * System.out.println("PWMControl " + Integer.toString(myOwnBit) +\r
+     * //" bit position = 0x" + Integer.toHexString(myOwnBit) +\r
+     * " output value = 0x" + Integer.toHexString(value));\r
+     */\r
+    if (value == PULSE_HIGH) {\r
+      pwmManager.writeToPort(m2BitPos, m2HighMask);\r
+    } else {\r
+      pwmManager.writeToPort(m2BitPos, lowMask);\r
+    }\r
+  }\r
+\r
+  /**\r
+   * setSpeedSpin - Set speed for the spin case motor 1.\r
+   * \r
+   * @param uptime\r
+   *          pulse width (time position)\r
+   */\r
+  public void setSpeedSpinLeft(int timePosition) {\r
+  }\r
+\r
+  /**\r
+   * setSpeedSpinRight - Set speed for the spin case right motor.\r
+   * \r
+   * @param uptime\r
+   *          pulse width (time position)\r
+   */\r
+  public void setSpeedSpinRight(int timePosition) {\r
+  }\r
+\r
+  /**\r
+   * setSpeedTurnM1 - set speed considering agility factor for motor 1\r
+   * \r
+   * @param uptime\r
+   *          pulse width (time position)\r
+   */\r
+  public void setSpeedTurnLeft(int timePosition) {\r
+  }\r
+\r
+  /**\r
+   * setSpeedTurnM1 - set speed considering agility factor for motor 2\r
+   * \r
+   * @param uptime\r
+   *          pulse width (time position)\r
+   */\r
+  public void setSpeedTurnRight(int timePosition) {\r
+  }\r
+\r
+  /**\r
+   * setSpeedLeft - speed control for motor 1.\r
+   * \r
+   * @param uptime\r
+   *          pulse width (time position)\r
+   */\r
+  public void setSpeedLeft(int timePosition) {\r
+  }\r
+\r
+  /**\r
+   * setSpeedRight - speed control for motor 1.\r
+   * \r
+   * @param uptime\r
+   *          pulse width (time position)\r
+   */\r
+  public void setSpeedRight(int timePosition) {\r
+  }\r
+\r
+  public void setSpeedAgilityFactors(int speed, int agility) {\r
+//    synchronized (this) {\r
+      speedFactor = speed;\r
+      agilityFactor = agility;\r
+//    }\r
+  }\r
+\r
+  public void setUrgentReverse() {\r
+  }\r
+\r
+  public void setUrgentStraight() {\r
+  }\r
+\r
+  /**\r
+   * Control debug messageing. true - Activate debug messages false - deactivate\r
+   * debug messages\r
+   */\r
+  public void setDebug(boolean debug) {\r
+    DEBUG = debug;\r
+  }\r
+}\r