Commit [062735] Maximize Restore History

Merge branch 'newport'

gloomyandy gloomyandy 2013-10-06

1 2 3 .. 8 > >> (Page 1 of 8)
added ev3classes/src/lejos/internal/ev3/EV3IOPort.java
added ev3classes/src/lejos/internal/ev3/EV3Port.java
added ev3classes/src/lejos/internal/ev3/EV3UARTPort.java
changed EV3BumperCar/src/EV3BumperCar.java
changed EV3ColorTest/src/EV3ColorTest.java
changed EV3GraphicsTest/src/org/lejos/sample/graphicssample/GraphicsSample.java
changed ev3classes/src/lejos/nxt/DeviceManager.java
changed ev3classes/src/lejos/nxt/EV3.java
changed ev3classes/src/lejos/nxt/EV3ColorSensor.java
changed ev3classes/src/lejos/nxt/EV3GyroSensor.java
changed ev3classes/src/lejos/nxt/EV3IRSensor.java
changed ev3classes/src/lejos/nxt/EV3SensorConstants.java
changed ev3classes/src/lejos/nxt/EV3TouchSensor.java
changed ev3classes/src/lejos/nxt/I2CPort.java
changed ev3classes/src/lejos/nxt/I2CSensor.java
changed ev3classes/src/lejos/nxt/LocalEV3.java
copied ev3classes/src/lejos/nxt/LocalAnalogPort.java -> ev3classes/src/lejos/internal/ev3/EV3AnalogPort.java
copied ev3classes/src/lejos/nxt/LocalBattery.java -> ev3classes/src/lejos/internal/ev3/EV3Battery.java
copied ev3classes/src/lejos/nxt/LocalI2CPort.java -> ev3classes/src/lejos/internal/ev3/EV3I2CPort.java
copied ev3classes/src/lejos/nxt/LocalMotorPort.java -> ev3classes/src/lejos/internal/ev3/EV3MotorPort.java
ev3classes/src/lejos/internal/ev3/EV3IOPort.java Diff Switch to side-by-side view
Loading...
ev3classes/src/lejos/internal/ev3/EV3Port.java Diff Switch to side-by-side view
Loading...
ev3classes/src/lejos/internal/ev3/EV3UARTPort.java Diff Switch to side-by-side view
Loading...
EV3BumperCar/src/EV3BumperCar.java Diff Switch to side-by-side view
Loading...
EV3ColorTest/src/EV3ColorTest.java Diff Switch to side-by-side view
Loading...
EV3GraphicsTest/src/org/lejos/sample/graphicssample/GraphicsSample.java Diff Switch to side-by-side view
Loading...
ev3classes/src/lejos/nxt/DeviceManager.java Diff Switch to side-by-side view
Loading...
ev3classes/src/lejos/nxt/EV3.java Diff Switch to side-by-side view
Loading...
ev3classes/src/lejos/nxt/EV3ColorSensor.java Diff Switch to side-by-side view
Loading...
ev3classes/src/lejos/nxt/EV3GyroSensor.java Diff Switch to side-by-side view
Loading...
ev3classes/src/lejos/nxt/EV3IRSensor.java Diff Switch to side-by-side view
Loading...
ev3classes/src/lejos/nxt/EV3SensorConstants.java Diff Switch to side-by-side view
Loading...
ev3classes/src/lejos/nxt/EV3TouchSensor.java Diff Switch to side-by-side view
Loading...
ev3classes/src/lejos/nxt/I2CPort.java Diff Switch to side-by-side view
Loading...
ev3classes/src/lejos/nxt/I2CSensor.java Diff Switch to side-by-side view
Loading...
ev3classes/src/lejos/nxt/LocalEV3.java Diff Switch to side-by-side view
Loading...
ev3classes/src/lejos/nxt/LocalAnalogPort.java to ev3classes/src/lejos/internal/ev3/EV3AnalogPort.java
--- a/ev3classes/src/lejos/nxt/LocalAnalogPort.java
+++ b/ev3classes/src/lejos/internal/ev3/EV3AnalogPort.java
@@ -1,8 +1,9 @@
-package lejos.nxt;
+package lejos.internal.ev3;
 
 import java.nio.ByteBuffer;
 
 import lejos.internal.io.NativeDevice;
