Removed analog and digital module numbers

AnalogModule and DigitalModule classes still exist, at least until they are
refactored into the classes that use them.

Change-Id: I5544d5418822f19d54ba0a5d651e64fad8b7b10d
This commit is contained in:
thomasclark
2014-06-13 17:45:10 -04:00
parent aa3b24092a
commit 58021f7397
90 changed files with 852 additions and 1988 deletions

View File

@@ -19,7 +19,7 @@ import edu.wpi.first.wpilibj.test.TestBench;
* Designed to allow the user to easily setup and tear down the fixture to allow for reuse.
* This class should be explicitly instantiated in the TestBed class to allow any test to access this fixture.
* This allows tests to be mailable so that you can easily reconfigure the physical testbed without breaking the tests.
*
*
* @author Jonathan Leitschuh
*
*/
@@ -31,7 +31,7 @@ public abstract class MotorEncoderFixture implements ITestFixture {
private Counter counters[] = new Counter[2];
protected DigitalInput aSource; //Stored so it can be freed at tear down
protected DigitalInput bSource;
/**
* Default constructor for a MotorEncoderFixture
* @param motor The SpeedControler for this MotorEncoder pair
@@ -40,10 +40,10 @@ public abstract class MotorEncoderFixture implements ITestFixture {
*/
public MotorEncoderFixture(){
}
/**
* Where the implementer of this class should pass the speed controller
* Constructor should only be called from outside this class if the Speed controller
* Constructor should only be called from outside this class if the Speed controller
* is not also an implementation of PWM interface
* @return
*/
@@ -60,14 +60,14 @@ public abstract class MotorEncoderFixture implements ITestFixture {
* @return Input B to be used when this class is instantiated
*/
abstract protected DigitalInput giveDigitalInputB();
final private void initialize(){
if(!initialized){
aSource = giveDigitalInputA();
bSource = giveDigitalInputB();
motor = giveSpeedController();
encoder = new Encoder(aSource, bSource);
counters[0] = new Counter(aSource);
counters[1] = new Counter(bSource);
@@ -77,14 +77,14 @@ public abstract class MotorEncoderFixture implements ITestFixture {
initialized = true;
}
}
@Override
public boolean setup() {
initialize();
encoder.start();
return true;
}
/**
* Gets the motor for this Object
* @return the motor this object refers too
@@ -93,7 +93,7 @@ public abstract class MotorEncoderFixture implements ITestFixture {
initialize();
return motor;
}
/**
* Gets the encoder for this object
* @return the encoder that this object refers too
@@ -102,12 +102,12 @@ public abstract class MotorEncoderFixture implements ITestFixture {
initialize();
return encoder;
}
public Counter[] getCounters(){
initialize();
return counters;
}
/**
* Retrieves the name of the motor that this object refers to
* @return The simple name of the motor {@link Class#getSimpleName()}
@@ -116,42 +116,42 @@ public abstract class MotorEncoderFixture implements ITestFixture {
initialize();
return motor.getClass().getSimpleName();
}
/**
* Checks to see if the speed of the motor is within some range of a given value.
* This is used instead of equals() because doubles can have inaccuracies.
* @param value The value to compare against
* @param acuracy The accuracy range to check against to see if the
* @return true if the range of values between motors speed ± accuracy contains the 'value'<br>
* @return true if the range of values between motors speed accuracy contains the 'value'<br>
* {@code Math.abs((Math.abs(motor.get()) - Math.abs(value))) < Math.abs(accuracy)}
*/
public boolean isMotorSpeedWithinRange(double value, double accuracy){
initialize();
return Math.abs((Math.abs(motor.get()) - Math.abs(value))) < Math.abs(accuracy);
}
@Override
public boolean reset(){
initialize();
boolean wasReset = true;
motor.set(0);
Timer.delay(TestBench.MOTOR_STOP_TIME); //DEFINED IN THE TestBench
encoder.reset();
for(Counter c : counters){
c.reset();
}
wasReset = wasReset && motor.get() == 0;
wasReset = wasReset && encoder.get() == 0;
for(Counter c : counters){
wasReset = wasReset && c.get() == 0;
}
return wasReset;
}
@Override
public boolean teardown() {
@@ -168,7 +168,7 @@ public abstract class MotorEncoderFixture implements ITestFixture {
counters[0] = null;
counters[1].free();
counters[1] = null;
aSource.free();
aSource = null;
bSource.free();
@@ -177,7 +177,7 @@ public abstract class MotorEncoderFixture implements ITestFixture {
} else {
throw new RuntimeException(type + " Motor Encoder torn down multiple times");
}
return true;
}

View File

@@ -53,7 +53,7 @@ public class FakeCounterSource
}
}
}
/**
* Create a fake encoder on a given port
* @param output the port to output the given signal to
@@ -76,18 +76,6 @@ public class FakeCounterSource
initEncoder();
}
/**
* Create a new fake encoder on the indicated slot and port
* @param slot Slot to create on
* @param port THe port that the encoder is supposably on
*/
public FakeCounterSource(int slot, int port)
{
m_output = new DigitalOutput(slot, port);
m_allocated = true;
initEncoder();
}
/**
* Destroy Object with minimum memory leak
*/
@@ -162,4 +150,3 @@ public class FakeCounterSource
m_mSec = mSec;
}
}

View File

@@ -74,14 +74,6 @@ public class FakeEncoderSource
}
}
public FakeEncoderSource(int slotA, int portA, int slotB, int portB)
{
m_outputA = new DigitalOutput(slotA, portA);
m_outputB = new DigitalOutput(slotB, portB);
allocatedOutputs = true;
initQuadEncoder();
}
public FakeEncoderSource(int portA, int portB)
{
m_outputA = new DigitalOutput(portA);