+import lejos.nxt.AnalogPort;
 
 import com.sun.jna.Pointer;
 
@@ -13,7 +14,7 @@
  * @author andy
  *
  */
-public class LocalAnalogPort extends LocalSensorPort implements ADSensorPort
+public class EV3AnalogPort extends EV3IOPort implements AnalogPort
 {
     protected static final int ANALOG_SIZE = 5172;
     protected static final int ANALOG_PIN1_OFF = 0;
@@ -35,16 +36,7 @@
         initDeviceIO();
     }
 
-    
-    /**
-     * allow access to the specified port
-     * @param p port number to open
-     */
-    public boolean open(int p)
-    {
-        return super.open(p);
-    }
-    
+        
     /**
      * Return the analog voltage reading from pin 1
      * @return the voltage in mV
@@ -114,7 +106,6 @@
     @Override
     public int readValue()
     {
-        // TODO Auto-generated method stub
         return (getPin1() + 3)/4;
     }
 
@@ -174,7 +165,7 @@
      * @param port
      * @return
      */
-    protected static int getPortType(int port)
+    public static int getPortType(int port)
     {
         if (port > PORTS || port < 0)
             return CONN_ERROR;
@@ -186,7 +177,7 @@
      * @param port
      * @return
      */
-    protected static int getAnalogSensorType(int port)
+    public static int getAnalogSensorType(int port)
     {
         if (port > PORTS || port < 0)
             return CONN_ERROR;
ev3classes/src/lejos/nxt/LocalBattery.java to ev3classes/src/lejos/internal/ev3/EV3Battery.java
--- a/ev3classes/src/lejos/nxt/LocalBattery.java
+++ b/ev3classes/src/lejos/internal/ev3/EV3Battery.java
@@ -1,4 +1,7 @@
-package lejos.nxt;
+package lejos.internal.ev3;
+
+import lejos.nxt.Battery;
+import lejos.nxt.EV3SensorConstants;
 
 /**
  * Class which provides information about the EV3 battery.<br>
@@ -7,7 +10,7 @@
  * @author andy
  *
  */
-public class LocalBattery implements Battery
+public class EV3Battery implements Battery
 {
     protected final static float SHUNT_IN = 0.11f;
     protected final static float AMP_CIN = 22.0f;
@@ -40,8 +43,8 @@
     @Override
     public float getVoltage()
     {
-        float CinV = convert(LocalAnalogPort.getBatteryCurrent())/AMP_CIN;
-        return convert(LocalAnalogPort.getBatteryVoltage())/AMP_VIN + CinV + VCE;
+        float CinV = convert(EV3AnalogPort.getBatteryCurrent())/AMP_CIN;
+        return convert(EV3AnalogPort.getBatteryVoltage())/AMP_VIN + CinV + VCE;
     }
 
     /**
@@ -50,7 +53,7 @@
     @Override
     public float getBatteryCurrent()
     {
-        return (convert(LocalAnalogPort.getBatteryCurrent())/AMP_CIN)/SHUNT_IN;
+        return (convert(EV3AnalogPort.getBatteryCurrent())/AMP_CIN)/SHUNT_IN;
     }
 
     /**
@@ -59,7 +62,7 @@
     @Override
     public float getMotorCurrent()
     {
-        return (convert(LocalAnalogPort.getMotorCurrent())/AMP_COUT)/SHUNT_OUT;
+        return (convert(EV3AnalogPort.getMotorCurrent())/AMP_COUT)/SHUNT_OUT;
     }
 
 }
ev3classes/src/lejos/nxt/LocalI2CPort.java to ev3classes/src/lejos/internal/ev3/EV3I2CPort.java
--- a/ev3classes/src/lejos/nxt/LocalI2CPort.java
+++ b/ev3classes/src/lejos/internal/ev3/EV3I2CPort.java
@@ -1,4 +1,4 @@
-package lejos.nxt;
+package lejos.internal.ev3;
 
 import java.nio.ByteBuffer;
 
@@ -6,6 +6,7 @@
 import com.sun.jna.Structure;
 
 import lejos.internal.io.NativeDevice;
+import lejos.nxt.I2CPort;
 import lejos.util.Delay;
 
 /**
@@ -16,7 +17,7 @@
     to be of limited use because most i2c sensors provide multiple data values etc.
     Because of this we only implement the basic i2c interface.
  */
-public class LocalI2CPort extends LocalSensorPort implements I2CPort
+public class EV3I2CPort extends EV3IOPort implements I2CPort
 {
     protected static NativeDevice i2c;
     protected static Pointer pIic;
@@ -104,9 +105,9 @@
      * allow access to the specified port
      * @param p port number to open
      */
-    public boolean open(int p)
+    public boolean open(int t, int p, EV3Port r)
     {
-        if (!super.open(p))
+        if (!super.open(t, p, r))
             return false;
         if (!initSensor())
         {
@@ -154,7 +155,7 @@
             //System.out.println("Ioctl result: " + iicdata.Result);
             if (iicdata.Result < 0)
                 return -1;
-            if (iicdata.Result == OK)
+            if (iicdata.Result == STATUS_OK)
             {
                 if (readLen > 0)
                     System.arraycopy(iicdata.RdData, 0, readBuf, readOffset,  readLen);
ev3classes/src/lejos/nxt/LocalMotorPort.java to ev3classes/src/lejos/internal/ev3/EV3MotorPort.java
--- a/ev3classes/src/lejos/nxt/LocalMotorPort.java
+++ b/ev3classes/src/lejos/internal/ev3/EV3MotorPort.java
@@ -1,9 +1,11 @@
-package lejos.nxt;
+package lejos.internal.ev3;
 
 import java.nio.ByteBuffer;
 import java.nio.IntBuffer;
 
 import lejos.internal.io.NativeDevice;
+import lejos.nxt.BasicMotorPort;
+import lejos.nxt.TachoMotorPort;
 
 /**
  * 
@@ -12,7 +14,7 @@
  * TODO: Sort out a better way to do this, or least clean up the magic numbers.
  *
  */
-public class LocalMotorPort implements MotorPort {
+public class EV3MotorPort extends EV3IOPort implements TachoMotorPort {
     static final byte OUTPUT_POWER = (byte)0xa4;
     static final byte OUTPUT_START = (byte)0xa6;
     static final byte OUTPUT_STOP = (byte)0xa3;
@@ -25,47 +27,11 @@
     {
         initDeviceIO();
     }
-    protected static LocalMotorPort [] openPorts = new LocalMotorPort[PORTS];    
-    protected int port;
     protected int curMode = FLOAT+1; // current mode is unknown
     protected byte[] cmd = new byte[8];
     
-    /** {@inheritDoc}
-     */    
-    @Override
-    public boolean open(int port)
-    {
-        synchronized (openPorts)
-        {
-            if (openPorts[port] == null)
-            {
-                openPorts[port] = this;
-                this.port = port;
-                return true;
-            }
-            return false;
-        }
-    }
    
-    /** {@inheritDoc}
-     */    
-    @Override
-    public void close()
-    {
-        if (port == -1)
-            throw new IllegalStateException("Port is not open");
-        synchronized (openPorts)
-        {
-            openPorts[port] = null;
-            port = -1;
-        }
-    }
     
-    public static MotorPort getInstance(int port)
-    {
-        return openPorts[port];
-    }
-
 
     /**
      * Low-level method to control a motor. 
@@ -147,11 +113,6 @@
     
     public void setPWMMode(int mode)
     {
-     }
-    
-    public int getId()
-    {
-        return this.port;
     }
     
     private static void initDeviceIO()
1 2 3 .. 8 > >> (Page 1 of 8)